[CMake] Selecting DEBUG and RELEASE Builds in Linux

BlinkEye gentoo at blinkeye.ch
Wed Mar 5 02:13:43 EST 2008


I guess you missed my answer yesterday ...

If I'm not mistaken calling just cmake path_to_your_project_srcs doesn't set the
BUILD_TYPE to anything.

What about the following:

% cd build/your_project/debug;
% cmake path_to_project_srcs -DCMAKE_BUILD_TYPE=DEBUG

% cd build/your_project/release
% cmake path_to_project_srcs -DCMAKE_BUILD_TYPE=RELEASE

You could easily create aliases for these 2 commands, like:

alias cmakedebug='cmake $1 -DCMAKE_BUILD_TYPE=DEBUG'
alias cmakerelease='cmake $1 -DCMAKE_BUILD_TYPE=RELEASE'

which would be used like:

% cd build/your_project/debug
% cmakedebug path_to_project_srcs

or

% cd build/your_project/release
% cmakerelease path_to_project_srcs

respectively.

To set a default build type I suggest the following:

if( NOT CMAKE_BUILD_TYPE )
  set( CMAKE_BUILD_TYPE Debug CACHE STRING
       "Choose the type of build, options are: None Debug Release RelWithDebInfo
MinSizeRel."
       FORCE )
endif()

This will just overwrite the CMAKE_BUILD_TYPE if it has not been set.

On Wed, March 5, 2008 07:02, Malhotra, Anupam wrote:
> Hi David
>
> Thanks for the help. I understood your solution but I want your help to
> implement this solution in my project. I am automating the entire build
> process which does not require any manual intervention. Now to achieve
> this after writing all my CMakeLists.txt files, I just give the command,
>
> "cmake ."
>
>
>
> in  the source directory. This creates all the relevant makefiles. Now
> my question is:
>
>
>
> 1.	What is the default BUILD TYPE if we are not changing anything?
> 2.	Is there a way if we can set the BUILD TYPE in my CMakeLists.txt
> so that after giving the command "cmake ." at the command prompt, I get
> the particular build type set in my makefiles?
>
>
>
> Thanks and Regards
>
> Anupam Malhotra
>
>
>
> ________________________________
>
> From: David Cole [mailto:david.cole at kitware.com]
> Sent: Tuesday, March 04, 2008 6:23 PM
> To: Malhotra, Anupam
> Cc: cmake at cmake.org
> Subject: Re: [CMake] Selecting DEBUG and RELEASE Builds in Linux
>
>
>
> With a make file generator, you do set CMAKE_BUILD_TYPE to Debug or
> Release at configure time. Then, if you want both builds, you need to
> have two build trees, one configured for Debug, the other for Release.
> The part of the Wiki you are referring to only applies to IDEs that have
> their own project files that manage multiple configurations at build
> time, like Visual Studio and Xcode.
>
>
> HTH,
> David
>
>
>
> On 3/4/08, Malhotra, Anupam <Anupam.Malhotra at safenet-inc.com> wrote:
>
> Hi
>
>
>
> I read on the CMake wiki page that:
>
>
>
> CMAKE_BUILD_TYPE is not initialized with a readable value at
> configuration time. This is because the user is free to select a build
> type at build time. Now in visual studio 6/visual studio 8 2005 we can
> select the build type by selecting Debug/Release after opening the
> workspace/solution. But how can the same be achieved in Linux? After my
> makefiles are generated using cmake, I want to first build the Debug
> mode and then the release mode. But how do I select which build type to
> select while building? Please advise.
>
>
>
> Thanks and Regards
>
> Anupam Malhotra
>
>
>
> The information contained in this electronic mail transmission
>
> may be privileged and confidential, and therefore, protected
>
> from disclosure. If you have received this communication in
>
> error, please notify us immediately by replying to this
>
>
>
>
> message and deleting it from your computer without copying
>
> or disclosing it.
>
>
>
>
>
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
>
>
>
> The information contained in this electronic mail transmission
> may be privileged and confidential, and therefore, protected
> from disclosure. If you have received this communication in
> error, please notify us immediately by replying to this
> message and deleting it from your computer without copying
> or disclosing it.
>
>
_______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake




More information about the CMake mailing list