The correct way to add system directories is to use the SYSTEM
option of the include_directories
command:
include_directories(SYSTEM "/foo/bar")
If include_directories
is not an option, you can specify a system include directory by directly modifying the target's COMPILE_FLAGS
property:
set_target_properties(main PROPERTIES APPEND_STRING PROPERTY
COMPILE_FLAGS " ${CMAKE_INCLUDE_SYSTEM_FLAG_CXX} /foo/bar")
The variable CMAKE_INCLUDE_SYSTEM_FLAG_CXX
usually resolves to -isystem
on UNIX systems.