Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

windows

cmake

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

like image 638
gct Avatar asked Feb 05 '10 19:02

gct


1 Answers

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) 
like image 122
Mike Willekes Avatar answered Oct 03 '22 01:10

Mike Willekes