4

美好的一天,在完全迁移到 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而不是namefor 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)。

4

1 回答 1

1

由于这是 google 上“仅标题库 waf”的第一件事,我想我应该发布通用解决方案。

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

这对我有用。

于 2014-12-22T23:35:40.110 回答