From: maier Date: Thu, 15 May 2014 16:14:42 +0000 (+0000) Subject: CMake: Some sanity, part I: X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7e9f2df44cc9e1840d2d94c0f25c49ae418ce64;p=dealii-svn.git CMake: Some sanity, part I: Save all cached variables belonging to a feature in a variable FEATURE_CLEAR_VARIABLES so that we know what cache entry belongs to a feature. git-svn-id: https://svn.dealii.org/trunk@32903 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/cmake/macros/macro_deal_ii_package_handle.cmake b/deal.II/cmake/macros/macro_deal_ii_package_handle.cmake index 460f5b5d35..4472f74c61 100644 --- a/deal.II/cmake/macros/macro_deal_ii_package_handle.cmake +++ b/deal.II/cmake/macros/macro_deal_ii_package_handle.cmake @@ -15,9 +15,36 @@ ## --------------------------------------------------------------------- # -# DEAL_II_PACKAGE_HANDLE +# DEAL_II_PACKAGE_HANDLE( +# { {(REQUIRED|OPTIONAL) }} +# [CLEAR ] +# ) # -# 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) @@ -33,6 +60,8 @@ 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)$" @@ -62,34 +91,44 @@ MACRO(DEAL_II_PACKAGE_HANDLE _feature _var) 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)") diff --git a/deal.II/cmake/modules/FindARPACK.cmake b/deal.II/cmake/modules/FindARPACK.cmake index c739c0ece8..f87bb19c64 100644 --- a/deal.II/cmake/modules/FindARPACK.cmake +++ b/deal.II/cmake/modules/FindARPACK.cmake @@ -39,4 +39,5 @@ FIND_LIBRARY(ARPACK_LIBRARY DEAL_II_PACKAGE_HANDLE(ARPACK LIBRARIES REQUIRED ARPACK_LIBRARY LAPACK_LIBRARIES LINKER_FLAGS OPTIONAL LAPACK_LINKER_FLAGS + CLEAR ARPACK_LIBRARY ) diff --git a/deal.II/cmake/modules/FindHDF5.cmake b/deal.II/cmake/modules/FindHDF5.cmake index 258621b53e..ea5e594e3f 100644 --- a/deal.II/cmake/modules/FindHDF5.cmake +++ b/deal.II/cmake/modules/FindHDF5.cmake @@ -46,7 +46,6 @@ FIND_FILE(HDF5_PUBCONF NAMES H5pubconf.h H5pubconf-64.h HINTS ${HDF5_INCLUDE_DIR} ${HDF5_DIR} PATH_SUFFIXES hdf5 hdf5/include include/hdf5 include ) -MARK_AS_ADVANCED(HDF5_PUBCONF) IF(EXISTS ${HDF5_PUBCONF}) # @@ -68,4 +67,5 @@ DEAL_II_PACKAGE_HANDLE(HDF5 OPTIONAL MPI_C_LIBRARIES INCLUDE_DIRS REQUIRED HDF5_INCLUDE_DIR + CLEAR HDF5_HL_LIBRARY HDF5_LIBRARY HDF5_INCLUDE_DIR HDF5_PUBCONF ) diff --git a/deal.II/cmake/modules/FindMETIS.cmake b/deal.II/cmake/modules/FindMETIS.cmake index 01483cf689..5f73bfdf92 100644 --- a/deal.II/cmake/modules/FindMETIS.cmake +++ b/deal.II/cmake/modules/FindMETIS.cmake @@ -101,4 +101,5 @@ DEAL_II_PACKAGE_HANDLE(METIS OPTIONAL MPI_C_LIBRARIES INCLUDE_DIRS REQUIRED METIS_INCLUDE_DIR + CLEAR METIS_LIBRARY PARMETIS_LIBRARY METIS_INCLUDE_DIR ) diff --git a/deal.II/cmake/modules/FindMUMPS.cmake b/deal.II/cmake/modules/FindMUMPS.cmake index b6d56d2ca1..54cb744eba 100644 --- a/deal.II/cmake/modules/FindMUMPS.cmake +++ b/deal.II/cmake/modules/FindMUMPS.cmake @@ -29,14 +29,39 @@ # 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} @@ -90,10 +115,14 @@ DEAL_II_PACKAGE_HANDLE(MUMPS 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 ) diff --git a/deal.II/cmake/modules/FindMUPARSER.cmake b/deal.II/cmake/modules/FindMUPARSER.cmake index d6e42eaf4d..ce861d9f2c 100644 --- a/deal.II/cmake/modules/FindMUPARSER.cmake +++ b/deal.II/cmake/modules/FindMUPARSER.cmake @@ -62,4 +62,5 @@ ENDIF() DEAL_II_PACKAGE_HANDLE(MUPARSER LIBRARIES REQUIRED MUPARSER_LIBRARY INCLUDE_DIRS REQUIRED MUPARSER_INCLUDE_DIR + CLEAR MUPARSER_LIBRARY MUPARSER_INCLUDE_DIR ) diff --git a/deal.II/cmake/modules/FindNETCDF.cmake b/deal.II/cmake/modules/FindNETCDF.cmake index 9b99e8b163..55d802ff40 100644 --- a/deal.II/cmake/modules/FindNETCDF.cmake +++ b/deal.II/cmake/modules/FindNETCDF.cmake @@ -51,4 +51,5 @@ FIND_LIBRARY(NETCDF_C_LIBRARY NAMES netcdf 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 ) diff --git a/deal.II/cmake/modules/FindP4EST.cmake b/deal.II/cmake/modules/FindP4EST.cmake index 204fdd0935..3888f7973d 100644 --- a/deal.II/cmake/modules/FindP4EST.cmake +++ b/deal.II/cmake/modules/FindP4EST.cmake @@ -156,4 +156,7 @@ DEAL_II_PACKAGE_HANDLE(P4EST 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 ) diff --git a/deal.II/cmake/modules/FindPETSC.cmake b/deal.II/cmake/modules/FindPETSC.cmake index 9011d48c17..c21090fbd6 100644 --- a/deal.II/cmake/modules/FindPETSC.cmake +++ b/deal.II/cmake/modules/FindPETSC.cmake @@ -183,6 +183,7 @@ IF(NOT PETSC_PETSCVARIABLES MATCHES "-NOTFOUND") 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: @@ -192,6 +193,8 @@ IF(NOT PETSC_PETSCVARIABLES MATCHES "-NOTFOUND") # 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() @@ -222,6 +225,9 @@ DEAL_II_PACKAGE_HANDLE(PETSC 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) diff --git a/deal.II/cmake/modules/FindSCALAPACK.cmake b/deal.II/cmake/modules/FindSCALAPACK.cmake deleted file mode 100644 index d8a295070d..0000000000 --- a/deal.II/cmake/modules/FindSCALAPACK.cmake +++ /dev/null @@ -1,63 +0,0 @@ -## --------------------------------------------------------------------- -## $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() diff --git a/deal.II/cmake/modules/FindSLEPC.cmake b/deal.II/cmake/modules/FindSLEPC.cmake index 28892f9b9a..b558e7a39e 100644 --- a/deal.II/cmake/modules/FindSLEPC.cmake +++ b/deal.II/cmake/modules/FindSLEPC.cmake @@ -95,4 +95,5 @@ DEAL_II_PACKAGE_HANDLE(SLEPC 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 ) diff --git a/deal.II/cmake/modules/FindTBB.cmake b/deal.II/cmake/modules/FindTBB.cmake index cf19170f4f..d2f07d7a59 100644 --- a/deal.II/cmake/modules/FindTBB.cmake +++ b/deal.II/cmake/modules/FindTBB.cmake @@ -84,4 +84,5 @@ ENDIF() DEAL_II_PACKAGE_HANDLE(TBB LIBRARIES REQUIRED ${_libraries} INCLUDE_DIRS REQUIRED TBB_INCLUDE_DIR + CLEAR TBB_DEBUG_LIBRARY TBB_LIBRARY TBB_INCLUDE_DIR ) diff --git a/deal.II/cmake/modules/FindTRILINOS.cmake b/deal.II/cmake/modules/FindTRILINOS.cmake index f1c493b05b..eb1b9b5685 100644 --- a/deal.II/cmake/modules/FindTRILINOS.cmake +++ b/deal.II/cmake/modules/FindTRILINOS.cmake @@ -79,6 +79,7 @@ ENDIF() # # Look for the one include file that we'll query for further information: # +# TODO: IF(_new_trilinos_config) UNSET(EPETRA_CONFIG_H CACHE) ENDIF() @@ -158,6 +159,7 @@ DEAL_II_PACKAGE_HANDLE(TRILINOS OPTIONAL MPI_CXX_LIBRARIES INCLUDE_DIRS REQUIRED Trilinos_INCLUDE_DIRS + CLEAR TRILINOS_CONFIG EPETRA_CONFIG_H ${_libraries} ) IF(TRILINOS_FOUND) diff --git a/deal.II/cmake/modules/FindUMFPACK.cmake b/deal.II/cmake/modules/FindUMFPACK.cmake index 0ab55c36b7..7a42e42a9e 100644 --- a/deal.II/cmake/modules/FindUMFPACK.cmake +++ b/deal.II/cmake/modules/FindUMFPACK.cmake @@ -158,6 +158,11 @@ DEAL_II_PACKAGE_HANDLE(UMFPACK 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)