[CMake] linking to different libraries in Debug and Release

Mike Jackson imikejackson at gmail.com
Wed Jan 23 15:28:03 EST 2008


What you need to do is to make a list of both libraries and store  
that in a variable with some "extras"

SET(MYLIB_LIBRARIES optimized mylib debug mylibd)

Then, TARGET_LINK_LIBRARIES(MY_EXE ${MYLIB_LIBRARIES})

VS should do the right thing.

Mike

On Jan 23, 2008, at 3:09 PM, Sylvain Jaume wrote:

> Hi Eric,
>
> It doesn't work because CMAKE_BUILD_TYPE is not defined at  
> configuration time for Visual Studio.
>
> Thanks anyway.
> Sylvain
>
> On Jan 23, 2008 2:27 PM, Eric Noulard < eric.noulard at gmail.com> wrote:
> 2008/1/23, Sylvain Jaume <sylvainjaume at gmail.com>:
> > Hi,
> >
> > How can I link to mylib.dll in Release and mylibd.dll in Debug?
> > I use VS8 and both libraries are in the same directory.
>
> I don't if it would work for VS8 but I would try:
>
> IF("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
>   SET(MYLIB "mylibd")
> ELSE("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
>   SET(MYLIB "mylib")
> ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
>
> TARGET_LINK_LIBRARIES(MY_EXE ${MYLIB})
>
> --
> Erk
>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20080123/0c77bc3e/attachment.html


More information about the CMake mailing list