开发者

Specifying different libraries for Debug & Release mode

开发者 https://www.devze.com 2023-02-22 16:33 出处:网络
I\'m trying to write a CMakeLists.txt file so that it generates a Visual Studio solu开发者_如何学编程tion. I have several external libraries, and some libraries have different import libraries for Deb

I'm trying to write a CMakeLists.txt file so that it generates a Visual Studio solu开发者_如何学编程tion. I have several external libraries, and some libraries have different import libraries for Debug & Release mode.

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.


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")

Also see the target_link_libraries command documentation.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号