[CMake] Setting build type

J Decker d3ck0r at gmail.com
Wed Feb 25 04:37:25 EST 2015


mkdir build-d
cd build-d
cmake
-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=out ../your/source/procject
cmake --build .
cd ..

mkdir build-r
cd build-r
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=out
../your/source/procject
cmake --build . --target install
cd ..


On Wed, Feb 25, 2015 at 1:16 AM, Adam Getchell <adam.getchell at gmail.com>
wrote:

> Thanks for your reply.
>
> I'm not sure I follow your answer. I do delete the directory each time I
> build, but I'm still not understanding how you're building release or debug
> versions to begin with.
>
> I'm just automatically getting Release, unless I edit CMakeCache.txt after
> I've built once.
>
> I just checked CGAL_CreateSingleSourceCGALProgram.cmake which is invoked
> in my CMakeLists.txt, but I do not see it setting the build type to Release.
>
> https://github.com/acgetchell/CDT-plusplus/blob/master/CMakeLists.txt
>
>
>
> On Tue, Feb 24, 2015 at 12:20 PM, J Decker <d3ck0r at gmail.com> wrote:
>
>> I use a different directory to build release and debug versions....
>>
>> if you didn't delete, then when it goes to build partial things, the .obj
>> files will still be newer than the .c files and will cause mixed
>> release-debug builds which generally results in bizarre crashes.
>> Once chosen, can't change the build type of a build; although if you
>> could it should do a clean also.
>>
>>
>> On Tue, Feb 24, 2015 at 11:42 AM, Adam Getchell <adam.getchell at gmail.com>
>> wrote:
>>
>>> Hello all,
>>>
>>> I've browsed this thread:
>>>
>>> http://www.cmake.org/pipermail/cmake/2008-September/023808.html
>>>
>>> But it doesn't work. My project is set to Release regardless, whether I
>>> do:
>>>
>>> project( CDT-plusplus_ )
>>> set(CMAKE_BUILD_TYPE RelWithDebInfo)
>>>
>>> Or:
>>>
>>> #
>>> # If the user specifies -DCMAKE_BUILD_TYPE on the command line, take
>>> their definition
>>> # and dump it in the cache along with proper documentation, otherwise
>>> set CMAKE_BUILD_TYPE
>>> # to Debug prior to calling PROJECT()
>>> #
>>> IF(DEFINED CMAKE_BUILD_TYPE)
>>>    SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the
>>> type of
>>> build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug
>>> Release RelWithDebInfo MinSizeRel.")
>>> ELSE()
>>>    SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build,
>>> options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release
>>> RelWithDebInfo MinSizeRel.")
>>> ENDIF()
>>>
>>> project( CDT-plusplus_ )
>>>
>>> The only way I can change the build type is by going into my build
>>> directory and editing CMakeCache.txt. However, I use an out of source
>>> build, so my build directory is generated automatically by scripts such as:
>>>
>>> https://github.com/acgetchell/CDT-plusplus/blob/master/scan-build.sh
>>>
>>> What's the correct method for being able to set the type of build via
>>> the command line?
>>>
>>> --
>>> Adam Getchell
>>> about.me/adamgetchell
>>> "Invincibility is in oneself, vulnerability in the opponent." -- Sun Tzu
>>>
>>> --
>>>
>>> Powered by www.kitware.com
>>>
>>> Please keep messages on-topic and check the CMake FAQ at:
>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Kitware offers various services to support the CMake community. For more
>>> information on each offering, please visit:
>>>
>>> CMake Support: http://cmake.org/cmake/help/support.html
>>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://public.kitware.com/mailman/listinfo/cmake
>>>
>>
>>
>
>
> --
> Adam Getchell
> about.me/adamgetchell
> "Invincibility is in oneself, vulnerability in the opponent." -- Sun Tzu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150225/5a803b5c/attachment-0001.html>


More information about the CMake mailing list