About the particular arguments, I took them from the earlier post in this thread; I failed to notice it wasn’t yours.
Regarding compiler selection: do you really need to do this using genexes? Those are great for things which are not fully known at configure time, or for things which are exported for consumers of your project (such as library usage requirements).
However, using clang-tidy applies only to building your project itself, and the compiler used is known at configure time. You can therefore wrap the whole setup in a normal if()
, which is much easier than working with genexes:
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set_property(TARGET ${PROJECT_NAME} PROPERTY
CXX_CLANG_TIDY
clang-tidy --checks=*,modernize*
)
endif()
If you still need a genex there (e.g. to only run cang-tidy in certain configurations), you need to ensure the whole genex remains one configure-time argument. Perhaps like this (not tested):
set_property(TARGET ${PROJECT_NAME} PROPERTY
CXX_CLANG_TIDY
"$<$<CONFIG:Debug>:clang-tidy;--checks=*,modernize*>"
)
Of course, then we’re back at needing explicit semicolon separation and quoting. That’s a downside of genexes, and why I feel they shouldn’t be overused.