Search code examples
c++build-processscons

scons setting CXXFLAGS in one module affects another one


in dirA/SConscript I have:

Import('env')
probeenv = env.Clone()
probeenv['CXXFLAGS'] +=  ['-fno-rtti','-Wnon-virtual-dtor']
... stuff that uses probeenv

in dirB/SConscript I have

Import('env')
sipenv = env.Clone()
... stuff that uses sipenv

Now, c++ files in dirB that gets compiled, gets the CXXFLAGS from dirA - how come ? This does not happen with CCFLAGS. Nor does it happen if I use probeenv['CXXFLAGS'] = ['-fno-rtti','-Wnon-virtual-dtor'] in dirA


Solution

  • This seems to be a scons bug if CXXFLAGS is not set in "main" SConstruct. The workaround is to simply set it to an empty list there.

    SConscript:

    env['CXXFLAGS'] = []