]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: fix `curl_add_clang_tidy_test_target` when no `-D` option
authorViktor Szakats <commit@vsz.me>
Sat, 28 Jun 2025 01:38:35 +0000 (03:38 +0200)
committerViktor Szakats <commit@vsz.me>
Fri, 4 Jul 2025 04:28:40 +0000 (06:28 +0200)
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

CMake/Macros.cmake

index 49ae47e7064b4e5a0ee86557e519a1443fa6f125..2acd7ff98bf4b354f54109885653f81adb933c93 100644 (file)
@@ -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 "")