Saturday, October 30, 2021

[SOLVED] Link library based on build configuration [cmake]

Issue

Possible Duplicate:
Debug and Release Library Linking with CMAKE (VISUAL STUDIO)

cmake newb here, I would like to tell target_link_libraries to link a debug lib when using the debug configuration and link to a release lib when compiling under the release configuration.

How do I tell cmake to link a different lib file for the debug configuration?


Solution

The solution is:

SET(LINK_LIBRARY optimized Foo debug Foo_d)
target_link_libraries(MyEXE ${LINK_LIBRARY})


Answered By - Naszta