Release and Debug build for same source folder?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Release and Debug build for same source folder?

mort.motes
I would like to create a Release and Debug Build for my source files.
Currently I have been able to make both build types separately but it
would be nice to not have duplicated source files.

My source files depends on ITK and Elastix. I have therefore made both
a Debug and Release build for ITK and Elastix.

Now in my source folder I need to create two CMakelist.txt files. One
that uses the ITK and Elastix Release build and another that uses the
Debug builds. But how do I make CMake use the right CMakeList.txt
file?

Or am I doing it wrong?
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: Release and Debug build for same source folder?

Eric Noulard
2009/9/14 motes motes <[hidden email]>:

> I would like to create a Release and Debug Build for my source files.
> Currently I have been able to make both build types separately but it
> would be nice to not have duplicated source files.
>
> My source files depends on ITK and Elastix. I have therefore made both
> a Debug and Release build for ITK and Elastix.
>
> Now in my source folder I need to create two CMakelist.txt files. One
> that uses the ITK and Elastix Release build and another that uses the
> Debug builds. But how do I make CMake use the right CMakeList.txt
> file?

You should use

1) the debug/optimized etc... flags from
    target_link_libraries

2) may be some IF(CMAKE_BUILD_TYPE STREQUAL "Debug") etc...

If you post here an example of what is different in your currently
separated CMakeLists.txt files we could help you with more
expressive example.

You may browse the ML archive for thread talking about "build type"
like may be this one:
http://www.cmake.org/pipermail/cmake/2007-April/013479.html

--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: Release and Debug build for same source folder?

mort.motes
This is the CmakeList.txt for the Debug build:




cmake_minimum_required(VERSION 2.6)

PROJECT(MYPROJ)

SET(EXTERNALS_DIR D:/code/local/lib)
SET(PROJECT_LIB D:/code/MYPROJ/src/lib)

# Find ITK.
SET(ITK_DIR ${EXTERNALS_DIR}/InsightToolkit-3.12.0/build)

# Elastix source
SET(ELASTIX_SRC ${EXTERNALS_DIR}/elastix_sources_v4.1/src)
# Elastix build
SET(ELASTIX_BUILD ${EXTERNALS_DIR}/elastix_sources_v4.1/src/build)


FIND_PACKAGE(ITK REQUIRED)
IF(ITK_FOUND)
  INCLUDE(${ITK_USE_FILE})
ENDIF(ITK_FOUND)

INCLUDE_DIRECTORIES(${ELASTIX_SRC})
INCLUDE_DIRECTORIES(${ELASTIX_SRC}/Common)
INCLUDE_DIRECTORIES(${ELASTIX_SRC}/Common/ImageSamplers)
INCLUDE_DIRECTORIES(${ELASTIX_SRC}/Common/xout)
INCLUDE_DIRECTORIES(${ELASTIX_SRC}/Common/ParameterFileParser)
INCLUDE_DIRECTORIES(${ELASTIX_SRC}/Common/CostFunctions)
INCLUDE_DIRECTORIES(${ELASTIX_SRC}/Common/Transforms)

INCLUDE_DIRECTORIES(${ELASTIX_SRC}/Core)
INCLUDE_DIRECTORIES(${ELASTIX_SRC}/Core/Install)
INCLUDE_DIRECTORIES(${ELASTIX_SRC}/Core/Kernel)
INCLUDE_DIRECTORIES(${ELASTIX_SRC}/Core/Configuration)
INCLUDE_DIRECTORIES(${ELASTIX_SRC}/Core/ComponentBaseClasses)

INCLUDE_DIRECTORIES(${ELASTIX_SRC}/Components/ImageSamplers/Random)
INCLUDE_DIRECTORIES(${ELASTIX_SRC}/Components/Metrics/AdvancedMeanSquares)
INCLUDE_DIRECTORIES(${ELASTIX_SRC}/Components/Optimizers/StandardGradientDescent)

INCLUDE_DIRECTORIES(${PROJECT_LIB})
INCLUDE_DIRECTORIES(${PROJECT_LIB}/CImg-1.21)
INCLUDE_DIRECTORIES(${PROJECT_LIB}/zlib-1.2.3-lib/include)
INCLUDE_DIRECTORIES(${PROJECT_LIB}/revised)

LINK_DIRECTORIES(${ELASTIX_BUILD})
LINK_DIRECTORIES(${ELASTIX_BUILD}/Components/Optimizers/StandardGradientDescent)
LINK_DIRECTORIES(${ELASTIX_BUILD}/Common)
LINK_DIRECTORIES(${ELASTIX_BUILD}/Core)

ADD_EXECUTABLE(MYPROJ main.cpp )

TARGET_LINK_LIBRARIES(ADAPTIVE ITKCommon ITKAlgorithms ITKBasicFilters
ITKNumerics ITKIO ITKBasicFilters StandardGradientDescent elxCommon
elxCore)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -lX11 -Dcimg_use_xshm
-lXext -Dcimg_use_xrandr -lXrandr -O3 -fpermissive -march=nocona -m64
-ffast-math -funroll-loops -finline-functions")





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.







On Mon, Sep 14, 2009 at 10:37 PM, Eric Noulard <[hidden email]> wrote:

> 2009/9/14 motes motes <[hidden email]>:
>> I would like to create a Release and Debug Build for my source files.
>> Currently I have been able to make both build types separately but it
>> would be nice to not have duplicated source files.
>>
>> My source files depends on ITK and Elastix. I have therefore made both
>> a Debug and Release build for ITK and Elastix.
>>
>> Now in my source folder I need to create two CMakelist.txt files. One
>> that uses the ITK and Elastix Release build and another that uses the
>> Debug builds. But how do I make CMake use the right CMakeList.txt
>> file?
>
> You should use
>
> 1) the debug/optimized etc... flags from
>    target_link_libraries
>
> 2) may be some IF(CMAKE_BUILD_TYPE STREQUAL "Debug") etc...
>
> If you post here an example of what is different in your currently
> separated CMakeLists.txt files we could help you with more
> expressive example.
>
> You may browse the ML archive for thread talking about "build type"
> like may be this one:
> http://www.cmake.org/pipermail/cmake/2007-April/013479.html
>
> --
> Erk
> Membre de l'April - « promouvoir et défendre le logiciel libre » -
> http://www.april.org
> _______________________________________________
> 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
>
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: Release and Debug build for same source folder?

Eric Noulard
2009/9/14 motes motes <[hidden email]>:
> 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
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: Release and Debug build for same source folder?

mort.motes
I build the Debug and Release build the same way with cmake. Its first
when I open the .snl project in Visual Studio 2008 that I choose to
build it either with Release or Debug mode.

But as I understand your mail I have to move this responsibility to cmake?



On Tue, Sep 15, 2009 at 9:53 AM, Eric Noulard <[hidden email]> wrote:

> 2009/9/14 motes motes <[hidden email]>:
>> 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
> _______________________________________________
> 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
>
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: Release and Debug build for same source folder?

Eric Noulard
2009/9/15 motes motes <[hidden email]>:
> I build the Debug and Release build the same way with cmake. Its first
> when I open the .snl project in Visual Studio 2008 that I choose to
> build it either with Release or Debug mode.
>
> But as I understand your mail I have to move this responsibility to cmake?

Ahhh I always forgot about that because I'm not using the IDE
capability to switch build type.

Yes my solution was for 2 differents build tree thus under the CMake
responsibilty.

May be there is a better way to do what you want but
I'm afraid I'm not the right person for that kind of help, sorry about that :-(

--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
_______________________________________________
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