From: maier Date: Sat, 29 Jun 2013 15:56:25 +0000 (+0000) Subject: CMake: Improve build type handling in DEAL_II_INVOKE_AUTOPILOT and DEAL_II_INITIALIZE... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c9ea1c11ef1bbcaca610b1e6d69f04f6dcb75a9;p=dealii-svn.git CMake: Improve build type handling in DEAL_II_INVOKE_AUTOPILOT and DEAL_II_INITIALIZE_CACHED_VARIABLES - only display "make release" and "make debug" if it is possible to change build types - forcefully change build type to a sane value in DEAL_II_INITIALIZE_CACHED_VARIABLES instead of bailing out git-svn-id: https://svn.dealii.org/trunk@29904 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/cmake/macros/macro_deal_ii_initialize_cached_variables.cmake b/deal.II/cmake/macros/macro_deal_ii_initialize_cached_variables.cmake index 6aa654d35b..5c5377cb14 100644 --- a/deal.II/cmake/macros/macro_deal_ii_initialize_cached_variables.cmake +++ b/deal.II/cmake/macros/macro_deal_ii_initialize_cached_variables.cmake @@ -49,24 +49,34 @@ MACRO(DEAL_II_INITIALIZE_CACHED_VARIABLES) ENDIF() # - # Bail out if build type is unknown... - # - IF( NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND - NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) - MESSAGE(FATAL_ERROR - "\nCMAKE_BUILD_TYPE does neither match Release nor Debug!\n\n" - ) - ENDIF() - # - # ... or unsupported + # Reset build type if unsupported: # IF(NOT DEAL_II_BUILD_TYPE MATCHES "${CMAKE_BUILD_TYPE}") - MESSAGE(FATAL_ERROR "\n" - "CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\" unsupported by current installation!\n" - "deal.II was build with \"${DEAL_II_BUILD_TYPE}\" only build type.\n\n" + IF("${DEAL_II_BUILD_TYPE}" STREQUAL "DebugRelease") + SET(_new_build_type "Debug") + ELSE() + SET(_new_build_type "${DEAL_II_BUILD_TYPE}") + ENDIF() + + MESSAGE( +"### +# +# WARNING: +# +# CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\" unsupported by current installation! +# deal.II was built with CMAKE_BUILD_TYPE \"${DEAL_II_BUILD_TYPE}\". +# +# CMAKE_BUILD_TYPE is forced to \"${_new_build_type}\". +# +###" + ) + SET(CMAKE_BUILD_TYPE "${_new_build_type}" CACHE STRING + "Choose the type of build, options are: Debug, Release" + FORCE ) ENDIF() + SET(CMAKE_CXX_COMPILER ${DEAL_II_CXX_COMPILER} CACHE STRING "CXX Compiler.") diff --git a/deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake b/deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake index e643446317..e22b9f37ac 100644 --- a/deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake +++ b/deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake @@ -81,22 +81,22 @@ MACRO(DEAL_II_INVOKE_AUTOPILOT) ENDIF() # Define custom targets to easily switch the build type: - IF(${DEAL_II_BUILD_TYPE} MATCHES "Debug") - ADD_CUSTOM_TARGET(debug - COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} - COMMENT "Switch CMAKE_BUILD_TYPE to Debug" - ) - SET(_switch_targets - "# $ make debug - to switch the build type to \"Debug\"\n" - ) - ENDIF() - IF(${DEAL_II_BUILD_TYPE} MATCHES "Release") - ADD_CUSTOM_TARGET(release - COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} - COMMENT "Switch CMAKE_BUILD_TYPE to Release" - ) + ADD_CUSTOM_TARGET(debug + COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} + COMMENT "Switch CMAKE_BUILD_TYPE to Debug" + ) + + ADD_CUSTOM_TARGET(release + COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} + COMMENT "Switch CMAKE_BUILD_TYPE to Release" + ) + + # Only mention release and debug targets if its actuallay possible to + # switch between them: + IF(${DEAL_II_BUILD_TYPE} MATCHES "DebugRelease") SET(_switch_targets - "${_switch_targets}# $ make release - to switch the build type to \"Release\"\n" +"# $ make debug - to switch the build type to \"Debug\" +# $ make release - to switch the build type to \"Release\"\n" ) ENDIF()