Closed kevinmoloney7 closed 1 year ago
Hi @kevinmoloney7 thanks for reporting!
Jup, you are right. This is a common issue and here is a workaround for it (simply disable clang-tidy for fetch content stuff).
# Define two macros for easy clearing and backing up CMake variables
macro(clear_variable)
cmake_parse_arguments(CLEAR_VAR "" "DESTINATION;BACKUP;REPLACE" "" ${ARGN})
set(${CLEAR_VAR_BACKUP} ${${CLEAR_VAR_DESTINATION}})
set(${CLEAR_VAR_DESTINATION} ${CLEAR_VAR_REPLACE})
endmacro()
macro(restore_variable)
cmake_parse_arguments(CLEAR_VAR "" "DESTINATION;BACKUP" "" ${ARGN})
set(${CLEAR_VAR_DESTINATION} ${${CLEAR_VAR_BACKUP}})
unset(${CLEAR_VAR_BACKUP})
endmacro()
# Disable linting for fetch content projects
clear_variable(DESTINATION CMAKE_CXX_CLANG_TIDY BACKUP CMAKE_CXX_CLANG_TIDY_BKP)
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git
GIT_TAG 1cb247a6dae0fddbb27ffb3ea63506b0fd83e636)
FetchContent_MakeAvailable(cpr)
# Restore clang-tidy config
restore_variable(DESTINATION CMAKE_CXX_CLANG_TIDY BACKUP CMAKE_CXX_CLANG_TIDY_BKP)
With clang tidy enabled for my project, it is failing when including cpr library. MY understanding was to get FetchContent to treat this dependency as a system library. From the release notes of CMake 3.1.25 it seems like this is possible by adding the system property from this PR
I also tried setting the target property to system and it failed too. I presume this is something people have encountered before and there is a workaround to?