]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
CMake: *yay* CMake's FindBLAS.cmake and FindLAPACK.cmake apparently set
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 12 Aug 2013 19:28:29 +0000 (19:28 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 12 Aug 2013 19:28:29 +0000 (19:28 +0000)
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

deal.II/cmake/configure/configure_1_lapack.cmake
deal.II/cmake/modules/FindARPACK.cmake
deal.II/cmake/modules/FindDEALII_LAPACK.cmake [new file with mode: 0644]
deal.II/cmake/modules/FindSCALAPACK.cmake
deal.II/cmake/modules/FindUMFPACK.cmake

index 234d4855680b3f3c184450fd7dd41c981fba614b..455a4944b493ac2cd0fd69eb436d4f2be5f97182 100644 (file)
 #
 
 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()
index 243899b9e0062937cc1d597f3b7c888ca46b5465..f2bb51d628a4bbc322c9c9afe29a207f2c0f3b39 100644 (file)
@@ -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 (file)
index 0000000..70cce2b
--- /dev/null
@@ -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()
index 4cd616dbaee956bba9a5d4d2b7b7dc7158422f6c..96a6a539b36f3305282de73209bada6e94086ff2 100644 (file)
@@ -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
index 378b68cb565078cc8d15a9f8aa125414bada7eb4..746fdf0143ad06fa714bd52c4959a4d3a556b19a 100644 (file)
@@ -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)
 
 #

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.