From: Matthias Maier Date: Thu, 15 May 2014 20:06:33 +0000 (+0000) Subject: CMake: Port LAPACK as well X-Git-Tag: v8.2.0-rc1~494 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e10308bafab02fa9161b5e1bede398703b9bab77;p=dealii.git CMake: Port LAPACK as well git-svn-id: https://svn.dealii.org/trunk@32912 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/cmake/configure/configure_1_lapack.cmake b/deal.II/cmake/configure/configure_1_lapack.cmake index 258af871f2..abdb153443 100644 --- a/deal.II/cmake/configure/configure_1_lapack.cmake +++ b/deal.II/cmake/configure/configure_1_lapack.cmake @@ -19,77 +19,74 @@ # MACRO(FEATURE_LAPACK_FIND_EXTERNAL var) - FIND_PACKAGE(DEALII_LAPACK) + FIND_PACKAGE(LAPACK) - IF(LAPACK_FOUND) - SET(${var} TRUE) - ENDIF() -ENDMACRO() - - -# -# We do a fine grained check for availability of every single LAPACK -# function we use. We have to ensure that this check is repeated every time -# the lapack library or DEAL_II_WITH_LAPACK changes. -# - -SET(DEAL_II_LAPACK_FUNCTIONS - daxpy_ dgeev_ dgeevx_ dgelsd_ dgemm_ dgemv_ dgeqrf_ dgesdd_ dgesvd_ - dgetrf_ dgetri_ dgetrs_ dorgqr_ dormqr_ dstev_ dsyevx_ dsygv_ dsygvx_ - dtrtrs_ saxpy_ sgeev_ sgeevx_ sgelsd_ sgemm_ sgemv_ sgeqrf_ sgesdd_ - sgesvd_ sgetrf_ sgetri_ sgetrs_ sorgqr_ sormqr_ sstev_ ssyevx_ ssygv_ - ssygvx_ strtrs_ - ) - -MACRO(CHECK_FOR_LAPACK_FUNCTIONS) - # - # Clear the test flags because the following test will use a C compiler - # - CLEAR_CMAKE_REQUIRED() - SET(CMAKE_REQUIRED_FLAGS "${LAPACK_LINKER_FLAGS}") - SET(CMAKE_REQUIRED_LIBRARIES ${LAPACK_LIBRARIES}) # - # Push -pthread as well: + # We do a check for availability of every single LAPACK function we use. # - ENABLE_IF_SUPPORTED(CMAKE_REQUIRED_FLAGS "-pthread") + IF(LAPACK_FOUND) + SET(${var} TRUE) - IF(CMAKE_C_COMPILER_WORKS) - FOREACH(_func ${DEAL_II_LAPACK_FUNCTIONS}) - STRING(TOUPPER ${_func} _func_uppercase) - CHECK_FUNCTION_EXISTS(${_func} HAVE_${_func_uppercase}) - ENDFOREACH() - ELSE() - MESSAGE(STATUS - "No suitable C compiler was found! Skipping LAPACK symbol check." - ) - FOREACH(_func ${DEAL_II_LAPACK_FUNCTIONS}) - SET_IF_EMPTY(HAVE_${_func_uppercase} TRUE) - ENDFOREACH() + # + # Clear the test flags because the following test will use a C compiler + # + CLEAR_CMAKE_REQUIRED() + SET(CMAKE_REQUIRED_FLAGS "${LAPACK_LINKER_FLAGS}") + SET(CMAKE_REQUIRED_LIBRARIES ${LAPACK_LIBRARIES}) + # Push -pthread as well: + ENABLE_IF_SUPPORTED(CMAKE_REQUIRED_FLAGS "-pthread") + + IF(CMAKE_C_COMPILER_WORKS) + + INCLUDE(CheckCSourceCompiles) + CHECK_C_SOURCE_COMPILES(" + char daxpy_(); char dgeev_(); char dgeevx_(); char dgelsd_(); char + dgemm_(); char dgemv_(); char dgeqrf_(); char dgesdd_(); char + dgesvd_(); char dgetrf_(); char dgetri_(); char dgetrs_(); char + dorgqr_(); char dormqr_(); char dstev_(); char dsyevx_(); char + dsygv_(); char dsygvx_(); char dtrtrs_(); char saxpy_(); char + sgeev_(); char sgeevx_(); char sgelsd_(); char sgemm_(); char + sgemv_(); char sgeqrf_(); char sgesdd_(); char sgesvd_(); char + sgetrf_(); char sgetri_(); char sgetrs_(); char sorgqr_(); char + sormqr_(); char sstev_(); char ssyevx_(); char ssygv_(); char + ssygvx_(); char strtrs_(); + int main(){ + daxpy_ (); dgeev_ (); dgeevx_ (); dgelsd_ (); dgemm_ (); dgemv_ (); + dgeqrf_ (); dgesdd_ (); dgesvd_ (); dgetrf_ (); dgetri_ (); dgetrs_ + (); dorgqr_ (); dormqr_ (); dstev_ (); dsyevx_ (); dsygv_ (); + dsygvx_ (); dtrtrs_ (); saxpy_ (); sgeev_ (); sgeevx_ (); sgelsd_ + (); sgemm_ (); sgemv_ (); sgeqrf_ (); sgesdd_ (); sgesvd_ (); + sgetrf_ (); sgetri_ (); sgetrs_ (); sorgqr_ (); sormqr_ (); sstev_ + (); ssyevx_ (); ssygv_ (); ssygvx_ (); strtrs_ (); + + return 0; + }" + LAPACK_SYMBOL_CHECK) + + IF(NOT LAPACK_SYMBOL_CHECK) + MESSAGE(STATUS + "Could not find a sufficient BLAS/LAPACK installation: " + "BLAS/LAPACK symbol check failed! Consult CMakefiles/CMakeError.log " + "for further information." + ) + SET(LAPACK_ADDITIONAL_ERROR_STRING + ${LAPACK_ADDITIONAL_ERROR_STRING} + "Could not find a sufficient BLAS/LAPACK installation: \n" + "BLAS/LAPACK symbol check failed! This usually means that your " + "BLAS/LAPACK installation is incomplete or the link line is " + "broken. Consult\n" + " CMakefiles/CMakeError.log\n" + "for further information.\n" + ) + SET(${var} FALSE) + ENDIF() + ELSE() + MESSAGE(STATUS + "No suitable C compiler was found! Skipping LAPACK symbol check." + ) + ENDIF() ENDIF() - - RESET_CMAKE_REQUIRED() -ENDMACRO() - - -MACRO(RESET_LAPACK_FUNCTIONS_CACHE) - FOREACH(_func ${DEAL_II_LAPACK_FUNCTIONS}) - STRING(TOUPPER ${_func} _func_uppercase) - UNSET(HAVE_${_func_uppercase} CACHE) - ENDFOREACH() -ENDMACRO() - - -MACRO(FEATURE_LAPACK_CONFIGURE_EXTERNAL) - CHECK_FOR_LAPACK_FUNCTIONS() ENDMACRO() CONFIGURE_FEATURE(LAPACK) - -# -# Call RESET_LAPACK_FUNCTIONS_CHECK if DEAL_II_WITH_LAPACK is unset to -# clean the configuration -# -IF(NOT DEAL_II_WITH_LAPACK) - RESET_LAPACK_FUNCTIONS_CACHE() -ENDIF() diff --git a/deal.II/cmake/macros/macro_purge_feature.cmake b/deal.II/cmake/macros/macro_purge_feature.cmake index 3b5a493504..34380a43e7 100644 --- a/deal.II/cmake/macros/macro_purge_feature.cmake +++ b/deal.II/cmake/macros/macro_purge_feature.cmake @@ -31,6 +31,9 @@ MACRO(PURGE_FEATURE _feature) ENDIF() ENDFOREACH() + UNSET(${_feature}_FOUND) + UNSET(${_feature}_VERSION) + # # cached: # diff --git a/deal.II/cmake/modules/FindDEALII_LAPACK.cmake b/deal.II/cmake/modules/FindDEALII_LAPACK.cmake deleted file mode 100644 index 1dc401e635..0000000000 --- a/deal.II/cmake/modules/FindDEALII_LAPACK.cmake +++ /dev/null @@ -1,118 +0,0 @@ -## --------------------------------------------------------------------- -## $Id$ -## -## Copyright (C) 2013 - 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. -## -## --------------------------------------------------------------------- - -# -# This module is a wrapper around the FindLAPACK.cmake module provided by -# CMake. -# -# This module exports -# -# LAPACK_FOUND -# LAPACK_LIBRARIES -# LAPACK_LINKER_FLAGS -# BLAS_FOUND -# BLAS_LIBRARIES -# BLAS_LINKER_FLAGS -# - - - -# -# We have to use a trick with CMAKE_PREFIX_PATH to make LAPACK_DIR and -# BLAS_DIR work... -# -SET(LAPACK_DIR "" CACHE PATH "An optional hint to a LAPACK installation") -SET(BLAS_DIR "" CACHE PATH "An optional hint to a BLAS installation") -SET_IF_EMPTY(BLAS_DIR "$ENV{BLAS_DIR}") -SET_IF_EMPTY(LAPACK_DIR "$ENV{LAPACK_DIR}") - -SET(_cmake_prefix_path_backup "${CMAKE_PREFIX_PATH}") -SET(CMAKE_PREFIX_PATH ${BLAS_DIR} ${LAPACK_DIR} ${_cmake_prefix_path_backup}) -FIND_PACKAGE(BLAS) -SET(CMAKE_PREFIX_PATH ${LAPACK_DIR} ${_cmake_prefix_path_backup}) -FIND_PACKAGE(LAPACK) -SET(CMAKE_PREFIX_PATH ${_cmake_prefix_path_backup}) - -MARK_AS_ADVANCED( - atlas_LIBRARY atlcblas_LIBRARY atllapack_LIBRARY blas_LIBRARY - eigen_blas_LIBRARY f77blas_LIBRARY gslcblas_LIBRARY lapack_LIBRARY - m_LIBRARY ptf77blas_LIBRARY ptlapack_LIBRARY refblas_LIBRARY - reflapack_LIBRARY - ) - - -IF(LAPACK_FOUND) - SET(DEALII_LAPACK_FOUND TRUE) - - # - # So, well... LAPACK_LINKER_FLAGS and LAPACK_LIBRARIES should contain the - # complete link interface. But for invalid user overrides we include - # BLAS_LIBRARIES and BLAS_LINKER_FLAGS as well.. - # - IF(NOT LAPACK_LINKER_FLAGS MATCHES "${BLAS_LINKER_FLAGS}") - MESSAGE(STATUS - "Manually adding BLAS_LINKER_FLAGS to LAPACK_LINKER_FLAGS" - ) - ADD_FLAGS(LAPACK_LINKER_FLAGS "${BLAS_LINKER_FLAGS}") - ENDIF() - IF(NOT "${LAPACK_LIBRARIES}" MATCHES "${BLAS_LIBRARIES}") - MESSAGE(STATUS - "Manually adding BLAS_LIBRARIES to LAPACK_LIBRARIES" - ) - LIST(APPEND LAPACK_LIBRARIES ${BLAS_LIBRARIES}) - ENDIF() - - # - # Well, in case of static archives we have to manually pick up the - # complete link interface. *sigh* - # - # If CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES is not available, do it - # unconditionally for the most common case (gfortran). - # - SET(_fortran_libs ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) - SET_IF_EMPTY(_fortran_libs gfortran m quadmath c) - - FOREACH(_lib ${_fortran_libs}) - FIND_SYSTEM_LIBRARY(${_lib}_LIBRARY NAMES ${_lib}) - MARK_AS_ADVANCED(${_lib}_LIBRARY) - - IF(NOT ${_lib}_LIBRARY MATCHES "-NOTFOUND") - LIST(APPEND BLAS_LIBRARIES ${${_lib}_LIBRARY}) - LIST(APPEND LAPACK_LIBRARIES ${${_lib}_LIBRARY}) - ENDIF() - - ENDFOREACH() - - # - # Filter out spurious "FALSE" in the library lists: - # - IF(DEFINED BLAS_LIBRARIES) - LIST(REMOVE_ITEM BLAS_LIBRARIES "FALSE") - ENDIF() - LIST(REMOVE_ITEM LAPACK_LIBRARIES "FALSE") - - MARK_AS_ADVANCED(BLAS_DIR LAPACK_DIR) - -ELSE() - SET(DEALII_LAPACK_FOUND FALSE) - - # - # Clean up the library variables in case we couldn't find the libraries - # to avoid spurious inclusions of "-NOTFOUND" or "FALSE": - # - SET(BLAS_LIBRARIES) - SET(LAPACK_LIBRARIES) -ENDIF() diff --git a/deal.II/cmake/modules/FindLAPACK.cmake b/deal.II/cmake/modules/FindLAPACK.cmake new file mode 100644 index 0000000000..20b996f377 --- /dev/null +++ b/deal.II/cmake/modules/FindLAPACK.cmake @@ -0,0 +1,90 @@ +## --------------------------------------------------------------------- +## $Id$ +## +## Copyright (C) 2013 - 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. +## +## --------------------------------------------------------------------- + +# +# This module is a wrapper around the FindLAPACK.cmake module provided by +# CMake. +# +# This module exports +# +# LAPACK_FOUND +# LAPACK_LIBRARIES +# LAPACK_LINKER_FLAGS +# BLAS_FOUND +# BLAS_LIBRARIES +# BLAS_LINKER_FLAGS +# + +# +# We have to use a trick with CMAKE_PREFIX_PATH to make LAPACK_DIR and +# BLAS_DIR work... +# +SET(LAPACK_DIR "" CACHE PATH "An optional hint to a LAPACK installation") +SET(BLAS_DIR "" CACHE PATH "An optional hint to a BLAS installation") +SET_IF_EMPTY(BLAS_DIR "$ENV{BLAS_DIR}") +SET_IF_EMPTY(LAPACK_DIR "$ENV{LAPACK_DIR}") + +SET(_cmake_prefix_path_backup "${CMAKE_PREFIX_PATH}") +LIST(REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules/) + +SET(CMAKE_PREFIX_PATH ${BLAS_DIR} ${LAPACK_DIR} ${_cmake_prefix_path_backup}) +FIND_PACKAGE(BLAS) + +SET(CMAKE_PREFIX_PATH ${LAPACK_DIR} ${_cmake_prefix_path_backup}) +FIND_PACKAGE(LAPACK) + +SET(CMAKE_PREFIX_PATH ${_cmake_prefix_path_backup}) +LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules/) + +# +# Filter out spurious "FALSE" in the library lists: +# +IF(DEFINED BLAS_LIBRARIES) + LIST(REMOVE_ITEM BLAS_LIBRARIES "FALSE") +ENDIF() +IF(DEFINED LAPACK_LIBRARIES) + LIST(REMOVE_ITEM LAPACK_LIBRARIES "FALSE") +ENDIF() + +# +# Well, in case of static archives we have to manually pick up the +# complete link interface. *sigh* +# +# If CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES is not available, do it +# unconditionally for the most common case (gfortran). +# +SET(_fortran_libs ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) +SET_IF_EMPTY(_fortran_libs gfortran m quadmath c) +FOREACH(_lib ${_fortran_libs}) + FIND_SYSTEM_LIBRARY(${_lib}_LIBRARY NAMES ${_lib}) + LIST(APPEND _additional_libraries ${_lib}_LIBRARY) +ENDFOREACH() + + +SET(_lapack_libraries ${LAPACK_LIBRARIES}) +SET(_lapack_linker_flags ${LAPACK_LINKER_FLAGS}) +DEAL_II_PACKAGE_HANDLE(LAPACK + LIBRARIES + REQUIRED _lapack_libraries + OPTIONAL BLAS_LIBRARIES ${_additional_libraries} + LINKER_FLAGS OPTIONAL _lapack_linker_flags BLAS_LINKER_FLAGS + CLEAR + atlas_LIBRARY atlcblas_LIBRARY atllapack_LIBRARY blas_LIBRARY + eigen_blas_LIBRARY f77blas_LIBRARY gslcblas_LIBRARY lapack_LIBRARY + m_LIBRARY ptf77blas_LIBRARY ptlapack_LIBRARY refblas_LIBRARY + reflapack_LIBRARY BLAS_LIBRARIES ${_additional_libraries} + LAPACK_SYMBOL_CHECK # Cleanup check in configure_1_lapack.cmake + )