Search code examples
c++boost-buildbjam

boost build: How to mark an include as a "system" include


In gcc and clang, include directories may be passed to the compiler using -I or -isystem.

The difference is, isystem paths are only searched when angle brackets <> are used in an #include directive, rather than quotes "". Also, certain warnings are suppressed when they appear in system headers (since you presumably can't work around problems in the system headers). (There may be other minor differences as far as I know.)

Not all compilers support this concept, it's an implementation issue, not part of the standard.

cmake supports this feature specifically, and will "do the right thing" on compilers that support it.

scons historically didn't support it, but there are ways to work around this, and also it has some support built-in since fairly recently.

Is there an equivalent feature in boost.build aka bjam, b2? In documentation and examples, the include directories are specified using <include>path/to/files and passed as a requirement of lib or exe targets. But I didn't find any <system_include> or similar feature.

If it doesn't exist, is there any way to work around it? Some projects won't build without warnings on gcc and clang unless these flags are used correctly.


Solution

  • No, there is no such feature in boost.build. What you can do instead is conditionally enable -isystem for particular toolsets which do support system includes, for example:

    exe myexe : mysrc.cpp : <toolset>gcc:<cxxflags>-isystem/path/to/include/files ;