问题描述
所以我有一个正在编译的库,我需要根据它是调试版本还是发布版本(特别是这些库的发布版本或调试版本)来链接不同的第三方内容.在 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 中为调试和发布构建链接不同的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!