Fix message about incorrect usage of dihedral type 9
[alexxy/gromacs.git] / cmake / FindBLAS.cmake
1 # - Find BLAS library
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).
7 #
8 # This module sets the following variables:
9 #  BLAS_FOUND - set to true if a library implementing the BLAS interface
10 #    is found
11 #  BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l
12 #    and -L).
13 #  BLAS_LIBRARIES - uncached list of libraries (using full path name) to
14 #    link against to use BLAS
15 #  BLAS95_LIBRARIES - uncached list of libraries (using full path name)
16 #    to link against to use BLAS95 interface
17 #  BLAS95_FOUND - set to true if a library implementing the BLAS f95 interface
18 #    is found
19 #  BLA_STATIC  if set on this determines what kind of linkage we do (static)
20 #  BLA_VENDOR  if set checks only the specified vendor, if not set checks
21 #     all the possibilities
22 #  BLA_F95     if set on tries to find the f95 interfaces for BLAS/LAPACK
23 ##########
24 ### List of vendors (BLA_VENDOR) valid in this module
25 ##  Goto,ATLAS PhiPACK,CXML,DXML,SunPerf,SCSL,SGIMATH,IBMESSL,Intel10_32 (intel mkl v10 32 bit),Intel10_64lp (intel mkl v10 64 bit,lp thread model, lp64 model),
26 ##  Intel10_64lp_seq (intel mkl v10 64 bit,sequential code, lp64 model),
27 ##  Intel( older versions of mkl 32 and 64 bit), ACML,ACML_MP,ACML_GPU,Apple, NAS, Generic
28 # C/CXX should be enabled to use Intel mkl
29
30 #=============================================================================
31 # Copyright 2007-2009 Kitware, Inc.
32 #
33 # Distributed under the OSI-approved BSD License (the "License");
34 # see accompanying file Copyright.txt for details.
35 #
36 # This software is distributed WITHOUT ANY WARRANTY; without even the
37 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
38 # See the License for more information.
39 #=============================================================================
40 # (To distribute this file outside of CMake, substitute the full
41 #  License text for the above reference.)
42
43 include(CheckFunctionExists)
44 include(CheckFortranFunctionExists)
45
46 set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
47
48 # Check the language being used
49 get_property( _LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES )
50 if( _LANGUAGES_ MATCHES Fortran )
51   set( _CHECK_FORTRAN TRUE )
52 elseif( (_LANGUAGES_ MATCHES C) OR (_LANGUAGES_ MATCHES CXX) )
53   set( _CHECK_FORTRAN FALSE )
54 else()
55   if(BLAS_FIND_REQUIRED)
56     message(FATAL_ERROR "FindBLAS requires Fortran, C, or C++ to be enabled.")
57   else(BLAS_FIND_REQUIRED)
58     message(STATUS "Looking for BLAS... - NOT found (Unsupported languages)")
59     return()
60   endif(BLAS_FIND_REQUIRED)
61 endif( )
62
63 macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
64 # This macro checks for the existence of the combination of fortran libraries
65 # given by _list.  If the combination is found, this macro checks (using the
66 # Check_Fortran_Function_Exists macro) whether can link against that library
67 # combination using the name of a routine given by _name using the linker
68 # flags given by _flags.  If the combination of libraries is found and passes
69 # the link test, LIBRARIES is set to the list of complete library paths that
70 # have been found.  Otherwise, LIBRARIES is set to FALSE.
71
72 # N.B. _prefix is the prefix applied to the names of all cached variables that
73 # are generated internally and marked advanced by this macro.
74
75 set(_libdir ${ARGN})
76
77 set(_libraries_work TRUE)
78 set(${LIBRARIES})
79 set(_combined_name)
80 if (NOT _libdir)
81   if (WIN32)
82     set(_libdir ENV LIB)
83   elseif (APPLE)
84     set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH)
85   else ()
86     set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH)
87   endif ()
88 endif ()
89
90 foreach(_library ${_list})
91   set(_combined_name ${_combined_name}_${_library})
92
93   if(_libraries_work)
94     if (BLA_STATIC)
95       if (WIN32)
96         set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
97       endif ( WIN32 )
98       if (APPLE)
99         set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
100       else (APPLE)
101         set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
102       endif (APPLE)
103     else (BLA_STATIC)
104       if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
105         # for ubuntu's libblas3gf and liblapack3gf packages
106         set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
107       endif ()
108     endif (BLA_STATIC)
109     find_library(${_prefix}_${_library}_LIBRARY
110       NAMES ${_library}
111       PATHS ${_libdir}
112       )
113     mark_as_advanced(${_prefix}_${_library}_LIBRARY)
114     set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
115     set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
116   endif(_libraries_work)
117 endforeach(_library ${_list})
118 if(_libraries_work)
119   # Test this combination of libraries.
120   set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_thread})
121 #  message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
122   if (_CHECK_FORTRAN)
123     check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS)
124   else()
125     check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS)
126   endif()
127   set(CMAKE_REQUIRED_LIBRARIES)
128   mark_as_advanced(${_prefix}${_combined_name}_WORKS)
129   set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
130 endif(_libraries_work)
131 if(NOT _libraries_work)
132   set(${LIBRARIES} FALSE)
133 endif(NOT _libraries_work)
134 #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
135 endmacro(Check_Fortran_Libraries)
136
137 set(BLAS_LINKER_FLAGS)
138 set(BLAS_LIBRARIES)
139 set(BLAS95_LIBRARIES)
140 if ($ENV{BLA_VENDOR} MATCHES ".+")
141   set(BLA_VENDOR $ENV{BLA_VENDOR})
142 else ($ENV{BLA_VENDOR} MATCHES ".+")
143   if(NOT BLA_VENDOR)
144     set(BLA_VENDOR "All")
145   endif(NOT BLA_VENDOR)
146 endif ($ENV{BLA_VENDOR} MATCHES ".+")
147
148 if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
149  if(NOT BLAS_LIBRARIES)
150   # gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2)
151   check_fortran_libraries(
152   BLAS_LIBRARIES
153   BLAS
154   sgemm
155   ""
156   "goto2"
157   ""
158   )
159  endif(NOT BLAS_LIBRARIES)
160 endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
161
162 if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All")
163  if(NOT BLAS_LIBRARIES)
164   # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
165   check_fortran_libraries(
166   BLAS_LIBRARIES
167   BLAS
168   dgemm
169   ""
170   "f77blas;atlas"
171   ""
172   )
173  endif(NOT BLAS_LIBRARIES)
174 endif (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All")
175
176 # BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
177 if (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All")
178  if(NOT BLAS_LIBRARIES)
179   check_fortran_libraries(
180   BLAS_LIBRARIES
181   BLAS
182   sgemm
183   ""
184   "sgemm;dgemm;blas"
185   ""
186   )
187  endif(NOT BLAS_LIBRARIES)
188 endif (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All")
189
190 # BLAS in Alpha CXML library?
191 if (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All")
192  if(NOT BLAS_LIBRARIES)
193   check_fortran_libraries(
194   BLAS_LIBRARIES
195   BLAS
196   sgemm
197   ""
198   "cxml"
199   ""
200   )
201  endif(NOT BLAS_LIBRARIES)
202 endif (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All")
203
204 # BLAS in Alpha DXML library? (now called CXML, see above)
205 if (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All")
206  if(NOT BLAS_LIBRARIES)
207   check_fortran_libraries(
208   BLAS_LIBRARIES
209   BLAS
210   sgemm
211   ""
212   "dxml"
213   ""
214   )
215  endif(NOT BLAS_LIBRARIES)
216 endif (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All")
217
218 # BLAS in Sun Performance library?
219 if (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All")
220  if(NOT BLAS_LIBRARIES)
221   check_fortran_libraries(
222   BLAS_LIBRARIES
223   BLAS
224   sgemm
225   "-xlic_lib=sunperf"
226   "sunperf;sunmath"
227   ""
228   )
229   if(BLAS_LIBRARIES)
230     set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf")
231   endif(BLAS_LIBRARIES)
232  endif(NOT BLAS_LIBRARIES)
233 endif (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All")
234
235 # BLAS in SCSL library?  (SGI/Cray Scientific Library)
236 if (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All")
237  if(NOT BLAS_LIBRARIES)
238   check_fortran_libraries(
239   BLAS_LIBRARIES
240   BLAS
241   sgemm
242   ""
243   "scsl"
244   ""
245   )
246  endif(NOT BLAS_LIBRARIES)
247 endif (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All")
248
249 # BLAS in SGIMATH library?
250 if (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All")
251  if(NOT BLAS_LIBRARIES)
252   check_fortran_libraries(
253   BLAS_LIBRARIES
254   BLAS
255   sgemm
256   ""
257   "complib.sgimath"
258   ""
259   )
260  endif(NOT BLAS_LIBRARIES)
261 endif (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All")
262
263 # BLAS in IBM ESSL library? (requires generic BLAS lib, too)
264 if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All")
265  if(NOT BLAS_LIBRARIES)
266   check_fortran_libraries(
267   BLAS_LIBRARIES
268   BLAS
269   sgemm
270   ""
271   "essl;blas"
272   ""
273   )
274  endif(NOT BLAS_LIBRARIES)
275 endif (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All")
276
277 #BLAS in acml library?
278 if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All")
279  if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR
280      ((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR
281      ((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS))
282    )
283    # try to find acml in "standard" paths
284    if( WIN32 )
285     file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" )
286    else()
287     file( GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt" )
288    endif()
289    if( WIN32 )
290     file( GLOB _ACML_GPU_ROOT "C:/AMD/acml*/GPGPUexamples" )
291    else()
292     file( GLOB _ACML_GPU_ROOT "/opt/acml*/GPGPUexamples" )
293    endif()
294    list(GET _ACML_ROOT 0 _ACML_ROOT)
295    list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT)
296    if( _ACML_ROOT )
297     get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH )
298     if( SIZEOF_INTEGER EQUAL 8 )
299      set( _ACML_PATH_SUFFIX "_int64" )
300     else()
301     set( _ACML_PATH_SUFFIX "" )
302    endif()
303    if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" )
304     set( _ACML_COMPILER32 "ifort32" )
305     set( _ACML_COMPILER64 "ifort64" )
306    elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" )
307     set( _ACML_COMPILER32 "sun32" )
308     set( _ACML_COMPILER64 "sun64" )
309    elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" )
310     set( _ACML_COMPILER32 "pgi32" )
311     if( WIN32 )
312      set( _ACML_COMPILER64 "win64" )
313     else()
314      set( _ACML_COMPILER64 "pgi64" )
315     endif()
316    elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Open64" )
317     # 32 bit builds not supported on Open64 but for code simplicity
318     # We'll just use the same directory twice
319     set( _ACML_COMPILER32 "open64_64" )
320     set( _ACML_COMPILER64 "open64_64" )
321    elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" )
322     set( _ACML_COMPILER32 "nag32" )
323     set( _ACML_COMPILER64 "nag64" )
324    else() #if( CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" )
325     set( _ACML_COMPILER32 "gfortran32" )
326     set( _ACML_COMPILER64 "gfortran64" )
327    endif()
328
329    if( BLA_VENDOR STREQUAL "ACML_MP" )
330     set(_ACML_MP_LIB_DIRS
331      "${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib"
332      "${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" )
333    else() #if( _BLAS_VENDOR STREQUAL "ACML" )
334     set(_ACML_LIB_DIRS
335      "${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib"
336      "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" )
337    endif()
338   endif()
339  elseif(BLAS_${BLA_VENDOR}_LIB_DIRS)
340    set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS})
341  endif()
342
343  if( BLA_VENDOR STREQUAL "ACML_MP" )
344   foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS})
345    check_fortran_libraries (
346      BLAS_LIBRARIES
347      BLAS
348      sgemm
349      "" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS}
350    )
351    if( BLAS_LIBRARIES )
352     break()
353    endif()
354   endforeach()
355  elseif( BLA_VENDOR STREQUAL "ACML_GPU" )
356   foreach( BLAS_ACML_GPU_LIB_DIRS ${_ACML_GPU_LIB_DIRS})
357    check_fortran_libraries (
358      BLAS_LIBRARIES
359      BLAS
360      sgemm
361      "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS}
362    )
363    if( BLAS_LIBRARIES )
364     break()
365    endif()
366   endforeach()
367  else() #if( _BLAS_VENDOR STREQUAL "ACML" )
368   foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} )
369    check_fortran_libraries (
370      BLAS_LIBRARIES
371      BLAS
372      sgemm
373      "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS}
374    )
375    if( BLAS_LIBRARIES )
376     break()
377    endif()
378   endforeach()
379  endif()
380
381  # Either acml or acml_mp should be in LD_LIBRARY_PATH but not both
382  if(NOT BLAS_LIBRARIES)
383   check_fortran_libraries(
384   BLAS_LIBRARIES
385   BLAS
386   sgemm
387   ""
388   "acml;acml_mv"
389   ""
390   )
391  endif(NOT BLAS_LIBRARIES)
392  if(NOT BLAS_LIBRARIES)
393   check_fortran_libraries(
394   BLAS_LIBRARIES
395   BLAS
396   sgemm
397   ""
398   "acml_mp;acml_mv"
399   ""
400   )
401  endif(NOT BLAS_LIBRARIES)
402  if(NOT BLAS_LIBRARIES)
403   check_fortran_libraries(
404   BLAS_LIBRARIES
405   BLAS
406   sgemm
407   ""
408   "acml;acml_mv;CALBLAS"
409   ""
410   )
411  endif(NOT BLAS_LIBRARIES)
412 endif () # ACML
413
414 # Apple BLAS library?
415 if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
416 if(NOT BLAS_LIBRARIES)
417   check_fortran_libraries(
418   BLAS_LIBRARIES
419   BLAS
420   dgemm
421   ""
422   "Accelerate"
423   ""
424   )
425  endif(NOT BLAS_LIBRARIES)
426 endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
427
428 if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
429  if ( NOT BLAS_LIBRARIES )
430     check_fortran_libraries(
431     BLAS_LIBRARIES
432     BLAS
433     dgemm
434     ""
435     "vecLib"
436     ""
437     )
438  endif ( NOT BLAS_LIBRARIES )
439 endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
440 # Generic BLAS library?
441 if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All")
442  if(NOT BLAS_LIBRARIES)
443   check_fortran_libraries(
444   BLAS_LIBRARIES
445   BLAS
446   sgemm
447   ""
448   "blas"
449   ""
450   )
451  endif(NOT BLAS_LIBRARIES)
452 endif (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All")
453
454 #BLAS in intel mkl 10 library? (em64t 64bit)
455 if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
456  if (NOT WIN32)
457   set(LM "-lm")
458  endif ()
459  if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
460   if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
461     find_package(Threads)
462   else(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
463     find_package(Threads REQUIRED)
464   endif(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
465
466   set(BLAS_SEARCH_LIBS "")
467
468   if(BLA_F95)
469     set(BLAS_mkl_SEARCH_SYMBOL SGEMM)
470     set(_LIBRARIES BLAS95_LIBRARIES)
471     if (WIN32)
472       list(APPEND BLAS_SEARCH_LIBS
473         "mkl_blas95 mkl_intel_c mkl_intel_thread mkl_core libguide40")
474     else (WIN32)
475       if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
476         list(APPEND BLAS_SEARCH_LIBS
477           "mkl_blas95 mkl_intel mkl_intel_thread mkl_core guide")
478       endif ()
479       if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
480         # old version
481         list(APPEND BLAS_SEARCH_LIBS
482           "mkl_blas95 mkl_intel_lp64 mkl_intel_thread mkl_core guide")
483
484         # mkl >= 10.3
485         if (CMAKE_C_COMPILER MATCHES ".+gcc.*")
486           list(APPEND BLAS_SEARCH_LIBS
487             "mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core")
488           set(LM "${LM};-lgomp")
489         else ()
490           list(APPEND BLAS_SEARCH_LIBS
491             "mkl_blas95_lp64 mkl_intel_lp64 mkl_intel_thread mkl_core iomp5")
492         endif ()
493       endif ()
494     endif (WIN32)
495     if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All")
496       list(APPEND BLAS_SEARCH_LIBS
497         "mkl_blas95_lp64 mkl_intel_lp64 mkl_sequential mkl_core")
498     endif ()
499   else (BLA_F95)
500     set(BLAS_mkl_SEARCH_SYMBOL sgemm)
501     set(_LIBRARIES BLAS_LIBRARIES)
502     if (WIN32)
503       list(APPEND BLAS_SEARCH_LIBS
504         "mkl_c_dll mkl_intel_thread_dll mkl_core_dll libguide40")
505     else (WIN32)
506       if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
507         list(APPEND BLAS_SEARCH_LIBS
508           "mkl_intel mkl_intel_thread mkl_core guide")
509       endif ()
510       if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
511
512         # old version
513         list(APPEND BLAS_SEARCH_LIBS
514           "mkl_intel_lp64 mkl_intel_thread mkl_core guide")
515
516         # mkl >= 10.3
517         if (CMAKE_C_COMPILER MATCHES ".+gcc.*")
518           list(APPEND BLAS_SEARCH_LIBS
519             "mkl_intel_lp64 mkl_gnu_thread mkl_core")
520           set(LM "${LM};-lgomp")
521         else ()
522           list(APPEND BLAS_SEARCH_LIBS
523             "mkl_intel_lp64 mkl_intel_thread mkl_core iomp5")
524         endif ()
525       endif ()
526
527       #older vesions of intel mkl libs
528       if (BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All")
529         list(APPEND BLAS_SEARCH_LIBS
530           "mkl")
531         list(APPEND BLAS_SEARCH_LIBS
532           "mkl_ia32")
533         list(APPEND BLAS_SEARCH_LIBS
534           "mkl_em64t")
535       endif ()
536     endif (WIN32)
537     if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All")
538       list(APPEND BLAS_SEARCH_LIBS
539         "mkl_intel_lp64 mkl_sequential mkl_core")
540     endif ()
541   endif (BLA_F95)
542
543   foreach (IT ${BLAS_SEARCH_LIBS})
544     string(REPLACE " " ";" SEARCH_LIBS ${IT})
545     if (${_LIBRARIES})
546     else ()
547       check_fortran_libraries(
548         ${_LIBRARIES}
549         BLAS
550         ${BLAS_mkl_SEARCH_SYMBOL}
551         ""
552         "${SEARCH_LIBS}"
553         "${CMAKE_THREAD_LIBS_INIT};${LM}"
554         )
555     endif ()
556   endforeach ()
557
558  endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
559 endif (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
560
561
562 if(BLA_F95)
563  if(BLAS95_LIBRARIES)
564     set(BLAS95_FOUND TRUE)
565   else(BLAS95_LIBRARIES)
566     set(BLAS95_FOUND FALSE)
567   endif(BLAS95_LIBRARIES)
568
569   if(NOT BLAS_FIND_QUIETLY)
570     if(BLAS95_FOUND)
571       message(STATUS "A library with BLAS95 API found.")
572     else(BLAS95_FOUND)
573       if(BLAS_FIND_REQUIRED)
574         message(FATAL_ERROR
575         "A required library with BLAS95 API not found. Please specify library location.")
576       else(BLAS_FIND_REQUIRED)
577         message(STATUS
578         "A library with BLAS95 API not found. Please specify library location.")
579       endif(BLAS_FIND_REQUIRED)
580     endif(BLAS95_FOUND)
581   endif(NOT BLAS_FIND_QUIETLY)
582   set(BLAS_FOUND TRUE)
583   set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}")
584 else(BLA_F95)
585   if(BLAS_LIBRARIES)
586     set(BLAS_FOUND TRUE)
587   else(BLAS_LIBRARIES)
588     set(BLAS_FOUND FALSE)
589   endif(BLAS_LIBRARIES)
590
591   if(NOT BLAS_FIND_QUIETLY)
592     if(BLAS_FOUND)
593       message(STATUS "A library with BLAS API found.")
594     else(BLAS_FOUND)
595       if(BLAS_FIND_REQUIRED)
596         message(FATAL_ERROR
597         "A required library with BLAS API not found. Please specify library location."
598         )
599       else(BLAS_FIND_REQUIRED)
600         message(STATUS
601         "A library with BLAS API not found. Please specify library location."
602         )
603       endif(BLAS_FIND_REQUIRED)
604     endif(BLAS_FOUND)
605   endif(NOT BLAS_FIND_QUIETLY)
606 endif(BLA_F95)
607
608 set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})