1 # - Find LAPACK library
\r
2 # This module finds an installed fortran library that implements the LAPACK
\r
3 # linear-algebra interface (see http://www.netlib.org/lapack/).
\r
5 # The approach follows that taken for the autoconf macro file, acx_lapack.m4
\r
6 # (distributed at http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html).
\r
8 # This module sets the following variables:
\r
9 # LAPACK_FOUND - set to true if a library implementing the LAPACK interface
\r
11 # LAPACK_LINKER_FLAGS - uncached list of required linker flags (excluding -l
\r
13 # LAPACK_LIBRARIES - uncached list of libraries (using full path name) to
\r
14 # link against to use LAPACK
\r
15 # LAPACK95_LIBRARIES - uncached list of libraries (using full path name) to
\r
16 # link against to use LAPACK95
\r
20 include(CheckFortranFunctionExists)
\r
21 set(LAPACK_FOUND FALSE)
\r
23 macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas)
\r
24 # This macro checks for the existence of the combination of fortran libraries
\r
25 # given by _list. If the combination is found, this macro checks (using the
\r
26 # Check_Fortran_Function_Exists macro) whether can link against that library
\r
27 # combination using the name of a routine given by _name using the linker
\r
28 # flags given by _flags. If the combination of libraries is found and passes
\r
29 # the link test, LIBRARIES is set to the list of complete library paths that
\r
30 # have been found. Otherwise, LIBRARIES is set to FALSE.
\r
32 # N.B. _prefix is the prefix applied to the names of all cached variables that
\r
33 # are generated internally and marked advanced by this macro.
\r
35 set(_libraries_work TRUE)
\r
38 foreach(_library ${_list})
\r
39 set(_combined_name ${_combined_name}_${_library})
\r
43 find_library(${_prefix}_${_library}_LIBRARY
\r
50 find_library(${_prefix}_${_library}_LIBRARY
\r
52 PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH
\r
55 find_library(${_prefix}_${_library}_LIBRARY
\r
57 PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH
\r
61 mark_as_advanced(${_prefix}_${_library}_LIBRARY)
\r
62 set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
\r
63 set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
\r
64 endif(_libraries_work)
\r
65 endforeach(_library ${_list})
\r
68 # Test this combination of libraries.
\r
69 set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas})
\r
70 #message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
\r
71 check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS)
\r
72 set(CMAKE_REQUIRED_LIBRARIES)
\r
73 mark_as_advanced(${_prefix}${_combined_name}_WORKS)
\r
74 set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
\r
75 #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
\r
76 endif(_libraries_work)
\r
78 if(NOT _libraries_work)
\r
79 set(${LIBRARIES} FALSE)
\r
80 endif(NOT _libraries_work)
\r
82 endmacro(Check_Lapack_Libraries)
\r
85 set(LAPACK_LINKER_FLAGS)
\r
86 set(LAPACK_LIBRARIES)
\r
87 set(LAPACK95_LIBRARIES)
\r
90 if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
\r
92 else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
\r
93 find_package(BLAS REQUIRED)
\r
94 endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
\r
97 set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
\r
100 if(NOT LAPACK_LIBRARIES)
\r
102 check_lapack_libraries(
\r
108 "${BLAS_LIBRARIES}"
\r
110 endif(NOT LAPACK_LIBRARIES)
\r
112 if(NOT LAPACK95_LIBRARIES)
\r
113 check_lapack_libraries(
\r
119 "${BLAS_LIBRARIES}"
\r
121 endif(NOT LAPACK95_LIBRARIES)
\r
124 if(NOT LAPACK_LIBRARIES)
\r
126 check_lapack_libraries(
\r
132 "${BLAS_LIBRARIES}"
\r
134 endif(NOT LAPACK_LIBRARIES)
\r
137 # Apple LAPACK library?
\r
138 if(NOT LAPACK_LIBRARIES)
\r
139 check_lapack_libraries(
\r
145 "${BLAS_LIBRARIES}"
\r
147 endif(NOT LAPACK_LIBRARIES)
\r
149 if ( NOT LAPACK_LIBRARIES )
\r
150 check_lapack_libraries(
\r
156 "${BLAS_LIBRARIES}"
\r
158 endif ( NOT LAPACK_LIBRARIES )
\r
160 # Generic LAPACK library?
\r
161 if ( NOT LAPACK_LIBRARIES )
\r
162 check_lapack_libraries(
\r
168 "${BLAS_LIBRARIES}"
\r
170 endif ( NOT LAPACK_LIBRARIES )
\r
173 message(STATUS "LAPACK requires BLAS")
\r
176 if(LAPACK_LIBRARIES)
\r
177 set(LAPACK_FOUND TRUE)
\r
178 else(LAPACK_LIBRARIES)
\r
179 set(LAPACK_FOUND FALSE)
\r
180 endif(LAPACK_LIBRARIES)
\r
182 if(NOT LAPACK_FIND_QUIETLY)
\r
184 message(STATUS "A library with LAPACK API found.")
\r
186 if(LAPACK_FIND_REQUIRED)
\r
187 message(FATAL_ERROR
\r
188 "A required library with LAPACK API not found. Please specify library location."
\r
190 else(LAPACK_FIND_REQUIRED)
\r
192 "A library with LAPACK API not found. Please specify library location."
\r
194 endif(LAPACK_FIND_REQUIRED)
\r
195 endif(LAPACK_FOUND)
\r
196 endif(NOT LAPACK_FIND_QUIETLY)
\r