From 8b52a332efa5526d4cc21344466a1eed67b8e4dc Mon Sep 17 00:00:00 2001 From: maier Date: Fri, 14 Sep 2012 14:32:25 +0000 Subject: [PATCH] DEAL_II_FEATURE_AUTODETECTION git-svn-id: https://svn.dealii.org/branches/branch_cmake@26384 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/CMakeLists.txt | 2 +- .../macros/macro_configure_feature.cmake | 160 +++++++++++------- 2 files changed, 97 insertions(+), 65 deletions(-) diff --git a/deal.II/CMakeLists.txt b/deal.II/CMakeLists.txt index 28fef9b25b..bb4a4b6afe 100644 --- a/deal.II/CMakeLists.txt +++ b/deal.II/CMakeLists.txt @@ -84,7 +84,7 @@ OPTION(DEAL_II_FEATURE_AUTODETECTION "Enables feature autodetection. This will automatically overwrite all DEAL_II_WITH_<...> toggles depending on whether they can be supported or not." - OFF) + ON) OPTION(DEAL_II_WITH_BLAS "Build deal.II with support for BLAS." diff --git a/deal.II/contrib/cmake/macros/macro_configure_feature.cmake b/deal.II/contrib/cmake/macros/macro_configure_feature.cmake index 421c8f59bb..0790c60036 100644 --- a/deal.II/contrib/cmake/macros/macro_configure_feature.cmake +++ b/deal.II/contrib/cmake/macros/macro_configure_feature.cmake @@ -47,7 +47,9 @@ # +# # Some black magic to have substitution in command names: +# MACRO(RUN_COMMAND the_command) FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/macro_configure_feature.tmp" "${the_command}") @@ -55,100 +57,130 @@ MACRO(RUN_COMMAND the_command) ENDMACRO() -MACRO(CONFIGURE_FEATURE feature) +# +# A small macro to set the DEAL_II_WITH_${feature} variables: +# +MACRO(SET_CACHED_OPTION feature value) + SET(DEAL_II_WITH_${feature} + ${value} + CACHE STRING + "Automatically set due to DEAL_II_FEATURE_AUTODETECTION" + FORCE) +ENDMACRO() - # - # First case: DEAL_II_FORCE_CONTRIB_${feature} is defined: - # - IF(DEAL_II_FORCE_CONTRIB_${feature}) - IF(HAVE_CONTRIB_FEATURE_${feature}) - RUN_COMMAND( - " - CONFIGURE_FEATURE_${feature}_CONTRIB( - FEATURE_${feature}_CONTRIB_CONFIGURED - ) - " - ) - IF(FEATURE_${feature}_CONTRIB_CONFIGURED) - MESSAGE(STATUS - "DEAL_II_WITH_${feature} successfully set up with contrib packages." - ) - ELSE() - MESSAGE(SEND_ERROR - "Failed to set up DEAL_II_WITH_${feature} with contrib packages." - ) - ENDIF() - ELSE() - MESSAGE(FATAL_ERROR - "Internal build system error: DEAL_II_FORCE_CONTRIB_${feature} defined, but HAVE_CONTRIB_FEATURE_${feature} not present." - ) - ENDIF() +MACRO(CONFIGURE_FEATURE feature) - ELSE() + # Only (try) to configure ${feature} if we have to: + IF(DEAL_II_FEATURE_AUTODETECTION OR DEAL_II_WITH_${feature}) # - # Second case: We may search for an external library: + # First case: DEAL_II_FORCE_CONTRIB_${feature} is defined: # - RUN_COMMAND( - "FIND_FEATURE_${feature}_EXTERNAL(FEATURE_${feature}_EXTERNAL_FOUND)" - ) - - IF(FEATURE_${feature}_EXTERNAL_FOUND) - - MESSAGE(STATUS - "All external dependencies for DEAL_II_WITH_${feature} are fullfilled." - ) + IF(DEAL_II_FORCE_CONTRIB_${feature}) - RUN_COMMAND( - " - CONFIGURE_FEATURE_${feature}_EXTERNAL( - FEATURE_${feature}_EXTERNAL_CONFIGURED - ) - " - ) - - IF(FEATURE_${feature}_EXTERNAL_CONFIGURED) - MESSAGE(STATUS - "DEAL_II_WITH_${feature} successfully set up with external dependencies." + IF(HAVE_CONTRIB_FEATURE_${feature}) + RUN_COMMAND( + " + CONFIGURE_FEATURE_${feature}_CONTRIB( + FEATURE_${feature}_CONTRIB_CONFIGURED + ) + " ) + IF(FEATURE_${feature}_CONTRIB_CONFIGURED) + MESSAGE(STATUS + "DEAL_II_WITH_${feature} successfully set up with contrib packages." + ) + IF(DEAL_II_FEATURE_AUTODETECTION) + SET_CACHED_OPTION(DEAL_II_WITH_${feature} on) + ENDIF() + ELSE() + # This should not happen. So give an error + MESSAGE(SEND_ERROR + "Failed to set up DEAL_II_WITH_${feature} with contrib packages." + ) + ENDIF() ELSE() - MESSAGE(SEND_ERROR - "Failed to set up DEAL_II_WITH_${feature} with external dependencies." + MESSAGE(FATAL_ERROR + "Internal build system error: DEAL_II_FORCE_CONTRIB_${feature} defined, but HAVE_CONTRIB_FEATURE_${feature} not present." ) ENDIF() ELSE() - MESSAGE(STATUS - "DEAL_II_WITH_${feature} has unmet external dependencies." + # + # Second case: We are allowed to search for an external library: + # + RUN_COMMAND( + "FIND_FEATURE_${feature}_EXTERNAL(FEATURE_${feature}_EXTERNAL_FOUND)" ) - IF(HAVE_CONTRIB_FEATURE_${feature} AND DEAL_II_ALLOW_CONTRIB) + IF(FEATURE_${feature}_EXTERNAL_FOUND) + + MESSAGE(STATUS + "All external dependencies for DEAL_II_WITH_${feature} are fullfilled." + ) + RUN_COMMAND( " - CONFIGURE_FEATURE_${feature}_CONTRIB( - FEATURE_${feature}_CONTRIB_CONFIGURED + CONFIGURE_FEATURE_${feature}_EXTERNAL( + FEATURE_${feature}_EXTERNAL_CONFIGURED ) " ) - IF(FEATURE_${feature}_CONTRIB_CONFIGURED) + + IF(FEATURE_${feature}_EXTERNAL_CONFIGURED) MESSAGE(STATUS - "DEAL_II_WITH_${feature} successfully set up with contrib packages." + "DEAL_II_WITH_${feature} successfully set up with external dependencies." ) + IF(DEAL_II_FEATURE_AUTODETECTION) + SET_CACHED_OPTION(DEAL_II_WITH_${feature} on) + ENDIF() ELSE() - # TODO: Opt out! + # This should not happen. So give an error MESSAGE(SEND_ERROR - "Failed to set up DEAL_II_WITH_${feature} with contrib packages." + "Failed to set up DEAL_II_WITH_${feature} with external dependencies." ) ENDIF() + ELSE() - # TODO: Opt out! - RUN_COMMAND( - "CONFIGURE_FEATURE_${feature}_ERROR_MESSAGE()" + + MESSAGE(STATUS + "DEAL_II_WITH_${feature} has unmet external dependencies." ) - ENDIF() + IF(HAVE_CONTRIB_FEATURE_${feature} AND DEAL_II_ALLOW_CONTRIB) + RUN_COMMAND( + " + CONFIGURE_FEATURE_${feature}_CONTRIB( + FEATURE_${feature}_CONTRIB_CONFIGURED + ) + " + ) + IF(FEATURE_${feature}_CONTRIB_CONFIGURED) + MESSAGE(STATUS + "DEAL_II_WITH_${feature} successfully set up with contrib packages." + ) + IF(DEAL_II_FEATURE_AUTODETECTION) + SET_CACHED_OPTION(DEAL_II_WITH_${feature} on) + ENDIF() + ELSE() + # This should not happen. So give an error + MESSAGE(SEND_ERROR + "Failed to set up DEAL_II_WITH_${feature} with contrib packages." + ) + ENDIF() + ELSE() + IF(DEAL_II_FEATURE_AUTODETECTION) + SET_CACHED_OPTION(DEAL_II_WITH_${feature} on) + ELSE() + RUN_COMMAND( + "CONFIGURE_FEATURE_${feature}_ERROR_MESSAGE()" + ) + ENDIF() + ENDIF() + + ENDIF() ENDIF() ENDIF() -- 2.39.5