Linking different libraries for Debug and Release builds in Cmake on windows?(在 Windows 上的 Cmake 中为调试和发布构建链接不同的库?)
问题描述
所以我有一个正在编译的库,我需要根据它是调试版本还是发布版本(特别是这些库的发布版本或调试版本)来链接不同的第三方内容.在 Cmake 中有没有一种简单的方法可以做到这一点?
我应该注意我使用的是visual studio
根据 CMake 文档:
target_link_libraries( [lib1 [lib2 [...]]] [[debug|optimized|general] ] ...) <块引用>
调试"、优化"或常规"关键字表示库紧随其后使用仅适用于相应的构建配置.
所以你应该能够做到这一点:
add_executable( MyEXE ${SOURCES})target_link_libraries(MyEXE 调试 3PDebugLib)target_link_libraries(MyEXE优化的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)
这篇关于在 Windows 上的 Cmake 中为调试和发布构建链接不同的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Windows 上的 Cmake 中为调试和发布构建链接不同的库?
基础教程推荐
- c++ STL设置差异 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
