]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
CMake: Improve build type handling in DEAL_II_INVOKE_AUTOPILOT and DEAL_II_INITIALIZE...
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 29 Jun 2013 15:56:25 +0000 (15:56 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 29 Jun 2013 15:56:25 +0000 (15:56 +0000)
  - 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

deal.II/cmake/macros/macro_deal_ii_initialize_cached_variables.cmake
deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake

index 6aa654d35b9116ea47beb6aa78de18ddc542fa8f..5c5377cb1451f757711ca774d866235bd8df7cfc 100644 (file)
@@ -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.")
 
index e643446317817784650321d1267fa817c7565bbb..e22b9f37ac015078360be712eaef8d02cfdedb8f 100644 (file)
@@ -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()
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.