如何从Jamfile内部将cxxflags传递给Boost库? [英] How do I pass cxxflags to Boost libraries from within my jamfile?

查看:288
本文介绍了如何从Jamfile内部将cxxflags传递给Boost库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有一些要求的项目,其中之一是设置c ++ 11编译器/链接器标志:

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
    ;

使用特定的c ++ 11标志编译特定于库的源 ,但是提到的 Boost库却没有.这不会导致二进制不兼容和链接器错误的发生.

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.

我不想在用户配置或命令行中明确指定cxxflags.我想确保jamroot/jamfiles是正确构建项目所必需的.

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.

我该如何传递"密码?所需的cxxflags到依赖的Boost库?

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

更新:我最近尝试使用alias来实现我的目标.来自文档:

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

别名规则的另一种用法是更改构建属性.例如,如果要静态使用到Boost Threads库的链接,则可以编写以下内容:

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 ;

但是为boost_filesystem进行设置并重建,例如path.cpp仍然忽略了我要构建的属性.

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

推荐答案

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.

这篇关于如何从Jamfile内部将cxxflags传递给Boost库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆