[vtkusers] Coexistence of different Win32 libraries

John Drescher drescherjm at gmail.com
Mon Dec 28 10:45:11 EST 2009


> On Win32, I want to build both release and debug libraries for both VS2005
> and VS2008. I've run CMake twice to output to different VS2005 and VS2008
> directories, and set the install path to distinct directories. But I don't
> see how to get both debug and release versions without using distinct build
> and install directories for each (ie. running CMake 4 times to create 4
> completely different builds). Is there a CMake variable to build the debug
> versions with a "d" suffix, for example?

Here is what I do.

IF(MSVC)
    SET(CMAKE_CXX_FLAGS "/MP /WL /GR /EHsc" )
    ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
	
	IF(MSVC90)
		SET(CMAKE_DEBUG_POSTFIX "_d_2008")
		SET(CMAKE_RELEASE_POSTFIX "_2008")
		SET(CMAKE_RELWITHDEBINFO_POSTFIX "_2008")
	ENDIF(MSVC90)
	
	IF(MSVC80)
		SET(CMAKE_DEBUG_POSTFIX "_d_2005")
		SET(CMAKE_RELEASE_POSTFIX "_2005")
		SET(CMAKE_RELWITHDEBINFO_POSTFIX "_2005")
	ENDIF(MSVC80)
	
	IF(MSVC71)
		SET(CMAKE_DEBUG_POSTFIX "_d_2003")
		SET(CMAKE_RELEASE_POSTFIX "_2003")
		SET(CMAKE_RELWITHDEBINFO_POSTFIX "_2003")
	ENDIF(MSVC71)
	
	IF(MSVC70)
		SET(CMAKE_DEBUG_POSTFIX "_d_2002")
		SET(CMAKE_RELEASE_POSTFIX "_2002")
		SET(CMAKE_RELWITHDEBINFO_POSTFIX "_2002")
	ENDIF(MSVC70)
	
	IF(MSVC60)
		SET(CMAKE_DEBUG_POSTFIX "_d_vc6")
		SET(CMAKE_RELEASE_POSTFIX "_vc6")
		SET(CMAKE_RELWITHDEBINFO_POSTFIX "_vc6")
	ENDIF(MSVC60)
		
configure_file (
	"${PROJECT_SOURCE_DIR}/install.bat.in"
	"${PROJECT_BINARY_DIR}/Batch/install.bat"
)
ELSE(MSVC)
	SET(CMAKE_DEBUG_POSTFIX "_d")
ENDIF(MSVC)



More information about the vtkusers mailing list