NO_SYSTEM_FROM_IMPORTED
tells us that IMPORTED
targets automagically get -isystem
. Does that also hold for targets introduced to the project with FetchContent?
If not (I assume so due to having problems with clang-tidy warnings on fetched targets), what is the best way to get -isystem
for such targets?
NO_SYSTEM_FROM_IMPORTED
tells us thatIMPORTED
targets automagically get-isystem
. Does that also hold for targets introduced to the project with FetchContent?
No, because targets added by FetchContent
are essentially added by add_subdirectory
: they become targets to build (instead of just import) in the generated buildystem.
If not (I assume so due to having problems with clang-tidy warnings on fetched targets), what is the best way to get -isystem for such targets?
If you are using CMake 3.25 (cmake_minimum_required(VERSION 3.25)
), you can use the SYSTEM
argument of FetchContent_Declare
, which was added in merge request #7399 by contributor daquexian.
For users of CPM, I have given the CPM authors a heads up about this change here.
There is also the new SYSTEM
target property, which was added in merge request #7308 (also by daquexian). If SYSTEM
is ON
, the INTERFACE_INCLUDE_DIRECTORIES
will be treated as system include directories.
If your cmake_minimum_required(VERSION ...)
is less than v3.25, then use this other answer.