From: Viktor Szakats Date: Sat, 28 Jun 2025 01:38:35 +0000 (+0200) Subject: cmake: fix `curl_add_clang_tidy_test_target` when no `-D` option X-Git-Tag: curl-8_15_0~109 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42fdc65a989d9e57c418eb56770ab8e31736d56a;p=thirdparty%2Fcurl.git cmake: fix `curl_add_clang_tidy_test_target` when no `-D` option Fix `curl_add_clang_tidy_test_target` generating an invalid option for `clang-tidy` if the tested target has no custom macro definition. Current build doesn't hit this case, but a pending PR does. Fixing: ``` [...] -Ilib -Itests/client -DCURL_HIDDEN_SYMBOLS -DHAVE_CONFIG_H -D_definitions_t-NOTFOUND ``` error: ISO C99 requires whitespace after the macro name [clang-diagnostic-c99-extensions,-warnings-as-errors] Cherry-picked from #17768 Closes #17813 --- diff --git a/CMake/Macros.cmake b/CMake/Macros.cmake index 49ae47e706..2acd7ff98b 100644 --- a/CMake/Macros.cmake +++ b/CMake/Macros.cmake @@ -141,6 +141,9 @@ macro(curl_add_clang_tidy_test_target _target_clang_tidy _target) # Collect macro definitions applying to the target get_directory_property(_definitions_d COMPILE_DEFINITIONS) get_target_property(_definitions_t ${_target} COMPILE_DEFINITIONS) + if(NOT _definitions_t) + unset(_definitions_t) + endif() set(_definitions "${_definitions_l};${_definitions_d};${_definitions_t}") list(REMOVE_ITEM _definitions "")