Merge topic 'cpack-innosetup-linux'
[kiteware-cmake.git] / Modules / FindLAPACK.cmake
blobe142516cf22943b5ddcdea2e22bdfaa7eb8ff91e
1 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 #[=======================================================================[.rst:
5 FindLAPACK
6 ----------
8 Find Linear Algebra PACKage (LAPACK) library
10 This module finds an installed Fortran library that implements the
11 `LAPACK linear-algebra interface`_.
13 At least one of the ``C``, ``CXX``, or ``Fortran`` languages must be enabled.
15 .. _`LAPACK linear-algebra interface`: https://netlib.org/lapack/
17 Input Variables
18 ^^^^^^^^^^^^^^^
20 The following variables may be set to influence this module's behavior:
22 ``BLA_STATIC``
23   if ``ON`` use static linkage
25 ``BLA_VENDOR``
26   Set to one of the :ref:`BLAS/LAPACK Vendors` to search for BLAS only
27   from the specified vendor.  If not set, all vendors are considered.
29 ``BLA_F95``
30   if ``ON`` tries to find the BLAS95/LAPACK95 interfaces
32 ``BLA_PREFER_PKGCONFIG``
33   .. versionadded:: 3.20
35   if set ``pkg-config`` will be used to search for a LAPACK library first
36   and if one is found that is preferred
38 ``BLA_PKGCONFIG_LAPACK``
39   .. versionadded:: 3.25
41   If set, the ``pkg-config`` method will look for this module name instead of
42   just ``lapack``.
45 ``BLA_SIZEOF_INTEGER``
46   .. versionadded:: 3.22
48   Specify the BLAS/LAPACK library integer size:
50   ``4``
51     Search for a BLAS/LAPACK with 32-bit integer interfaces.
52   ``8``
53     Search for a BLAS/LAPACK with 64-bit integer interfaces.
54   ``ANY``
55     Search for any BLAS/LAPACK.
56     Most likely, a BLAS/LAPACK with 32-bit integer interfaces will be found.
58 Imported targets
59 ^^^^^^^^^^^^^^^^
61 This module defines the following :prop_tgt:`IMPORTED` targets:
63 ``LAPACK::LAPACK``
64   .. versionadded:: 3.18
66   The libraries to use for LAPACK, if found.
68 Result Variables
69 ^^^^^^^^^^^^^^^^
71 This module defines the following variables:
73 ``LAPACK_FOUND``
74   library implementing the LAPACK interface is found
75 ``LAPACK_LINKER_FLAGS``
76   uncached list of required linker flags (excluding ``-l`` and ``-L``).
77 ``LAPACK_LIBRARIES``
78   uncached list of libraries (using full path name) to link against
79   to use LAPACK
80 ``LAPACK95_LIBRARIES``
81   uncached list of libraries (using full path name) to link against
82   to use LAPACK95
83 ``LAPACK95_FOUND``
84   library implementing the LAPACK95 interface is found
86 Intel MKL
87 ^^^^^^^^^
89 To use the Intel MKL implementation of LAPACK, a project must enable at least
90 one of the ``C`` or ``CXX`` languages.  Set ``BLA_VENDOR`` to an Intel MKL
91 variant either on the command-line as ``-DBLA_VENDOR=Intel10_64lp`` or in
92 project code:
94 .. code-block:: cmake
96   set(BLA_VENDOR Intel10_64lp)
97   find_package(LAPACK)
99 In order to build a project using Intel MKL, and end user must first
100 establish an Intel MKL environment.  See the :module:`FindBLAS` module
101 section on :ref:`Intel MKL` for details.
103 #]=======================================================================]
105 # The approach follows that of the ``autoconf`` macro file, ``acx_lapack.m4``
106 # (distributed at http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html).
108 if(CMAKE_Fortran_COMPILER_LOADED)
109   include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake)
110 else()
111   include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake)
112 endif()
113 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
115 function(_add_lapack_target)
116   if(LAPACK_FOUND AND NOT TARGET LAPACK::LAPACK)
117     add_library(LAPACK::LAPACK INTERFACE IMPORTED)
119     # Filter out redundant BLAS info and replace with the BLAS target
120     set(_lapack_libs "${LAPACK_LIBRARIES}")
121     set(_lapack_flags "${LAPACK_LINKER_FLAGS}")
122     if(TARGET BLAS::BLAS)
123       if(_lapack_libs AND BLAS_LIBRARIES)
124         foreach(_blas_lib IN LISTS BLAS_LIBRARIES)
125           list(REMOVE_ITEM _lapack_libs "${_blas_lib}")
126         endforeach()
127       endif()
128       if(_lapack_flags AND BLAS_LINKER_FLAGS)
129         foreach(_blas_flag IN LISTS BLAS_LINKER_FLAGS)
130           list(REMOVE_ITEM _lapack_flags "${_blas_flag}")
131         endforeach()
132       endif()
133       list(APPEND _lapack_libs BLAS::BLAS)
134     endif()
135     if(_lapack_libs)
136       set_target_properties(LAPACK::LAPACK PROPERTIES
137         INTERFACE_LINK_LIBRARIES "${_lapack_libs}"
138       )
139     endif()
140     if(_lapack_flags)
141       set_target_properties(LAPACK::LAPACK PROPERTIES
142         INTERFACE_LINK_OPTIONS "${_lapack_flags}"
143       )
144     endif()
145   endif()
146 endfunction()
148 # TODO: move this stuff to a separate module
150 function(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs _blas)
151   # This function checks for the existence of the combination of libraries
152   # given by _list.  If the combination is found, this checks whether can link
153   # against that library combination using the name of a routine given by _name
154   # using the linker flags given by _flags.  If the combination of libraries is
155   # found and passes the link test, ${LIBRARIES} is set to the list of complete
156   # library paths that have been found.  Otherwise, ${LIBRARIES} is set to FALSE.
158   set(_libraries_work TRUE)
159   set(_libraries)
160   set(_combined_name)
162   if(BLA_STATIC)
163     if(WIN32)
164       set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
165     else()
166       set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
167     endif()
168   else()
169     if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
170       # for ubuntu's libblas3gf and liblapack3gf packages
171       set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
172     endif()
173   endif()
175   set(_extaddlibdir "${_addlibdir}")
176   if(WIN32)
177     list(APPEND _extaddlibdir ENV LIB)
178   elseif(APPLE)
179     list(APPEND _extaddlibdir ENV DYLD_LIBRARY_PATH)
180   else()
181     list(APPEND _extaddlibdir ENV LD_LIBRARY_PATH)
182   endif()
183   list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
185   foreach(_library ${_list})
186     if(_library MATCHES "^-")
187       # Respect linker flags as-is (required by MKL)
188       list(APPEND _libraries "${_library}")
189     else()
190       string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}")
191       string(APPEND _combined_name "_${_lib_var}")
192       if(NOT "${_deps}" STREQUAL "")
193         string(APPEND _combined_name "_deps")
194       endif()
195       if(_libraries_work)
196         find_library(${_prefix}_${_lib_var}_LIBRARY
197           NAMES ${_library}
198           NAMES_PER_DIR
199           PATHS ${_extaddlibdir}
200           PATH_SUFFIXES ${_subdirs}
201         )
202         mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY)
203         list(APPEND _libraries ${${_prefix}_${_lib_var}_LIBRARY})
204         set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY})
205       endif()
206     endif()
207   endforeach()
209   foreach(_flag ${_flags})
210     string(REGEX REPLACE "[^A-Za-z0-9]" "_" _flag_var "${_flag}")
211     string(APPEND _combined_name "_${_flag_var}")
212   endforeach()
213   if(_libraries_work)
214     # Test this combination of libraries.
215     set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${_libraries} ${_blas} ${_deps})
216     set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY})
217     if(CMAKE_Fortran_COMPILER_LOADED)
218       check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS)
219     else()
220       check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS)
221     endif()
222     set(CMAKE_REQUIRED_LIBRARIES)
223     set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
224   endif()
226   if(_libraries_work)
227     if("${_list}${_blas}" STREQUAL "")
228       set(_libraries "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
229     else()
230       list(APPEND _libraries ${_blas} ${_deps})
231     endif()
232   else()
233     set(_libraries FALSE)
234   endif()
235   set(${LIBRARIES} "${_libraries}" PARENT_SCOPE)
236 endfunction()
238 macro(_lapack_find_dependency dep)
239   set(_lapack_quiet_arg)
240   if(LAPACK_FIND_QUIETLY)
241     set(_lapack_quiet_arg QUIET)
242   endif()
243   set(_lapack_required_arg)
244   if(LAPACK_FIND_REQUIRED)
245     set(_lapack_required_arg REQUIRED)
246   endif()
247   find_package(${dep} ${ARGN}
248     ${_lapack_quiet_arg}
249     ${_lapack_required_arg}
250   )
251   if (NOT ${dep}_FOUND)
252     set(LAPACK_NOT_FOUND_MESSAGE "LAPACK could not be found because dependency ${dep} could not be found.")
253   endif()
255   set(_lapack_required_arg)
256   set(_lapack_quiet_arg)
257 endmacro()
259 set(LAPACK_LINKER_FLAGS)
260 set(LAPACK_LIBRARIES)
261 set(LAPACK95_LIBRARIES)
262 set(_lapack_fphsa_req_var LAPACK_LIBRARIES)
264 # Check the language being used
265 if(NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED))
266   set(LAPACK_NOT_FOUND_MESSAGE
267     "FindLAPACK requires Fortran, C, or C++ to be enabled.")
268 endif()
270 if(NOT BLA_SIZEOF_INTEGER)
271   # in the reality we do not know which API of BLAS/LAPACK is masked in library
272   set(_lapack_sizeof_integer "ANY")
273 elseif((BLA_SIZEOF_INTEGER STREQUAL "ANY") OR
274        (BLA_SIZEOF_INTEGER STREQUAL "4") OR
275        (BLA_SIZEOF_INTEGER STREQUAL "8"))
276   set(_lapack_sizeof_integer ${BLA_SIZEOF_INTEGER})
277 else()
278   message(FATAL_ERROR "BLA_SIZEOF_INTEGER can have only <no value>, ANY, 4, or 8 values")
279 endif()
281 # Load BLAS
282 if(NOT LAPACK_NOT_FOUND_MESSAGE)
283   _lapack_find_dependency(BLAS)
284 endif()
286 # Search with pkg-config if specified
287 if(BLA_PREFER_PKGCONFIG)
288   if(NOT BLA_PKGCONFIG_LAPACK)
289     set(BLA_PKGCONFIG_LAPACK "lapack")
290   endif()
291   find_package(PkgConfig QUIET)
292   pkg_check_modules(PKGC_LAPACK QUIET ${BLA_PKGCONFIG_LAPACK})
293   if(PKGC_LAPACK_FOUND)
294     set(LAPACK_FOUND TRUE)
295     set(LAPACK_LIBRARIES "${PKGC_LAPACK_LINK_LIBRARIES}")
296     if (BLAS_LIBRARIES)
297       list(APPEND LAPACK_LIBRARIES "${BLAS_LIBRARIES}")
298     endif()
299     _add_lapack_target()
300     return()
301   endif()
302 endif()
304 # Search for different LAPACK distributions if BLAS is found
305 if(NOT LAPACK_NOT_FOUND_MESSAGE)
306   set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
307   if(NOT BLA_VENDOR)
308     if(NOT "$ENV{BLA_VENDOR}" STREQUAL "")
309       set(BLA_VENDOR "$ENV{BLA_VENDOR}")
310     else()
311       set(BLA_VENDOR "All")
312     endif()
313   endif()
315   # LAPACK in the Intel MKL 10+ library?
316   if(NOT LAPACK_LIBRARIES
317       AND (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
318       AND (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED))
319     # System-specific settings
320     if(NOT WIN32)
321       set(LAPACK_mkl_LM "-lm")
322       set(LAPACK_mkl_LDL "-ldl")
323     endif()
325     _lapack_find_dependency(Threads)
327     if(_lapack_sizeof_integer EQUAL 8)
328       set(LAPACK_mkl_ILP_MODE "ilp64")
329     elseif(_lapack_sizeof_integer EQUAL 4)
330       set(LAPACK_mkl_ILP_MODE "lp64")
331     else()
332       if(BLA_VENDOR MATCHES "_64ilp")
333         set(LAPACK_mkl_ILP_MODE "ilp64")
334       else()
335         set(LAPACK_mkl_ILP_MODE "lp64")
336       endif()
337     endif()
339     set(LAPACK_SEARCH_LIBS "")
341     if(BLA_F95)
342       set(LAPACK_mkl_SEARCH_SYMBOL "cheev_f95")
343       set(_LAPACK_LIBRARIES LAPACK95_LIBRARIES)
344       set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES})
346       # old
347       list(APPEND LAPACK_SEARCH_LIBS
348         "mkl_lapack95")
349       # new >= 10.3
350       list(APPEND LAPACK_SEARCH_LIBS
351         "mkl_intel_c")
352       list(APPEND LAPACK_SEARCH_LIBS
353         "mkl_lapack95_${LAPACK_mkl_ILP_MODE}")
354     else()
355       set(LAPACK_mkl_SEARCH_SYMBOL "cheev")
356       set(_LAPACK_LIBRARIES LAPACK_LIBRARIES)
357       set(_BLAS_LIBRARIES ${BLAS_LIBRARIES})
359       # old and new >= 10.3
360       list(APPEND LAPACK_SEARCH_LIBS
361         "mkl_lapack")
362     endif()
364     # MKL uses a multitude of partially platform-specific subdirectories:
365     if(BLA_VENDOR STREQUAL "Intel10_32")
366       set(LAPACK_mkl_ARCH_NAME "ia32")
367     else()
368       set(LAPACK_mkl_ARCH_NAME "intel64")
369     endif()
370     if(WIN32)
371       set(LAPACK_mkl_OS_NAME "win")
372     elseif(APPLE)
373       set(LAPACK_mkl_OS_NAME "mac")
374     else()
375       set(LAPACK_mkl_OS_NAME "lin")
376     endif()
377     if(DEFINED ENV{MKLROOT})
378       file(TO_CMAKE_PATH "$ENV{MKLROOT}" LAPACK_mkl_MKLROOT)
379       # If MKLROOT points to the subdirectory 'mkl', use the parent directory instead
380       # so we can better detect other relevant libraries in 'compiler' or 'tbb':
381       get_filename_component(LAPACK_mkl_MKLROOT_LAST_DIR "${LAPACK_mkl_MKLROOT}" NAME)
382       if(LAPACK_mkl_MKLROOT_LAST_DIR STREQUAL "mkl")
383           get_filename_component(LAPACK_mkl_MKLROOT "${LAPACK_mkl_MKLROOT}" DIRECTORY)
384       endif()
385     endif()
386     set(LAPACK_mkl_LIB_PATH_SUFFIXES
387         "compiler/lib" "compiler/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}"
388         "compiler/lib/${LAPACK_mkl_ARCH_NAME}"
389         "mkl/lib" "mkl/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}"
390         "mkl/lib/${LAPACK_mkl_ARCH_NAME}"
391         "lib" "lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}"
392         "lib/${LAPACK_mkl_ARCH_NAME}"
393         )
395     # First try empty lapack libs (implicitly linked or automatic from BLAS)
396     if(NOT ${_LAPACK_LIBRARIES})
397       check_lapack_libraries(
398         ${_LAPACK_LIBRARIES}
399         LAPACK
400         ${LAPACK_mkl_SEARCH_SYMBOL}
401         ""
402         ""
403         "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}"
404         "${LAPACK_mkl_MKLROOT}"
405         "${LAPACK_mkl_LIB_PATH_SUFFIXES}"
406         "${_BLAS_LIBRARIES}"
407       )
408       if(LAPACK_WORKS AND NOT _BLAS_LIBRARIES)
409         # Give a more helpful "found" message
410         set(LAPACK_WORKS "implicitly linked")
411         set(_lapack_fphsa_req_var LAPACK_WORKS)
412       endif()
413     endif()
415     # Then try the search libs
416     foreach(_search ${LAPACK_SEARCH_LIBS})
417       string(REPLACE " " ";" _search ${_search})
418       if(NOT ${_LAPACK_LIBRARIES})
419         check_lapack_libraries(
420           ${_LAPACK_LIBRARIES}
421           LAPACK
422           ${LAPACK_mkl_SEARCH_SYMBOL}
423           ""
424           "${_search}"
425           "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}"
426           "${LAPACK_mkl_MKLROOT}"
427           "${LAPACK_mkl_LIB_PATH_SUFFIXES}"
428           "${_BLAS_LIBRARIES}"
429         )
430       endif()
431     endforeach()
433     unset(_search)
434     unset(LAPACK_mkl_ILP_MODE)
435     unset(LAPACK_mkl_SEARCH_SYMBOL)
436     unset(LAPACK_mkl_LM)
437     unset(LAPACK_mkl_LDL)
438     unset(LAPACK_mkl_MKLROOT)
439     unset(LAPACK_mkl_ARCH_NAME)
440     unset(LAPACK_mkl_OS_NAME)
441     unset(LAPACK_mkl_LIB_PATH_SUFFIXES)
442   endif()
444   # gotoblas? (http://www.tacc.utexas.edu/tacc-projects/gotoblas2)
445   if(NOT LAPACK_LIBRARIES
446       AND (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All"))
447     check_lapack_libraries(
448       LAPACK_LIBRARIES
449       LAPACK
450       cheev
451       ""
452       "goto2"
453       ""
454       ""
455       ""
456       "${BLAS_LIBRARIES}"
457     )
458   endif()
460   # FlexiBLAS? (http://www.mpi-magdeburg.mpg.de/mpcsc/software/FlexiBLAS/)
461   if(NOT LAPACK_LIBRARIES
462       AND (BLA_VENDOR STREQUAL "FlexiBLAS" OR BLA_VENDOR STREQUAL "All"))
463     set(_lapack_flexiblas_lib "flexiblas")
465     if(_lapack_sizeof_integer EQUAL 8)
466       string(APPEND _lapack_flexiblas_lib "64")
467     endif()
469     check_lapack_libraries(
470       LAPACK_LIBRARIES
471       LAPACK
472       cheev
473       ""
474       "${_lapack_flexiblas_lib}"
475       ""
476       ""
477       ""
478       "${BLAS_LIBRARIES}"
479     )
481     unset(_lapack_flexiblas_lib)
482   endif()
484   # OpenBLAS? (http://www.openblas.net)
485   if(NOT LAPACK_LIBRARIES
486       AND (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All"))
487     set(_lapack_openblas_lib "openblas")
489     if(_lapack_sizeof_integer EQUAL 8)
490       if(MINGW)
491         string(APPEND _lapack_openblas_lib "_64")
492       else()
493         string(APPEND _lapack_openblas_lib "64")
494       endif()
495     endif()
497     check_lapack_libraries(
498       LAPACK_LIBRARIES
499       LAPACK
500       cheev
501       ""
502       "${_lapack_openblas_lib}"
503       ""
504       ""
505       ""
506       "${BLAS_LIBRARIES}"
507     )
509     unset(_lapack_openblas_lib)
510   endif()
512   # ArmPL? (https://developer.arm.com/tools-and-software/server-and-hpc/compile/arm-compiler-for-linux/arm-performance-libraries)
513   if(NOT LAPACK_LIBRARIES
514       AND (BLA_VENDOR MATCHES "Arm" OR BLA_VENDOR STREQUAL "All"))
515     # Check for 64bit Integer support
516     if(_lapack_sizeof_integer EQUAL 8)
517       set(LAPACK_armpl_LIB "armpl_ilp64")
518     elseif(_lapack_sizeof_integer EQUAL 4)
519       set(LAPACK_armpl_LIB "armpl_lp64")
520     else()
521       if(BLA_VENDOR MATCHES "_ilp64")
522         set(LAPACK_armpl_LIB "armpl_ilp64")
523       else()
524         set(LAPACK_armpl_LIB "armpl_lp64")
525       endif()
526     endif()
528     # Check for OpenMP support, VIA BLA_VENDOR of Arm_mp or Arm_ipl64_mp
529     if(BLA_VENDOR MATCHES "_mp")
530       string(APPEND LAPACK_armpl_LIB "_mp")
531     endif()
533     check_lapack_libraries(
534       LAPACK_LIBRARIES
535       LAPACK
536       cheev
537       ""
538       "${LAPACK_armpl_LIB}"
539       ""
540       ""
541       ""
542       "${BLAS_LIBRARIES}"
543     )
544   endif()
546   # FLAME's blis library? (https://github.com/flame/blis)
547   if(NOT LAPACK_LIBRARIES
548       AND (BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All"))
549     if(_lapack_sizeof_integer EQUAL 8)
550       if(BLA_VENDOR STREQUAL "FLAME")
551         message(FATAL_ERROR "libFLAME does not support Int64 type")
552       endif()
553     else()
554       check_lapack_libraries(
555         LAPACK_LIBRARIES
556         LAPACK
557         cheev
558         ""
559         "flame"
560         ""
561         ""
562         ""
563         "${BLAS_LIBRARIES}"
564       )
565     endif()
566   endif()
568   # AOCL? (https://developer.amd.com/amd-aocl/)
569   if(NOT LAPACK_LIBRARIES
570       AND (BLA_VENDOR MATCHES "AOCL" OR BLA_VENDOR STREQUAL "All"))
571     if(_lapack_sizeof_integer EQUAL 8)
572       set(_lapack_aocl_subdir "ILP64")
573     else()
574       set(_lapack_aocl_subdir "LP64")
575     endif()
577     check_lapack_libraries(
578       LAPACK_LIBRARIES
579       LAPACK
580       cheev
581       ""
582       "flame"
583       "-fopenmp"
584       ""
585       "${_lapack_aocl_subdir}"
586       "${BLAS_LIBRARIES}"
587     )
588     unset(_lapack_aocl_subdir)
589   endif()
591   # LAPACK in SCSL library? (SGI/Cray Scientific Library)
592   if(NOT LAPACK_LIBRARIES
593       AND (BLA_VENDOR MATCHES "SCSL" OR BLA_VENDOR STREQUAL "All"))
594     set(_lapack_scsl_lib "scs")
596     if(_lapack_sizeof_integer EQUAL 8)
597       string(APPEND _lapack_scsl_lib "_i8")
598     endif()
599     # Check for OpenMP support, VIA BLA_VENDOR of scs_mp
600     if(BLA_VENDOR MATCHES "_mp")
601       string(APPEND _lapack_scsl_lib "_mp")
602     endif()
604     check_lapack_libraries(
605       LAPACK_LIBRARIES
606       LAPACK
607       cheev
608       ""
609       "${_lapack_scsl_lib}"
610       ""
611       ""
612       ""
613       "${BLAS_LIBRARIES}"
614     )
615     unset(_lapack_scsl_lib)
616   endif()
618   # BLAS in acml library?
619   if(BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All")
620     if(BLAS_LIBRARIES MATCHES ".+acml.+")
621       set(LAPACK_LIBRARIES ${BLAS_LIBRARIES})
622     endif()
623   endif()
625   # Apple LAPACK library?
626   if(NOT LAPACK_LIBRARIES
627       AND (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All"))
628     if(_lapack_sizeof_integer EQUAL 8)
629       if(BLA_VENDOR STREQUAL "Apple")
630         message(FATAL_ERROR "Accelerate Framework does not support Int64 type")
631       endif()
632     else()
633       check_lapack_libraries(
634         LAPACK_LIBRARIES
635         LAPACK
636         cheev
637         ""
638         "Accelerate"
639         ""
640         ""
641         ""
642         "${BLAS_LIBRARIES}"
643       )
644     endif()
645   endif()
647   # Apple NAS (vecLib) library?
648   if(NOT LAPACK_LIBRARIES
649       AND (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All"))
650     if(_lapack_sizeof_integer EQUAL 8)
651       if(BLA_VENDOR STREQUAL "NAS")
652         message(FATAL_ERROR "Accelerate Framework does not support Int64 type")
653       endif()
654     else()
655       check_lapack_libraries(
656         LAPACK_LIBRARIES
657         LAPACK
658         cheev
659         ""
660         "vecLib"
661         ""
662         ""
663         ""
664         "${BLAS_LIBRARIES}"
665       )
666     endif()
667   endif()
669   # Elbrus Math Library?
670   if(NOT LAPACK_LIBRARIES
671       AND (BLA_VENDOR MATCHES "EML" OR BLA_VENDOR STREQUAL "All"))
672     if(BLAS_LIBRARIES MATCHES "eml.+")
673       set(LAPACK_LIBRARIES ${BLAS_LIBRARIES})
674     endif()
675   endif()
677   # Fujitsu SSL2 Library?
678   if(NOT LAPACK_LIBRARIES
679       AND (BLA_VENDOR MATCHES "Fujitsu_SSL2" OR BLA_VENDOR STREQUAL "All"))
680     if(BLAS_LIBRARIES MATCHES "fjlapack.+")
681       set(LAPACK_LIBRARIES ${BLAS_LIBRARIES})
682       set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
683     endif()
684   endif()
686   # LAPACK in IBM ESSL library?
687   if(NOT LAPACK_LIBRARIES
688       AND (BLA_VENDOR MATCHES "IBMESSL" OR BLA_VENDOR STREQUAL "All"))
689     if(BLAS_LIBRARIES MATCHES "essl.+")
690       set(LAPACK_LIBRARIES ${BLAS_LIBRARIES})
691     endif()
692   endif()
694   # NVHPC Library?
696   if(NOT LAPACK_LIBRARIES
697       AND (BLA_VENDOR MATCHES "NVHPC" OR BLA_VENDOR STREQUAL "All"))
698     set(_lapack_nvhpc_lib "lapack")
700     if(_lapack_sizeof_integer EQUAL 8)
701       string(APPEND _lapack_nvhpc_lib "_ilp64")
702     elseif(_lapack_sizeof_integer EQUAL 4)
703       string(APPEND _lapack_nvhpc_lib "_lp64")
704     endif()
705     set(_lapack_nvhpc_flags)
706     if(";${CMAKE_C_COMPILER_ID};${CMAKE_CXX_COMPILER_ID};${CMAKE_Fortran_COMPILER_ID};" MATCHES ";(NVHPC|PGI);")
707       set(_lapack_nvhpc_flags "-fortranlibs")
708     endif()
710     check_lapack_libraries(
711       LAPACK_LIBRARIES
712       LAPACK
713       cheev
714       ""
715       "${_lapack_nvhpc_lib}"
716       "${_lapack_nvhpc_flags}"
717       ""
718       ""
719       "${BLAS_LIBRARIES}"
720     )
722     # an additional check for NVHPC 2020
723     # which does not have differentiation
724     # between lp64 and ilp64 modes
725     if(NOT LAPACK_LIBRARIES AND NOT _lapack_sizeof_integer EQUAL 8)
726       set(_lapack_nvhpc_lib "lapack")
728       check_lapack_libraries(
729         LAPACK_LIBRARIES
730         LAPACK
731         cheev
732         ""
733         "${_lapack_nvhpc_lib}"
734         "${_lapack_nvhpc_flags}"
735         ""
736         ""
737         "${BLAS_LIBRARIES}"
738       )
739     endif()
741     unset(_lapack_nvhpc_lib)
742     unset(_lapack_nvhpc_flags)
743   endif()
745   # Generic LAPACK library?
746   if(NOT LAPACK_LIBRARIES
747       AND (BLA_VENDOR STREQUAL "Generic"
748            OR BLA_VENDOR STREQUAL "ATLAS"
749            OR BLA_VENDOR STREQUAL "All"))
750     set(_lapack_generic_lib "lapack")
751     if(BLA_STATIC)
752       # We do not know for sure how the LAPACK reference implementation
753       # is built on this host.  Guess typical dependencies.
754       set(_lapack_generic_deps "-lgfortran;-lm")
755     else()
756       set(_lapack_generic_deps "")
757     endif()
759     if(_lapack_sizeof_integer EQUAL 8)
760       string(APPEND _lapack_generic_lib "64")
761     endif()
763     check_lapack_libraries(
764       LAPACK_LIBRARIES
765       LAPACK
766       cheev
767       ""
768       "${_lapack_generic_lib}"
769       "${_lapack_generic_deps}"
770       ""
771       ""
772       "${BLAS_LIBRARIES}"
773     )
775     unset(_lapack_generic_deps)
776     unset(_lapack_generic_lib)
777   endif()
778 endif()
780 if(BLA_F95)
781   set(LAPACK_LIBRARIES "${LAPACK95_LIBRARIES}")
782 endif()
784 if(LAPACK_NOT_FOUND_MESSAGE)
785   set(LAPACK_NOT_FOUND_MESSAGE
786     REASON_FAILURE_MESSAGE ${LAPACK_NOT_FOUND_MESSAGE})
787 endif()
788 find_package_handle_standard_args(LAPACK REQUIRED_VARS ${_lapack_fphsa_req_var}
789   ${LAPACK_NOT_FOUND_MESSAGE})
790 unset(LAPACK_NOT_FOUND_MESSAGE)
792 if(BLA_F95)
793   set(LAPACK95_FOUND ${LAPACK_FOUND})
794 endif()
796 # On compilers that implicitly link LAPACK (such as ftn, cc, and CC on Cray HPC machines)
797 # we used a placeholder for empty LAPACK_LIBRARIES to get through our logic above.
798 if(LAPACK_LIBRARIES STREQUAL "LAPACK_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
799   set(LAPACK_LIBRARIES "")
800 endif()
802 _add_lapack_target()
803 unset(_lapack_fphsa_req_var)
804 unset(_lapack_sizeof_integer)
805 unset(_LAPACK_LIBRARIES)