[vtkusers] Creating different named dll's for debug and release - possible?
John Drescher
drescherjm at gmail.com
Mon Feb 13 14:49:52 EST 2012
On Mon, Feb 13, 2012 at 7:26 AM, Jon Payne <jpayne at hgl-dynamics.com> wrote:
> Hi all,
>
> At when building VTK shared libraries (DLL's on windows specifically) the
> debug and release mode dll's are given the same name. Does anyone know if it
> is possible to give them different names e.g. add a _debug or _release
> suffix?
>
> I know you can't _currently_ but is it possible using CMake? And if so how?
> :)
>
> This would really help us because at the moment when we're developing (and
> deploying) and switching between debug/release mode the wrong version of the
> DLL's can get loaded causing crashes and sometimes hard to diagnose
> problems.
>
Here is what I do in my own projects. One could adapt similar to VTK.
Possibly by just setting the POSTFIX variables with a -D when invoking
cmake.
# GetComplilerVersion.cmake
OPTION(DEBUG_COMPILER_VERSION "Debug the compiler version determination" OFF)
# Attempt to guess the compiler suffix
# NOTE: this is not perfect yet, if you experience any issues
# please report them and use the PROJECT_COMPILER_VERSION variable
# to work around the problems.
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel"
OR "${CMAKE_CXX_COMPILER}" MATCHES "icl"
OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
if(WIN32)
set (PROJECT_COMPILER_VERSION "iw")
else()
set (PROJECT_COMPILER_VERSION "il")
endif()
elseif (MSVC90)
set(PROJECT_COMPILER_VERSION "vc90")
elseif (MSVC10)
set(PROJECT_COMPILER_VERSION "vc100")
elseif (MSVC80)
set(PROJECT_COMPILER_VERSION "vc80")
elseif (MSVC71)
set(PROJECT_COMPILER_VERSION "vc71")
elseif (MSVC70) # Good luck!
set(PROJECT_COMPILER_VERSION "vc7") # yes, this is correct
elseif (MSVC60) # Good luck!
set(PROJECT_COMPILER_VERSION "vc6") # yes, this is correct
elseif (BORLAND)
set(PROJECT_COMPILER_VERSION "bcb")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "SunPro")
set(PROJECT_COMPILER_VERSION "sw")
elseif (MINGW)
set(PROJECT_COMPILER_VERSION "mgw") # no GCC version encoding prior to 1.34
elseif (UNIX)
if (CMAKE_COMPILER_IS_GNUCXX)
set(PROJECT_COMPILER_VERSION "gcc") # no GCC version encoding prior to 1.34
endif (CMAKE_COMPILER_IS_GNUCXX)
endif()
if(DEBUG_COMPILER_VERSION)
# message(STATUS "compiler is : ${CMAKE_CXX_COMPILER_ID}
${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ABI}")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"guessed PROJECT_COMPILER_VERSION = ${PROJECT_COMPILER_VERSION}")
endif()
if (CMAKE_SIZEOF_VOID_P MATCHES 8)
set( PROJECT_ARCH "x86_64" )
else(CMAKE_SIZEOF_VOID_P MATCHES 8)
set( PROJECT_ARCH "x86" )
endif(CMAKE_SIZEOF_VOID_P MATCHES 8)
if (NOT "${PROJECT_COMPILER_VERSION}" STREQUAL "")
set (${PROJECT_NAME}_VERSION_PATCH
"${${PROJECT_NAME}_VERSION_PATCH}.${PROJECT_COMPILER_VERSION}")
endif (NOT "${PROJECT_COMPILER_VERSION}" STREQUAL "")
IF (CMAKE_SIZEOF_VOID_P MATCHES 8)
set (${PROJECT_NAME}_VERSION_PATCH
"${${PROJECT_NAME}_VERSION_PATCH}.${PROJECT_ARCH}")
ENDIF(CMAKE_SIZEOF_VOID_P MATCHES 8)
#NamingConvention.cmake
macro( setup_naming_convention Name )
if (NOT "${PROJECT_COMPILER_VERSION}" STREQUAL "")
if (NOT "${${Name}_VERSION_STRING}" STREQUAL "")
set(ARCH_SUFFIX)
if (NOT "${PROJECT_ARCH}" STREQUAL "")
set(ARCH_SUFFIX "-${PROJECT_ARCH}")
endif (NOT "${PROJECT_ARCH}" STREQUAL "")
SET(CMAKE_DEBUG_POSTFIX
"-${${Name}_VERSION_STRING}-d-${PROJECT_COMPILER_VERSION}${ARCH_SUFFIX}")
SET(CMAKE_RELEASE_POSTFIX
"-${${Name}_VERSION_STRING}-r-${PROJECT_COMPILER_VERSION}${ARCH_SUFFIX}")
SET(CMAKE_RELWITHDEBINFO_POSTFIX
"-${${Name}_VERSION_STRING}-rd-${PROJECT_COMPILER_VERSION}${ARCH_SUFFIX}")
SET(CMAKE_MINSIZEREL_POSTFIX
"-${${Name}_VERSION_STRING}-rms-${PROJECT_COMPILER_VERSION}${ARCH_SUFFIX}")
else(NOT "${${Name}_VERSION_STRING}" STREQUAL "")
message( WARNING "${Name}_VERSION_STRING must be set before using
the setup_naming_convention MACRO." )
endif(NOT "${${Name}_VERSION_STRING}" STREQUAL "")
else(NOT "${PROJECT_COMPILER_VERSION}" STREQUAL "")
message( WARNING "PROJECT_COMPILER_VERSION must be set before using
the setup_naming_convention MACRO." )
endif (NOT "${PROJECT_COMPILER_VERSION}" STREQUAL "")
endmacro( setup_naming_convention )
John
More information about the vtkusers
mailing list