From 31087241aedc6de7ec9ef3d872fa089dfdaccd04 Mon Sep 17 00:00:00 2001 From: maier Date: Mon, 24 Sep 2012 12:22:00 +0000 Subject: [PATCH] Finalize the external library hinting and write some documentation git-svn-id: https://svn.dealii.org/branches/branch_cmake@26656 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/README_CMAKE | 46 ++++ deal.II/cmake/features.m4 | 309 ----------------------- deal.II/cmake/modules/FindAMD.cmake | 10 + deal.II/cmake/modules/FindMETIS.cmake | 6 + deal.II/cmake/modules/FindP4EST.cmake | 16 +- deal.II/cmake/modules/FindPETSC.cmake | 32 +++ deal.II/cmake/modules/FindSC.cmake | 22 +- deal.II/cmake/modules/FindTRILINOS.cmake | 13 +- deal.II/cmake/modules/FindUMFPACK.cmake | 7 + deal.II/cmake/petsc.m4 | 258 +++++++++++++++++++ 10 files changed, 400 insertions(+), 319 deletions(-) create mode 100644 deal.II/cmake/modules/FindPETSC.cmake create mode 100644 deal.II/cmake/petsc.m4 diff --git a/deal.II/README_CMAKE b/deal.II/README_CMAKE index b3be990d38..7d5a57178a 100644 --- a/deal.II/README_CMAKE +++ b/deal.II/README_CMAKE @@ -28,6 +28,8 @@ TABLE OF CONTENTS Feature configuration + External library locations + Component selection Build configuration @@ -225,6 +227,50 @@ CONFIGURATION separately. + External library locations + ========================== + + External libraries will be searched depending on hints in the following + order: + + 1.) Paths specified via CMAKE_PREFIX_PATH take precedence, e.g. with + + $ cmake -DCMAKE_PREFIX_PATH=~/workspace/local ../deal.II + + libraries from ~/workspace/local will be preferred for dependency + resolution. + + 2.) Hints given by _DIR via command line or environment for + _some_ libraries: + + $ cmake -DP4EST_DIR=~/workspace/p4est-install/ ../deal.II + or + $ export P4EST_DIR=~/workspace/p4est-install/ + $ cmake ../deal.II + where -D_DIR takes precedence over environment. + + Currently, the following variables will be considered: + + METIS_DIR, + P4EST_DIR, + PETSC_DIR (and SC_DIR), + TRILINOS_DIR, + UMFPACK_DIR (and AMD_DIR) + + + Alternatively, cached variables set by the Find mechanism may be + set, hinted or overwritten directly! + + These variables are usually called _INCLUDE_DIR(S) and + _(LIBRARY|LIBRARIES) (highly dependend of the actual library...). + + You can get a list via + + $ ccmake ../deal.II + + and entering advanced configuration mode by pressing [t]. + Variables that could not be determined are suffixed with -NOTFOUND and + may be set by hand. Component selection diff --git a/deal.II/cmake/features.m4 b/deal.II/cmake/features.m4 index cd37735968..02e0474e23 100644 --- a/deal.II/cmake/features.m4 +++ b/deal.II/cmake/features.m4 @@ -70,315 +70,6 @@ AC_DEFUN(DEAL_II_CONFIGURE_TECPLOT, dnl -dnl ------------------------------------------------------------ -dnl Check whether PETSc is installed, and if so store the -dnl respective links -dnl -dnl Usage: DEAL_II_CONFIGURE_PETSC -dnl -dnl ------------------------------------------------------------ -AC_DEFUN(DEAL_II_CONFIGURE_PETSC, dnl -[ - dnl First check for the PETSc directory - AC_MSG_CHECKING([for PETSc library directory]) - - AC_ARG_WITH(petsc, - [AS_HELP_STRING([--with-petsc=path/to/petsc], - [Specify the path to the PETSc installation, of which the include and library directories are subdirs; use this if you want to override the PETSC_DIR environment variable.])], - [ - dnl Special case when someone does --with-petsc=no - if test "x$withval" = "xno" ; then - AC_MSG_RESULT([explicitly disabled]) - USE_CONTRIB_PETSC=no - else - USE_CONTRIB_PETSC=yes - DEAL_II_PETSC_DIR="$withval" - AC_MSG_RESULT($DEAL_II_PETSC_DIR) - - dnl Make sure that what was specified is actually correct - if test ! -d $DEAL_II_PETSC_DIR/include \ - ; then - AC_MSG_ERROR([Path to PETSc specified with --with-petsc does not point to a complete PETSc installation]) - fi - fi - ], - [ - dnl Take something from the environment variables, if it is there - if test "x$PETSC_DIR" != "x" ; then - USE_CONTRIB_PETSC=yes - DEAL_II_PETSC_DIR="$PETSC_DIR" - AC_MSG_RESULT($DEAL_II_PETSC_DIR) - - dnl Make sure that what this is actually correct - if test ! -d $DEAL_II_PETSC_DIR/include \ - ; then - AC_MSG_ERROR([The path to PETSc specified in the PETSC_DIR environment variable does not point to a complete PETSc installation]) - fi - else - USE_CONTRIB_PETSC=no - DEAL_II_PETSC_DIR="" - AC_MSG_RESULT([not found]) - fi - ]) - if test "$USE_CONTRIB_PETSC" = "yes" ; then - AC_DEFINE([DEAL_II_USE_PETSC], [1], - [Defined if a PETSc installation was found and is going to be used]) - - dnl Set an additional variable (not via AC_DEFINE, since we don't want - dnl to have it in config.h) which we can use in doc/doxygen/options.dox.in. - dnl If we have PETSc, then the value of this variable expands to - dnl defining the string "DEAL_II_USE_PETSC" for the preprocessor. If - dnl we don't have no PETSc, then it does not define this string. - DEAL_II_DEFINE_DEAL_II_USE_PETSC=DEAL_II_USE_PETSC - - dnl Also work around a stupidity in PETSc that makes sure it interferes in - dnl a completely obnoxious way with boost. - AC_DEFINE([PETSC_SKIP_UNDERSCORE_CHKERR], [1], - [Make sure PETSc doesn't re-define the underscore through the preprocessor, since this interferes with boost. PETSc redefines the underscore to be "__gterr =", but then forgets to undef this thing. Boost simply wants to concatenate the underscore with another string to form a class name, which then of course isn't valid any more. See mails in early Feb 2006.]) - fi - - dnl If we have found PETSc, determine additional pieces of data - if test "$USE_CONTRIB_PETSC" = "yes" ; then - DEAL_II_CONFIGURE_PETSC_VERSION - DEAL_II_CONFIGURE_PETSC_ARCH - - DEAL_II_CONFIGURE_PETSC_MPIUNI_LIB - DEAL_II_CHECK_PETSC_MPI_CONSISTENCY - DEAL_II_CONFIGURE_PETSC_COMPLEX - - DEAL_II_EXPAND_PETSC_VECTOR="PETScWrappers::Vector" - DEAL_II_EXPAND_PETSC_MPI_VECTOR="PETScWrappers::MPI::Vector" - DEAL_II_EXPAND_PETSC_BLOCKVECTOR="PETScWrappers::BlockVector" - DEAL_II_EXPAND_PETSC_MPI_BLOCKVECTOR="PETScWrappers::MPI::BlockVector" - - dnl Finally set with_petsc if this hasn't happened yet - if test "x$with_petsc" = "x" ; then - with_petsc="yes" - fi - fi - - dnl Make sure that the right values for PETSC vectors are written - dnl into common/template-arguments.in - AC_SUBST(DEAL_II_EXPAND_PETSC_VECTOR) - AC_SUBST(DEAL_II_EXPAND_PETSC_MPI_VECTOR) - AC_SUBST(DEAL_II_EXPAND_PETSC_BLOCKVECTOR) - AC_SUBST(DEAL_II_EXPAND_PETSC_MPI_BLOCKVECTOR) -]) - - - -dnl ------------------------------------------------------------ -dnl Figure out the architecture used for PETSc, since that -dnl determines where object and configuration files will be found. -dnl -dnl Usage: DEAL_II_CONFIGURE_PETSC_ARCH -dnl -dnl ------------------------------------------------------------ -AC_DEFUN(DEAL_II_CONFIGURE_PETSC_ARCH, dnl -[ - AC_MSG_CHECKING([for PETSc library architecture]) - - AC_ARG_WITH(petsc-arch, - [AS_HELP_STRING([--with-petsc-arch=architecture], - [Specify the architecture for your PETSc installation; use this if you want to override the PETSC_ARCH environment variable.])], - [DEAL_II_PETSC_ARCH="$withval" - AC_MSG_RESULT($DEAL_II_PETSC_ARCH) - ], - [dnl Take something from the environment variables - if test "x$PETSC_ARCH" != "x" ; then - DEAL_II_PETSC_ARCH="$PETSC_ARCH" - AC_MSG_RESULT($DEAL_II_PETSC_ARCH) - else - AC_MSG_ERROR([If PETSc is used, you must specify the architecture either through the PETSC_ARCH environment variable, or through the --with-petsc-arch flag]) - fi - ]) - - if test "x$PETSC_ARCH" != "x" ; then - - dnl PETSc change the locations where they store their libraries - dnl from time-to-time; so make sure that what was specified is - dnl actually correct. - case "${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}" in - 3.*) dnl - if test ! -d $DEAL_II_PETSC_DIR/$DEAL_II_PETSC_ARCH/lib \ - ; then - AC_MSG_ERROR([PETSc has not been compiled for the architecture specified with --with-petsc-arch]) - fi - ;; - *) dnl - AC_MSG_ERROR([Unknown PETSc version ${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}]) - ;; - esac - fi -]) - - - -dnl ------------------------------------------------------------ -dnl Figure out the version numbers of PETSc. This is unfortunately -dnl necessary since PETSc has a habit to change function signatures, -dnl library names, etc, in random ways between versions... -dnl -dnl Usage: DEAL_II_CONFIGURE_PETSC_VERSION -dnl -dnl ------------------------------------------------------------ -AC_DEFUN(DEAL_II_CONFIGURE_PETSC_VERSION, dnl -[ - AC_MSG_CHECKING([for PETSc version]) - DEAL_II_PETSC_VERSION_MAJOR=`cat $DEAL_II_PETSC_DIR/include/petscversion.h \ - | grep "#define PETSC_VERSION_MAJOR" \ - | perl -pi -e 's/.*MAJOR\s+//g;'` - DEAL_II_PETSC_VERSION_MINOR=`cat $DEAL_II_PETSC_DIR/include/petscversion.h \ - | grep "#define PETSC_VERSION_MINOR" \ - | perl -pi -e 's/.*MINOR\s+//g;'` - DEAL_II_PETSC_VERSION_SUBMINOR=`cat $DEAL_II_PETSC_DIR/include/petscversion.h \ - | grep "#define PETSC_VERSION_SUBMINOR" \ - | perl -pi -e 's/.*MINOR\s+//g;'` - PETSC_VERSION="$DEAL_II_PETSC_VERSION_MAJOR.$DEAL_II_PETSC_VERSION_MINOR.$DEAL_II_PETSC_VERSION_SUBMINOR" - - dnl Here is where we check if the PETSc version we have is a - dnl release but do nothing about it. - PETSC_RELEASE=`cat $DEAL_II_PETSC_DIR/include/petscversion.h \ - | grep "#define PETSC_VERSION_RELEASE" \ - | perl -pi -e 's/.*RELEASE\s+//g;'` - if test "$PETSC_RELEASE" = "0" ; then - PETSC_VERSION+="-dev" - DEAL_II_PETSC_VERSION_DEV=yes - AC_DEFINE([DEAL_II_USE_PETSC_DEV], [1], - [Defined if a PETSc installation was found and is not a release]) - else - DEAL_II_PETSC_VERSION_DEV=no - fi - - AC_MSG_RESULT($PETSC_VERSION) -]) - - -dnl ------------------------------------------------------------- -dnl Make sure that if PETSc and deal.II were built with the same -dnl MPI enabled (or disabled) functionality. -dnl -dnl Usage: DEAL_II_CHECK_PETSC_MPI_CONSISTENCY -dnl -dnl ------------------------------------------------------------- -AC_DEFUN(DEAL_II_CHECK_PETSC_MPI_CONSISTENCY, dnl -[ - dnl Then check for MPI consistency. - AC_MSG_CHECKING(for consistency of PETSc and deal.II MPI settings) - - if test "x$DEAL_II_USE_MPI" = "xyes" ; then - - dnl So we support MPI. Check that our PETSc installation does - dnl too. PETSc sets the variable PETSC_HAVE_MPIUNI to 1 in case - dnl he *does not* support MPI, so just read out that information. - dnl - dnl Like always, we have to cake care of version control! - case "${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}" in - 3.*) dnl - AC_TRY_COMPILE( - [#include "$DEAL_II_PETSC_DIR/$DEAL_II_PETSC_ARCH/include/petscconf.h" - ], - [#ifdef PETSC_HAVE_MPIUNI - compile error; - #endif - ], - [AC_MSG_RESULT(yes)], - [AC_MSG_ERROR([PETSc was not built for MPI, but deal.II is!] - )]) - ;; - *) dnl - AC_MSG_ERROR([Unknown PETSc version ${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}]) - ;; - esac - else - case "${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}" in - 3.*) dnl - AC_TRY_COMPILE( - [#include "$DEAL_II_PETSC_DIR/$DEAL_II_PETSC_ARCH/include/petscconf.h" - ], - [#ifndef PETSC_HAVE_MPIUNI - compile error; - #endif], - [AC_MSG_RESULT(yes)], - [AC_MSG_ERROR([PETSc was built for MPI, but deal.II is not!]) - ]) - ;; - *) dnl - AC_MSG_ERROR([Unknown PETSc version ${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}]) - ;; - esac - fi -]) - - -dnl ------------------------------------------------------------ -dnl See if there is a library libmpiuni.a/so available. We need -dnl to link with it on some systems where PETSc is built without -dnl a real MPI and we need to handle trivial (one process) MPI -dnl functionality. -dnl -dnl Usage: DEAL_II_CONFIGURE_PETSC_MPIUNI_LIB -dnl -dnl ------------------------------------------------------------ -AC_DEFUN(DEAL_II_CONFIGURE_PETSC_MPIUNI_LIB, dnl -[ - AC_MSG_CHECKING([for PETSc libmpiuni library]) - case "${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}" in - 3.*) dnl - if test -f $DEAL_II_PETSC_DIR/$DEAL_II_PETSC_ARCH/lib/libmpiuni.a ; then - DEAL_II_PETSC_MPIUNI_LIB="$DEAL_II_PETSC_DIR/$DEAL_II_PETSC_ARCH/lib/libmpiuni.a" - fi - ;; - *) dnl - AC_MSG_ERROR([Unknown PETSc version ${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}]) - ;; - esac - - if test "$DEAL_II_PETSC_MPIUNI_LIB" = "" ; then - AC_MSG_RESULT([not found]) - else - AC_MSG_RESULT($DEAL_II_PETSC_MPIUNI_LIB) - fi -]) - - -dnl ------------------------------------------------------------ -dnl Figure out PETSc was compiled with --scalar-type=complex by -dnl scanning PETSc configuration file. -dnl -dnl Warning: Up tp now, PETSc>3.0.0 is being supported and -dnl deal.II will not safely compile if this option is "yes". -dnl -dnl Usage: DEAL_II_CONFIGURE_PETSC_COMPLEX -dnl -dnl ------------------------------------------------------------ -AC_DEFUN(DEAL_II_CONFIGURE_PETSC_COMPLEX, dnl -[ - case "${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}" in - 3.3*) - AC_MSG_CHECKING([for PETSc scalar complex]) - DEAL_II_PETSC_COMPLEX=`cat $DEAL_II_PETSC_DIR/$DEAL_II_PETSC_ARCH/include/petscconf.h \ - | grep "#define PETSC_USE_COMPLEX" \ - | perl -pi -e 's/.*COMPLEX\s+//g;'` - if test "$DEAL_II_PETSC_COMPLEX" = "1" ; then - AC_MSG_RESULT(yes) - else - AC_MSG_RESULT(no) - fi - - dnl If we have previously found PETSc and here with a complex - dnl scalar type then set the DEAL_II_USE_COMPLEX macro - if test "$USE_CONTRIB_PETSC" = "yes" ; then - if test "$DEAL_II_PETSC_COMPLEX" = "1" ; then - AC_DEFINE([DEAL_II_USE_PETSC_COMPLEX], [1], - [Defined if a PETSc installation was found with complex scalar type and is going to be used]) - fi fi - ;; - esac -]) - - - dnl ------------------------------------------------------------ dnl Check whether SLEPc is installed, and if so store the dnl respective links. diff --git a/deal.II/cmake/modules/FindAMD.cmake b/deal.II/cmake/modules/FindAMD.cmake index 57a7f191d9..b084d2f8d8 100644 --- a/deal.II/cmake/modules/FindAMD.cmake +++ b/deal.II/cmake/modules/FindAMD.cmake @@ -5,10 +5,20 @@ INCLUDE(FindPackageHandleStandardArgs) FIND_PATH(AMD_INCLUDE_DIR amd.h + HINTS + ${AMD_DIR}/include + $ENV{AMD_DIR}/include + ${UMFPACK_DIR}/include + $ENV{UMFPACK_DIR}/include ) FIND_LIBRARY(AMD_LIBRARY NAMES amd + HINTS + ${AMD_DIR} + $ENV{AMD_DIR} + ${UMFPACK_DIR} + $ENV{UMFPACK_DIR} PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib ) diff --git a/deal.II/cmake/modules/FindMETIS.cmake b/deal.II/cmake/modules/FindMETIS.cmake index ac25f0c713..ba7357566f 100644 --- a/deal.II/cmake/modules/FindMETIS.cmake +++ b/deal.II/cmake/modules/FindMETIS.cmake @@ -5,11 +5,17 @@ INCLUDE(FindPackageHandleStandardArgs) FIND_PATH(METIS_INCLUDE_DIR metis.h + HINTS + ${METIS_DIR}/include + $ENV{METIS_DIR}/include PATH_SUFFIXES metis ) FIND_LIBRARY(METIS_LIBRARY NAMES metis + HINTS + ${METIS_DIR} + $ENV{METIS_DIR} PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib ) diff --git a/deal.II/cmake/modules/FindP4EST.cmake b/deal.II/cmake/modules/FindP4EST.cmake index 8642303013..c09d32ad3b 100644 --- a/deal.II/cmake/modules/FindP4EST.cmake +++ b/deal.II/cmake/modules/FindP4EST.cmake @@ -4,17 +4,27 @@ INCLUDE(FindPackageHandleStandardArgs) -FIND_PATH(P4EST_INCLUDE_DIR p4est.h) +FIND_PATH(P4EST_INCLUDE_DIR p4est.h + HINTS + ${P4EST_DIR}/include + $ENV{P4EST_DIR}/include + ) FIND_LIBRARY(P4EST_LIBRARY NAMES p4est + HINTS + ${P4EST_DIR} + $ENV{P4EST_DIR} PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib -) + ) FIND_LIBRARY(P4EST_DEBUG_LIBRARY NAMES p4est_debug p4est.g + HINTS + ${P4EST_DIR} + $ENV{P4EST_DIR} PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib -) + ) FIND_PACKAGE_HANDLE_STANDARD_ARGS(P4EST DEFAULT_MSG P4EST_LIBRARY P4EST_INCLUDE_DIR) FIND_PACKAGE_HANDLE_STANDARD_ARGS(P4EST_DEBUG DEFAULT_MSG P4EST_DEBUG_LIBRARY P4EST_INCLUDE_DIR) diff --git a/deal.II/cmake/modules/FindPETSC.cmake b/deal.II/cmake/modules/FindPETSC.cmake new file mode 100644 index 0000000000..97e7da4748 --- /dev/null +++ b/deal.II/cmake/modules/FindPETSC.cmake @@ -0,0 +1,32 @@ +# +# Try to find the petsc library +# + +INCLUDE(FindPackageHandleStandardArgs) + +FIND_PATH(PETSC_INCLUDE_DIR petscconf.h + HINTS + # petsc is special. Account for that + ${PETSC_DIR}/${PETSC_ARCH}/include + $ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/include + PATH_SUFFIXES petsc +) + +FIND_LIBRARY(PETSC_LIBRARY + NAMES petsc + HINTS + # petsc is special. Account for that + ${PETSC_DIR}/${PETSC_ARCH} + $ENV{PETSC_DIR}/$ENV{PETSC_ARCH} + PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib +) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PETSC DEFAULT_MSG PETSC_LIBRARY PETSC_INCLUDE_DIR) + +IF(PETSC_FOUND) + MARK_AS_ADVANCED( + PETSC_LIBRARY + PETSC_INCLUDE_DIR + ) +ENDIF() + diff --git a/deal.II/cmake/modules/FindSC.cmake b/deal.II/cmake/modules/FindSC.cmake index 3d93f92243..3335349879 100644 --- a/deal.II/cmake/modules/FindSC.cmake +++ b/deal.II/cmake/modules/FindSC.cmake @@ -2,18 +2,34 @@ INCLUDE(FindPackageHandleStandardArgs) -FIND_PATH(SC_INCLUDE_DIR sc.h) +FIND_PATH(SC_INCLUDE_DIR sc.h + HINTS + ${SC_DIR}/include + $ENV{SC_DIR}/include + ${P4EST_DIR}/include + $ENV{P4EST_DIR}/include + ) FIND_LIBRARY(SC_LIBRARY NAMES sc + HINTS + ${SC_DIR} + $ENV{SC_DIR} + ${P4EST_DIR} + $ENV{P4EST_DIR} PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib -) + ) FIND_LIBRARY(SC_DEBUG_LIBRARY NAMES sc_debug sc.g + HINTS + ${SC_DIR} + $ENV{SC_DIR} + ${P4EST_DIR} + $ENV{P4EST_DIR} PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib -) + ) FIND_PACKAGE_HANDLE_STANDARD_ARGS(SC DEFAULT_MSG SC_LIBRARY SC_INCLUDE_DIR) FIND_PACKAGE_HANDLE_STANDARD_ARGS(SC_DEBUG DEFAULT_MSG SC_DEBUG_LIBRARY SC_INCLUDE_DIR) diff --git a/deal.II/cmake/modules/FindTRILINOS.cmake b/deal.II/cmake/modules/FindTRILINOS.cmake index 20dc792500..325d6e1c5e 100644 --- a/deal.II/cmake/modules/FindTRILINOS.cmake +++ b/deal.II/cmake/modules/FindTRILINOS.cmake @@ -10,8 +10,13 @@ INCLUDE(FindPackageHandleStandardArgs) find_package(TRILINOS QUIET CONFIG NAMES Trilinos TRILINOS - HINTS ${TRILINOS_DIR} - PATH_PREFIXES lib64/cmake/Trilinos lib/cmake/Trilinos + HINTS + ${TRILINOS_DIR} + $ENV{TRILINOS_DIR} + PATH_SUFFIXES + lib${LIB_SUFFIX}/cmake/Trilinos + lib64/cmake/Trilinos + lib/cmake/Trilinos ) # @@ -37,9 +42,9 @@ SET(TRILINOS_INCLUDE_DIRS ${Trilinos_INCLUDE_DIRS}) # exports a list with short names... # So we check again for every lib and store the full path: # -FOREACH(macro_library ${Trilinos_LIBRARIES}) +FOREACH(library ${Trilinos_LIBRARIES}) FIND_LIBRARY(TRILINOS_LIBRARY_${macro_library} - NAMES ${macro_library} + NAMES ${library} HINTS ${Trilinos_LIBRARY_DIRS} ) MARK_AS_ADVANCED(TRILINOS_LIBRARY_${macro_library}) diff --git a/deal.II/cmake/modules/FindUMFPACK.cmake b/deal.II/cmake/modules/FindUMFPACK.cmake index da92c6462d..efc2a706c0 100644 --- a/deal.II/cmake/modules/FindUMFPACK.cmake +++ b/deal.II/cmake/modules/FindUMFPACK.cmake @@ -5,10 +5,17 @@ INCLUDE(FindPackageHandleStandardArgs) FIND_PATH(UMFPACK_INCLUDE_DIR umfpack.h + HINTS + ${UMFPACK_DIR}/include + $ENV{UMFPACK_DIR}/include + PATH_SUFFIXES umfpack ) FIND_LIBRARY(UMFPACK_LIBRARY NAMES umfpack + HINTS + ${UMFPACK_DIR} + $ENV{UMFPACK_DIR} PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib ) diff --git a/deal.II/cmake/petsc.m4 b/deal.II/cmake/petsc.m4 new file mode 100644 index 0000000000..e9be2b4df3 --- /dev/null +++ b/deal.II/cmake/petsc.m4 @@ -0,0 +1,258 @@ + + dnl Set an additional variable (not via AC_DEFINE, since we don't want + dnl to have it in config.h) which we can use in doc/doxygen/options.dox.in. + dnl If we have PETSc, then the value of this variable expands to + dnl defining the string "DEAL_II_USE_PETSC" for the preprocessor. If + dnl we don't have no PETSc, then it does not define this string. + DEAL_II_DEFINE_DEAL_II_USE_PETSC=DEAL_II_USE_PETSC + + + + dnl Also work around a stupidity in PETSc that makes sure it interferes in + dnl a completely obnoxious way with boost. + AC_DEFINE([PETSC_SKIP_UNDERSCORE_CHKERR], [1], + [Make sure PETSc doesn't re-define the underscore through the preprocessor, since this interferes with boost. PETSc redefines the underscore to be "__gterr =", but then forgets to undef this thing. Boost simply wants to concatenate the underscore with another string to form a class name, which then of course isn't valid any more. See mails in early Feb 2006.]) + fi + + + + dnl If we have found PETSc, determine additional pieces of data + if test "$USE_CONTRIB_PETSC" = "yes" ; then + DEAL_II_CONFIGURE_PETSC_VERSION + DEAL_II_CONFIGURE_PETSC_ARCH + + DEAL_II_CONFIGURE_PETSC_MPIUNI_LIB + DEAL_II_CHECK_PETSC_MPI_CONSISTENCY + DEAL_II_CONFIGURE_PETSC_COMPLEX + + DEAL_II_EXPAND_PETSC_VECTOR="PETScWrappers::Vector" + DEAL_II_EXPAND_PETSC_MPI_VECTOR="PETScWrappers::MPI::Vector" + DEAL_II_EXPAND_PETSC_BLOCKVECTOR="PETScWrappers::BlockVector" + DEAL_II_EXPAND_PETSC_MPI_BLOCKVECTOR="PETScWrappers::MPI::BlockVector" + + dnl Finally set with_petsc if this hasn't happened yet + if test "x$with_petsc" = "x" ; then + with_petsc="yes" + fi + fi + + dnl Make sure that the right values for PETSC vectors are written + dnl into common/template-arguments.in + AC_SUBST(DEAL_II_EXPAND_PETSC_VECTOR) + AC_SUBST(DEAL_II_EXPAND_PETSC_MPI_VECTOR) + AC_SUBST(DEAL_II_EXPAND_PETSC_BLOCKVECTOR) + AC_SUBST(DEAL_II_EXPAND_PETSC_MPI_BLOCKVECTOR) +]) + + + +dnl ------------------------------------------------------------ +dnl Figure out the architecture used for PETSc, since that +dnl determines where object and configuration files will be found. +dnl +dnl Usage: DEAL_II_CONFIGURE_PETSC_ARCH +dnl +dnl ------------------------------------------------------------ +AC_DEFUN(DEAL_II_CONFIGURE_PETSC_ARCH, dnl +[ + AC_MSG_CHECKING([for PETSc library architecture]) + + AC_ARG_WITH(petsc-arch, + [AS_HELP_STRING([--with-petsc-arch=architecture], + [Specify the architecture for your PETSc installation; use this if you want to override the PETSC_ARCH environment variable.])], + [DEAL_II_PETSC_ARCH="$withval" + AC_MSG_RESULT($DEAL_II_PETSC_ARCH) + ], + [dnl Take something from the environment variables + if test "x$PETSC_ARCH" != "x" ; then + DEAL_II_PETSC_ARCH="$PETSC_ARCH" + AC_MSG_RESULT($DEAL_II_PETSC_ARCH) + else + AC_MSG_ERROR([If PETSc is used, you must specify the architecture either through the PETSC_ARCH environment variable, or through the --with-petsc-arch flag]) + fi + ]) + + if test "x$PETSC_ARCH" != "x" ; then + + dnl PETSc change the locations where they store their libraries + dnl from time-to-time; so make sure that what was specified is + dnl actually correct. + case "${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}" in + 3.*) dnl + if test ! -d $DEAL_II_PETSC_DIR/$DEAL_II_PETSC_ARCH/lib \ + ; then + AC_MSG_ERROR([PETSc has not been compiled for the architecture specified with --with-petsc-arch]) + fi + ;; + *) dnl + AC_MSG_ERROR([Unknown PETSc version ${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}]) + ;; + esac + fi +]) + + + +dnl ------------------------------------------------------------ +dnl Figure out the version numbers of PETSc. This is unfortunately +dnl necessary since PETSc has a habit to change function signatures, +dnl library names, etc, in random ways between versions... +dnl +dnl Usage: DEAL_II_CONFIGURE_PETSC_VERSION +dnl +dnl ------------------------------------------------------------ +AC_DEFUN(DEAL_II_CONFIGURE_PETSC_VERSION, dnl +[ + AC_MSG_CHECKING([for PETSc version]) + DEAL_II_PETSC_VERSION_MAJOR=`cat $DEAL_II_PETSC_DIR/include/petscversion.h \ + | grep "#define PETSC_VERSION_MAJOR" \ + | perl -pi -e 's/.*MAJOR\s+//g;'` + DEAL_II_PETSC_VERSION_MINOR=`cat $DEAL_II_PETSC_DIR/include/petscversion.h \ + | grep "#define PETSC_VERSION_MINOR" \ + | perl -pi -e 's/.*MINOR\s+//g;'` + DEAL_II_PETSC_VERSION_SUBMINOR=`cat $DEAL_II_PETSC_DIR/include/petscversion.h \ + | grep "#define PETSC_VERSION_SUBMINOR" \ + | perl -pi -e 's/.*MINOR\s+//g;'` + PETSC_VERSION="$DEAL_II_PETSC_VERSION_MAJOR.$DEAL_II_PETSC_VERSION_MINOR.$DEAL_II_PETSC_VERSION_SUBMINOR" + + dnl Here is where we check if the PETSc version we have is a + dnl release but do nothing about it. + PETSC_RELEASE=`cat $DEAL_II_PETSC_DIR/include/petscversion.h \ + | grep "#define PETSC_VERSION_RELEASE" \ + | perl -pi -e 's/.*RELEASE\s+//g;'` + if test "$PETSC_RELEASE" = "0" ; then + PETSC_VERSION+="-dev" + DEAL_II_PETSC_VERSION_DEV=yes + AC_DEFINE([DEAL_II_USE_PETSC_DEV], [1], + [Defined if a PETSc installation was found and is not a release]) + else + DEAL_II_PETSC_VERSION_DEV=no + fi + + AC_MSG_RESULT($PETSC_VERSION) +]) + + +dnl ------------------------------------------------------------- +dnl Make sure that if PETSc and deal.II were built with the same +dnl MPI enabled (or disabled) functionality. +dnl +dnl Usage: DEAL_II_CHECK_PETSC_MPI_CONSISTENCY +dnl +dnl ------------------------------------------------------------- +AC_DEFUN(DEAL_II_CHECK_PETSC_MPI_CONSISTENCY, dnl +[ + dnl Then check for MPI consistency. + AC_MSG_CHECKING(for consistency of PETSc and deal.II MPI settings) + + if test "x$DEAL_II_USE_MPI" = "xyes" ; then + + dnl So we support MPI. Check that our PETSc installation does + dnl too. PETSc sets the variable PETSC_HAVE_MPIUNI to 1 in case + dnl he *does not* support MPI, so just read out that information. + dnl + dnl Like always, we have to cake care of version control! + case "${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}" in + 3.*) dnl + AC_TRY_COMPILE( + [#include "$DEAL_II_PETSC_DIR/$DEAL_II_PETSC_ARCH/include/petscconf.h" + ], + [#ifdef PETSC_HAVE_MPIUNI + compile error; + #endif + ], + [AC_MSG_RESULT(yes)], + [AC_MSG_ERROR([PETSc was not built for MPI, but deal.II is!] + )]) + ;; + *) dnl + AC_MSG_ERROR([Unknown PETSc version ${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}]) + ;; + esac + else + case "${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}" in + 3.*) dnl + AC_TRY_COMPILE( + [#include "$DEAL_II_PETSC_DIR/$DEAL_II_PETSC_ARCH/include/petscconf.h" + ], + [#ifndef PETSC_HAVE_MPIUNI + compile error; + #endif], + [AC_MSG_RESULT(yes)], + [AC_MSG_ERROR([PETSc was built for MPI, but deal.II is not!]) + ]) + ;; + *) dnl + AC_MSG_ERROR([Unknown PETSc version ${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}]) + ;; + esac + fi +]) + + +dnl ------------------------------------------------------------ +dnl See if there is a library libmpiuni.a/so available. We need +dnl to link with it on some systems where PETSc is built without +dnl a real MPI and we need to handle trivial (one process) MPI +dnl functionality. +dnl +dnl Usage: DEAL_II_CONFIGURE_PETSC_MPIUNI_LIB +dnl +dnl ------------------------------------------------------------ +AC_DEFUN(DEAL_II_CONFIGURE_PETSC_MPIUNI_LIB, dnl +[ + AC_MSG_CHECKING([for PETSc libmpiuni library]) + case "${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}" in + 3.*) dnl + if test -f $DEAL_II_PETSC_DIR/$DEAL_II_PETSC_ARCH/lib/libmpiuni.a ; then + DEAL_II_PETSC_MPIUNI_LIB="$DEAL_II_PETSC_DIR/$DEAL_II_PETSC_ARCH/lib/libmpiuni.a" + fi + ;; + *) dnl + AC_MSG_ERROR([Unknown PETSc version ${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}]) + ;; + esac + + if test "$DEAL_II_PETSC_MPIUNI_LIB" = "" ; then + AC_MSG_RESULT([not found]) + else + AC_MSG_RESULT($DEAL_II_PETSC_MPIUNI_LIB) + fi +]) + + +dnl ------------------------------------------------------------ +dnl Figure out PETSc was compiled with --scalar-type=complex by +dnl scanning PETSc configuration file. +dnl +dnl Warning: Up tp now, PETSc>3.0.0 is being supported and +dnl deal.II will not safely compile if this option is "yes". +dnl +dnl Usage: DEAL_II_CONFIGURE_PETSC_COMPLEX +dnl +dnl ------------------------------------------------------------ +AC_DEFUN(DEAL_II_CONFIGURE_PETSC_COMPLEX, dnl +[ + case "${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}" in + 3.3*) + AC_MSG_CHECKING([for PETSc scalar complex]) + DEAL_II_PETSC_COMPLEX=`cat $DEAL_II_PETSC_DIR/$DEAL_II_PETSC_ARCH/include/petscconf.h \ + | grep "#define PETSC_USE_COMPLEX" \ + | perl -pi -e 's/.*COMPLEX\s+//g;'` + if test "$DEAL_II_PETSC_COMPLEX" = "1" ; then + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + + dnl If we have previously found PETSc and here with a complex + dnl scalar type then set the DEAL_II_USE_COMPLEX macro + if test "$USE_CONTRIB_PETSC" = "yes" ; then + if test "$DEAL_II_PETSC_COMPLEX" = "1" ; then + AC_DEFINE([DEAL_II_USE_PETSC_COMPLEX], [1], + [Defined if a PETSc installation was found with complex scalar type and is going to be used]) + fi fi + ;; + esac +]) + -- 2.39.5