[CMake] select debug or optimized at make time instead of at cmake time

Alexander Neundorf a.neundorf-work at gmx.net
Fri Oct 6 17:34:07 EDT 2006


Hi,

Von: Brad King <brad.king at kitware.com>

> Richard Fuchs wrote:
> > Is there a way to be able to select if the build will be debug or
> > optimized at make time instead of during cmake time?
> > 
> > So, I can SET(CMAKE_BUILD_TYPE Debug) or SET(CMAKE_BUILD_TYPE Release)
> > for debug or optimized code respectively, then when I run make, the
> > corresponding compiler flags are set.  What I'd like to be able to do is
> > have it so that when I run 'make', it uses debug flags and when a run
> > something like 'make release', it'll use the optimize flags.  Is
> > something like this possible?
> 
> Not with the current Makefile generators.  The Xcode and Visual Studio
> generators do this because the native tools support multiple
> configurations chosen at build time.  The current Makefile generator
> design is single-configuration only, so CMAKE_BUILD_TYPE is used to
> select which one to build.
> 
> You might be able to fake it by having a tiny top level CMakeLists.txt
> file that just contains custom targets called "debug" and "release" that
> use ctest --build-and-test to drive builds of a sub-project setting
> CMAKE_BUILD_TYPE to debug or release respectively.

Or you simply create two build directories, one set up for release builds, and one setup for debug builds. For that you have to use out-of-source builds.

Bye
Alex

-- 
GMX DSL-Flatrate 0,- Euro* - Überall, wo DSL verfügbar ist!
NEU: Jetzt bis zu 16.000 kBit/s! http://www.gmx.net/de/go/dsl


More information about the CMake mailing list