[Cmake] CMake 1.8.2: Visual Studio 6 library postfix

Stefan Kowski stefan.kowski at gmx.de
Thu, 29 Jan 2004 12:47:20 +0100


Hi all,

given this example CMakeLists.txt file:

PROJECT(TestLib)

IF(WIN32)
   IF(CMAKE_BUILD_TYPE MATCHES "Debug")
      SET(PPVM_LIB_SUFFIX "sd")
      SET(PPVM_DLL_SUFFIX "d")
   ELSE(CMAKE_BUILD_TYPE MATCHES "Debug")
      SET(PPVM_LIB_SUFFIX "s")
      SET(PPVM_DLL_SUFFIX "")
   ENDIF(CMAKE_BUILD_TYPE MATCHES "Debug")
ELSE(WIN32)
   SET(PPVM_LIB_SUFFIX "")
   SET(PPVM_DLL_SUFFIX "")
ENDIF(WIN32)

MESSAGE("CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}")
MESSAGE("CMAKE_INTDIR is ${CMAKE_INTDIR}")
MESSAGE("CMAKE_CFG_INTDIR is ${CMAKE_CFG_INTDIR}")
MESSAGE("suffix is ${PPVM_LIB_SUFFIX}")

SET(TARGET_TESTLIB TestLib${PPVM_LIB_SUFFIX})
ADD_LIBRARY(${TARGET_TESTLIB} source/TestLib.cpp)

ADD_CUSTOM_COMMAND(
	TARGET	${TARGET_TESTLIB}
	POST_BUILD
	COMMAND ${CMAKE_COMMAND}
	ARGS 	-E copy

${TestLib_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${TARGET_TESTLIB}${CMAKE_STATIC_LI
BRARY_SUFFIX}
         	${TestLib_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${TARGET_TESTLIB}.extend
	)

I want to set the target file name depending on the library type
(static/shared) and the build type (debug/release), eg. TestLibs.lib for
static/release and TestLibd.dll for shared/debug.

For the build, I use the NMake Makefiles generator for batch builds and
Visual Studio 6 generator for development.

Everything works fine with NMake, but using Visual Studio the variable
CMAKE_BUILD_TYPE is not set and the library suffix is not being set
correctly.

Is it possible to refer to the build type selected in Visual Studio to be
able to set the name of the targets?

Another question:

To copy a file, I can use 'cmake -E copy'. Is it possible to move a file, I
did not find a 'cmake -E move' command?

Greetings,
Stefan