[CMake] Decoupuling configuration and toolchain
Alexander Neundorf
a.neundorf-work at gmx.net
Thu Sep 23 14:09:31 EDT 2010
On Thursday 23 September 2010, Andrea Galeazzi wrote:
> Hi everybody,
> I've got a project with two configuration (Debug and Release) and two
> target: win32 and ARM.
> In your opinion what's the best way to manage a such kind of project?
> As an example, in my CmakeList I have the following piece of code that
> works fine only for visual studio.
> if(CMAKE_CONFIGURATION_TYPES)
> set(CMAKE_CONFIGURATION_TYPES Debug Release)
> set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}"
> CACHE STRING "Reset the configurations to what we need" FORCE)
> set(CMAKE_CXX_FLAGS_DEBUG "/D _DEBUG")
> set(CMAKE_CXX_FLAGS_RELEASE "/D _NDEBUG")
> endif()
In KDE we collect this in a separate file which is then include()d in the main
CMakeLists.txt.
This file has sections like
if(${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
.. setting for gcc
endif(${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
if(${CMAKE_CXX_COMPILER_ID} MATCHES MSVC)
... settings for MS compilers
endif(${CMAKE_CXX_COMPILER_ID} MATCHES MSVC)
if(${CMAKE_SYSTEM_NAME} MATCHES Linux)
... settings when building for Linux
endif(${CMAKE_SYSTEM_NAME} MATCHES Linux)
if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
... settings when building for Windows
endif(${CMAKE_SYSTEM_NAME} MATCHES Windows)
etc.
Alex
More information about the CMake
mailing list