summaryrefslogtreecommitdiff
blob: 321f05302aa14fadba159e2b2171b6ab8635ece6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
--- a/Modules/FindLAPACK.cmake
+++ b/Modules/FindLAPACK.cmake
@@ -4,6 +4,10 @@
 #
 # Find LAPACK library
 #
+# Version modified for Gentoo Linux.
+# If a valid PkgConfig configuration is found, this overrides and cancels
+# all further checks.
+#
 # This module finds an installed fortran library that implements the
 # LAPACK linear-algebra interface (see http://www.netlib.org/lapack/).
 #
@@ -140,6 +144,23 @@
 
 endmacro()
 
+#
+# first, try PkgConfig
+#
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(PC_LAPACK lapack)
+if(PC_LAPACK_FOUND)
+  foreach(PC_LIB ${PC_LAPACK_LIBRARIES})
+    find_library(${PC_LIB}_LIBRARY NAMES ${PC_LIB} HINTS ${PC_LAPACK_LIBRARY_DIRS} )
+    if (NOT ${PC_LIB}_LIBRARY)
+      message(FATAL_ERROR "Something is wrong in your pkg-config file - lib ${PC_LIB} not found in ${PC_LAPACK_LIBRARY_DIRS}")
+    endif (NOT ${PC_LIB}_LIBRARY)
+    list(APPEND LAPACK_LIBRARIES ${${PC_LIB}_LIBRARY})
+  endforeach(PC_LIB)
+  find_package_handle_standard_args(LAPACK DEFAULT_MSG LAPACK_LIBRARIES)
+  mark_as_advanced(LAPACK_LIBRARIES)
+else(PC_LAPACK_FOUND)
+message(STATUS "No PkgConfig configuration for LAPACK found; starting more extensive search.")
 
 set(LAPACK_LINKER_FLAGS)
 set(LAPACK_LIBRARIES)
@@ -348,3 +369,5 @@
 endif()
 
 set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
+
+endif(PC_LAPACK_FOUND)