Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 786
Zack Avatar asked Dec 07 '22 21:12

Zack


2 Answers

The solution is:

SET(LINK_LIBRARY optimized Foo debug Foo_d)
target_link_libraries(MyEXE ${LINK_LIBRARY})
like image 100
Naszta Avatar answered Apr 02 '23 18:04

Naszta


The target_link_libraries command lets you use keywords which indicate that the library immediately following is to be used only for the corresponding build configuration, e.g.:

target_link_libraries(foo debug bard.lib optimized bar.lib)

If you add multiple libraries with one target_link_libraries statement, the keyword has to be repeated for each library.

like image 33
sakra Avatar answered Apr 02 '23 17:04

sakra