[CMake] libraryname decoration

John Drescher drescherjm at gmail.com
Fri Jul 30 08:16:01 EDT 2010


> Please do explain. How would this work? What would the API be? And now it suddenly sounds like CMake isn't supposed to do everything automagically anymore. If that is the case, please RTFM and look into the OUTPUT_NAME target property. It offers exactly what you want!
>

Or the prefix variables.

I have the following in a file called NamingConvention.cmake.

IF(MSVC)
	
	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)
	
	#Name 64bit libaraies differenly
	IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
		SET(CMAKE_DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}_x64")
		SET(CMAKE_RELEASE_POSTFIX "${CMAKE_RELEASE_POSTFIX}_x64")
		SET(CMAKE_RELWITHDEBINFO_POSTFIX "${CMAKE_RELWITHDEBINFO_POSTFIX}_x64")
		
		IF(DETECT_64BIT_PORTABILITY)
			SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wp64")
		ENDIF(DETECT_64BIT_PORTABILITY)
	ENDIF(CMAKE_SIZEOF_VOID_P MATCHES 8)
		
ENDIF(MSVC)

To activate the naming convention for any of my projects I just call
include(CMake\NamingConvention.cmake) in the top of my CMakeLists.txt
and my libraries all have decorated names that distinguish between
compiler name and 32/64 bit. If I wanted I could spend 5 minutes and
add gcc and other defined compilers to this.

John


More information about the CMake mailing list