将不同的库链接到Cmake中的Debug和Release版本? [英] Linking different libraries for Debug and Release builds in Cmake on windows?

查看:6031
本文介绍了将不同的库链接到Cmake中的Debug和Release版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个库我编译,我需要链接不同的第三方事情,取决于它是调试还是发布版本(特别是那些库的发布或调试版本)。



编辑:我应该注意我正在使用visual studio

解决方案

根据 CMake文档

  target_link_libraries(< target> [lib1 [lib2 [...]]] [[debug | optimized | general ]< lib>] ...)




,optimized或general
关键字指示紧接其后的库
将仅用于对应的构建
配置中的


所以你应该能够这样做:

  add_executable(MyEXE $ {SOURCES})

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

So I've got a library I'm compiling and I need to link different third party things in depending on if it's the debug or release build (specifically the release or debug versions of those libraries). Is there an easy way to do this in Cmake?

Edit: I should note I'm using visual studio

解决方案

According to the CMake documentation:

target_link_libraries(<target> [lib1 [lib2 [...]]] [[debug|optimized|general] <lib>] ...)

A "debug", "optimized", or "general" keyword indicates that the library immediately following it is to be used only for the corresponding build configuration.

So you should be able to do this:

add_executable( MyEXE ${SOURCES})

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

这篇关于将不同的库链接到Cmake中的Debug和Release版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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