带有waf的C ++头文件库

时间:2012-11-10 21:53:48

标签: c++ waf header-only

美好的一天, 在完全迁移到waf(1.7.5)之前,我试图创建一个这种结构的简单项目:

wafproject
├── application
│   ├── main.cpp
│   └── wscript
├── library1
│   ├── foo1.hpp
│   ├── foo2.hpp
│   └── wscript
└── wscript

这是根wscript

def options(opt) :
    opt.load('compiler_cxx')

def configure(cnf) :
    cnf.load('compiler_cxx')

def build(bld) :
    bld.recurse('library1')
    bld.recurse('application')

这是application wscript

def build(bld) :
    bld( features = 'cxx cxxprogram'
       , target = 'application'
       , source = 'main.cpp'
       , use = ['library1']
       )

这是library1 wscript

def build(bld) :
    bld( name = 'library1'
       , inludes = '../../'
       , export_inludes = '../../'
       )

(注意:我已尝试使用target代替name library1,我也有 尝试为cxx cxxshlib启用library1功能。)

这是main.cpp

#include <wafproject/library1/foo1.hpp>
#include <wafproject/library1/foo2.hpp>

int main()
{
}

这是我得到的错误:

Setting top to                           : /home/<path>/wafproject 
Setting out to                           : /home/<path>/wafproject/build 
Checking for 'g++' (c++ compiler)        : /usr/bin/g++ 
'configure' finished successfully (0.038s)
Waf: Entering directory `/home/<path>/wafproject/build'
[1/3] cxxshlib:  -> build/library1/liblibrary1.so
[2/3] cxx: application/main.cpp -> build/application/main.cpp.1.o
../application/main.cpp:1:40: fatal error: wafproject/library1/foo1.hpp: Directory or file does not exist.
compilation terminated.
Waf: Leaving directory `/home/<path>/wafproject/build'
Build failed
 -> task in 'application' failed (exit status 1): 
        {task 139729350901264: cxx main.cpp -> main.cpp.1.o}
['/usr/bin/g++', '../application/main.cpp', '-c', '-o', 'application/main.cpp.1.o']

我不想改变我包含标题的方式,但为此我显然需要改变我的项目设置方式。

我很高兴有任何意见,谢谢。

编辑:解决了,这只是一个错字(inludes而不是includesexport_inludes而不是export_includes。)

1 个答案:

答案 0 :(得分:1)

由于这是google上第一个“仅限标题库waf”,我认为我应该发布通用解决方案。

bld(name = 'libname', export_includes = 'PATH/TO/lib/')

哪个适合我。