From: maier Date: Wed, 27 Feb 2013 17:21:29 +0000 (+0000) Subject: Code refactoring X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c94c82bb269f7277fdbcabf52f58a76d43e98fcd;p=dealii-svn.git Code refactoring git-svn-id: https://svn.dealii.org/branches/branch_cmake@28618 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/cmake/configure/configure_1_mpi.cmake b/deal.II/cmake/configure/configure_1_mpi.cmake index d7e4a0d854..1859962f69 100644 --- a/deal.II/cmake/configure/configure_1_mpi.cmake +++ b/deal.II/cmake/configure/configure_1_mpi.cmake @@ -58,9 +58,6 @@ MACRO(FEATURE_MPI_CONFIGURE_EXTERNAL var) ENDMACRO() -SET(FEATURE_MPI_CUSTOM_ERROR_MESSAGE TRUE) - - MACRO(FEATURE_MPI_ERROR_MESSAGE) MESSAGE(FATAL_ERROR "\n" "Could not find any suitable mpi library!\n" diff --git a/deal.II/cmake/configure/configure_1_threads.cmake b/deal.II/cmake/configure/configure_1_threads.cmake index 5a69e99707..9aad0ffdaa 100644 --- a/deal.II/cmake/configure/configure_1_threads.cmake +++ b/deal.II/cmake/configure/configure_1_threads.cmake @@ -38,7 +38,7 @@ MACRO(SETUP_THREADING var) SET(DEAL_II_USE_MT TRUE) # - # Change -lphtread to -pthread for more compatibility on non linux + # Change -lphtread to -pthread for better compatibility on non linux # platforms: # IF("${CMAKE_THREAD_LIBS_INIT}" MATCHES "-lpthread") @@ -90,7 +90,6 @@ MACRO(SETUP_THREADING var) ENDMACRO() - # # Set up the tbb library: # diff --git a/deal.II/cmake/configure/configure_arpack.cmake b/deal.II/cmake/configure/configure_arpack.cmake index 6e4ef1ef0e..70a427f778 100644 --- a/deal.II/cmake/configure/configure_arpack.cmake +++ b/deal.II/cmake/configure/configure_arpack.cmake @@ -17,15 +17,6 @@ # -MACRO(FEATURE_ARPACK_FIND_EXTERNAL var) - FIND_PACKAGE(ARPACK) - - IF(ARPACK_FOUND) - SET(${var} TRUE) - ENDIF() -ENDMACRO() - - MACRO(FEATURE_ARPACK_CONFIGURE_EXTERNAL var) LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${ARPACK_LIBRARIES}) ADD_FLAGS(CMAKE_SHARED_LINKER_FLAGS "${ARPACK_LINKER_FLAGS}") diff --git a/deal.II/cmake/configure/configure_boost.cmake b/deal.II/cmake/configure/configure_boost.cmake index c26b03a093..fc1f48436e 100644 --- a/deal.II/cmake/configure/configure_boost.cmake +++ b/deal.II/cmake/configure/configure_boost.cmake @@ -40,7 +40,7 @@ MACRO(FEATURE_BOOST_FIND_EXTERNAL var) # # We require at least version 1.44 # - FIND_PACKAGE (Boost 1.44 COMPONENTS serialization thread) + FIND_PACKAGE(Boost 1.44 COMPONENTS serialization thread) IF(Boost_THREAD_FOUND AND Boost_SERIALIZATION_FOUND) SET(${var} TRUE) diff --git a/deal.II/cmake/configure/configure_functionparser.cmake b/deal.II/cmake/configure/configure_functionparser.cmake index ad92d51228..3276db0b30 100644 --- a/deal.II/cmake/configure/configure_functionparser.cmake +++ b/deal.II/cmake/configure/configure_functionparser.cmake @@ -34,9 +34,6 @@ MACRO(FEATURE_FUNCTIONPARSER_CONFIGURE_BUNDLED var) ENDMACRO() -SET(FEATURE_FUNCTIONPARSER_CUSTOM_ERROR_MESSAGE TRUE) - - MACRO(FEATURE_FUNCTIONPARSER_ERROR_MESSAGE) MESSAGE(FATAL_ERROR "\n" "No module available for finding functionparser externally.\n" diff --git a/deal.II/cmake/configure/configure_hdf5.cmake b/deal.II/cmake/configure/configure_hdf5.cmake index f77a4add11..2f0ff3e937 100644 --- a/deal.II/cmake/configure/configure_hdf5.cmake +++ b/deal.II/cmake/configure/configure_hdf5.cmake @@ -17,15 +17,6 @@ # -MACRO(FEATURE_HDF5_FIND_EXTERNAL var) - FIND_PACKAGE(HDF5) - - IF(HDF5_FOUND) - SET(${var} TRUE) - ENDIF() -ENDMACRO() - - MACRO(FEATURE_HDF5_CONFIGURE_EXTERNAL var) INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIRS}) LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${HDF5_LIBRARIES}) @@ -36,9 +27,6 @@ MACRO(FEATURE_HDF5_CONFIGURE_EXTERNAL var) ENDMACRO() -SET(FEATURE_HDF5_CUSTOM_ERROR_MESSAGE TRUE) - - MACRO(FEATURE_HDF5_ERROR_MESSAGE) MESSAGE(FATAL_ERROR "\n" "Could not find the hdf5 library!\n" diff --git a/deal.II/cmake/configure/configure_metis.cmake b/deal.II/cmake/configure/configure_metis.cmake index a6e1419d6a..b051ee2120 100644 --- a/deal.II/cmake/configure/configure_metis.cmake +++ b/deal.II/cmake/configure/configure_metis.cmake @@ -47,9 +47,6 @@ MACRO(FEATURE_METIS_CONFIGURE_EXTERNAL var) ENDMACRO() -SET(FEATURE_METIS_CUSTOM_ERROR_MESSAGE TRUE) - - MACRO(FEATURE_METIS_ERROR_MESSAGE) MESSAGE(FATAL_ERROR "\n" "Could not find the metis library!\n" diff --git a/deal.II/cmake/configure/configure_mumps.cmake b/deal.II/cmake/configure/configure_mumps.cmake index 05f25a0434..b45381ba38 100644 --- a/deal.II/cmake/configure/configure_mumps.cmake +++ b/deal.II/cmake/configure/configure_mumps.cmake @@ -20,15 +20,6 @@ SET(FEATURE_MUMPS_DEPENDS DEAL_II_WITH_MPI) -MACRO(FEATURE_MUMPS_FIND_EXTERNAL var) - FIND_PACKAGE(MUMPS) - - IF(MUMPS_FOUND) - SET(${var} TRUE) - ENDIF() -ENDMACRO() - - MACRO(FEATURE_MUMPS_CONFIGURE_EXTERNAL var) INCLUDE_DIRECTORIES(${MUMPS_INCLUDE_DIRS}) LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES @@ -43,9 +34,6 @@ MACRO(FEATURE_MUMPS_CONFIGURE_EXTERNAL var) ENDMACRO() -SET(FEATURE_MUMPS_CUSTOM_ERROR_MESSAGE TRUE) - - MACRO(FEATURE_MUMPS_ERROR_MESSAGE) MESSAGE(FATAL_ERROR "\n" "Could not find the mumps library!\n" diff --git a/deal.II/cmake/configure/configure_netcdf.cmake b/deal.II/cmake/configure/configure_netcdf.cmake index e2d7044e30..9a9344b262 100644 --- a/deal.II/cmake/configure/configure_netcdf.cmake +++ b/deal.II/cmake/configure/configure_netcdf.cmake @@ -17,15 +17,6 @@ # -MACRO(FEATURE_NETCDF_FIND_EXTERNAL var) - FIND_PACKAGE(NETCDF) - - IF(NETCDF_FOUND) - SET(${var} TRUE) - ENDIF() -ENDMACRO() - - MACRO(FEATURE_NETCDF_CONFIGURE_EXTERNAL var) INCLUDE_DIRECTORIES(${NETCDF_INCLUDE_DIRS}) LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${NETCDF_LIBRARIES}) diff --git a/deal.II/cmake/configure/configure_p4est.cmake b/deal.II/cmake/configure/configure_p4est.cmake index 028ca79a94..b26cfdbb8d 100644 --- a/deal.II/cmake/configure/configure_p4est.cmake +++ b/deal.II/cmake/configure/configure_p4est.cmake @@ -54,9 +54,6 @@ MACRO(FEATURE_P4EST_CONFIGURE_EXTERNAL var) ENDMACRO() -SET(FEATURE_P4EST_CUSTOM_ERROR_MESSAGE TRUE) - - MACRO(FEATURE_P4EST_ERROR_MESSAGE) MESSAGE(FATAL_ERROR "\n" "Could not find the p4est and sc libraries!\n" diff --git a/deal.II/cmake/configure/configure_petsc.cmake b/deal.II/cmake/configure/configure_petsc.cmake index 1b3f67c30c..92d7440614 100644 --- a/deal.II/cmake/configure/configure_petsc.cmake +++ b/deal.II/cmake/configure/configure_petsc.cmake @@ -95,9 +95,6 @@ MACRO(FEATURE_PETSC_CONFIGURE_EXTERNAL var) ENDMACRO() -SET(FEATURE_PETSC_CUSTOM_ERROR_MESSAGE TRUE) - - MACRO(FEATURE_PETSC_ERROR_MESSAGE) MESSAGE(FATAL_ERROR "\n" "Could not find the petsc library!\n" diff --git a/deal.II/cmake/configure/configure_slepc.cmake b/deal.II/cmake/configure/configure_slepc.cmake index 0f66434eed..8f4fe2d0d4 100644 --- a/deal.II/cmake/configure/configure_slepc.cmake +++ b/deal.II/cmake/configure/configure_slepc.cmake @@ -63,9 +63,6 @@ MACRO(FEATURE_SLEPC_CONFIGURE_EXTERNAL var) ENDMACRO() -SET(FEATURE_SLEPC_CUSTOM_ERROR_MESSAGE TRUE) - - MACRO(FEATURE_SLEPC_ERROR_MESSAGE) MESSAGE(FATAL_ERROR "\n" "Could not find the SLEPc library!\n" @@ -85,4 +82,3 @@ ENDMACRO() CONFIGURE_FEATURE(SLEPC) - diff --git a/deal.II/cmake/configure/configure_trilinos.cmake b/deal.II/cmake/configure/configure_trilinos.cmake index 0783c48c9d..ee1f523f0e 100644 --- a/deal.II/cmake/configure/configure_trilinos.cmake +++ b/deal.II/cmake/configure/configure_trilinos.cmake @@ -199,9 +199,6 @@ MACRO(FEATURE_TRILINOS_CONFIGURE_EXTERNAL var) ENDMACRO() -SET(FEATURE_TRILINOS_CUSTOM_ERROR_MESSAGE TRUE) - - MACRO(FEATURE_TRILINOS_ERROR_MESSAGE) MESSAGE(FATAL_ERROR "\n" "Could not find a suitable set of trilinos libraries!\n" diff --git a/deal.II/cmake/configure/configure_umfpack.cmake b/deal.II/cmake/configure/configure_umfpack.cmake index f83c683742..529be4d846 100644 --- a/deal.II/cmake/configure/configure_umfpack.cmake +++ b/deal.II/cmake/configure/configure_umfpack.cmake @@ -23,15 +23,6 @@ SET(FEATURE_UMFPACK_DEPENDS DEAL_II_WITH_LAPACK) -MACRO(FEATURE_UMFPACK_FIND_EXTERNAL var) - FIND_PACKAGE(UMFPACK) - - IF(UMFPACK_FOUND) - SET(${var} TRUE) - ENDIF() -ENDMACRO() - - MACRO(FEATURE_UMFPACK_CONFIGURE_EXTERNAL var) INCLUDE_DIRECTORIES(${UMFPACK_INCLUDE_DIRS}) @@ -60,9 +51,6 @@ MACRO(FEATURE_UMFPACK_CONFIGURE_BUNDLED var) ENDMACRO() -SET(FEATURE_UMFPACK_CUSTOM_ERROR_MESSAGE TRUE) - - MACRO(FEATURE_UMFPACK_ERROR_MESSAGE) MESSAGE(FATAL_ERROR "\n" "Could not find the umfpack and amd libraries!\n" diff --git a/deal.II/cmake/configure/configure_zlib.cmake b/deal.II/cmake/configure/configure_zlib.cmake index 858d81f9ca..fc835e8e33 100644 --- a/deal.II/cmake/configure/configure_zlib.cmake +++ b/deal.II/cmake/configure/configure_zlib.cmake @@ -17,15 +17,6 @@ # -MACRO(FEATURE_ZLIB_FIND_EXTERNAL var) - FIND_PACKAGE(ZLIB) - - IF(ZLIB_FOUND) - SET(${var} TRUE) - ENDIF() -ENDMACRO() - - MACRO(FEATURE_ZLIB_CONFIGURE_EXTERNAL var) INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS}) LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${ZLIB_LIBRARIES}) @@ -36,4 +27,3 @@ ENDMACRO() CONFIGURE_FEATURE(ZLIB) - diff --git a/deal.II/cmake/macros/macro_configure_feature.cmake b/deal.II/cmake/macros/macro_configure_feature.cmake index 67804f6d4b..a8edf6b156 100644 --- a/deal.II/cmake/macros/macro_configure_feature.cmake +++ b/deal.II/cmake/macros/macro_configure_feature.cmake @@ -19,9 +19,7 @@ # CONFIGURE_FEATURE(feature) # # -# For a feature ${feature} (written in all caps) the following options, -# variables and macros have to be defined (except marked as optional): -# +# This macro uses the following variables and macros: # # FEATURE_${feature}_DEPENDS (variable, optional) # a variable which contains an optional list of other features @@ -39,22 +37,18 @@ # bundled source dependencies. var set to TRUE indicates success, # otherwise this script should issue a FATAL_ERROR. # -# FEATURE_${feature}_FIND_EXTERNAL(var) (macro, mandatory) +# FEATURE_${feature}_FIND_EXTERNAL(var) (macro, optional) # which should set var to TRUE if all dependencies for the feature are # fullfilled. In this case all necessary variables for # FEATURE_${feature}_CONFIGURE_EXTERNAL must be set. Otherwise # var should remain unset. -# This macro should give an error (FATAL_ERROR). +# If not defined, FIND_PACKAGE(${feature}) is called. # # FEATURE_${feature}_CONFIGURE_EXTERNAL(var) (macro, mandatory) # which should setup all necessary configuration for the feature with # external dependencies. var set to TRUE indicates success, # otherwise this script gives an error. # -# FEATURE_${feature}_CUSTOM_ERROR_MESSAGE() (variable, optional) -# which should either be set to TRUE if FEATURE_${feature}_ERROR_MESSAGE -# is set up, or be undefined. -# # FEATURE_${feature}_ERROR_MESSAGE() (macro, optional) # which should print a meaningfull error message (with FATAL_ERROR) for # the case that no external library was found (and bundled is not @@ -64,9 +58,11 @@ # -# -# Some helper macros: -# +########################################################################### +# # +# Helper Macros: # +# # +########################################################################### # # Some black magic to have substitution in command names: @@ -117,6 +113,23 @@ MACRO(FEATURE_ERROR_MESSAGE _feature) ENDMACRO() +# +# Default macro for finding an external library: +# +MACRO(FEATURE_FIND_EXTERNAL _feature _var) + FIND_PACKAGE(${_feature}) + IF(${_feature}_FOUND) + SET(${_var} TRUE) + ENDIF() +ENDMACRO() + + +########################################################################### +# # +# CONFIGURE_FEATURE: # +# # +########################################################################### + MACRO(CONFIGURE_FEATURE _feature) # # This script is arcane black magic. But at least for the better good: We @@ -185,15 +198,10 @@ MACRO(CONFIGURE_FEATURE _feature) # # First case: DEAL_II_FORCE_BUNDLED_${_feature} is defined: # - IF(FEATURE_${_feature}_HAVE_BUNDLED) - RUN_COMMAND( - "FEATURE_${_feature}_CONFIGURE_BUNDLED(FEATURE_${_feature}_BUNDLED_CONFIGURED)" - ) + RUN_COMMAND("FEATURE_${_feature}_CONFIGURE_BUNDLED(FEATURE_${_feature}_BUNDLED_CONFIGURED)") IF(FEATURE_${_feature}_BUNDLED_CONFIGURED) - MESSAGE(STATUS - "DEAL_II_WITH_${_feature} successfully set up with bundled packages." - ) + MESSAGE(STATUS "DEAL_II_WITH_${_feature} successfully set up with bundled packages.") SET_CACHED_OPTION(${_feature} ON) ELSE() # This should not happen. So give an error @@ -213,23 +221,18 @@ MACRO(CONFIGURE_FEATURE _feature) # # Second case: We are allowed to search for an external library # - - RUN_COMMAND( - "FEATURE_${_feature}_FIND_EXTERNAL(FEATURE_${_feature}_EXTERNAL_FOUND)" - ) + IF(COMMAND FEATURE_${_feature}_FIND_EXTERNAL) + RUN_COMMAND("FEATURE_${_feature}_FIND_EXTERNAL(FEATURE_${_feature}_EXTERNAL_FOUND)") + ELSE() + FEATURE_FIND_EXTERNAL(${_feature} FEATURE_${_feature}_EXTERNAL_FOUND) + ENDIF() IF(FEATURE_${_feature}_EXTERNAL_FOUND) - MESSAGE(STATUS - "All external dependencies for DEAL_II_WITH_${_feature} are fullfilled." - ) - RUN_COMMAND( - "FEATURE_${_feature}_CONFIGURE_EXTERNAL(FEATURE_${_feature}_EXTERNAL_CONFIGURED)" - ) + MESSAGE(STATUS "All external dependencies for DEAL_II_WITH_${_feature} are fullfilled.") + RUN_COMMAND("FEATURE_${_feature}_CONFIGURE_EXTERNAL(FEATURE_${_feature}_EXTERNAL_CONFIGURED)") IF(FEATURE_${_feature}_EXTERNAL_CONFIGURED) - MESSAGE(STATUS - "DEAL_II_WITH_${_feature} successfully set up with external dependencies." - ) + MESSAGE(STATUS "DEAL_II_WITH_${_feature} successfully set up with external dependencies.") SET_CACHED_OPTION(${_feature} ON) ELSE() # This should not happen. So give an error @@ -241,18 +244,12 @@ MACRO(CONFIGURE_FEATURE _feature) ELSE(FEATURE_${_feature}_EXTERNAL_FOUND) - MESSAGE(STATUS - "DEAL_II_WITH_${_feature} has unmet external dependencies." - ) + MESSAGE(STATUS "DEAL_II_WITH_${_feature} has unmet external dependencies.") IF(FEATURE_${_feature}_HAVE_BUNDLED AND DEAL_II_ALLOW_BUNDLED) - RUN_COMMAND( - "FEATURE_${_feature}_CONFIGURE_BUNDLED(FEATURE_${_feature}_BUNDLED_CONFIGURED)" - ) + RUN_COMMAND("FEATURE_${_feature}_CONFIGURE_BUNDLED(FEATURE_${_feature}_BUNDLED_CONFIGURED)") IF(FEATURE_${_feature}_BUNDLED_CONFIGURED) - MESSAGE(STATUS - "DEAL_II_WITH_${_feature} successfully set up with bundled packages." - ) + MESSAGE(STATUS "DEAL_II_WITH_${_feature} successfully set up with bundled packages.") SET_CACHED_OPTION(${_feature} ON) ELSE() # This should not happen. So give an error @@ -263,7 +260,7 @@ MACRO(CONFIGURE_FEATURE _feature) ENDIF() ELSE() IF(DEAL_II_WITH_${_feature}) - IF(FEATURE_${_feature}_CUSTOM_ERROR_MESSAGE) + IF(COMMAND FEATURE_${_feature}_ERROR_MESSAGE) RUN_COMMAND("FEATURE_${_feature}_ERROR_MESSAGE()") ELSE() FEATURE_ERROR_MESSAGE(${_feature}) diff --git a/deal.II/doc/development/cmake.html b/deal.II/doc/development/cmake.html index b41d4c36dd..3e3c88b30d 100644 --- a/deal.II/doc/development/cmake.html +++ b/deal.II/doc/development/cmake.html @@ -1027,12 +1027,12 @@ to work.) The features must be given with the full option toggle DEAL_II_WITH_[...] - FEATURE_<FEATURE>_FIND_EXTERNAL(var) (macro, mandatory) + FEATURE_<FEATURE>_FIND_EXTERNAL(var) (macro, optional) - which should set var to TRUE if all dependencies for the feature are fulfilled. In this case all necessary variables for FEATURE_<FEATURE>_CONFIGURE_EXTERNAL must be set. Otherwise var should remain unset. - This macro must not give an error (SEND_ERROR or FATAL_ERROR). + If not defined, FIND_PACKAGE(${feature}) is called. FEATURE_<FEATURE>_CONFIGURE_EXTERNAL(var) (macro, mandatory) - which should setup all necessary configuration for the feature with @@ -1041,17 +1041,15 @@ FEATURE_<FEATURE>_CONFIGURE_BUNDLED(var) (macro, optional) - which should setup all necessary configuration for the feature with - bundled source dependencies. var set to TRUE indicates success. - - FEATURE_<FEATURE>_CUSTOM_ERROR_MESSAGE() (variable, optional) - - which should either be set to TRUE if FEATURE_<FEATURE>_ERROR_MESSAGE - is set up, or be undefined. + bundled source dependencies. var set to TRUE indicates success, + otherwise this script should issue a FATAL_ERROR. FEATURE_<FEATURE>_ERROR_MESSAGE() (macro, optional) - which should print a meaningful error message (with FATAL_ERROR) for the case that no external library was found (and bundled is not allowed to be used.) If not defined, a suitable default error message will be printed. +