Be able to overwrite BUILD_TYPE using CLI 85/15085/3 sandbox/sdesneux/4a_master
authorRomain Forlot <romain.forlot@iot.bzh>
Fri, 6 Jul 2018 14:10:33 +0000 (16:10 +0200)
committerRomain Forlot <romain.forlot@iot.bzh>
Tue, 10 Jul 2018 14:01:48 +0000 (16:01 +0200)
If not defined using CLI CMake set the variable CMAKE_BUILD_TYPE
to an empty value. As it is a CACHE variable it can't be
overwritten except if you force it. This fix setting this variable
the first defined value wins:

CLI > Config.cmake > Default value (DEBUG)

Change-Id: I7ff3c9063febf71b898fa7f19058ce2fb25fae01
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
cmake/cmake.d/01-build_options.cmake
samples.d/config.cmake.sample

index 36830f1..18aff71 100644 (file)
@@ -32,7 +32,14 @@ INCLUDE(CheckIncludeFiles)
 INCLUDE(CheckLibraryExists)
 INCLUDE(GNUInstallDirs)
 
-set(CMAKE_BUILD_TYPE Debug CACHE STRING "the type of build")
+if(NOT CMAKE_BUILD_TYPE)
+       if(BUILD_TYPE)
+               set(CMAKE_BUILD_TYPE ${BUILD_TYPE} CACHE STRING "the type of build" FORCE)
+       else()
+               set(CMAKE_BUILD_TYPE DEBUG CACHE STRING "the type of build" FORCE)
+       endif()
+endif()
+
 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 set(CMP0048 1)
 
index d7268cd..70715fc 100644 (file)
@@ -41,7 +41,7 @@ set(PROJECT_APP_TEMPLATES_DIR "conf.d/app-templates")
 
 # Compilation Mode (DEBUG, RELEASE)
 # ----------------------------------
-#set(CMAKE_BUILD_TYPE "DEBUG")
+#set(BUILD_TYPE "DEBUG")
 #set(USE_EFENCE 1)
 
 # Kernel selection if needed. You can choose between a