2 # This module finds an installed fortran library that implements the BLAS
3 # linear-algebra interface (see http://www.netlib.org/blas/).
4 # The list of libraries searched for is taken
5 # from the autoconf macro file, acx_blas.m4 (distributed at
6 # http://ac-archive.sourceforge.net/ac-archive/acx_blas.html).
8 # This module sets the following variables:
9 # BLAS_FOUND - set to true if a library implementing the BLAS interface
11 # BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l
13 # BLAS_LIBRARIES - uncached list of libraries (using full path name) to
14 # link against to use BLAS
17 include(CheckFortranFunctionExists)
19 macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list)
20 # This macro checks for the existence of the combination of fortran libraries
21 # given by _list. If the combination is found, this macro checks (using the
22 # Check_Fortran_Function_Exists macro) whether can link against that library
23 # combination using the name of a routine given by _name using the linker
24 # flags given by _flags. If the combination of libraries is found and passes
25 # the link test, LIBRARIES is set to the list of complete library paths that
26 # have been found. Otherwise, LIBRARIES is set to FALSE.
28 # N.B. _prefix is the prefix applied to the names of all cached variables that
29 # are generated internally and marked advanced by this macro.
31 set(_libraries_work TRUE)
34 foreach(_library ${_list})
35 set(_combined_name ${_combined_name}_${_library})
40 find_library(${_prefix}_${_library}_LIBRARY
42 PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH
46 find_library(${_prefix}_${_library}_LIBRARY
48 PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH
51 mark_as_advanced(${_prefix}_${_library}_LIBRARY)
52 set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
53 set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
54 endif(_libraries_work)
55 endforeach(_library ${_list})
57 # Test this combination of libraries.
58 set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}})
59 #message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
60 check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS)
61 set(CMAKE_REQUIRED_LIBRARIES)
62 mark_as_advanced(${_prefix}${_combined_name}_WORKS)
63 set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
64 endif(_libraries_work)
65 if(NOT _libraries_work)
66 set(${LIBRARIES} FALSE)
67 endif(NOT _libraries_work)
68 #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
69 endmacro(Check_Fortran_Libraries)
71 set(BLAS_LINKER_FLAGS)
76 if(NOT BLAS_LIBRARIES)
77 # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
78 check_fortran_libraries(
85 endif(NOT BLAS_LIBRARIES)
87 # BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
88 if(NOT BLAS_LIBRARIES)
89 check_fortran_libraries(
96 endif(NOT BLAS_LIBRARIES)
98 # BLAS in Alpha CXML library?
99 if(NOT BLAS_LIBRARIES)
100 check_fortran_libraries(
107 endif(NOT BLAS_LIBRARIES)
109 # BLAS in Alpha DXML library? (now called CXML, see above)
110 if(NOT BLAS_LIBRARIES)
111 check_fortran_libraries(
118 endif(NOT BLAS_LIBRARIES)
120 # BLAS in Sun Performance library?
121 if(NOT BLAS_LIBRARIES)
122 check_fortran_libraries(
130 set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf")
131 endif(BLAS_LIBRARIES)
133 endif(NOT BLAS_LIBRARIES)
135 # BLAS in SCSL library? (SGI/Cray Scientific Library)
136 if(NOT BLAS_LIBRARIES)
137 check_fortran_libraries(
144 endif(NOT BLAS_LIBRARIES)
146 # BLAS in SGIMATH library?
147 if(NOT BLAS_LIBRARIES)
148 check_fortran_libraries(
155 endif(NOT BLAS_LIBRARIES)
157 # BLAS in IBM ESSL library? (requires generic BLAS lib, too)
158 if(NOT BLAS_LIBRARIES)
159 check_fortran_libraries(
166 endif(NOT BLAS_LIBRARIES)
171 # BLAS in intel mkl library? (shared)
172 if(NOT BLAS_LIBRARIES)
173 check_fortran_libraries(
180 endif(NOT BLAS_LIBRARIES)
182 #BLAS in intel mkl library? (static, 32bit)
183 if(NOT BLAS_LIBRARIES)
184 check_fortran_libraries(
189 "mkl_ia32;guide;pthread"
191 endif(NOT BLAS_LIBRARIES)
193 #BLAS in intel mkl library? (static, em64t 64bit)
194 if(NOT BLAS_LIBRARIES)
195 check_fortran_libraries(
200 "mkl_em64t;guide;pthread"
202 endif(NOT BLAS_LIBRARIES)
205 #BLAS in acml library?
206 if(NOT BLAS_LIBRARIES)
207 check_fortran_libraries(
214 endif(NOT BLAS_LIBRARIES)
218 # Apple BLAS library?
219 if(NOT BLAS_LIBRARIES)
220 check_fortran_libraries(
228 endif(NOT BLAS_LIBRARIES)
230 if ( NOT BLAS_LIBRARIES )
231 check_fortran_libraries(
238 endif ( NOT BLAS_LIBRARIES )
241 # Generic BLAS library?
242 if(NOT BLAS_LIBRARIES)
243 check_fortran_libraries(
250 endif(NOT BLAS_LIBRARIES)
256 set(BLAS_FOUND FALSE)
257 endif(BLAS_LIBRARIES)
259 if(NOT BLAS_FIND_QUIETLY)
261 message(STATUS "A library with BLAS API found.")
263 if(BLAS_FIND_REQUIRED)
265 "A required library with BLAS API not found. Please specify library location."
267 else(BLAS_FIND_REQUIRED)
269 "A library with BLAS API not found. Please specify library location."
271 endif(BLAS_FIND_REQUIRED)
273 endif(NOT BLAS_FIND_QUIETLY)