From 332f377e84a673cdcfe52ce71c932f39c4b48022 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Fri, 6 Jul 2018 16:10:33 +0200 Subject: Be able to overwrite BUILD_TYPE using CLI 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 --- cmake/cmake.d/01-build_options.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'cmake') diff --git a/cmake/cmake.d/01-build_options.cmake b/cmake/cmake.d/01-build_options.cmake index 36830f1..18aff71 100644 --- a/cmake/cmake.d/01-build_options.cmake +++ b/cmake/cmake.d/01-build_options.cmake @@ -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) -- cgit 1.2.3-korg