我尝试使用scons函数来检测特定的头文件是否可用。给定文件main.cpp
并带有#include "fns.h"
。我创造了这个:
env = Environment(CXXFLAGS='-I.')
conf = Configure(env)
if not conf.CheckCXXHeader('fns.h'):
print 'please get fns.h'
Exit(1)
env.Program('main.cpp')
我第一次运行它时,实际上会检查标题,但之后它总是使用缓存的结果
$ scons
scons: Reading SConscript files ...
Checking for C++ header file fns.h... no
please get fns.h
$ touch fns.h
$ scons
scons: Reading SConscript files ...
Checking for C++ header file fns.h... yes
scons: done reading SConscript files.
scons: Building targets ...
g++ -o main.o -c -I. main.cpp
g++ -o main main.o
scons: done building targets.
$ rm fns.h # delete it
$ scons # should check again here, but doesn't
scons: Reading SConscript files ...
Checking for C++ header file fns.h... (cached) yes
scons: done reading SConscript files.
scons: Building targets ...
g++ -o main.o -c -I. main.cpp
main.cpp:1:17: fatal error: fns.h: No such file or directory
#include "fns.h"
答案 0 :(得分:1)
请查看SCons手册(man scons),您正在寻找的命令行选项是" - config = force"。您还可以通过在SConscript文件中设置config选项使其成为构建的默认行为:
SetOption('config', 'force')