【问题标题】:Adding different include directory for Debug and Release builds in Cmake?在 Cmake 中为调试和发布版本添加不同的包含目录?
【发布时间】:2018-08-28 03:18:35
【问题描述】:

我正在开发一个库,我需要添加一个仅用于调试构建的第三方标头库。它仅用于开发。

在 CMake 中是否有一种简单的方法可以做到这一点?

我知道我们可以do the same for linking libraries

add_executable( MyEXE ${SOURCES})

target_link_libraries( MyEXE debug 3PDebugLib)
target_link_libraries( MyEXE optimized 3PReleaseLib)

target_include_directories 似乎没有这样的选项。

使用 CMake 3.11.4 和 VS2017。

【问题讨论】:

    标签: cmake


    【解决方案1】:

    虽然target_include_directories 本身不提供区分不同构建类型的可能性,但您可以使用generator expressions,例如:

    target_include_directories(MyEXE
        PRIVATE
            $<$<CONFIG:Debug>:3PDebugLib>
            $<$<CONFIG:Release>:3PReleaseLib>
    )
    

    【讨论】:

    • target_include_directories (foo_exe PRIVATE $:debug_dir,release_dir>)
    猜你喜欢
    • 2018-11-13
    • 2014-01-05
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    • 2018-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多