Reputation: 5088
Is it possible with cmake 2.6 (or higher, if not possible in this version) to check whether an include directory is marked as SYSTEM
(e.g. compile with the isystem
gcc flag, see 2.8 System Headers)?
For example, I get the include directories of the current target with:
GET_PROPERTY(_target_include_dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
How do I know which ones are marked as isystem
?
Thanks
Upvotes: 3
Views: 1292
Reputation: 182000
Looking at the CMake source, whether an include directory added with include_directories
is marked as SYSTEM
seems to be tracked in CMake internals, and is not available for consumption inside your CMakeLists.txt
¹.
However, for the target property INTERFACE_INCLUDE_DIRECTORIES
(populated by target_include_directories
with either PUBLIC
or INTERFACE
), there is another target property named INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
:
add_library(testlib test.cc)
target_include_directories(testlib SYSTEM INTERFACE /target_system)
get_property(_system_include_dirs TARGET testlib PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES)
message("System: ${_system_include_dirs}")
So maybe you can use that instead.
¹ There is mention of a SYSTEM_INCLUDE_DIRECTORIES
property available through a generator expression, but I couldn't get it to work.
Upvotes: 1