Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set scons system include path

Tags:

c++

scons

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.

like image 855
Michael Anderson Avatar asked Mar 14 '10 03:03

Michael Anderson


3 Answers

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.

like image 94
BenG Avatar answered Oct 14 '22 12:10

BenG


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.

like image 40
GaryO Avatar answered Oct 14 '22 12:10

GaryO


According to the SCons release notes, "-isystem" is supported since version 2.3.4 for the environment's CCFLAGS.

So, you can, for example, do the following:

env.AppendUnique(CCFLAGS=('-isystem', '/your/path/to/boost'))

Still, you need to be sure that your compiler supports that option.

like image 4
LangerJan Avatar answered Oct 14 '22 14:10

LangerJan