Linking different libraries for Debug and Release builds in Cmake on windows?

本文介绍如何使用CMake根据不同构建配置(调试或发布版本)来选择链接不同的第三方库。通过`target_link_libraries`命令结合`debug`和`optimized`关键字实现这一目的。

问题叙述性说明:

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?


解决方法:

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) 


參考:

http://stackoverflow.com/questions/2209929/linking-different-libraries-for-debug-and-release-builds-in-cmake-on-windows


版权声明:本文博客原创文章,博客,未经同意,不得转载。

转载于:https://www.cnblogs.com/gcczhongduan/p/4658341.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值