Use of -isystem

Removing -isystem in general is not a good solution. That’s supposed to apply to user-provided include directories e.g. for external dependencies.

CMake tries pretty hard not to pass the compiler’s own implicit include directories on the command line at all. We even have CMake Issue 19227 where people want to turn that filtering off.

If CMake is generating an explicit -isystem $sysroot/usr/include when that is one of the compiler’s builtin include directories then something is going wrong with the detection and filtering. In a build tree where this happens, what is the output of the following?

$ grep IMPLICIT_INCLUDE_DIRECTORIES CMakeFiles/*/CMake*Compiler.cmake