tags:

views:

563

answers:

2

Using scons I can easily set my include paths:

env.Append( CPPPATH=['foo'] )

This passes the flag

-Ifoo

to gcc

However I'm trying to compile with a lot of warnings enabled. In particular with

env.Append( CPPFLAGS=['-Werror', '-Wall', '-Wextra'] )

which dies horribly on certain boost includes ... I can fix this by adding the boost includes to the system include path rather than the include path as gcc treats system includes differently.

So what I need to get passed to gcc instead of -Ifoo is

-isystem foo

I guess I could do this with the CPPFLAGS variable, but was wondering if there was a better solution built into scons.

+2  A: 

There is no built-in way to pass -isystem include paths in SCons, mainly because it is very compiler/platform specific.

Putting it in the CXXFLAGS will work, but note that this will hide the headers from SCons' dependency scanner, which only looks at CPPPATH.

This is probably OK if you don't expect those headers to ever change, but could cause weird issues if you use the build results cache and/or implicit dependency cache.

BennyG
Thanks for the confirmation of what I expected (but hoped was wrong)
Michael Anderson
+1  A: 

If you do

  print env.Dump()

you'll see _CPPINCFLAGS, and you'll see that variable used in CCCOM (or _CCCOMCOM). _CPPINCFLAGS typically looks like this:

  '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'

From this you can probably see how you could add an "isystem" set of includes as well, like _CPPSYSTEMINCFLAGS or some such. Just define your own prefix, path var name (e.g. CPPSYSTEMPATH) and suffix and use the above idiom to concatenate the prefix. Then just append your _CPPSYSTEMINCFLAGS to CCCOM or _CCCOMCOM and off you go.

Of course this is system-specific but you can conditionally include your new variable in the compiler command line as and when you want.

garyo