## ---------------------------------------------------------------------
#
-# DEAL_II_PACKAGE_HANDLE
+# DEAL_II_PACKAGE_HANDLE(<feature>
+# {<conf. variable> {(REQUIRED|OPTIONAL) <variables>}}
+# [CLEAR <variables>]
+# )
#
-# TODO: Documentation
+# This macro is an alternative implementation of the
+# FIND_PACKAGE_HANDLE_STANDARD_ARGS macro shipped with CMake - aka do
+# everything that was expected from CMake in the first place *sigh*
+#
+# It's usage is
+# best explained with an example:
+#
+# DEAL_II_PACKAGE_HANDLE(PETSC
+# LIBRARIES
+# REQUIRED PETSC_LIBRARY
+# OPTIONAL _petsc_libraries
+# INCLUDE_DIRS
+# REQUIRED PETSC_INCLUDE_DIR_COMMON PETSC_INCLUDE_DIR_ARCH
+# OPTIONAL _petsc_includes
+# CLEAR PETSC_LIBRARY PETSC_INCLUDE_DIR_COMMON PETSC_INCLUDE_DIR_ARCH
+# )
+#
+# This will check whether all REQUIRED variables are non-empty and
+# different from "-NOTFOUND". If so, PETSC_LIBRARIES and PETSC_INCLUDE_DIRS
+# is defined and populated with the contents of all specified variables.
+# Optional variables with no content or whose content is "-NOTFOUND" are
+# filtered out.
+# After the 'CLEAR' statement all internally cached variables should be
+# listed - this is used to provide a possibility to undo a feature
+# search.
#
MACRO(DEAL_II_PACKAGE_HANDLE _feature _var)
SET(${_feature}_${_variable} "")
SET(_required TRUE)
SET(_fine TRUE)
+ SET(_fill_clear FALSE)
+ SET(_clear "")
FOREACH(_arg ${ARGN})
IF(_arg MATCHES "^LIBRARIES(|_DEBUG|_RELEASE)$"
SET(_required TRUE)
ELSEIF("${_arg}" STREQUAL "OPTIONAL")
SET(_required FALSE)
- ELSEIF( _arg MATCHES "^(optimized|debug|general)$"
+ ELSEIF(_arg MATCHES "^(optimized|debug|general)$"
AND "${_variable}" STREQUAL "LIBRARIES")
#
# Keywords are special...
#
LIST(APPEND ${_feature}_${_variable} ${_arg})
+ ELSEIF("${_arg}" STREQUAL "CLEAR")
+ SET(_fill_clear TRUE)
ELSE()
MARK_AS_ADVANCED(${_arg})
- IF(NOT DEFINED ${_arg} OR ${_arg} MATCHES "-NOTFOUND")
- IF(_required AND _fine)
- IF(NOT DEFINED ${_arg})
- MESSAGE(STATUS
- " ${_feature}_${_variable}: *** Required variable \"${_arg}\" undefined ***"
- )
- ELSE()
- MESSAGE(STATUS
- " ${_feature}_${_variable}: *** Required variable \"${_arg}\" set to NOTFOUND ***"
- )
- ENDIF()
- SET(${_feature}_FOUND FALSE)
- SET(_fine FALSE)
+ IF(_fill_clear)
+ IF(NOT _arg MATCHES "^(optimized|debug|general)$")
+ LIST(APPEND _clear ${_arg})
ENDIF()
ELSE()
- LIST(APPEND ${_feature}_${_variable} ${${_arg}})
+ IF(NOT DEFINED ${_arg} OR ${_arg} MATCHES "-NOTFOUND")
+ IF(_required AND _fine)
+ IF(NOT DEFINED ${_arg})
+ MESSAGE(STATUS
+ " ${_feature}_${_variable}: *** Required variable \"${_arg}\" undefined ***"
+ )
+ ELSE()
+ MESSAGE(STATUS
+ " ${_feature}_${_variable}: *** Required variable \"${_arg}\" set to NOTFOUND ***"
+ )
+ ENDIF()
+ SET(${_feature}_FOUND FALSE)
+ SET(_fine FALSE)
+ ENDIF()
+ ELSE()
+ LIST(APPEND ${_feature}_${_variable} ${${_arg}})
+ ENDIF()
ENDIF()
ENDIF()
ENDFOREACH()
+ SET(${_feature}_CLEAR_VARIABLES ${_clear} CACHE INTERNAL "")
+
IF(_fine)
IF(_variable MATCHES "^CXX_FLAGS(|_DEBUG|_RELEASE)"
OR _variable MATCHES "^LINKER_FLAGS(|_DEBUG|_RELEASE)")
DEAL_II_PACKAGE_HANDLE(ARPACK
LIBRARIES REQUIRED ARPACK_LIBRARY LAPACK_LIBRARIES
LINKER_FLAGS OPTIONAL LAPACK_LINKER_FLAGS
+ CLEAR ARPACK_LIBRARY
)
HINTS ${HDF5_INCLUDE_DIR} ${HDF5_DIR}
PATH_SUFFIXES hdf5 hdf5/include include/hdf5 include
)
-MARK_AS_ADVANCED(HDF5_PUBCONF)
IF(EXISTS ${HDF5_PUBCONF})
#
OPTIONAL MPI_C_LIBRARIES
INCLUDE_DIRS
REQUIRED HDF5_INCLUDE_DIR
+ CLEAR HDF5_HL_LIBRARY HDF5_LIBRARY HDF5_INCLUDE_DIR HDF5_PUBCONF
)
OPTIONAL MPI_C_LIBRARIES
INCLUDE_DIRS
REQUIRED METIS_INCLUDE_DIR
+ CLEAR METIS_LIBRARY PARMETIS_LIBRARY METIS_INCLUDE_DIR
)
#
SET(MUMPS_DIR "" CACHE PATH "An optional hint to a mumps directory")
+SET(SCALAPACK_DIR "" CACHE PATH "An optional hint to a SCALAPACK directory")
+SET(BLACS_DIR "" CACHE PATH "An optional hint to a BLACS directory")
SET_IF_EMPTY(MUMPS_DIR "$ENV{MUMPS_DIR}")
+SET_IF_EMPTY(SCALAPACK_DIR "$ENV{SCALAPACK_DIR}")
+SET_IF_EMPTY(BLACS_DIR "$ENV{BLACS_DIR}")
#
-# Search for all known dependencies of MUMPS:
-# (We'll rely on the user of FindMUMPS, setting up mpi *cough*)
+# Search for scalapack:
#
-FIND_PACKAGE(SCALAPACK) # which will also include lapack and blas
+FIND_LIBRARY(SCALAPACK_LIBRARY NAMES scalapack
+ HINTS ${SCALAPACK_DIR}
+ PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib
+ )
+
+#
+# Well, depending on the version of scalapack and the distribution it might
+# be necessary to search for blacs, too. So we do this in a very
+# probabilistic way...
+#
+FOREACH(_lib blacs blacsCinit blacsF77init)
+ STRING(TOUPPER "${_lib}" _lib_upper)
+ FIND_LIBRARY(${_lib_upper}_LIBRARY
+ NAMES ${_lib} ${_lib}_MPI-LINUX-0 ${_lib}_MPI-DARWIN-0
+ HINTS ${BLACS_DIR} ${SCALAPACK_DIR} ${SCALAPACK_DIR}/../blacs/
+ PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib LIB
+ )
+ MARK_AS_ADVANCED(${_lib_upper}_LIBRARY)
+ENDFOREACH()
+
+#
+# Search for mumps:
+#
FIND_PATH(MUMPS_INCLUDE_DIR dmumps_c.h
HINTS ${MUMPS_DIR}
LIBRARIES
REQUIRED DMUMPS_LIBRARY MUMPS_COMMON_LIBRARY
OPTIONAL PORD_LIBRARY
- REQUIRED SCALAPACK_LIBRARIES
+ REQUIRED SCALAPACK_LIBRARY LAPACK_LIBRARIES
+ OPTIONAL BLACS_LIBRARY BLACSCINIT_LIBRARY BLACSF77INIT_LIBRARY MPI_Fortran_LIBRARIES
OPTIONAL METIS_LIBRARIES MPI_Fortran_LIBRARIES
INCLUDE_DIRS
REQUIRED MUMPS_INCLUDE_DIR
LINKER_FLAGS
- OPTIONAL SCALAPACK_LINKER_FLAGS
+ OPTIONAL LAPACK_LINKER_FLAGS
+ CLEAR
+ DMUMPS_LIBRARY MUMPS_COMMON_LIBRARY PORD_LIBRARY SCALAPACK_LIBRARY
+ BLACS_LIBRARY BLACSCINIT_LIBRARY BLACSF77INIT_LIBRARY MUMPS_INCLUDE_DIR
)
DEAL_II_PACKAGE_HANDLE(MUPARSER
LIBRARIES REQUIRED MUPARSER_LIBRARY
INCLUDE_DIRS REQUIRED MUPARSER_INCLUDE_DIR
+ CLEAR MUPARSER_LIBRARY MUPARSER_INCLUDE_DIR
)
DEAL_II_PACKAGE_HANDLE(NETCDF
LIBRARIES REQUIRED NETCDF_CPLUSPLUS_LIBRARY NETCDF_C_LIBRARY
INCLUDE_DIRS REQUIRED NETCDF_INCLUDE_DIR
+ CLEAR NETCDF_CPLUSPLUS_LIBRARY NETCDF_C_LIBRARY NETCDF_INCLUDE_DIR
)
OPTIONAL LAPACK_LIBRARIES MPI_C_LIBRARIES
INCLUDE_DIRS
REQUIRED P4EST_INCLUDE_DIR SC_INCLUDE_DIR
+ CLEAR
+ SC_INCLUDE_DIR P4EST_LIBRARY_OPTIMIZED SC_LIBRARY_OPTIMIZED
+ P4EST_LIBRARY_DEBUG SC_LIBRARY_DEBUG P4EST_INCLUDE_DIR
)
SET(_hints)
SET(_petsc_libraries)
+ SET(_cleanup_variables)
FOREACH(_token ${PETSC_EXTERNAL_LINK_LINE}})
IF(_token MATCHES "^-L")
# Build up hints with the help of all tokens passed with -L:
# Search for every library that was specified with -l:
STRING(REGEX REPLACE "^-l" "" _token "${_token}")
+ # TODO:
+ LIST(APPEND _cleanup_variables PETSC_LIBRARY_${_token})
IF(_new_petsc_external_link_line)
UNSET(PETSC_LIBRARY_${_token} CACHE)
ENDIF()
INCLUDE_DIRS
REQUIRED PETSC_INCLUDE_DIR_COMMON PETSC_INCLUDE_DIR_ARCH
OPTIONAL _petsc_includes
+ CLEAR
+ PETSC_LIBRARY PETSC_INCLUDE_DIR_COMMON PETSC_INCLUDE_DIR_ARCH
+ ${_cleanup_variables}
)
IF(PETSC_FOUND)
+++ /dev/null
-## ---------------------------------------------------------------------
-## $Id$
-##
-## Copyright (C) 2012 - 2014 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.
-##
-## ---------------------------------------------------------------------
-
-#
-# Try to find the SCALAPACK library
-#
-# Used as a helper module for FindMUMPS.cmake
-#
-# This module exports
-#
-# SCALAPACK_LIBRARIES
-# SCALAPACK_LINKER_FLAGS
-#
-
-SET(SCALAPACK_DIR "" CACHE PATH "An optional hint to a SCALAPACK directory")
-SET(BLACS_DIR "" CACHE PATH "An optional hint to a BLACS directory")
-SET_IF_EMPTY(SCALAPACK_DIR "$ENV{SCALAPACK_DIR}")
-SET_IF_EMPTY(BLACS_DIR "$ENV{BLACS_DIR}")
-
-FIND_LIBRARY(SCALAPACK_LIBRARY NAMES scalapack
- HINTS ${SCALAPACK_DIR}
- PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib
- )
-
-#
-# Well, depending on the version of scalapack and the distribution it might
-# be necessary to search for blacs, too. So we do this in a very
-# probabilistic way...
-#
-FOREACH(_lib blacs blacsCinit blacsF77init)
- STRING(TOUPPER "${_lib}" _lib_upper)
- FIND_LIBRARY(${_lib_upper}_LIBRARY
- NAMES ${_lib} ${_lib}_MPI-LINUX-0 ${_lib}_MPI-DARWIN-0
- HINTS ${BLACS_DIR} ${SCALAPACK_DIR} ${SCALAPACK_DIR}/../blacs/
- PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib LIB
- )
- MARK_AS_ADVANCED(${_lib_upper}_LIBRARY)
-ENDFOREACH()
-
-DEAL_II_PACKAGE_HANDLE(SCALAPACK
- LIBRARIES
- REQUIRED SCALAPACK_LIBRARY LAPACK_LIBRARIES
- OPTIONAL BLACS_LIBRARY BLACSCINIT_LIBRARY BLACSF77INIT_LIBRARY MPI_Fortran_LIBRARIES
- LINKER_FLAGS
- OPTIONAL LAPACK_LINKER_FLAGS
- )
-
-IF(SCALAPACK_FOUND)
- MARK_AS_ADVANCED(BLACS_DIR)
-ENDIF()
REQUIRED SLEPC_LIBRARY PETSC_LIBRARIES
INCLUDE_DIRS
REQUIRED SLEPC_INCLUDE_DIR_ARCH SLEPC_INCLUDE_DIR_COMMON
+ CLEAR SLEPC_LIBRARY SLEPC_INCLUDE_DIR_ARCH SLEPC_INCLUDE_DIR_COMMON
)
DEAL_II_PACKAGE_HANDLE(TBB
LIBRARIES REQUIRED ${_libraries}
INCLUDE_DIRS REQUIRED TBB_INCLUDE_DIR
+ CLEAR TBB_DEBUG_LIBRARY TBB_LIBRARY TBB_INCLUDE_DIR
)
#
# Look for the one include file that we'll query for further information:
#
+# TODO:
IF(_new_trilinos_config)
UNSET(EPETRA_CONFIG_H CACHE)
ENDIF()
OPTIONAL MPI_CXX_LIBRARIES
INCLUDE_DIRS
REQUIRED Trilinos_INCLUDE_DIRS
+ CLEAR TRILINOS_CONFIG EPETRA_CONFIG_H ${_libraries}
)
IF(TRILINOS_FOUND)
OPTIONAL SuiteSparse_config_INCLUDE_DIR
LINKER_FLAGS
OPTIONAL LAPACK_LINKER_FLAGS
+ CLEAR
+ UMFPACK_LIBRARY CHOLMOD_LIBRARY CCOLAMD_LIBRARY COLAMD_LIBRARY
+ CAMD_LIBRARY SuiteSparse_config_LIBRARY AMD_LIBRARY METIS_LIBRARIES
+ LAPACK_LIBRARIES UMFPACK_INCLUDE_DIR AMD_INCLUDE_DIR
+ SuiteSparse_config_INCLUDE_DIR
)
IF(UMFPACK_FOUND)