Skip to content

Detect GCC system include paths at run-time and automatically add them to CMAKE_${LANG}_IMPLICIT_INCLUDE_DIRECTORIES

Hi,

GCC 6 has introduced a change that broke some C++ projects when the project uses system includes (-isystem) via passing the parameter SYSTEM to CMake's functions include_directories or target_include_directories.

This didn't broke the 99% of the standard builds because CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES and CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES already default to /usr/include. So CMake automatically filters /usr/include from the list of includes when calling the compiler.

But when cross-compiling or when using a non-default system include directory, the build breaks.

On the WebKit project we work-around'ed this by calling GCC at run-time to obtain the list of system includes, to automatically add this directories to the above variables.

Perhaps it makes sense to introduce this change in CMake itself, as I think it may be useful for everybody. It is also probably a good idea to avoid passing -I/-isystem for directories that the compiler already assumes as default include directories. It keeps thinga cleaner and simple.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information