From: Matthias Maier Date: Mon, 12 Aug 2013 19:28:29 +0000 (+0000) Subject: CMake: *yay* CMake's FindBLAS.cmake and FindLAPACK.cmake apparently set X-Git-Tag: v8.1.0~1082 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de026cf36d0ec2825a08eeec18139a5d28fbfe56;p=dealii.git CMake: *yay* CMake's FindBLAS.cmake and FindLAPACK.cmake apparently set BLAS_LIBRARIES and LAPACK_LIBRARIES to "FALSE" if they weren't found. We have to manually remove this content... Now, these are so many changes to the native behaviour that it deserves its own FindDEALII_LAPACK.cmake module to do this properly git-svn-id: https://svn.dealii.org/trunk@30292 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 234d485568..455a4944b4 100644 --- a/deal.II/cmake/configure/configure_1_lapack.cmake +++ b/deal.II/cmake/configure/configure_1_lapack.cmake @@ -19,63 +19,9 @@ # MACRO(FEATURE_LAPACK_FIND_EXTERNAL var) - FIND_PACKAGE(LAPACK) - - # - # 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() - - MARK_AS_ADVANCED( - atlas_LIBRARY - blas_LIBRARY - gslcblas_LIBRARY - lapack_LIBRARY - m_LIBRARY - ptf77blas_LIBRARY - ptlapack_LIBRARY - refblas_LIBRARY - reflapack_LIBRARY - ) + FIND_PACKAGE(DEALII_LAPACK) IF(LAPACK_FOUND) - # - # Well, in case of static archives we have to manually pick up the - # complete link interface. *sigh* - # - # Do this unconditionally for the most common case: - # TODO: Non-GNU setups... - # - # Switch the library preference back to prefer dynamic libraries if - # DEAL_II_PREFER_STATIC_LIBS=TRUE but DEAL_II_STATIC_EXECUTABLE=FALSE. In - # this case system libraries should be linked dynamically. - # - SWITCH_LIBRARY_PREFERENCE() - FOREACH(_lib gfortran m quadmath) - FIND_LIBRARY(${_lib}_LIBRARY - NAMES ${_lib} - HINTS ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES}) - MARK_AS_ADVANCED(${_lib}_LIBRARY) - - IF(NOT ${_lib}_LIBRARY MATCHES "-NOTFOUND") - LIST(APPEND LAPACK_LIBRARIES ${${_lib}_LIBRARY}) - ENDIF() - ENDFOREACH() - SWITCH_LIBRARY_PREFERENCE() - SET(${var} TRUE) ENDIF() ENDMACRO() diff --git a/deal.II/cmake/modules/FindARPACK.cmake b/deal.II/cmake/modules/FindARPACK.cmake index 243899b9e0..f2bb51d628 100644 --- a/deal.II/cmake/modules/FindARPACK.cmake +++ b/deal.II/cmake/modules/FindARPACK.cmake @@ -34,7 +34,7 @@ SET_IF_EMPTY(ARPACK_DIR "$ENV{ARPACK_DIR}") # # ARPACK needs LAPACK and BLAS as dependencies: # -FIND_PACKAGE(LAPACK) +FIND_PACKAGE(DEALII_LAPACK) FIND_LIBRARY(ARPACK_LIBRARY NAMES arpack diff --git a/deal.II/cmake/modules/FindDEALII_LAPACK.cmake b/deal.II/cmake/modules/FindDEALII_LAPACK.cmake new file mode 100644 index 0000000000..70cce2b329 --- /dev/null +++ b/deal.II/cmake/modules/FindDEALII_LAPACK.cmake @@ -0,0 +1,126 @@ +## --------------------------------------------------------------------- +## $Id$ +## +## Copyright (C) 2013 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 +# METIS_INCLUDE_DIRS +# + + + +# +# We have to use a trick with CMAKE_PREFIX_PATH to make LAPACK_DIR and +# BLAS_DIR work... +# +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}) + + + +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() + + MARK_AS_ADVANCED( + atlas_LIBRARY + blas_LIBRARY + gslcblas_LIBRARY + lapack_LIBRARY + m_LIBRARY + ptf77blas_LIBRARY + ptlapack_LIBRARY + refblas_LIBRARY + reflapack_LIBRARY + ) + + # + # Well, in case of static archives we have to manually pick up the + # complete link interface. *sigh* + # + # Do this unconditionally for the most common case: + # TODO: Non-GNU setups... + # + # Switch the library preference back to prefer dynamic libraries if + # DEAL_II_PREFER_STATIC_LIBS=TRUE but DEAL_II_STATIC_EXECUTABLE=FALSE. In + # this case system libraries should be linked dynamically. + # + SWITCH_LIBRARY_PREFERENCE() + FOREACH(_lib gfortran m quadmath) + FIND_LIBRARY(${_lib}_LIBRARY + NAMES ${_lib} + HINTS ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES}) + 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() + SWITCH_LIBRARY_PREFERENCE() + +ELSE() + + # + # If we couldn't find LAPACK, clean up the library variables: + # + + IF("${BLAS_LIBRARIES}" STREQUAL "FALSE") + SET(BLAS_LIBRARIES "") + ENDIF() + IF("${LAPACK_LIBRARIES}" STREQUAL "FALSE") + SET(LAPACK_LIBRARIES "") + ENDIF() + +ENDIF() diff --git a/deal.II/cmake/modules/FindSCALAPACK.cmake b/deal.II/cmake/modules/FindSCALAPACK.cmake index 4cd616dbae..96a6a539b3 100644 --- a/deal.II/cmake/modules/FindSCALAPACK.cmake +++ b/deal.II/cmake/modules/FindSCALAPACK.cmake @@ -41,7 +41,7 @@ FIND_LIBRARY(SCALAPACK_LIBRARY NAMES scalapack # SCALAPACK needs LAPACK and BLAS as dependency, search for them with the help # of the LAPACK find module: # -FIND_PACKAGE(LAPACK) +FIND_PACKAGE(DEALII_LAPACK) # # Well, depending on the version of scalapack and the distribution it might diff --git a/deal.II/cmake/modules/FindUMFPACK.cmake b/deal.II/cmake/modules/FindUMFPACK.cmake index 378b68cb56..746fdf0143 100644 --- a/deal.II/cmake/modules/FindUMFPACK.cmake +++ b/deal.II/cmake/modules/FindUMFPACK.cmake @@ -36,7 +36,7 @@ ENDFOREACH() # TODO: There might be an external dependency for metis, ignore this for # now. # -FIND_PACKAGE(LAPACK) +FIND_PACKAGE(DEALII_LAPACK) FIND_PACKAGE(METIS) #