[Cmake] Debug and Release library name
Brad King
brad.king at kitware.com
Tue Mar 28 14:11:05 EST 2006
Viroleau, Vincent (SCR US EXT) wrote:
> I'm working with Cmake and VS2005, and I would like to have, in the same project,
> a different name of the library I'm building depending on if I'm on Debug or Release configuration.
>
> For example, if I'm on Debug mode, I would like the output to be mylib_d.dll,
> and if I'm on Release mode : mylib.dll
>
> I would like also to be able to link with different library depending on the build status.
>
> For example :
>
> When I'm on Debug mode : TARGET_LINK_LIBRARIES(MyLib_d depend_d)
> And on the Release mode : TARGET_LINK_LIBRARIES(MyLib depend)
>
> Here is my Cmakelist :
>
> PROJECT(MyLib)
>
>
> SET(SRCS init.cpp)
> SET(HEADS init.h)
>
SET(CMAKE_DEBUG_POSTFIX _d)
> ADD_LIBRARY(MyLib SHARED ${SRCS} ${HEADS})
>
> TARGET_LINK_LIBRARIES(MyLib depend)
If "depend" is built by the same project then it should just work. If
it is an outside library then you need
TARGET_LINK_LIBRARIES(MyLib debug depend_d optimized depend)
FYI, CVS CMake has much better support for this, and it will be included
in the next release. CMake 2.2 and earlier were a bit flaky with
CMAKE_DEBUG_POSTFIX.
-Brad
More information about the CMake
mailing list