CMake 3.14.2 does not put -isystem includes before all include paths using include_directories(BEFORE SYSTEM
Within our toplevel CMakeLists.txt we have specified:
include_directories(BEFORE SYSTEM
${CMAKE_PREFIX_PATH}/include
${CMAKE_PREFIX_PATH}/include/platform
${CMAKE_PREFIX_PATH}/usr/include/platform
)
So, it should include those three paths as system path, before including any other paths. With the CMake 3.14.2, this leads to the following make command:
cd <output_path> && ccache /usr/bin/c++ ...
-I<build_directory>
-I<local_includes>
-isystem <staging_root>/usr/local/usr/include/platform
-isystem <staging_root>/usr/local/include/platform
-isystem <staging_root>/usr/local/include
-ggdb -O0 -ggdb -std=c++11 -fno-optimize-sibling-calls -D_GLIBCXX_USE_C99=1 -Wall -Wextra -Werror -funsigned-char -Wno-long-long -Wpedantic -Wuninitialized -Winit-self -Wcast-qual -Wcast-align -Wconversion -g -fprofile-arcs -ftest-coverage -o <object> -c <source>
This FAILS due to -Werror failing on external libraries in <staging_root>. I am not sure why. Whereas in CMake 3.10.2, it would work fine and with the same CMakeLists.txt, it would generate following Make command:
cd <output_path> && ccache /usr/bin/c++ ...
-isystem <staging_root>/usr/local/usr/include/platform
-isystem <staging_root>/usr/local/include/platform
-isystem <staging_root>/usr/local/include
-I<build_directory>
-I<local_includes>
-ggdb -O0 -ggdb -std=c++11 -fno-optimize-sibling-calls -D_GLIBCXX_USE_C99=1 -Wall -Wextra -Werror -funsigned-char -Wno-long-long -Wpedantic -Wuninitialized -Winit-self -Wcast-qual -Wcast-align -Wconversion -g -fprofile-arcs -ftest-coverage -o <object> -c <source>
The above command would work fine. It does not fail on -Werror on external libraries, but only the source and project includes.
Thanks to Ino Dekker for details.