From 4c661d05f8c47ff431502553b15a6d5f22b66914 Mon Sep 17 00:00:00 2001 From: maier Date: Wed, 13 Nov 2013 23:48:05 +0000 Subject: [PATCH] CMake: Unify registration of feature configurations and provide a central possibility to filter configuration options in macro_register_feature.cmake git-svn-id: https://svn.dealii.org/trunk@31644 0785d39b-7218-0410-832d-ea1e28bc413d --- .../cmake/configure/configure_1_lapack.cmake | 5 +- deal.II/cmake/configure/configure_1_mpi.cmake | 12 +-- .../cmake/configure/configure_1_threads.cmake | 4 +- .../configure/configure_2_trilinos.cmake | 8 +- .../cmake/configure/configure_3_petsc.cmake | 6 +- deal.II/cmake/configure/configure_boost.cmake | 49 ++++----- deal.II/cmake/configure/configure_hdf5.cmake | 12 +-- deal.II/cmake/configure/configure_mumps.cmake | 10 +- deal.II/cmake/configure/configure_p4est.cmake | 11 +-- deal.II/cmake/configure/configure_slepc.cmake | 11 +-- .../macros/macro_configure_feature.cmake | 18 +--- .../macro_deal_ii_append_libraries.cmake | 47 --------- .../cmake/macros/macro_register_feature.cmake | 99 +++++++++++++++++++ 13 files changed, 152 insertions(+), 140 deletions(-) delete mode 100644 deal.II/cmake/macros/macro_deal_ii_append_libraries.cmake create mode 100644 deal.II/cmake/macros/macro_register_feature.cmake diff --git a/deal.II/cmake/configure/configure_1_lapack.cmake b/deal.II/cmake/configure/configure_1_lapack.cmake index 65f52b38e8..ede31c24ba 100644 --- a/deal.II/cmake/configure/configure_1_lapack.cmake +++ b/deal.II/cmake/configure/configure_1_lapack.cmake @@ -79,11 +79,8 @@ MACRO(RESET_LAPACK_FUNCTIONS_CACHE) ENDMACRO() - MACRO(FEATURE_LAPACK_CONFIGURE_EXTERNAL) - ADD_FLAGS(DEAL_II_LINKER_FLAGS "${LAPACK_LINKER_FLAGS}") - DEAL_II_APPEND_LIBRARIES(${LAPACK_LIBRARIES}) - + REGISTER_FEATURE(LAPACK) CHECK_FOR_LAPACK_FUNCTIONS() ENDMACRO() diff --git a/deal.II/cmake/configure/configure_1_mpi.cmake b/deal.II/cmake/configure/configure_1_mpi.cmake index cd92d2707c..647ea4a81c 100644 --- a/deal.II/cmake/configure/configure_1_mpi.cmake +++ b/deal.II/cmake/configure/configure_1_mpi.cmake @@ -143,14 +143,12 @@ ENDMACRO() MACRO(FEATURE_MPI_CONFIGURE_EXTERNAL) - ADD_FLAGS(CMAKE_CXX_FLAGS "${MPI_CXX_COMPILE_FLAGS}") - ADD_FLAGS(DEAL_II_LINKER_FLAGS "${MPI_CXX_LINK_FLAGS}") - - DEAL_II_APPEND_LIBRARIES(${MPI_CXX_LIBRARIES}) - INCLUDE_DIRECTORIES(${MPI_CXX_INCLUDE_PATH}) - + # # The user has to know the location of the mpi headers as well: - LIST(APPEND DEAL_II_USER_INCLUDE_DIRS ${MPI_CXX_INCLUDE_PATH}) + # + SET(MPI_CXX_ADD_TO_USER_INCLUDE_DIRS TRUE) + + REGISTER_FEATURE(MPI_CXX) ENDMACRO() diff --git a/deal.II/cmake/configure/configure_1_threads.cmake b/deal.II/cmake/configure/configure_1_threads.cmake index 52e16e0ab8..bd75aae705 100644 --- a/deal.II/cmake/configure/configure_1_threads.cmake +++ b/deal.II/cmake/configure/configure_1_threads.cmake @@ -151,9 +151,8 @@ ENDMACRO() MACRO(FEATURE_THREADS_CONFIGURE_EXTERNAL) - INCLUDE_DIRECTORIES(${TBB_INCLUDE_DIR}) - DEAL_II_APPEND_LIBRARIES(${TBB_LIBRARIES}) + REGISTER_FEATURE(TBB) IF(CMAKE_BUILD_TYPE MATCHES "Debug") IF(TBB_WITH_DEBUG_LIB) @@ -161,7 +160,6 @@ MACRO(FEATURE_THREADS_CONFIGURE_EXTERNAL) "TBB_USE_DEBUG=1" "TBB_DO_ASSERT=1" ) ENDIF() - ENDIF() # diff --git a/deal.II/cmake/configure/configure_2_trilinos.cmake b/deal.II/cmake/configure/configure_2_trilinos.cmake index 6693073042..0060efb50b 100644 --- a/deal.II/cmake/configure/configure_2_trilinos.cmake +++ b/deal.II/cmake/configure/configure_2_trilinos.cmake @@ -195,12 +195,8 @@ ENDMACRO() MACRO(FEATURE_TRILINOS_CONFIGURE_EXTERNAL) - INCLUDE_DIRECTORIES(${TRILINOS_INCLUDE_DIRS}) - - # The user has to know the location of the trilinos headers as well: - LIST(APPEND DEAL_II_USER_INCLUDE_DIRS ${TRILINOS_INCLUDE_DIRS}) - - DEAL_II_APPEND_LIBRARIES(${TRILINOS_LIBRARIES}) + SET(TRILINOS_ADD_TO_USER_INCLUDE_DIRS TRUE) + REGISTER_FEATURE(TRILINOS) SET(DEAL_II_EXPAND_TRILINOS_VECTOR "TrilinosWrappers::Vector") SET(DEAL_II_EXPAND_TRILINOS_BLOCKVECTOR "TrilinosWrappers::BlockVector") diff --git a/deal.II/cmake/configure/configure_3_petsc.cmake b/deal.II/cmake/configure/configure_3_petsc.cmake index c1c71a4a83..3627e7c49c 100644 --- a/deal.II/cmake/configure/configure_3_petsc.cmake +++ b/deal.II/cmake/configure/configure_3_petsc.cmake @@ -114,10 +114,8 @@ ENDMACRO() MACRO(FEATURE_PETSC_CONFIGURE_EXTERNAL) INCLUDE_DIRECTORIES(${PETSC_INCLUDE_DIRS}) - # The user has to know the location of the petsc headers as well: - LIST(APPEND DEAL_II_USER_INCLUDE_DIRS ${PETSC_INCLUDE_DIRS}) - - DEAL_II_APPEND_LIBRARIES(${PETSC_LIBRARIES}) + SET(PETSC_ADD_TO_USER_INCLUDE_DIRS TRUE) + REGISTER_FEATURE(PETSC) # # Disable a bunch of warnings when compiling with petsc: diff --git a/deal.II/cmake/configure/configure_boost.cmake b/deal.II/cmake/configure/configure_boost.cmake index b6ed7c3b2c..9571fe9b0e 100644 --- a/deal.II/cmake/configure/configure_boost.cmake +++ b/deal.II/cmake/configure/configure_boost.cmake @@ -74,21 +74,33 @@ MACRO(FEATURE_BOOST_FIND_EXTERNAL var) MARK_AS_ADVANCED(Boost_DIR) - SET(BOOST_VERSION_MAJOR "${Boost_MAJOR_VERSION}") - SET(BOOST_VERSION_MINOR "${Boost_MINOR_VERSION}") - SET(BOOST_VERSION_SUBMINOR "${Boost_SUBMINOR_VERSION}") - SET(BOOST_VERSION - "${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_SUBMINOR}" - ) - IF( Boost_SERIALIZATION_FOUND AND Boost_SYSTEM_FOUND AND - (NOT DEAL_II_WITH_THREADS OR Boost_THREAD_FOUND) - ) + (NOT DEAL_II_WITH_THREADS OR Boost_THREAD_FOUND) ) + + SET(BOOST_VERSION_MAJOR "${Boost_MAJOR_VERSION}") + SET(BOOST_VERSION_MINOR "${Boost_MINOR_VERSION}") + SET(BOOST_VERSION_SUBMINOR "${Boost_SUBMINOR_VERSION}") + SET(BOOST_VERSION + "${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_SUBMINOR}" + ) + + # + # Remove "pthread" from Boost_LIBRARIES. Threading, if necessary, is + # already set up via configure_1_threads.cmake. + # + LIST(REMOVE_ITEM Boost_LIBRARIES "pthread") + + SET(BOOST_INCLUDE_DIRS ${Boost_INCLUDE_DIRS}) + SET(BOOST_LIBRARIES ${Boost_LIBRARIES}) + MARK_AS_ADVANCED(BOOST_DIR) + SET(${var} TRUE) + ELSE() + SET(BOOST_DIR "" CACHE PATH "An optional hint to a boost directory" ) @@ -96,21 +108,10 @@ MACRO(FEATURE_BOOST_FIND_EXTERNAL var) ENDMACRO() -MACRO(FEATURE_BOOST_CONFIGURE_EXTERNAL) - INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIRS}) - - # The user has to know the location of the boost headers as well: - LIST(APPEND DEAL_II_USER_INCLUDE_DIRS ${Boost_INCLUDE_DIRS}) - - # - # Remove "pthread" from Boost_LIBRARIES. Threading, if necessary, is - # already set up via configure_1_threads.cmake. - # - LIST(REMOVE_ITEM Boost_LIBRARIES "pthread") - - DEAL_II_APPEND_LIBRARIES(${Boost_LIBRARIES}) - -ENDMACRO() +# +# The user has to know the location of the boost headers as well: +# +SET(BOOST_ADD_TO_USER_INCLUDE_DIRS TRUE) MACRO(FEATURE_BOOST_CONFIGURE_BUNDLED) diff --git a/deal.II/cmake/configure/configure_hdf5.cmake b/deal.II/cmake/configure/configure_hdf5.cmake index a5a40a255a..81e71ceffa 100644 --- a/deal.II/cmake/configure/configure_hdf5.cmake +++ b/deal.II/cmake/configure/configure_hdf5.cmake @@ -47,14 +47,10 @@ MACRO(FEATURE_HDF5_FIND_EXTERNAL var) ENDMACRO() -MACRO(FEATURE_HDF5_CONFIGURE_EXTERNAL) - INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIRS}) - - # The user has to know the location of the HDF5 headers as well: - LIST(APPEND DEAL_II_USER_INCLUDE_DIRS ${HDF5_INCLUDE_DIRS}) - - DEAL_II_APPEND_LIBRARIES(${HDF5_LIBRARIES}) -ENDMACRO() +# +# The user has to know the location of the hdf5 headers as well: +# +SET(HDF5_ADD_TO_USER_INCLUDE_DIRS TRUE) CONFIGURE_FEATURE(HDF5) diff --git a/deal.II/cmake/configure/configure_mumps.cmake b/deal.II/cmake/configure/configure_mumps.cmake index 0739098602..4022f98026 100644 --- a/deal.II/cmake/configure/configure_mumps.cmake +++ b/deal.II/cmake/configure/configure_mumps.cmake @@ -20,13 +20,11 @@ SET(FEATURE_MUMPS_DEPENDS DEAL_II_WITH_MPI DEAL_II_WITH_LAPACK) -MACRO(FEATURE_MUMPS_CONFIGURE_EXTERNAL) - INCLUDE_DIRECTORIES(${MUMPS_INCLUDE_DIRS}) - # The user has to know the location of the MUMPS headers as well: - LIST(APPEND DEAL_II_USER_INCLUDE_DIRS ${MUMPS_INCLUDE_DIRS}) +# +# The user has to know the location of the MUMPS headers as well: +# +SET(MUMPS_ADD_TO_USER_INCLUDE_DIRS TRUE) - DEAL_II_APPEND_LIBRARIES(${MUMPS_LIBRARIES}) -ENDMACRO() CONFIGURE_FEATURE(MUMPS) diff --git a/deal.II/cmake/configure/configure_p4est.cmake b/deal.II/cmake/configure/configure_p4est.cmake index de91ef6ea1..4055c0f30c 100644 --- a/deal.II/cmake/configure/configure_p4est.cmake +++ b/deal.II/cmake/configure/configure_p4est.cmake @@ -75,13 +75,10 @@ MACRO(FEATURE_P4EST_FIND_EXTERNAL var) ENDMACRO() -MACRO(FEATURE_P4EST_CONFIGURE_EXTERNAL) - INCLUDE_DIRECTORIES(${P4EST_INCLUDE_DIRS}) - - # The user has to know the location of the P4EST headers as well: - LIST(APPEND DEAL_II_USER_INCLUDE_DIRS ${P4EST_INCLUDE_DIRS}) +# +# The user has to know the location of the P4est headers as well: +# +SET(P4EST_ADD_TO_USER_INCLUDE_DIRS TRUE) - DEAL_II_APPEND_LIBRARIES(${P4EST_LIBRARIES}) -ENDMACRO() CONFIGURE_FEATURE(P4EST) diff --git a/deal.II/cmake/configure/configure_slepc.cmake b/deal.II/cmake/configure/configure_slepc.cmake index bf5415a0ff..fdb87649d0 100644 --- a/deal.II/cmake/configure/configure_slepc.cmake +++ b/deal.II/cmake/configure/configure_slepc.cmake @@ -57,14 +57,11 @@ MACRO(FEATURE_SLEPC_FIND_EXTERNAL var) ENDIF() ENDMACRO() -MACRO(FEATURE_SLEPC_CONFIGURE_EXTERNAL) - INCLUDE_DIRECTORIES(${SLEPC_INCLUDE_DIRS}) - # The user has to know the location of the SLEPC headers as well: - LIST(APPEND DEAL_II_USER_INCLUDE_DIRS ${SLEPC_INCLUDE_DIRS}) - - DEAL_II_APPEND_LIBRARIES(${SLEPC_LIBRARIES}) -ENDMACRO() +# +# The user has to know the location of the SLEPC headers as well: +# +SET(SLEPC_ADD_TO_USER_INCLUDE_DIRS TRUE) MACRO(FEATURE_SLEPC_ERROR_MESSAGE) diff --git a/deal.II/cmake/macros/macro_configure_feature.cmake b/deal.II/cmake/macros/macro_configure_feature.cmake index 0ffbf4fb10..4a35b260fd 100644 --- a/deal.II/cmake/macros/macro_configure_feature.cmake +++ b/deal.II/cmake/macros/macro_configure_feature.cmake @@ -134,22 +134,6 @@ MACRO(FEATURE_FIND_EXTERNAL _feature _var) ENDMACRO() -# -# Default macro for basic external setup: -# -MACRO(FEATURE_CONFIGURE_EXTERNAL _feature) - IF(DEFINED ${_feature}_INCLUDE_DIRS) - INCLUDE_DIRECTORIES(${${_feature}_INCLUDE_DIRS}) - ENDIF() - IF(DEFINED ${_feature}_LIBRARIES) - DEAL_II_APPEND_LIBRARIES(${${_feature}_LIBRARIES}) - ENDIF() - IF(DEFINED ${_feature}_LINKER_FLAGS) - ADD_FLAGS(DEAL_II_LINKER_FLAGS "${${_feature}_LINKER_FLAGS}") - ENDIF() -ENDMACRO() - - ######################################################################## # # # CONFIGURE_FEATURE: # @@ -249,7 +233,7 @@ MACRO(CONFIGURE_FEATURE _feature) IF(COMMAND FEATURE_${_feature}_CONFIGURE_EXTERNAL) RUN_COMMAND("FEATURE_${_feature}_CONFIGURE_EXTERNAL()") ELSE() - FEATURE_CONFIGURE_EXTERNAL(${_feature}) + REGISTER_FEATURE(${_feature}) ENDIF() MESSAGE(STATUS "DEAL_II_WITH_${_feature} successfully set up with external dependencies.") diff --git a/deal.II/cmake/macros/macro_deal_ii_append_libraries.cmake b/deal.II/cmake/macros/macro_deal_ii_append_libraries.cmake deleted file mode 100644 index de291d39b6..0000000000 --- a/deal.II/cmake/macros/macro_deal_ii_append_libraries.cmake +++ /dev/null @@ -1,47 +0,0 @@ -## --------------------------------------------------------------------- -## $Id$ -## -## Copyright (C) 2013 by the deal.II authors -## -## This file is part of the deal.II library. -## -## The deal.II library is free software; you can use it, redistribute -## it, and/or modify it under the terms of the GNU Lesser General -## Public License as published by the Free Software Foundation; either -## version 2.1 of the License, or (at your option) any later version. -## The full text of the license can be found in the file LICENSE at -## the top level of the deal.II distribution. -## -## --------------------------------------------------------------------- - -# -# A small macro to add libraries to -# DEAL_II_EXTERNAL_LIBRARIES -# DEAL_II_EXTERNAL_LIBRARIES_DEBUG -# DEAL_II_EXTERNAL_LIBRARIES_RELEASE -# depending on the "optmized", "debug" or "general" keyword -# -# Usage: -# DEAL_II_APPEND_LIBRARIES() -# - -MACRO(DEAL_II_APPEND_LIBRARIES) - - SET(_toggle "general") - FOREACH(_tmp ${ARGN}) - IF( "${_tmp}" STREQUAL "debug" OR - "${_tmp}" STREQUAL "optimized" OR - "${_tmp}" STREQUAL "general" ) - SET(_toggle "${_tmp}") - ELSE() - IF("${_toggle}" STREQUAL "general") - LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${_tmp}) - ELSEIF("${_toggle}" STREQUAL "debug") - LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES_DEBUG ${_tmp}) - ELSEIF("${_toggle}" STREQUAL "optimized") - LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES_RELEASE ${_tmp}) - ENDIF() - ENDIF() - ENDFOREACH() - -ENDMACRO() diff --git a/deal.II/cmake/macros/macro_register_feature.cmake b/deal.II/cmake/macros/macro_register_feature.cmake new file mode 100644 index 0000000000..a4408fe8d9 --- /dev/null +++ b/deal.II/cmake/macros/macro_register_feature.cmake @@ -0,0 +1,99 @@ +## --------------------------------------------------------------------- +## $Id$ +## +## Copyright (C) 2013 by the deal.II authors +## +## This file is part of the deal.II library. +## +## The deal.II library is free software; you can use it, redistribute +## it, and/or modify it under the terms of the GNU Lesser General +## Public License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## The full text of the license can be found in the file LICENSE at +## the top level of the deal.II distribution. +## +## --------------------------------------------------------------------- + +# +# This macro is used for the feature configuration in deal.II +# +# Usage: +# REGISTER_FEATURE(feature) +# +# This macro will +# +# - add ${feature}_INCLUDE_DIRS and ${feature}_INCLUDE_PATH +# to the list of (internal) include +# directories +# - and if ${feature}_ADD_TO_USER_INCLUDE_DIRS is defined also to +# DEAL_II_USER_INCLUDE_DIRS +# +# - add ${feature}_LINKER_FLAGS and ${feature}_LINK_FLAGS to +# DEAL_II_LINKER_FLAGS +# +# - add ${feature}_CXX_FLAGS and ${feature}_COMPILE_FLAGS to +# CMAKE_CXX_FLAGS +# +# - add ${feature}_LIBRARIES to the list of deal.II libraries depending +# on general, optimized or debug keyword +# + + +MACRO(REGISTER_FEATURE _feature) + MESSAGE(STATUS "Register enabled external feature ${_feature}:") + + # variables for include directories: + FOREACH(_var ${_feature}_INCLUDE_DIRS ${_feature}_INCLUDE_PATH) + IF(DEFINED ${_var}) + MESSAGE(STATUS " ${_var}") + INCLUDE_DIRECTORIES(${${_var}}) + IF(${_feature}_ADD_TO_USER_INCLUDE_DIRS) + LIST(APPEND DEAL_II_USER_INCLUDE_DIRS ${${_var}}) + ENDIF() + ENDIF() + ENDFOREACH() + + # variables for linker flags: + FOREACH(_var ${_feature}_LINKER_FLAGS ${_feature}_LINK_FLAGS) + IF(DEFINED ${_var}) + MESSAGE(STATUS " ${_var}") + ADD_FLAGS(DEAL_II_LINKER_FLAGS "${${_var}}") + ENDIF() + ENDFOREACH() + + # variables for compiler flags: + FOREACH(_var ${_feature}_CXX_FLAGS ${_feature}_COMPILE_FLAGS) + IF(DEFINED ${_var}) + MESSAGE(STATUS " ${_var}") + ADD_FLAGS(CMAKE_CXX_FLAGS "${${_var}}") + ENDIF() + ENDFOREACH() + + IF(DEFINED ${_feature}_LIBRARIES) + MESSAGE(STATUS " ${_feature}_LIBRARIES") + # + # Add ${_feature}_LIBRARIES to + # DEAL_II_EXTERNAL_LIBRARIES + # DEAL_II_EXTERNAL_LIBRARIES_DEBUG + # DEAL_II_EXTERNAL_LIBRARIES_RELEASE + # depending on the "optmized", "debug" or "general" keyword + # + SET(_toggle "general") + FOREACH(_tmp ${${_feature}_LIBRARIES}) + IF( "${_tmp}" STREQUAL "debug" OR + "${_tmp}" STREQUAL "optimized" OR + "${_tmp}" STREQUAL "general" ) + SET(_toggle "${_tmp}") + ELSE() + IF("${_toggle}" STREQUAL "general") + LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${_tmp}) + ELSEIF("${_toggle}" STREQUAL "debug") + LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES_DEBUG ${_tmp}) + ELSEIF("${_toggle}" STREQUAL "optimized") + LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES_RELEASE ${_tmp}) + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + +ENDMACRO() -- 2.39.5