【问题标题】:In boost build, how to set compiler options conditionally?在 boost build 中,如何有条件地设置编译器选项?
【发布时间】:2014-01-13 07:09:18
【问题描述】:

有没有办法(不修改源文件)指定我想用 msvc 来构建 boost,其中一组附加选项在调试中,另一组在发布变体中?在某些 config.jam 中,甚至在命令行中更好?喜欢

using msvc : : <compileflags>-DRELEASE_DEFINES; - only if variant=release
using msvc : : <compileflags>-DDEBUG_DEFINES; - only if variant=debug
using msvc : : <compileflags>-DLL_SPECIFIC_STUFF; - only if link=shared

我能够找到一个建议来使用像 variant=debug/somefeature=somevalue 这样的命令行,但这不起作用。

【问题讨论】:

    标签: boost-build


    【解决方案1】:

    好吧,经过一些实验,我能够通过 project-config.jam 使其工作,这是一个示例:

    import option ;
    import toolset ;
    
    using msvc ;
    
    toolset.flags msvc.compile CFLAGS <variant>release : "/GL /arch:SSE2 /fp:fast" : unchecked ;
    toolset.flags msvc.compile CFLAGS <variant>debug : "/RTCc /RTC1 /GS" : unchecked ;
    toolset.flags msvc.archive AROPTIONS <variant>release/<link>static : "/LTCG" : unchecked ;
    toolset.flags msvc.link LINKFLAGS <variant>release/<link>shared : "/LTCG /OPT:REF /OPT:ICF" : unchecked ;
    toolset.flags msvc.link LINKFLAGS <link>shared : "/PDB:c:\\Lib\\boost\\stage\\lib\\" : unchecked ;
    
    option.set keep-going : false ; 
    

    【讨论】:

      猜你喜欢
      • 2019-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-27
      • 2018-07-02
      • 2012-08-07
      • 2015-06-05
      • 1970-01-01
      相关资源
      最近更新 更多