From d9578fc46af8263cefbf64ed4146ddc67252b189 Mon Sep 17 00:00:00 2001 From: maier Date: Fri, 14 Sep 2012 14:31:46 +0000 Subject: [PATCH] Complete rewrite of the feature configuration git-svn-id: https://svn.dealii.org/branches/branch_cmake@26380 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/CMakeLists.txt | 93 +++++++---- .../cmake/configure/configure_blas.cmake | 48 ++++++ .../cmake/configure/configure_boost.cmake | 57 +++++-- .../configure/configure_functionparser.cmake | 39 +++-- .../cmake/configure/configure_lapack.cmake | 49 ++++++ .../cmake/configure/configure_mpi.cmake | 57 +++++-- .../cmake/configure/configure_netcdf.cmake | 43 ++++- .../cmake/configure/configure_tbb.cmake | 141 ++++++++++++++++ .../cmake/configure/configure_threads.cmake | 113 ------------- .../cmake/configure/configure_umfpack.cmake | 85 ++++++---- .../cmake/configure/configure_zlib.cmake | 40 ++++- .../macros/macro_configure_feature.cmake | 158 ++++++++++++++++++ .../cmake/macros/macro_list_contains.cmake | 9 + .../macros/macro_message_not_found.cmake | 77 ++++++++- 14 files changed, 774 insertions(+), 235 deletions(-) create mode 100644 deal.II/contrib/cmake/configure/configure_blas.cmake create mode 100644 deal.II/contrib/cmake/configure/configure_lapack.cmake create mode 100644 deal.II/contrib/cmake/configure/configure_tbb.cmake delete mode 100644 deal.II/contrib/cmake/configure/configure_threads.cmake create mode 100644 deal.II/contrib/cmake/macros/macro_configure_feature.cmake create mode 100644 deal.II/contrib/cmake/macros/macro_list_contains.cmake diff --git a/deal.II/CMakeLists.txt b/deal.II/CMakeLists.txt index 7ce0f60b28..60e041c904 100644 --- a/deal.II/CMakeLists.txt +++ b/deal.II/CMakeLists.txt @@ -24,6 +24,15 @@ SET(VERSION "8.0.pre") # always an exception, isn't it?) DEAL_II_FORCE_CONTRIB_ forces # the use of the bundled contrib library. # +# +# Autoconfiguration: If the option DEAL_II_FEATURE_AUTODETECTION is enabled +# the DEAL_II_WITH_ toggles will be automatically set (overwriting +# any previous configuration) depending on whether they can be supported or +# not. +# (Note: DEAL_II_FEATURE_AUTODETECTION will respect DEAL_II_ALLOW_CONTRIB +# and DEAL_II_FORCE_CONTRIB_) +# +# # The option DEAL_II_FORCE_CONTRIB_ forces the use of the bundled # contrib library regardless whether DEAL_II_ALLOW_CONTRIB is set to OFF or # an external library is found. @@ -67,8 +76,26 @@ SET(VERSION "8.0.pre") # # ########################################################################### +# +# Feature selection: +# + +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) + +OPTION(DEAL_II_WITH_BLAS + "Build deal.II with support for BLAS." + ON) + OPTION(DEAL_II_WITH_FUNCTIONPARSER "Build deal.II with support for functionparser." + OFF) + +OPTION(DEAL_II_WITH_LAPACK + "Build deal.II with support for LAPACK." ON) OPTION(DEAL_II_WITH_METIS @@ -83,12 +110,12 @@ OPTION(DEAL_II_WITH_NETCDF "Build deal.II with support for netcdf." OFF) -OPTION(DEAL_II_WITH_THREADS - "Build deal.II with support for threads. This pulls in libtbb as a dependency." +OPTION(DEAL_II_WITH_TBB + "Build deal.II with support for tbb. This will enable thread support in deal.II." ON) OPTION(DEAL_II_WITH_UMFPACK - "Build deal.II with support for UMFPACK, BLAS and LAPACK." + "Build deal.II with support for UMFPACK." ON) OPTION(DEAL_II_WITH_ZLIB @@ -105,11 +132,11 @@ 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" - OFF) + ON) OPTION(DEAL_II_FORCE_CONTRIB_FUNCTIONPARSER "Always use the bundled functionparser library instead of an external one." - ON) + OFF) OPTION(DEAL_II_FORCE_CONTRIB_BOOST "Always use the bundled boost library instead of an external one." @@ -117,11 +144,11 @@ OPTION(DEAL_II_FORCE_CONTRIB_BOOST OPTION(DEAL_II_FORCE_CONTRIB_TBB "Always use the bundled tbb library instead of an external one." - ON) + OFF) OPTION(DEAL_II_FORCE_CONTRIB_UMFPACK "Always use the bundled umfpack library instead of an external one." - ON) + OFF) # # Compatibility support: @@ -217,38 +244,34 @@ SET(deal_ii_external_libraries) # Run all system checks: # -FILE(GLOB macro_files "contrib/cmake/check/*.cmake") -FOREACH(file ${macro_files}) - MESSAGE(STATUS "Include ${file}") - INCLUDE(${file}) -ENDFOREACH() +#FILE(GLOB check_files "contrib/cmake/check/*.cmake") +#FOREACH(file ${check_files}) +# MESSAGE(STATUS "Include ${file}") +# INCLUDE(${file}) +#ENDFOREACH() # # Feature configuration: # -IF(DEAL_II_WITH_FUNCTIONPARSER) - INCLUDE(configure_functionparser) -ENDIF() -IF(DEAL_II_WITH_MPI) - INCLUDE(configure_mpi) -ENDIF() -IF(DEAL_II_WITH_NETCDF) - INCLUDE(configure_netcdf) -ENDIF() -IF(DEAL_II_WITH_THREADS) - INCLUDE(configure_threads) -ENDIF() -# Boost depends on configuration variables set in configure_threads.cmake +INCLUDE(configure_blas) +INCLUDE(configure_lapack) +INCLUDE(configure_umfpack) + +INCLUDE(configure_functionparser) + +INCLUDE(configure_mpi) + +INCLUDE(configure_netcdf) + +INCLUDE(configure_tbb) + +# Boost has to be incluted after threads because it depends on the thread +# configuration INCLUDE(configure_boost) -IF(DEAL_II_WITH_UMFPACK) - INCLUDE(configure_umfpack) -ENDIF() -IF(DEAL_II_WITH_ZLIB) - INCLUDE(configure_zlib) -ENDIF() +INCLUDE(configure_zlib) @@ -283,3 +306,11 @@ INCLUDE_DIRECTORIES( ADD_SUBDIRECTORY(include) ADD_SUBDIRECTORY(source) + +MESSAGE(STATUS "Configured features:") +GET_CMAKE_PROPERTY(res VARIABLES) +FOREACH(var ${res}) + IF(var MATCHES "DEAL_II_WITH") + MESSAGE(STATUS "${var} : ${${var}}") + ENDIF() +ENDFOREACH() diff --git a/deal.II/contrib/cmake/configure/configure_blas.cmake b/deal.II/contrib/cmake/configure/configure_blas.cmake new file mode 100644 index 0000000000..f204114988 --- /dev/null +++ b/deal.II/contrib/cmake/configure/configure_blas.cmake @@ -0,0 +1,48 @@ +# +# Configuration for the blas library: +# + +# TODO: +# - include dir? +# - unit checks and definitions. + +MACRO(FIND_FEATURE_BLAS_EXTERNAL var) + + FIND_PACKAGE(BLAS) + + IF(BLAS_FOUND) + SET(${var} TRUE) + ENDIF() + +ENDMACRO() + + +MACRO(CONFIGURE_FEATURE_BLAS_EXTERNAL var) + + SET(CMAKE_SHARED_LINKER_FLAGS + "${CMAKE_SHARED_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}" + ) + + LIST(APPEND deal_ii_external_libraries + ${BLAS_LIBRARIES} + ) + + SET(HAVE_LIBBLAS TRUE) + + SET(${var} TRUE) +ENDMACRO() + + +MACRO(CONFIGURE_FEATURE_BLAS_ERROR_MESSAGE) + MESSAGE(SEND_ERROR " +Could not find the blas library! + +Please ensure that the blas library is installed on your computer. +If the library is not at a default location, either provide some hints +for the autodetection, or set the relevant variables by hand in ccmake. + +") +ENDMACRO() + + +CONFIGURE_FEATURE(BLAS) diff --git a/deal.II/contrib/cmake/configure/configure_boost.cmake b/deal.II/contrib/cmake/configure/configure_boost.cmake index 06c00f935c..7ce09063bc 100644 --- a/deal.II/contrib/cmake/configure/configure_boost.cmake +++ b/deal.II/contrib/cmake/configure/configure_boost.cmake @@ -1,22 +1,28 @@ -IF(NOT DEAL_II_FORCE_CONTRIB_BOOST) +# +# Configuration for the boost library: +# + +# Always true. We need it :-] +SET(DEAL_II_WITH_BOOST "ON" + CACHE STRING "Build deal.II with support for boost." FORCE + ) + + +MACRO(FIND_FEATURE_BOOST_EXTERNAL var) FIND_PACKAGE (Boost COMPONENTS serialization thread) - IF(NOT DEAL_II_ALLOW_CONTRIB) - IF(NOT Boost_THREAD_FOUND OR NOT Boost_SERIALIZATION_FOUND) - macro_message_not_found("boost" "Boost") - ENDIF() - ELSE() + IF(Boost_THREAD_FOUND AND Boost_SERIALIZATION_FOUND) + SET(${var} TRUE) + # Get rid of this annoying unimportant variable: MARK_AS_ADVANCED(Boost_DIR) ENDIF() -ENDIF() +ENDMACRO() -IF( NOT DEAL_II_FORCE_CONTRIB_BOOST AND - Boost_THREAD_FOUND AND - Boost_SERIALIZATION_FOUND ) +MACRO(CONFIGURE_FEATURE_BOOST_EXTERNAL var) INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIR}) @@ -30,7 +36,14 @@ IF( NOT DEAL_II_FORCE_CONTRIB_BOOST AND ) ENDIF() -ELSE() + SET(${var} TRUE) +ENDMACRO() + + +SET(HAVE_CONTRIB_FEATURE_BOOST TRUE) + + +MACRO(CONFIGURE_FEATURE_BOOST_CONTRIB var) # compile the necessary parts of boost out of ./contrib @@ -62,4 +75,24 @@ ELSE() ) ENDIF() -ENDIF() + SET(${var} TRUE) +ENDMACRO() + + +MACRO(CONFIGURE_FEATURE_BOOST_ERROR_MESSAGE) + MESSAGE(SEND_ERROR " +Could not find the boost library! + +Please ensure that the boost library is installed on your computer. +If the library is not at a default location, either provide some hints +for the autodetection, or set the relevant variables by hand in ccmake. + +Alternatively you may choose to compile the bundled contrib library of +boost by setting DEAL_II_ALLOW_CONTRIB=on or +DEAL_II_FORCE_CONTRIB_BOOST=on. + +") +ENDMACRO() + + +CONFIGURE_FEATURE(BOOST) diff --git a/deal.II/contrib/cmake/configure/configure_functionparser.cmake b/deal.II/contrib/cmake/configure/configure_functionparser.cmake index c6c4698a2b..39dcf61d3c 100644 --- a/deal.II/contrib/cmake/configure/configure_functionparser.cmake +++ b/deal.II/contrib/cmake/configure/configure_functionparser.cmake @@ -1,12 +1,17 @@ -IF(NOT DEAL_II_FORCE_CONTRIB_FUNCTIONPARSER) +MACRO(FIND_FEATURE_FUNCTIONPARSER_EXTERNAL var) +ENDMACRO() - IF(NOT DEAL_II_ALLOW_CONTRIB) - MESSAGE(FATAL_ERROR "FindFunctionparser.cmake not written, yet. :-[") - ENDIF() -ENDIF() +MACRO(CONFIGURE_FEATURE_FUNCTIONPARSER_EXTERNAL var) +ENDMACRO() -IF(DEAL_II_FORCE_CONTRIB_FUNCTIONPARSER OR NOT Functionparser_FOUND) + +SET(HAVE_CONTRIB_FEATURE_FUNCTIONPARSER TRUE) + + +MACRO(CONFIGURE_FEATURE_FUNCTIONPARSER_CONTRIB var) + + # compile the necessary parts of functionparser out of ./contrib INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/contrib/functionparser/ @@ -21,12 +26,24 @@ IF(DEAL_II_FORCE_CONTRIB_FUNCTIONPARSER OR NOT Functionparser_FOUND) $ ) -ELSE() + SET(HAVE_FUNCTIONPARSER TRUE) + + SET(${var} TRUE) +ENDMACRO() + + +MACRO(CONFIGURE_FEATURE_FUNCTIONPARSER_ERROR_MESSAGE) + MESSAGE(SEND_ERROR " +Could not find the functionparser library! + +Module not written, yet... - INCLUDE_DIRECTORIES(${Functionparser_INCLUDE_DIR}) +You may want to choose to compile the bundled contrib library of +functionparser by setting DEAL_II_ALLOW_CONTRIB=on or +DEAL_II_FORCE_CONTRIB_FUNCTIONPARSER=on. - LIST(APPEND deal_ii_external_libraries ${Functionparser_LIBRARY}) +") +ENDMACRO() -ENDIF() -SET(HAVE_FUNCTIONPARSER TRUE) +CONFIGURE_FEATURE(FUNCTIONPARSER) diff --git a/deal.II/contrib/cmake/configure/configure_lapack.cmake b/deal.II/contrib/cmake/configure/configure_lapack.cmake new file mode 100644 index 0000000000..7d022a8477 --- /dev/null +++ b/deal.II/contrib/cmake/configure/configure_lapack.cmake @@ -0,0 +1,49 @@ +# +# Configuration for the lapack library: +# + +# TODO: +# - include dir? +# - unit checks and definitions. + +MACRO(FIND_FEATURE_LAPACK_EXTERNAL var) + + FIND_PACKAGE(LAPACK) + + IF(LAPACK_FOUND) + SET(${var} TRUE) + ENDIF() + +ENDMACRO() + + +MACRO(CONFIGURE_FEATURE_LAPACK_EXTERNAL var) + + SET(CMAKE_SHARED_LINKER_FLAGS + "${CMAKE_SHARED_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}" + ) + + LIST(APPEND deal_ii_external_libraries + ${LAPACK_LIBRARIES} + ) + + SET(HAVE_LIBLAPACK TRUE) + + SET(${var} TRUE) + +ENDMACRO() + + +MACRO(CONFIGURE_FEATURE_BLAS_ERROR_MESSAGE) + MESSAGE(SEND_ERROR " +Could not find the lapack library! + +Please ensure that the lapack library is installed on your computer. +If the library is not at a default location, either provide some hints +for the autodetection, or set the relevant variables by hand in ccmake. + +") +ENDMACRO() + + +CONFIGURE_FEATURE(LAPACK) diff --git a/deal.II/contrib/cmake/configure/configure_mpi.cmake b/deal.II/contrib/cmake/configure/configure_mpi.cmake index 97661d72c7..322ad8ac9f 100644 --- a/deal.II/contrib/cmake/configure/configure_mpi.cmake +++ b/deal.II/contrib/cmake/configure/configure_mpi.cmake @@ -1,23 +1,52 @@ -FIND_PACKAGE(MPI REQUIRED CXX) +# +# Configuration for mpi support: +# -# TODO: A deal.II specific error message if mpi is not found +MACRO(FIND_FEATURE_MPI_EXTERNAL var) -INCLUDE_DIRECTORIES(${MPI_CXX_INCLUDE_PATH}) + FIND_PACKAGE(MPI) -SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${MPI_CXX_LINK_FLAGS}") + IF(MPI_CXX_FOUND) + SET(${var} TRUE) + ENDIF() -LIST(APPEND deal_ii_external_libraries ${MPI_CXX_LIBRARIES}) +ENDMACRO() -SET(DEAL_II_COMPILER_SUPPORTS_MPI TRUE) +MACRO(CONFIGURE_FEATURE_MPI_EXTERNAL var) -# MPI_CXX_COMPILER MPI Compiler wrapper for CXX -# MPI_CXX_COMPILE_FLAGS Compilation flags for MPI programs + INCLUDE_DIRECTORIES(${MPI_CXX_INCLUDE_PATH}) + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${MPI_CXX_LINK_FLAGS}") + LIST(APPEND deal_ii_external_libraries ${MPI_CXX_LIBRARIES}) + SET(DEAL_II_COMPILER_SUPPORTS_MPI TRUE) -# MPIEXEC Executable for running MPI programs -# MPIEXEC_NUMPROC_FLAG Flag to pass to MPIEXEC before giving -# it the number of processors to run on -# MPIEXEC_PREFLAGS Flags to pass to MPIEXEC directly -# before the executable to run. -# MPIEXEC_POSTFLAGS Flags to pass to MPIEXEC after other flags + + #MPI_CXX_COMPILER MPI Compiler wrapper for CXX + #MPI_CXX_COMPILE_FLAGS Compilation flags for MPI programs + + + #MPIEXEC Executable for running MPI programs + #MPIEXEC_NUMPROC_FLAG Flag to pass to MPIEXEC before giving + # it the number of processors to run on + #MPIEXEC_PREFLAGS Flags to pass to MPIEXEC directly + # before the executable to run. + #MPIEXEC_POSTFLAGS Flags to pass to MPIEXEC after other flags + + SET(${var} TRUE) +ENDMACRO() + + +MACRO(CONFIGURE_FEATURE_MPI_ERROR_MESSAGE) + MESSAGE(SEND_ERROR " +Could not find any suitable mpi library! + +Please ensure that an mpi library is installed on your computer. +If the library is not at a default location, either provide some hints +for the autodetection, or set the relevant variables by hand in ccmake. + +") +ENDMACRO() + + +CONFIGURE_FEATURE(MPI) diff --git a/deal.II/contrib/cmake/configure/configure_netcdf.cmake b/deal.II/contrib/cmake/configure/configure_netcdf.cmake index 324af91dc8..6afb37a9e7 100644 --- a/deal.II/contrib/cmake/configure/configure_netcdf.cmake +++ b/deal.II/contrib/cmake/configure/configure_netcdf.cmake @@ -1,11 +1,40 @@ -FIND_PACKAGE(NETCDF) +# +# Configuration for the netcdf library: +# -IF(NOT NETCDF_FOUND) - macro_message_not_found("netcdf" "NETCDF") -ENDIF() +MACRO(FIND_FEATURE_NETCDF_EXTERNAL var) -INCLUDE_DIRECTORIES(${NETCDF_INCLUDE_DIR}) + FIND_PACKAGE(NETCDF) -LIST(APPEND deal_ii_external_libraries ${NETCDF_LIBRARY}) + IF(NETCDF_FOUND) + SET(${var} TRUE) + ENDIF() -SET(HAVE_LIBNETCDF TRUE) +ENDMACRO() + + +MACRO(CONFIGURE_FEATURE_NETCDF_EXTERNAL var) + + INCLUDE_DIRECTORIES(${NETCDF_INCLUDE_DIR}) + LIST(APPEND deal_ii_external_libraries ${NETCDF_LIBRARY}) + SET(HAVE_LIBNETCDF TRUE) + + SET(${var} TRUE) +ENDMACRO() + + +MACRO(CONFIGURE_FEATURE_NETCDF_ERROR_MESSAGE) + + MESSAGE(SEND_ERROR " +Could not find the netcdf library! + +Please ensure that the netcdf library is installed on your computer. +If the library is not at a default location, either provide some hints +for the autodetection, or set the relevant variables by hand in ccmake. + +") + +ENDMACRO() + + +CONFIGURE_FEATURE(NETCDF) diff --git a/deal.II/contrib/cmake/configure/configure_tbb.cmake b/deal.II/contrib/cmake/configure/configure_tbb.cmake new file mode 100644 index 0000000000..52b6a89771 --- /dev/null +++ b/deal.II/contrib/cmake/configure/configure_tbb.cmake @@ -0,0 +1,141 @@ +# +# Configuration for the tbb library: +# + +INCLUDE(CheckCXXSourceCompiles) + +# +# Set up genereal threading. The macro will be included in +# CONFIGURE_FEATURE_TBB_EXTERNAL/CONTRIB: +# +MACRO(SETUP_THREADING var) + FIND_PACKAGE(Threads) + + IF(Threads_FOUND) + SET(${var} TRUE) + + # + # We support threading. Go on and configure the rest: + # + + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_THREAD_LIBS_INIT}") + + SET(DEAL_II_USE_MT TRUE) + + # + # Set up some posix threads specific configuration toggles: + # + IF(CMAKE_USE_PTHREADS_INIT) + SET(DEAL_II_USE_MT_POSIX TRUE) + + # Check whether posix thread barriers are available: + + LIST(APPEND CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}") + + CHECK_CXX_SOURCE_COMPILES( + " + #include + int main() + { + pthread_barrier_t pb; + pthread_barrier_init (&pb, 0, 1); + pthread_barrier_wait (&pb); + pthread_barrier_destroy (&pb); + return 0; + } + " + DEAL_II_HAVE_MT_POSIX_BARRIERS) + + LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}") + + IF(NOT DEAL_II_HAVE_MT_POSIX_BARRIERS) + SET(DEAL_II_USE_MT_POSIX_NO_BARRIERS TRUE) + ENDIF() + ENDIF() + + # + # In some cases, -threads (or whatever else command line option) + # switches on some preprocessor flags. If this is not the case, + # then define them explicitely. + # + + LIST(APPEND CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}") + CHECK_CXX_SOURCE_COMPILES( + " + #if !defined (_REENTRANT) && !defined (_THREAD_SAFE) + # error Neither _REENTRANT nor _THREAD_SAFE were defined. + nonsense + #endif + int main(){ return 0; } + " + DEAL_II_HAVE_SANE_MT_DEFINITIONS) + LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}") + + IF(NOT DEAL_II_HAVE_SANE_MT_DEFINITIONS) + ADD_DEFINITIONS("-D_REENTRANT" "-D_THREAD_SAFE") + ENDIF() + + ENDIF(Threads_FOUND) +ENDMACRO() + + + +# +# Set up the tbb library: +# + +MACRO(FIND_FEATURE_TBB_EXTERNAL var) + + FIND_PACKAGE(TBB) + + # In case we don't have a debug library: + IF(NOT TBB_DEBUG_FOUND) + SET(TBB_DEBUG_LIBRARY ${TBB_LIBRARY}) + ENDIF() + + IF(TBB_FOUND) + SET(${var} TRUE) + ENDIF() + +ENDMACRO() + + +MACRO(CONFIGURE_FEATURE_TBB_EXTERNAL var) + + INCLUDE_DIRECTORIES(${TBB_INCLUDE_DIR}) + + IF (CMAKE_BUILD_TYPE MATCHES "Debug") + LIST(APPEND deal_ii_external_libraries ${TBB_DEBUG_LIBRARY}) + ELSE() + LIST(APPEND deal_ii_external_libraries ${TBB_LIBRARY}) + ENDIF() + + # Setup threading and if successfull return TRUE: + SETUP_THREADING(${var}) +ENDMACRO() + + +SET(HAVE_CONTRIB_FEATURE_TBB TRUE) + + +MACRO(CONFIGURE_FEATURE_BOOST_CONTRIB var) + # + # Add tbb directly to the object files of deal.II + # + + INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/contrib/tbb/tbb30_104oss/include + ) + + ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/contrib/tbb/tbb30_104oss/src) + + LIST(APPEND deal_ii_additional_object_files + $ + ) + + # Setup threading and if successfull return TRUE: + SETUP_THREADING(${var}) +ENDMACRO() + + +CONFIGURE_FEATURE(TBB) diff --git a/deal.II/contrib/cmake/configure/configure_threads.cmake b/deal.II/contrib/cmake/configure/configure_threads.cmake deleted file mode 100644 index 0d060eac4d..0000000000 --- a/deal.II/contrib/cmake/configure/configure_threads.cmake +++ /dev/null @@ -1,113 +0,0 @@ -INCLUDE(CheckCXXSourceCompiles) - - -# -# Set up genereal threading: -# - -FIND_PACKAGE(Threads REQUIRED) - -SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_THREAD_LIBS_INIT}") - -SET(DEAL_II_USE_MT TRUE) - - -# -# Set up some posix threads specific configuration toggles: -# -IF(CMAKE_USE_PTHREADS_INIT) - SET(DEAL_II_USE_MT_POSIX TRUE) - - # Check whether posix thread barriers are available: - - LIST(APPEND CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}") - - CHECK_CXX_SOURCE_COMPILES( - " - #include - int main() - { - pthread_barrier_t pb; - pthread_barrier_init (&pb, 0, 1); - pthread_barrier_wait (&pb); - pthread_barrier_destroy (&pb); - return 0; - } - " - DEAL_II_HAVE_MT_POSIX_BARRIERS) - - LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}") - - IF(NOT DEAL_II_HAVE_MT_POSIX_BARRIERS) - SET(DEAL_II_USE_MT_POSIX_NO_BARRIERS TRUE) - ENDIF() -ENDIF() - - -# -# In some cases, -threads (or whatever else command line option) -# switches on some preprocessor flags. If this is not the case, -# then define them explicitely. -# - -LIST(APPEND CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}") -CHECK_CXX_SOURCE_COMPILES( - " - #if !defined (_REENTRANT) && !defined (_THREAD_SAFE) - # error Neither _REENTRANT nor _THREAD_SAFE were defined. - nonsense - #endif - int main(){ return 0; } - " - DEAL_II_HAVE_SANE_MT_DEFINITIONS) -LIST(REMOVE_ITEM CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}") - -IF(NOT DEAL_II_HAVE_SANE_MT_DEFINITIONS) - ADD_DEFINITIONS("-D_REENTRANT" "-D_THREAD_SAFE") -ENDIF() - - -# -# Set up the tbb library: -# - - -IF(NOT DEAL_II_FORCE_CONTRIB_TBB) - - FIND_PACKAGE(TBB) - - IF(NOT DEAL_II_ALLOW_CONTRIB AND NOT TBB_FOUND) - macro_message_not_found("tbb" "TBB") - ENDIF() - - # In case we don't have a debug library: - IF(NOT TBB_DEBUG_FOUND) - SET(TBB_DEBUG_LIBRARY ${TBB_LIBRARY}) - ENDIF() -ENDIF() - -IF(DEAL_II_FORCE_CONTRIB_TBB OR NOT TBB_FOUND) - - # - # Add tbb directly to the object files of deal.II - # - - INCLUDE_DIRECTORIES( - ${CMAKE_SOURCE_DIR}/contrib/tbb/tbb30_104oss/include - ) - - ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/contrib/tbb/tbb30_104oss/src) - - LIST(APPEND deal_ii_additional_object_files - $ - ) - -ENDIF() - -INCLUDE_DIRECTORIES(${TBB_INCLUDE_DIR}) - -IF (CMAKE_BUILD_TYPE MATCHES "Debug") - LIST(APPEND deal_ii_external_libraries ${TBB_DEBUG_LIBRARY}) -ELSE() - LIST(APPEND deal_ii_external_libraries ${TBB_LIBRARY}) -ENDIF() diff --git a/deal.II/contrib/cmake/configure/configure_umfpack.cmake b/deal.II/contrib/cmake/configure/configure_umfpack.cmake index 5e8539a04b..2221076322 100644 --- a/deal.II/contrib/cmake/configure/configure_umfpack.cmake +++ b/deal.II/contrib/cmake/configure/configure_umfpack.cmake @@ -1,39 +1,40 @@ -FIND_PACKAGE(LAPACK REQUIRED) -FIND_PACKAGE(BLAS REQUIRED) +# +# Configuration for the umfpack and amd libraries: +# -SET(CMAKE_SHARED_LINKER_FLAGS - "${CMAKE_SHARED_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}" - ) +# TODO: Implement the dependency on BLAS and LAPACK -LIST(APPEND deal_ii_external_libraries - ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} - ) - -# TODO: A deal.II specific error message if blas or lapack is not found - - -IF(NOT DEAL_II_FORCE_CONTRIB_UMFPACK) +MACRO(FIND_FEATURE_UMFPACK_EXTERNAL var) FIND_PACKAGE(UMFPACK) FIND_PACKAGE(AMD) - IF(NOT DEAL_II_ALLOW_CONTRIB) - IF(NOT UMFPACK_FOUND) - macro_message_not_found("umfpack" "UMFPACK") - ENDIF() - IF(NOT AMD_FOUND) - macro_message_not_found("amd" "AMD") - ENDIF() + IF(UMFPACK_FOUND AND AMD_FOUND) + SET(${var} TRUE) ENDIF() -ENDIF() +ENDMACRO() + + +MACRO(CONFIGURE_FEATURE_UMFPACK_EXTERNAL var) + + INCLUDE_DIRECTORIES(${UMFPACK_INCLUDE_DIR} ${AMD_INCLUDE_DIR}) + + LIST(APPEND deal_ii_external_libraries + ${UMFPACK_LIBRARY} ${AMD_LIBRARY} + ) + + SET(HAVE_LIBUMFPACK TRUE) + + SET(${var} TRUE) -IF(UMFPACK_FOUND AND AMD_FOUND) # TODO - SET(UMFPACKAMD_FOUND TRUE) -ELSE() - SET(UMFPACKAMD_FOUND FALSE) -ENDIF() -IF(DEAL_II_FORCE_CONTRIB_UMFPACK OR NOT UMFPACKAMD_FOUND) +ENDMACRO() + + +SET(HAVE_CONTRIB_FEATURE_UMFPACK TRUE) + + +MACRO(CONFIGURE_FEATURE_UMFPACK_CONTRIB var) INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/contrib/umfpack/UMFPACK/Include @@ -53,17 +54,29 @@ IF(DEAL_II_FORCE_CONTRIB_UMFPACK OR NOT UMFPACKAMD_FOUND) $ ) -ELSE() + SET(HAVE_LIBUMFPACK TRUE) - INCLUDE_DIRECTORIES(${UMFPACK_INCLUDE_DIR} ${AMD_INCLUDE_DIR}) + SET(${var} TRUE) - LIST(APPEND deal_ii_external_libraries - ${UMFPACK_LIBRARY} ${AMD_LIBRARY} - ) +ENDMACRO() + + +MACRO(CONFIGURE_FEATURE_BOOST_ERROR_MESSAGE) + MESSAGE(SEND_ERROR " +Could not find the umfpack and amd libraries! + +Please ensure that the libraries are installed on your computer. +If the libraries are not at a default location, either provide some hints +via environment variables: +UMFPACK_LIBRARY_DIR UMFPACK_INCLUDE_DIR +AMD_LIBRARY_DIR AMD_INCLUDE_DIR +Or set the relevant variables by hand in ccmake. + +Alternatively you may choose to compile the bundled contrib libraries +by setting DEAL_II_ALLOW_CONTRIB=on or DEAL_II_FORCE_CONTRIB_UMFPACK=on. -ENDIF() +") +ENDMACRO() -SET(HAVE_LIBBLAS TRUE) -SET(HAVE_LIBLAPACK TRUE) -SET(HAVE_LIBUMFPACK TRUE) +CONFIGURE_FEATURE(UMFPACK) diff --git a/deal.II/contrib/cmake/configure/configure_zlib.cmake b/deal.II/contrib/cmake/configure/configure_zlib.cmake index e878e7208f..ef98798230 100644 --- a/deal.II/contrib/cmake/configure/configure_zlib.cmake +++ b/deal.II/contrib/cmake/configure/configure_zlib.cmake @@ -1,9 +1,39 @@ -FIND_PACKAGE(Netcdf REQUIRED) +# +# Configuration for the zlib library: +# -FIND_PACKAGE(ZLIB REQUIRED) +MACRO(FIND_FEATURE_ZLIB_EXTERNAL var) -INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS}) + FIND_PACKAGE(ZLIB) -LIST(APPEND deal_ii_external_libraries ${ZLIB_LIBRARIES}) + IF(ZLIB_FOUND) + SET(${var} TRUE) + ENDIF() -SET(HAVE_LIBZ TRUE) +ENDMACRO() + + +MACRO(CONFIGURE_FEATURE_ZLIB_EXTERNAL var) + + INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS}) + LIST(APPEND deal_ii_external_libraries ${ZLIB_LIBRARIES}) + SET(HAVE_LIBZ TRUE) + + SET(${var} TRUE) + +ENDMACRO() + + +MACRO(CONFIGURE_FEATURE_ZLIB_ERROR_MESSAGE) + MESSAGE(SEND_ERROR " +Could not find the zlib library! + +Please ensure that the zlib library is installed on your computer. +If the library is not at a default location, either provide some hints +for the autodetection, or set the relevant variables by hand in ccmake. + +") +ENDMACRO() + + +CONFIGURE_FEATURE(ZLIB) diff --git a/deal.II/contrib/cmake/macros/macro_configure_feature.cmake b/deal.II/contrib/cmake/macros/macro_configure_feature.cmake new file mode 100644 index 0000000000..517921808a --- /dev/null +++ b/deal.II/contrib/cmake/macros/macro_configure_feature.cmake @@ -0,0 +1,158 @@ +# +# This macro is used in the feature configuration mechanism of deal.II +# +# Usage: +# +# CONFIGURE_FEATURE(feature_name) +# +# This macro assumes the following macros and variables to be defined: +# +# +# HAVE_CONTRIB_FEATURE_${feature_name} +# +# - which is either set to TRUE if all necessary libraries of the +# features comes bundled with deal.II and hence can be supported +# without external dependencies +# +# CONFIGURE_FEATURE_${feature_name}_CONTRIB(var) +# +# - which shall setup all necessary configuration for the feature with +# contrib source dependencies. var set to TRUE shall indicate success. +# +# +# FIND_FEATURE_${feature_name}_EXTERNAL(var) +# +# - which shall set var to TRUE if all dependencies for the feature are +# fullfilled. In this case all necessary variables for +# CONFIGURE_FEATURE_${feature_name}_EXTERNAL shall be set. Otherwise +# var should remain unset. +# +# CONFIGURE_FEATURE_${feature_name}_EXTERNAL(var) +# +# - which shall setup all necessary configuration for the feature with +# external dependencies. var set to TRUE shall indicate success. +# +# CONFIGURE_FEATURE_${feature_name}_ERROR_MESSAGE() +# +# - which shall print a meaningfull error message if case no external +# library is found (and contrib is not allowed to be used.) +# +# + +# +# FAT NOTE: +# This script is arcane black magic. But at least for the better good: We +# don't have to copy the configuration logic to every single +# configure_.cmake script. +# + + +# 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}") + INCLUDE("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/macro_configure_feature.tmp") +ENDMACRO() + + +MACRO(CONFIGURE_FEATURE feature) + + # + # 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() + + ELSE() + + # + # Second case: We may search for an external library: + # + 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(FEATURE_${feature}_EXTERNAL_CONFIGURED) + MESSAGE(STATUS + "DEAL_II_WITH_${feature} successfully set up with external dependencies." + ) + ELSE() + MESSAGE(SEND_ERROR + "Failed to set up DEAL_II_WITH_${feature} with external dependencies." + ) + ENDIF() + + ELSE() + + 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." + ) + ELSE() + # TODO: Opt out! + MESSAGE(SEND_ERROR + "Failed to set up DEAL_II_WITH_${feature} with contrib packages." + ) + RUN_COMMAND( + "CONFIGURE_FEATURE_${feature}_ERROR_MESSAGE()" + ) + ENDIF() + ELSE() + # TODO: Opt out! + RUN_COMMAND( + "CONFIGURE_FEATURE_${feature}_ERROR_MESSAGE()" + ) + ENDIF() + + ENDIF() + + ENDIF() +ENDMACRO() diff --git a/deal.II/contrib/cmake/macros/macro_list_contains.cmake b/deal.II/contrib/cmake/macros/macro_list_contains.cmake new file mode 100644 index 0000000000..283e664b0e --- /dev/null +++ b/deal.II/contrib/cmake/macros/macro_list_contains.cmake @@ -0,0 +1,9 @@ +# grml... +MACRO(LIST_CONTAINS var value) + SET(${var}) + FOREACH (value2 ${ARGN}) + IF (${value} STREQUAL ${value2}) + SET(${var} TRUE) + ENDIF (${value} STREQUAL ${value2}) + ENDFOREACH (value2) +ENDMACRO(LIST_CONTAINS) diff --git a/deal.II/contrib/cmake/macros/macro_message_not_found.cmake b/deal.II/contrib/cmake/macros/macro_message_not_found.cmake index 6bfe11e41f..fa9470e914 100644 --- a/deal.II/contrib/cmake/macros/macro_message_not_found.cmake +++ b/deal.II/contrib/cmake/macros/macro_message_not_found.cmake @@ -1,10 +1,63 @@ -MACRO(macro_message_not_found library) - # TODO: Check for each Find<...> module how to hint for a library - # location... +FUNCTION(macro_message_not_found library library_uppercase) - STRING(TOUPPER "${library}" library_uppercase) + # We have contrib source and our own Find<...> module: + SET(contrib_and_find amd tbb umfpack) - MESSAGE(SEND_ERROR " + # We have contrib source and use an external Find<...> module: + SET(contrib boost) + + # We use our own Find<...> module: + SET(find_module netcdf) + + + IF(library_uppercase MATCHES AMD) + SET(library_contrib UMFPACK) + ELSE() + SET(library_contrib ${library_uppercase}) + ENDIF() + + + LIST_CONTAINS(result library ${contrib_and_find}) + IF(result) + MESSAGE(SEND_ERROR " +Could not find the ${library} library! + +Please ensure that the ${library} library is installed on your computer. +If the library is not at a default location, either provide some hints +via environment variables: +${library_uppercase}_LIBRARY_DIR ${library_uppercase}_INCLUDE_DIR +Or set the relevant variables by hand in ccmake. + +Alternatively you may choose to compile the bundled contrib library of +${library} by setting DEAL_II_ALLOW_CONTRIB=on or +DEAL_II_FORCE_CONTRIB_${library_contrib}=on. + +") + RETURN() + ENDIF() + + + LIST_CONTAINS(result library ${contrib}) + IF(result) + MESSAGE(SEND_ERROR " +Could not find the ${library} library! + +Please ensure that the ${library} library is installed on your computer. +If the library is not at a default location, either provide some hints +for the autodetection, or set the relevant variables by hand in ccmake. + +Alternatively you may choose to compile the bundled contrib library of +${library} by setting DEAL_II_ALLOW_CONTRIB=on or +DEAL_II_FORCE_CONTRIB_${library_contrib}=on. + +") + RETURN() + ENDIF() + + + LIST_CONTAINS(result library ${find_module}) + IF(result) + MESSAGE(SEND_ERROR " Could not find the ${library} library! Please ensure that the ${library} library is installed on your computer. @@ -13,6 +66,18 @@ via environment variables: ${library_uppercase}_LIBRARY_DIR ${library_uppercase}_INCLUDE_DIR Or set the relevant variables by hand in ccmake. +") + RETURN() + ENDIF() + + + MESSAGE(SEND_ERROR " +Could not find the ${library} library! + +Please ensure that the ${library} library is installed on your computer. +If the library is not at a default location, either provide some hints +for the autodetection, or set the relevant variables by hand in ccmake. + ") -ENDMACRO() +ENDFUNCTION() -- 2.39.5