I have a C++ project builds with Scons. At first I have only the optimized version to compile, it works fine. Then I also need a debug version, then I add another environment for it. Here is the Scons code:
env = Environment()
opt = env.Clone(CCFLAGS=['-pthread', '-O3', '-Wall'])
opt_objs = opt.Glob('src/*.cpp')
prog = opt.Program('prog', opt_objs)
dbg = env.Clone(CCFLAGS=['-pthread', '-Wall', '-g', '-O0'])
dbg_objs = dbg.Glob('src/*.cpp')
dbg_prog = dbg.Program('dbg_prog', dbg_objs)
With this code, I ran into error:
scons: *** Two environments with different actions were specified for the same target:
src/CometReadService.o
As you can see, those .o files targets created by opt.Glob('src/.cpp') and dbg.Glob('src/.cpp') exactly same name. By reading the document Multiple Construction Environments I know I can rename the object like "opt.Object('xxx-opt', 'xxx.c')", but however, it is Glob not Object. How can I solve this problem?