为Debug&指定不同的库释放模式 [英] Specifying different libraries for Debug & Release mode
问题描述
我正在尝试编写一个 CMakeLists.txt
文件,以便它生成Visual Studio解决方案。我有几个外部库,有些库具有用于Debug&的不同导入库。释放模式。
I'm trying to write a CMakeLists.txt
file so that it generates a Visual Studio solution. I have several external libraries, and some libraries have different import libraries for Debug & Release mode.
在Visual Studio中,我将手动选择每种模式,然后更改库的名称和所需的目录。我想我需要玩 target_link_libraries
和 set(CMAKE_BUILD_TYPE Release)
,但是到目前为止我还没有运气。
In Visual Studio, I'd manually select each mode, and change the name of the library and the required directory. I think I need to play with target_link_libraries
and set(CMAKE_BUILD_TYPE Release)
but I haven't had any luck so far.
推荐答案
target_link_libraries
命令支持调试和优化关键字,表示紧随其后的库仅用于相应的构建配置:
The target_link_libraries
command supports "debug" and "optimized" keywords, which indicate that the library immediately following it is to be used only for the corresponding build configuration:
target_link_libraries(MyTarget debug externalLib_d optimized externalLib)
如果调试和发布库位于不同的目录中,请指定完整路径,即:
If the debug and release libraries reside in different directories, specify the full path, i.e.:
target_link_libraries(MyTarget debug "debug_dir/externalLib_d" optimized "release_dir/externalLib")
另请参见 target_link_libraries命令文档。
这篇关于为Debug&指定不同的库释放模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!