How do I pass cxxflags to Boost libraries from within my jamfile?

允我心安 提交于 2019-12-23 03:36:09

问题


I have a project with some requirements, one of which is to set the c++11 compiler/linker flags:

jamroot.jam:

project
    : requirements
      <toolset>clang:<cxxflags>"-stdlib=libc++ -std=c++11"
      <toolset>clang:<linkflags>"-lc++"
      # ... etc
    ;

lib mylibrary
    : #sources
        [ glob source/*.cpp ]
        /boost/filesystem
        /boost/system
        /boost/thread//boost_thread
    ;

The library-specific sources are being compiled with the necessary c++11 flags, however the Boost libraries mentioned do not. This is causing no end of binary incompatibilities and linker errors.

I do not want to specify the cxxflags explicitly in either the user-config or the command line. I would like to make sure the jamroot/jamfiles are all that is necessary to build the project properly.

How do I "pass in" the desired cxxflags to the dependent Boost libraries?

Update: I recently tried using an alias to accomplish my goal. From the docs:

Another use of the alias rule is to change build properties. For example, if you want to use link statically to the Boost Threads library, you can write the following:

alias threads : /boost/thread//boost_thread : <link>static ;

However setting this up for boost_filesystem and rebuilding, say, path.cpp still omits the properties I am trying to build with.


回答1:


This was resolved by setting up a feature (thanks to Steven Watanabe):

feature.feature cpp11 :
    on :
    composite optional propagated
    ;

feature.compose <cpp11>on :
        <cxxflags>"-stdlib=libc++ -std=c++11"
        <define>BOOST_NO_CXX11_NUMERIC_LIMITS=1
        <linkflags>"-lc++"
    ;

project
    : requirements
      <cpp11>on
      # ... etc
    ;

Apparently this is the only way to get variables to propagate to dependent libraries.



来源:https://stackoverflow.com/questions/19599194/how-do-i-pass-cxxflags-to-boost-libraries-from-within-my-jamfile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!