From: Michihiro NAKAJIMA Date: Tue, 6 Mar 2012 03:58:28 +0000 (+0900) Subject: Do not overwrite CMAKE_BUILD_TYPE if it has already been set. X-Git-Tag: v3.0.4~2^2~30 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6fa9939e146630a5293dcfe5e4af5ef4176b45eb;p=thirdparty%2Flibarchive.git Do not overwrite CMAKE_BUILD_TYPE if it has already been set. Record CMAKE_BUILD_TYPE in CACHE so that you can edit CMAKE_BUILD_TYPE easily through GUI. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 3914f249b..9de91b16b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,11 +9,28 @@ if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) endif() # # Set the Build type for make based generators. -# -SET(CMAKE_BUILD_TYPE "Debug") # Debug build -#SET(CMAKE_BUILD_TYPE "Release") # Release build -#SET(CMAKE_BUILD_TYPE "RelWithDebInfo") # Release build with Debug Info -#SET(CMAKE_BUILD_TYPE "MinSizeRel") # Release Min Size build +# You can choose following types: +# Debug : Debug build +# Release : Release build +# RelWithDebInfo : Release build with Debug Info +# MinSizeRel : Release Min Size build +IF(NOT CMAKE_BUILD_TYPE) + SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build Type" FORCE) +ENDIF(NOT CMAKE_BUILD_TYPE) +# Set a value type to properly display CMAKE_BUILD_TYPE on GUI if the +# value type is "UNINITIALIZED". +GET_PROPERTY(cached_type CACHE CMAKE_BUILD_TYPE PROPERTY TYPE) +IF("${cached_type}" STREQUAL "UNINITIALIZED") + SET(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "Build Type" FORCE) +ENDIF("${cached_type}" STREQUAL "UNINITIALIZED") +# Check the Build Type. +IF(NOT "${CMAKE_BUILD_TYPE}" + MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)\$") + MESSAGE(FATAL_ERROR + "Unknown keyword for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}\n" + "Acceptable keywords: Debug,Release,RelWithDebInfo,MinSizeRel") +ENDIF(NOT "${CMAKE_BUILD_TYPE}" + MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)\$") # On MacOS, prefer MacPorts libraries to system libraries. # I haven't come up with a compelling argument for this to be conditional.