[CMake] Release and Debug build for same source folder?

Eric Noulard eric.noulard at gmail.com
Tue Sep 15 03:53:45 EDT 2009


2009/9/14 motes motes <mort.motes at gmail.com>:
> This is the CmakeList.txt for the Debug build:
[...]
>
> # Find ITK.
> SET(ITK_DIR ${EXTERNALS_DIR}/InsightToolkit-3.12.0/build)
>
> # Elastix build
> SET(ELASTIX_BUILD ${EXTERNALS_DIR}/elastix_sources_v4.1/src/build)

[...]

>
> The CMakeList.txt for the Release build is the same except from these lines:
>
> SET(ITK_DIR ${EXTERNALS_DIR}/InsightToolkit-3.12.0/buildRelease)
>
> # Elastix build
> SET(ELASTIX_BUILD ${EXTERNALS_DIR}/elastix_sources_v4.1/src/buildRelease)
>
> So its basically just two lines thats different between the two
> CMakeList.txt files, but I still need to build my project with CMake
> (and replace the correct CMakeList.txt file) each time I will change
> from Debug to Release or the other way around.

Then following your way it should be enough to do define
ITK_DIR and ELASTIX_BUILD depending on CMAKE_BUILD_TYPE, which
should be something like:

IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
    SET(ITK_DIR ${EXTERNALS_DIR}/InsightToolkit-3.12.0/build)
    SET(ELASTIX_BUILD ${EXTERNALS_DIR}/elastix_sources_v4.1/src/build)
ENDIF (CMAKE_BUILD_TYPE STREQUAL "Debug")

IF (CMAKE_BUILD_TYPE STREQUAL "Release")
    SET(ITK_DIR ${EXTERNALS_DIR}/InsightToolkit-3.12.0/buildRelease)
    SET(ELASTIX_BUILD ${EXTERNALS_DIR}/elastix_sources_v4.1/src/buildRelease)
ENDIF (CMAKE_BUILD_TYPE STREQUAL "Release")

However since ITK and may be ELASTIX seems to be build with CMake
you should have look at:
http://www.itk.org/Wiki/CMake:ExportInterface

which may be a better way to use "external" libraries.

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list