CMake: Only set CMAKE_BUILD_TYPE_INIT when not set
authorCampbell Barton <ideasman42@gmail.com>
Mon, 26 Jun 2017 23:50:35 +0000 (09:50 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 26 Jun 2017 23:50:35 +0000 (09:50 +1000)
Convenience makefile now uses CMAKE_BUILD_TYPE_INIT,
this means you can change the build type of an existing build
and it won't be overwritten when running `make`.

Useful if you want to add debug info to a release build for profiling.

CMakeLists.txt
GNUmakefile

index e7917278434e55d8d96b6f703bd9dd0024f47d4c..04237812d8709995298c167182b150684769c188 100644 (file)
@@ -58,7 +58,9 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/Modules")
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/platform")
 
 # avoid having empty buildtype
-set(CMAKE_BUILD_TYPE_INIT "Release")
+if(NOT DEFINED CMAKE_BUILD_TYPE_INIT)
+       set(CMAKE_BUILD_TYPE_INIT "Release")
+endif()
 
 # quiet output for Makefiles, 'make -s' helps too
 # set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
index 86964e68873e08789c7294bff68d122a53433560..ba7f89c3097317b5f3a06be36323748fca941872 100644 (file)
@@ -104,7 +104,7 @@ endif
 CMAKE_CONFIG = cmake $(BUILD_CMAKE_ARGS) \
                      -H"$(BLENDER_DIR)" \
                      -B"$(BUILD_DIR)" \
-                     -DCMAKE_BUILD_TYPE:STRING=$(BUILD_TYPE)
+                     -DCMAKE_BUILD_TYPE_INIT:STRING=$(BUILD_TYPE)
 
 
 # -----------------------------------------------------------------------------