leeeroy
leeeroy

Reputation: 11456

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

Upvotes: 1

Views: 1949

Answers (3)

Destroyica
Destroyica

Reputation: 4267

The best way to achieve this is:

env.Prepend(CXXFLAGS = ['-fno-rtti', '-Wnon-virtual-dtor'])

Like this, you don't get an error and you avoid a workaround, because if the CXXFLAGS value is not set, it is created automaticaly.

Upvotes: 0

leeeroy
leeeroy

Reputation: 11456

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'] = []

Upvotes: 1

bialix
bialix

Reputation: 21533

There is dedicated method to append data to various compiler flags:

probenv.Append(CXXFLAGS = ['-fno-rtti','-Wnon-virtual-dtor'])

There is also AppendUnique and AppendENVPath. See the man for description.

Upvotes: 1

Related Questions