C ++ header-only library with waf

Good afternoon, before completely switching to waf (1.7.5), I tried to create a simple project of this structure:

wafproject β”œβ”€β”€ application β”‚ β”œβ”€β”€ main.cpp β”‚ └── wscript β”œβ”€β”€ library1 β”‚ β”œβ”€β”€ foo1.hpp β”‚ β”œβ”€β”€ foo2.hpp β”‚ └── wscript └── wscript 

This is the root of wscript :

 def options(opt) : opt.load('compiler_cxx') def configure(cnf) : cnf.load('compiler_cxx') def build(bld) : bld.recurse('library1') bld.recurse('application') 

This is application wscript :

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

This is library1 wscript

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

(Note: I tried to use target instead of name for library1 , and I also tried to enable the cxx cxxshlib functions for library1 .)

This is main.cpp :

 #include <wafproject/library1/foo1.hpp> #include <wafproject/library1/foo2.hpp> int main() { } 

And this is the error I get:

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

I do not want to change the way headers are included, but for this I clearly need to change the way I create my project.

I would be happy for any input, thanks.

EDIT: Solved, it was just a typo ( inludes instead of includes and export_inludes instead of export_includes ).

+4
source share
1 answer

Since this is the first thing google needs for a 'header only library waf', I thought I should post a general solution.

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

What works for me.

+1
source

Source: https://habr.com/ru/post/1445262/


All Articles