Hello, I have some questions regarding CMake generator for VS9. My library can be built as shared or static. Currently, this is handled using two different targets in CMakeLists.txt. The problem is that under Visual Studio 2008, those two targets are two projects !
So in the solution explorer I have something like : * MyLibrary_Solution * Module1_static * Module1_dynamic * Module2_static * Module2_dynamic ... This is really annoying, since the source files are the same, only the configuration changes (defines ...). I wondered whether it would be possible to have those different targets become different configurations. I would like to have such configurations : Static Debug Static Release Dynamic Debug Dynamic Release And such projects : Module 1 Module 2 Module 3 ... Here is my CMakeLists.txt for a module (Windowing) : ############################## Minimum CMake version to run > ################### CMAKE_MINIMUM_REQUIRED( VERSION 2.6 ) > ############################## Checks > ######################################### IF ( NOT CMAKE_BUILD_TYPE ) SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Available build types: Debug | > Release" FORCE ) ENDIF ( NOT CMAKE_BUILD_TYPE ) > ############################## Project name > ################################### PROJECT( Windowing ) > ############################## Preprocessor definitions > ####################### IF ( CMAKE_SYSTEM_NAME STREQUAL "Darwin" ) # MacOS ADD_DEFINITIONS( -DOMG_PLATFORM_MACOSX ) ELSEIF ( CMAKE_SYSTEM_NAME STREQUAL "Windows" ) # Windows ADD_DEFINITIONS( -DOMG_PLATFORM_WINDOWS ) ELSEIF ( CMAKE_SYSTEM_NAME STREQUAL "Linux" ) # Linux ADD_DEFINITIONS( -DOMG_PLATFORM_LINUX ) ENDIF () > ############################## Informative messages > ########################### MESSAGE( "--------------------------------------------------" ) MESSAGE( STATUS "Configuring project Windowing" ) MESSAGE( STATUS "Host system is ${CMAKE_SYSTEM_NAME}" ) MESSAGE( STATUS "Configuration is ${CMAKE_BUILD_TYPE}" ) > ############################## Sources > ######################################## FILE( GLOB_RECURSE WindowingSources ./PrivateSource/*.cpp ) # Scan > all source files FILE( GLOB_RECURSE WindowingHeaders ./PrivateInclude/*.h ) # Scan > all header files FILE( GLOB_RECURSE WindowingInterfaces ../../Include/Windowing/*.h ) # Scan > all interface files > SOURCE_GROUP("Public Interfaces" FILES ${WindowingInterfaces}) SOURCE_GROUP("Private Headers" FILES ${WindowingHeaders}) SOURCE_GROUP("Private Sources" FILES ${WindowingSources}) ############################## Includes > ####################################### INCLUDE_DIRECTORIES( ../../Include ) # Public headers INCLUDE_DIRECTORIES( ./PrivateInclude ) # Private headers > ############################## Project generation > ############################# ADD_LIBRARY( Windowing_static STATIC ${WindowingSources} > ${WindowingHeaders} ${WindowingInterfaces} ) # Windowing_static libraries ADD_LIBRARY( Windowing_dynamic MODULE ${WindowingSources} > ${WindowingHeaders} ${WindowingInterfaces} ) # Windowing_dynamic libraries > ############################## Target Properties > ############################## SET_TARGET_PROPERTIES( Windowing_static PROPERTIES LINKER_LANGUAGE CXX ) # > Linker language is.. SET_TARGET_PROPERTIES( Windowing_dynamic PROPERTIES LINKER_LANGUAGE CXX ) # > ..forced to C++ > SET_TARGET_PROPERTIES( Windowing_static PROPERTIES DEBUG_POSTFIX "d" ) # > Debug libraries have.. SET_TARGET_PROPERTIES( Windowing_dynamic PROPERTIES DEBUG_POSTFIX "d" ) # > ..a trailing "d" > SET_TARGET_PROPERTIES( Windowing_static PROPERTIES RELEASE_POSTFIX "" ) # > Release libraries have.. SET_TARGET_PROPERTIES( Windowing_dynamic PROPERTIES RELEASE_POSTFIX "" ) # > ..no postfix > SET_TARGET_PROPERTIES( Windowing_static PROPERTIES PREFIX "" ) # We > don't want.. SET_TARGET_PROPERTIES( Windowing_dynamic PROPERTIES PREFIX "" ) # ..the > "lib" prefix > SET_TARGET_PROPERTIES( Windowing_static PROPERTIES > ARCHIVE_OUTPUT_DIRECTORY ../../Build/Static${CMAKE_BUILD_TYPE} ) SET_TARGET_PROPERTIES( Windowing_dynamic PROPERTIES LIBRARY_OUTPUT_DIRECTORY > ../../Build/Dynamic${CMAKE_BUILD_TYPE} ) > SET_TARGET_PROPERTIES( Windowing_static PROPERTIES OUTPUT_NAME "Windowing" > ) SET_TARGET_PROPERTIES( Windowing_dynamic PROPERTIES OUTPUT_NAME "Windowing" > ) > SET_TARGET_PROPERTIES( Windowing_static PROPERTIES > COMPILE_DEFINITIONS_DEBUG OMG_DEBUG COMPILE_DEFINITIONS_RELEASE > OMG_RELEASE ) SET_TARGET_PROPERTIES( Windowing_dynamic PROPERTIES > COMPILE_DEFINITIONS_DEBUG OMG_DEBUG COMPILE_DEFINITIONS_RELEASE > OMG_RELEASE )
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake