From 3d6616dff1ed167c2e7669dc2d4da99d0d366465 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Tue, 5 Feb 2019 15:12:52 -0600 Subject: [PATCH] CMake: error message + guard target - Add a helpful message to make debug/release targets. - Only create the corresponding debug/release target if the build type is available. --- .../macro_deal_ii_invoke_autopilot.cmake | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/cmake/macros/macro_deal_ii_invoke_autopilot.cmake b/cmake/macros/macro_deal_ii_invoke_autopilot.cmake index a494f0a9e8..ca5a1c0832 100644 --- a/cmake/macros/macro_deal_ii_invoke_autopilot.cmake +++ b/cmake/macros/macro_deal_ii_invoke_autopilot.cmake @@ -138,19 +138,37 @@ MACRO(DEAL_II_INVOKE_AUTOPILOT) ) ENDIF() + # # Define custom targets to easily switch the build type: - 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" - ) + IF(${DEAL_II_BUILD_TYPE} MATCHES "Debug") + ADD_CUSTOM_TARGET(debug + COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR} + COMMAND ${CMAKE_COMMAND} -E echo "***" + COMMAND ${CMAKE_COMMAND} -E echo "*** Switched to Debug mode. Now recompile with: ${_make_command}" + COMMAND ${CMAKE_COMMAND} -E echo "***" + COMMENT "Switch CMAKE_BUILD_TYPE to Debug" + VERBATIM + ) + ENDIF() + IF(${DEAL_II_BUILD_TYPE} MATCHES "Release") + ADD_CUSTOM_TARGET(release + COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR} + COMMAND ${CMAKE_COMMAND} -E echo "***" + COMMAND ${CMAKE_COMMAND} -E echo "*** Switched to Release mode. Now recompile with: ${_make_command}" + COMMAND ${CMAKE_COMMAND} -E echo "***" + COMMENT "Switch CMAKE_BUILD_TYPE to Release" + VERBATIM + ) + ENDIF() + + # # Only mention release and debug targets if it is actually possible to # switch between them: + # + IF(${DEAL_II_BUILD_TYPE} MATCHES "DebugRelease") SET(_switch_targets "# ${_make_command} debug - to switch the build type to 'Debug' -- 2.39.5