【问题标题】:Use bjam to build two libraries with same sources使用 bjam 构建两个具有相同源的库
【发布时间】:2016-09-08 08:00:39
【问题描述】:

我正在使用 Boost 的 bjam,我正在尝试从同一个 Jamfile 构建同一个库的两个不同版本。需要使用定义的宏来构建库的一个版本以启用特殊功能。我希望在同一个最终位置实现两个不同的名称库。

举例来说,

lib a
: [glob a.cpp]
;

lib a_special
: [glob a.cpp]
: <define>SPECIAL_FUNCTIONALITY
;

问题在于a.o(从a.cpp 生成的目标文件)被生成了两次——每个目标一次。我从 bjam 得到的实际错误是

error: Name clash for '<pbin/gcc-5.2.1/debug/link-static>a.o'
error: 
error: Tried to build the target twice, with property sets having 
error: these incompatible properties:
error: 
error:     -  none
error:     -  <define>SPECIAL_FUNCTIONALITY
error: 

有谁知道让目标的中间文件转到不同位置的方法吗? 谁能想到更好的方法来实现我想要做的事情?

【问题讨论】:

    标签: c++ boost bjam


    【解决方案1】:

    定义为free, and incidental, features,不会影响构建变体。您需要做的是创建一个非附带的功能来描述改变您生成的构建的属性。例如:

    import feature : feature ;
    feature special : off on : propagated ;
    
    lib a : a.cpp : <special>off ;
    lib a_special : a.cpp : <special>on <special>on:<define>SPECIAL_FUNCTIONALITY ;
    

    上面使用目标要求来定义当您要求特殊功能时要构建的库。它还使用条件属性来定义特殊库上的预定义符号。一旦定义了特性,还有其他方法可以获得等效结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-25
      • 1970-01-01
      • 2020-12-29
      • 1970-01-01
      相关资源
      最近更新 更多