From: maier Date: Sun, 16 Sep 2012 18:10:10 +0000 (+0000) Subject: Add a dependency mechanism to macro_configure_feature X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8566e92718bc1e40b87de31ee797347542d9f4a;p=dealii-svn.git Add a dependency mechanism to macro_configure_feature git-svn-id: https://svn.dealii.org/branches/branch_cmake@26414 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/CMakeLists.txt b/deal.II/CMakeLists.txt index f144c87831..8a7952e4fd 100644 --- a/deal.II/CMakeLists.txt +++ b/deal.II/CMakeLists.txt @@ -85,7 +85,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." - ON) + OFF) OPTION(DEAL_II_ALLOW_CONTRIB "Allow the use of contrib libraries bundled with the source tarball. @@ -93,7 +93,7 @@ OPTION(DEAL_II_ALLOW_CONTRIB packages, so to ensure that only external libraries are used DEAL_II_ALLOW_CONTRIB as well as all DEAL_II_FORCE_CONTRIB_* have to be OFF" - ON) + OFF) OPTION(DEAL_II_WITH_BLAS "Build deal.II with support for BLAS." @@ -128,14 +128,14 @@ OPTION(DEAL_II_WITH_TBB OFF) OPTION(DEAL_II_FORCE_CONTRIB_TBB "Always use the bundled tbb library instead of an external one." - ON) + OFF) OPTION(DEAL_II_WITH_UMFPACK "Build deal.II with support for UMFPACK." - OFF) + ON) OPTION(DEAL_II_FORCE_CONTRIB_UMFPACK "Always use the bundled umfpack library instead of an external one." - ON) + OFF) OPTION(DEAL_II_WITH_ZLIB "Build deal.II with support for zlib." diff --git a/deal.II/contrib/cmake/configure/configure_umfpack.cmake b/deal.II/contrib/cmake/configure/configure_umfpack.cmake index b75c63286b..98018cf35b 100644 --- a/deal.II/contrib/cmake/configure/configure_umfpack.cmake +++ b/deal.II/contrib/cmake/configure/configure_umfpack.cmake @@ -3,6 +3,12 @@ # +SET(FEATURE_UMFPACK_DEPENDS + DEAL_II_WITH_BLAS + DEAL_II_WITH_LAPACK + ) + + MACRO(FIND_FEATURE_UMFPACK_EXTERNAL var) FIND_PACKAGE(UMFPACK) @@ -77,25 +83,5 @@ by setting DEAL_II_ALLOW_CONTRIB=on or DEAL_II_FORCE_CONTRIB_UMFPACK=on. ") ENDMACRO() -# -# UMFPACK needs BLAS and LAPACK to be configured: -# -# TODO: Encapsulate this in a depend logic and migrate this check into the -# macro - -IF(DEAL_II_WITH_BLAS AND DEAL_II_WITH_LAPACK) - CONFIGURE_FEATURE(UMFPACK) -ELSE() - IF(DEAL_II_FEATURE_AUTODETECT) - MESSAGE(STATUS - "DEAL_II_WITH_UMFPACK has unmet configuration requirements: Both, DEAL_II_WITH_BLAS and DEAL_II_WITH_LAPACK have to be set." - ) - SET_CACHED_OPTION(DEAL_II_WITH_UMFPACK OFF) - ELSE() - IF(DEA_II_WITH_UMFPACK) - MESSAGE(SEND_ERROR - "DEAL_II_WITH_UMFPACK has unmet configuration requirements: Both, DEAL_II_WITH_BLAS and DEAL_II_WITH_LAPACK have to be set." - ) - ENDIF() - ENDIF() -ENDIF() + +CONFIGURE_FEATURE(UMFPACK) diff --git a/deal.II/contrib/cmake/macros/macro_configure_feature.cmake b/deal.II/contrib/cmake/macros/macro_configure_feature.cmake index 753e876e4e..b163f125b5 100644 --- a/deal.II/contrib/cmake/macros/macro_configure_feature.cmake +++ b/deal.II/contrib/cmake/macros/macro_configure_feature.cmake @@ -7,6 +7,10 @@ # # This macro assumes the following macros and variables to be defined: # +# FEATURE_${feature_name}_DEPENDS (variable) +# +# - A variable which contains an optional list of features this feature +# depends on (and which have to be enbled for this feature to work.) # # HAVE_CONTRIB_FEATURE_${feature_name} (variable) # @@ -75,91 +79,88 @@ MACRO(CONFIGURE_FEATURE feature) IF(DEAL_II_FEATURE_AUTODETECTION OR DEAL_II_WITH_${feature}) # - # First case: DEAL_II_FORCE_CONTRIB_${feature} is defined: + # Are all dependencies fullfilled? # - IF(DEAL_II_FORCE_CONTRIB_${feature}) + SET(macro_dependencies_ok TRUE) - IF(HAVE_CONTRIB_FEATURE_${feature}) - RUN_COMMAND( - " - CONFIGURE_FEATURE_${feature}_CONTRIB( - FEATURE_${feature}_CONTRIB_CONFIGURED - ) - " - ) - IF(FEATURE_${feature}_CONTRIB_CONFIGURED) + FOREACH(macro_dependency ${FEATURE_${feature}_DEPENDS}) + IF(NOT ${macro_dependency}) + + IF(DEAL_II_FEATURE_AUTODETECTION) MESSAGE(STATUS - "DEAL_II_WITH_${feature} successfully set up with contrib packages." + "DEAL_II_WITH_${feature} has unmet configuration requirements: ${macro_dependency} has to be set to \"ON\"." ) - IF(DEAL_II_FEATURE_AUTODETECTION) - SET_CACHED_OPTION(DEAL_II_WITH_${feature} ON) - ENDIF() + SET_CACHED_OPTION(DEAL_II_WITH_${feature} OFF) ELSE() - # This should not happen. So give an error MESSAGE(SEND_ERROR - "Failed to set up DEAL_II_WITH_${feature} with contrib packages." + "DEAL_II_WITH_${feature} has unmet configuration requirements: ${macro_dependency} has to be set to \"ON\"." ) ENDIF() - ELSE() - MESSAGE(FATAL_ERROR - "Internal build system error: DEAL_II_FORCE_CONTRIB_${feature} defined, but HAVE_CONTRIB_FEATURE_${feature} not present." - ) + + SET(macro_dependencies_ok FALSE) ENDIF() + ENDFOREACH() - ELSE(DEAL_II_FORCE_CONTRIB_${feature}) + IF(macro_dependencies_ok) # - # Second case: We are allowed to 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." - ) - - RUN_COMMAND( - " - CONFIGURE_FEATURE_${feature}_EXTERNAL( - FEATURE_${feature}_EXTERNAL_CONFIGURED - ) - " - ) + IF(DEAL_II_FORCE_CONTRIB_${feature}) - 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(DEAL_II_FEATURE_AUTODETECTION) - SET_CACHED_OPTION(DEAL_II_WITH_${feature} ON) + 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() - # This should not happen. So give an error - 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() + ELSE(DEAL_II_FORCE_CONTRIB_${feature}) - 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) @@ -167,21 +168,50 @@ MACRO(CONFIGURE_FEATURE feature) ELSE() # 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() - IF(DEAL_II_FEATURE_AUTODETECTION) - SET_CACHED_OPTION(DEAL_II_WITH_${feature} ON) + + MESSAGE(STATUS + "DEAL_II_WITH_${feature} has unmet external dependencies." + ) + + 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() - RUN_COMMAND( - "CONFIGURE_FEATURE_${feature}_ERROR_MESSAGE()" + # 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(DEAL_II_FORCE_CONTRIB_${feature}) - ENDIF() - ENDIF(DEAL_II_FORCE_CONTRIB_${feature}) + ENDIF() ENDIF() ENDMACRO()