I'm having trouble setting my default build configuration to Release, in my CMakeLists.txt file I set CMAKE_BUILD_TYPE at the top of the file with
#enable Release ALWAYS, configure vars
set(CMAKE_BUILD_TYPE Release)
set(EXECUTABLE_NAME "ParticleSimulator")
set(VERSION_MAJOR 0)
set(VERSION_MINOR 2)
but upon building my project and opening the solution, I'm always presented with Debug mode, contrary to what I specified in my CMakeLists file. What am I doing wrong? I've looked at some of the other question on there but didn't see anything that was specific to this question.
A gist of the CMakeLists.txt
There are a two type of generators: single-configurations and multi-configurations.
Single configurations
Make-like generators: Unix Makefiles, NMake Makefiles, MinGW Makefiles, ...
You set the configuration type on generate step:
In this case build step is always Debug:
Multi-configuration
IDE generators: Visual Studio, Xcode
CMAKE_BUILD_TYPE
on generate step is ignored, both:and
will have the same effect:
This is because all the configurations is internal (i.e.
_builds/msvc-opaque/Release
and_builds/msvc-opaque/Debug
or something, doesn't matter). You can use--config
options to switch:Control (?)
Yes, you can. Just define CMAKE_CONFIGURATION_TYPES:
Default output:
Rewrite it:
You can even define your own config-type:
And build:
Messy (?)
Not at all if you know the trick :) This is how to build/test config in script/CI server/documentation's build instruction etc:
Bad pattern
Good one
Works nice.
Thank you! :) you save a day for one programmer.
Works for me with Makefile, I'm happy ...
Some quote from a nice book of a nice guy you probably know (emphasis mine):