From 2d705ef8110279cd90719e4e717a905d22280908 Mon Sep 17 00:00:00 2001 From: Hombre Date: Mon, 14 Feb 2011 02:10:29 +0100 Subject: [PATCH] CMAKE_BUILD_TYPE now properly handled and information printed in AboutThisBuild.txt, thanks to greatbull69 --- About-Apple.cmake | 3 ++- About-Linux.cmake | 4 ++-- About-Windows.cmake | 3 ++- CMakeLists.txt | 6 ++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/About-Apple.cmake b/About-Apple.cmake index 22a02aa1a..8f4ed6f55 100644 --- a/About-Apple.cmake +++ b/About-Apple.cmake @@ -1,7 +1,7 @@ # this will generate a target that will never exist, so it will (should) be executed on each build #WARNING: Actually, only Gcc is supported -string (TOUPPER ${BUILD_TYPE} UPPER_CMAKE_BUILD_TYPE) +string (TOUPPER ${CMAKE_BUILD_TYPE} UPPER_CMAKE_BUILD_TYPE) # wee look for the hg command in this paths by order of preference find_file(HG_CMD hg PATHS "/opt/local/bin" "/usr/local/bin" "/usr/bin") @@ -27,6 +27,7 @@ add_custom_target (AboutFile ALL COMMAND echo Processor: ${PROC_LABEL} >>${OUT_FILE} COMMAND echo Bit depth: ${PROC_BIT_DEPTH} >>${OUT_FILE} COMMAND echo Gtkmm: V${GTKMM_VERSION} >>${OUT_FILE} + COMMAND echo Build type: ${CMAKE_BUILD_TYPE} >>${OUT_FILE} COMMAND echo Build flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPER_CMAKE_BUILD_TYPE}} >>${OUT_FILE} COMMAND echo Link flags: ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${UPPER_CMAKE_BUILD_TYPE}} >>${OUT_FILE} COMMAND if [ \"${OPTION_OMP}\" = \"ON\" ] \; then echo OpenMP support: Yes >>${OUT_FILE} \;else echo OpenMP support: No >>${OUT_FILE} \;fi diff --git a/About-Linux.cmake b/About-Linux.cmake index 22a02aa1a..5761a785f 100644 --- a/About-Linux.cmake +++ b/About-Linux.cmake @@ -1,10 +1,9 @@ # this will generate a target that will never exist, so it will (should) be executed on each build #WARNING: Actually, only Gcc is supported -string (TOUPPER ${BUILD_TYPE} UPPER_CMAKE_BUILD_TYPE) +string (TOUPPER ${CMAKE_BUILD_TYPE} UPPER_CMAKE_BUILD_TYPE) # wee look for the hg command in this paths by order of preference -find_file(HG_CMD hg PATHS "/opt/local/bin" "/usr/local/bin" "/usr/bin") find_file(HG_CMD hg) if (HG_CMD STREQUAL HG_CMD-NOTFOUND) @@ -27,6 +26,7 @@ add_custom_target (AboutFile ALL COMMAND echo Processor: ${PROC_LABEL} >>${OUT_FILE} COMMAND echo Bit depth: ${PROC_BIT_DEPTH} >>${OUT_FILE} COMMAND echo Gtkmm: V${GTKMM_VERSION} >>${OUT_FILE} + COMMAND echo Build type: ${CMAKE_BUILD_TYPE} >>${OUT_FILE} COMMAND echo Build flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPER_CMAKE_BUILD_TYPE}} >>${OUT_FILE} COMMAND echo Link flags: ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${UPPER_CMAKE_BUILD_TYPE}} >>${OUT_FILE} COMMAND if [ \"${OPTION_OMP}\" = \"ON\" ] \; then echo OpenMP support: Yes >>${OUT_FILE} \;else echo OpenMP support: No >>${OUT_FILE} \;fi diff --git a/About-Windows.cmake b/About-Windows.cmake index 6f591d2b4..398a9ed36 100644 --- a/About-Windows.cmake +++ b/About-Windows.cmake @@ -1,7 +1,7 @@ # this will generate a target that will never exist, so it will (should) be executed on each build #WARNING: Actually, only Gcc is supported -string (TOUPPER ${BUILD_TYPE} UPPER_CMAKE_BUILD_TYPE) +string (TOUPPER ${CMAKE_BUILD_TYPE} UPPER_CMAKE_BUILD_TYPE) set (OUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/AboutThisBuild.txt") set (VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/rtgui/version.h") @@ -13,6 +13,7 @@ add_custom_target (AboutFile ALL COMMAND \(echo Processor: ${PROC_LABEL}\) >>${OUT_FILE} COMMAND \(echo Bit depth: ${PROC_BIT_DEPTH}\) >>${OUT_FILE} COMMAND \(echo Gtkmm: V${GTKMM_VERSION}\) >>${OUT_FILE} + COMMAND \(echo Build type: ${CMAKE_BUILD_TYPE}\) >>${OUT_FILE} COMMAND \(echo Build flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPER_CMAKE_BUILD_TYPE}} \) >>${OUT_FILE} COMMAND \(echo Link flags: ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${UPPER_CMAKE_BUILD_TYPE}} \) >>${OUT_FILE} COMMAND (if ${OPTION_OMP}==ON \(echo OpenMP support: Yes\) else \(echo OpenMP support: No\)) >>${OUT_FILE} diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b5d6c848..edd224509 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,10 @@ cmake_minimum_required(VERSION 2.6) # the default target is 'Debug' -set (CMAKE_BUILD_TYPE Debug CACHE STRING "One of: None Debug Release RelWithDebInfo MinSizeRel.") +if (CMAKE_BUILD_TYPE STREQUAL "") + set (CMAKE_BUILD_TYPE Debug CACHE STRING "One of: None Debug Release RelWithDebInfo MinSizeRel." FORCE) +endif () +message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") # By default, we don't use specific processor target, so PROC_TARGET_NUMBER is set to 0. If can specify other values to select specific # processor targets, which list can be found in ProcessorTargets.cmake. @@ -139,7 +142,6 @@ elseif (CMAKE_SIZEOF_VOID_P EQUAL 8) endif (CMAKE_SIZEOF_VOID_P EQUAL 4) #generating AboutThisBuild.txt -set (BUILD_TYPE CMAKE_BUILD_TYPE) if (WIN32) include (About-Windows.cmake) elseif (APPLE)