Implicit include path detection versus CPATH env var
EDIT: After discussion below the situation is this:
The CPATH
environment variable tells the compiler to treat its paths as implicitly used by all compilations. Therefore such paths show up in CMake 3.14's detection of implicit include directories (!2716 (merged)). CMake interprets this to mean "the compiler automatically uses these include directories so we should never specify them explicitly" (because doing so for real compiler builtin include dirs may break system header ordering). Therefore CMake will never pass the directories with -I
or -isystem
, so using include_directories(SYSTEM <path>)
with one of the entries of CPATH
does nothing.
The result is that third-party headers included from directories in CPATH
are treated as -I
rather than -isystem
and warnings in them are not suppressed. Environments that provide third-party dependencies can use {C,CPLUS}_INCLUDE_PATH
in order to make them available as -isystem
and avoid warnings.
The original description follows.
CMake 3.14.x doesn't respect SYSTEM in include_directories
I appear to be getting warnings in 3.14.x in system headers when using include_directories(SYSTEM <path>)
where 3.13.x has the expected (correct) behavior. It also appears that 3.14.x appears to ignore warnings (correct behavior) in system headers when running and building in a script using ctest -S
.