FindLAPACK.cmake 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindLAPACK
  5. ----------
  6. Find Linear Algebra PACKage (LAPACK) library
  7. This module finds an installed Fortran library that implements the
  8. LAPACK linear-algebra interface (see http://www.netlib.org/lapack/).
  9. Input Variables
  10. ^^^^^^^^^^^^^^^
  11. The following variables may be set to influence this module's behavior:
  12. ``BLA_STATIC``
  13. if ``ON`` use static linkage
  14. ``BLA_VENDOR``
  15. Set to one of the :ref:`BLAS/LAPACK Vendors` to search for BLAS only
  16. from the specified vendor. If not set, all vendors are considered.
  17. ``BLA_F95``
  18. if ``ON`` tries to find the BLAS95/LAPACK95 interfaces
  19. ``BLA_PREFER_PKGCONFIG``
  20. .. versionadded:: 3.20
  21. if set ``pkg-config`` will be used to search for a LAPACK library first
  22. and if one is found that is preferred
  23. Imported targets
  24. ^^^^^^^^^^^^^^^^
  25. This module defines the following :prop_tgt:`IMPORTED` targets:
  26. ``LAPACK::LAPACK``
  27. .. versionadded:: 3.18
  28. The libraries to use for LAPACK, if found.
  29. Result Variables
  30. ^^^^^^^^^^^^^^^^
  31. This module defines the following variables:
  32. ``LAPACK_FOUND``
  33. library implementing the LAPACK interface is found
  34. ``LAPACK_LINKER_FLAGS``
  35. uncached list of required linker flags (excluding ``-l`` and ``-L``).
  36. ``LAPACK_LIBRARIES``
  37. uncached list of libraries (using full path name) to link against
  38. to use LAPACK
  39. ``LAPACK95_LIBRARIES``
  40. uncached list of libraries (using full path name) to link against
  41. to use LAPACK95
  42. ``LAPACK95_FOUND``
  43. library implementing the LAPACK95 interface is found
  44. .. note::
  45. C, CXX or Fortran must be enabled to detect a BLAS/LAPACK library.
  46. C or CXX must be enabled to use Intel Math Kernel Library (MKL).
  47. For example, to use Intel MKL libraries and/or Intel compiler:
  48. .. code-block:: cmake
  49. set(BLA_VENDOR Intel10_64lp)
  50. find_package(LAPACK)
  51. #]=======================================================================]
  52. # The approach follows that of the ``autoconf`` macro file, ``acx_lapack.m4``
  53. # (distributed at http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html).
  54. if(CMAKE_Fortran_COMPILER_LOADED)
  55. include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake)
  56. else()
  57. include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake)
  58. endif()
  59. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  60. function(_add_lapack_target)
  61. if(LAPACK_FOUND AND NOT TARGET LAPACK::LAPACK)
  62. add_library(LAPACK::LAPACK INTERFACE IMPORTED)
  63. # Filter out redundant BLAS info and replace with the BLAS target
  64. set(_lapack_libs "${LAPACK_LIBRARIES}")
  65. set(_lapack_flags "${LAPACK_LINKER_FLAGS}")
  66. if(TARGET BLAS::BLAS)
  67. if(_lapack_libs AND BLAS_LIBRARIES)
  68. foreach(_blas_lib IN LISTS BLAS_LIBRARIES)
  69. list(REMOVE_ITEM _lapack_libs "${_blas_lib}")
  70. endforeach()
  71. endif()
  72. if(_lapack_flags AND BLAS_LINKER_FLAGS)
  73. foreach(_blas_flag IN LISTS BLAS_LINKER_FLAGS)
  74. list(REMOVE_ITEM _lapack_flags "${_blas_flag}")
  75. endforeach()
  76. endif()
  77. list(APPEND _lapack_libs BLAS::BLAS)
  78. endif()
  79. if(_lapack_libs)
  80. set_target_properties(LAPACK::LAPACK PROPERTIES
  81. INTERFACE_LINK_LIBRARIES "${_lapack_libs}"
  82. )
  83. endif()
  84. if(_lapack_flags)
  85. set_target_properties(LAPACK::LAPACK PROPERTIES
  86. INTERFACE_LINK_OPTIONS "${_lapack_flags}"
  87. )
  88. endif()
  89. endif()
  90. endfunction()
  91. # TODO: move this stuff to a separate module
  92. function(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs _blas)
  93. # This function checks for the existence of the combination of libraries
  94. # given by _list. If the combination is found, this checks whether can link
  95. # against that library combination using the name of a routine given by _name
  96. # using the linker flags given by _flags. If the combination of libraries is
  97. # found and passes the link test, ${LIBRARIES} is set to the list of complete
  98. # library paths that have been found. Otherwise, ${LIBRARIES} is set to FALSE.
  99. set(_libraries_work TRUE)
  100. set(_libraries)
  101. set(_combined_name)
  102. if(BLA_STATIC)
  103. if(WIN32)
  104. set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
  105. else()
  106. set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
  107. endif()
  108. else()
  109. if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  110. # for ubuntu's libblas3gf and liblapack3gf packages
  111. set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
  112. endif()
  113. endif()
  114. set(_extaddlibdir "${_addlibdir}")
  115. if(WIN32)
  116. list(APPEND _extaddlibdir ENV LIB)
  117. elseif(APPLE)
  118. list(APPEND _extaddlibdir ENV DYLD_LIBRARY_PATH)
  119. else()
  120. list(APPEND _extaddlibdir ENV LD_LIBRARY_PATH)
  121. endif()
  122. list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
  123. foreach(_library ${_list})
  124. if(_library MATCHES "^-")
  125. # Respect linker flags as-is (required by MKL)
  126. list(APPEND _libraries "${_library}")
  127. else()
  128. string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}")
  129. set(_combined_name ${_combined_name}_${_lib_var})
  130. if(NOT "${_deps}" STREQUAL "")
  131. set(_combined_name ${_combined_name}_deps)
  132. endif()
  133. if(_libraries_work)
  134. find_library(${_prefix}_${_lib_var}_LIBRARY
  135. NAMES ${_library}
  136. NAMES_PER_DIR
  137. PATHS ${_extaddlibdir}
  138. PATH_SUFFIXES ${_subdirs}
  139. )
  140. mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY)
  141. list(APPEND _libraries ${${_prefix}_${_lib_var}_LIBRARY})
  142. set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY})
  143. endif()
  144. endif()
  145. endforeach()
  146. foreach(_flag ${_flags})
  147. string(REGEX REPLACE "[^A-Za-z0-9]" "_" _flag_var "${_flag}")
  148. set(_combined_name ${_combined_name}_${_flag_var})
  149. endforeach()
  150. if(_libraries_work)
  151. # Test this combination of libraries.
  152. set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${_libraries} ${_blas} ${_deps})
  153. set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY})
  154. if(CMAKE_Fortran_COMPILER_LOADED)
  155. check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS)
  156. else()
  157. check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS)
  158. endif()
  159. set(CMAKE_REQUIRED_LIBRARIES)
  160. set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
  161. endif()
  162. if(_libraries_work)
  163. if("${_list}${_blas}" STREQUAL "")
  164. set(_libraries "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
  165. else()
  166. list(APPEND _libraries ${_blas} ${_deps})
  167. endif()
  168. else()
  169. set(_libraries FALSE)
  170. endif()
  171. set(${LIBRARIES} "${_libraries}" PARENT_SCOPE)
  172. endfunction()
  173. macro(_lapack_find_dependency dep)
  174. set(_lapack_quiet_arg)
  175. if(LAPACK_FIND_QUIETLY)
  176. set(_lapack_quiet_arg QUIET)
  177. endif()
  178. set(_lapack_required_arg)
  179. if(LAPACK_FIND_REQUIRED)
  180. set(_lapack_required_arg REQUIRED)
  181. endif()
  182. find_package(${dep} ${ARGN}
  183. ${_lapack_quiet_arg}
  184. ${_lapack_required_arg}
  185. )
  186. if (NOT ${dep}_FOUND)
  187. set(LAPACK_NOT_FOUND_MESSAGE "LAPACK could not be found because dependency ${dep} could not be found.")
  188. endif()
  189. set(_lapack_required_arg)
  190. set(_lapack_quiet_arg)
  191. endmacro()
  192. set(LAPACK_LINKER_FLAGS)
  193. set(LAPACK_LIBRARIES)
  194. set(LAPACK95_LIBRARIES)
  195. set(_lapack_fphsa_req_var LAPACK_LIBRARIES)
  196. # Check the language being used
  197. if(NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED))
  198. set(LAPACK_NOT_FOUND_MESSAGE
  199. "FindLAPACK requires Fortran, C, or C++ to be enabled.")
  200. endif()
  201. # Load BLAS
  202. if(NOT LAPACK_NOT_FOUND_MESSAGE)
  203. _lapack_find_dependency(BLAS)
  204. endif()
  205. # Search with pkg-config if specified
  206. if(BLA_PREFER_PKGCONFIG)
  207. find_package(PkgConfig)
  208. pkg_check_modules(PKGC_LAPACK lapack)
  209. if(PKGC_LAPACK_FOUND)
  210. set(LAPACK_FOUND TRUE)
  211. set(LAPACK_LIBRARIES "${PKGC_LAPACK_LINK_LIBRARIES}")
  212. if (BLAS_LIBRARIES)
  213. list(APPEND LAPACK_LIBRARIES "${BLAS_LIBRARIES}")
  214. endif()
  215. _add_lapack_target()
  216. return()
  217. endif()
  218. endif()
  219. # Search for different LAPACK distributions if BLAS is found
  220. if(NOT LAPACK_NOT_FOUND_MESSAGE)
  221. set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
  222. if(NOT $ENV{BLA_VENDOR} STREQUAL "")
  223. set(BLA_VENDOR $ENV{BLA_VENDOR})
  224. elseif(NOT BLA_VENDOR)
  225. set(BLA_VENDOR "All")
  226. endif()
  227. # LAPACK in the Intel MKL 10+ library?
  228. if(NOT LAPACK_LIBRARIES
  229. AND (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
  230. AND (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED))
  231. # System-specific settings
  232. if(NOT WIN32)
  233. set(LAPACK_mkl_LM "-lm")
  234. set(LAPACK_mkl_LDL "-ldl")
  235. endif()
  236. _lapack_find_dependency(Threads)
  237. if(BLA_VENDOR MATCHES "_64ilp")
  238. set(LAPACK_mkl_ILP_MODE "ilp64")
  239. else()
  240. set(LAPACK_mkl_ILP_MODE "lp64")
  241. endif()
  242. set(LAPACK_SEARCH_LIBS "")
  243. if(BLA_F95)
  244. set(LAPACK_mkl_SEARCH_SYMBOL "cheev_f95")
  245. set(_LIBRARIES LAPACK95_LIBRARIES)
  246. set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES})
  247. # old
  248. list(APPEND LAPACK_SEARCH_LIBS
  249. "mkl_lapack95")
  250. # new >= 10.3
  251. list(APPEND LAPACK_SEARCH_LIBS
  252. "mkl_intel_c")
  253. list(APPEND LAPACK_SEARCH_LIBS
  254. "mkl_lapack95_${LAPACK_mkl_ILP_MODE}")
  255. else()
  256. set(LAPACK_mkl_SEARCH_SYMBOL "cheev")
  257. set(_LIBRARIES LAPACK_LIBRARIES)
  258. set(_BLAS_LIBRARIES ${BLAS_LIBRARIES})
  259. # old and new >= 10.3
  260. list(APPEND LAPACK_SEARCH_LIBS
  261. "mkl_lapack")
  262. endif()
  263. # MKL uses a multitude of partially platform-specific subdirectories:
  264. if(BLA_VENDOR STREQUAL "Intel10_32")
  265. set(LAPACK_mkl_ARCH_NAME "ia32")
  266. else()
  267. set(LAPACK_mkl_ARCH_NAME "intel64")
  268. endif()
  269. if(WIN32)
  270. set(LAPACK_mkl_OS_NAME "win")
  271. elseif(APPLE)
  272. set(LAPACK_mkl_OS_NAME "mac")
  273. else()
  274. set(LAPACK_mkl_OS_NAME "lin")
  275. endif()
  276. if(DEFINED ENV{MKLROOT})
  277. file(TO_CMAKE_PATH "$ENV{MKLROOT}" LAPACK_mkl_MKLROOT)
  278. # If MKLROOT points to the subdirectory 'mkl', use the parent directory instead
  279. # so we can better detect other relevant libraries in 'compiler' or 'tbb':
  280. get_filename_component(LAPACK_mkl_MKLROOT_LAST_DIR "${LAPACK_mkl_MKLROOT}" NAME)
  281. if(LAPACK_mkl_MKLROOT_LAST_DIR STREQUAL "mkl")
  282. get_filename_component(LAPACK_mkl_MKLROOT "${LAPACK_mkl_MKLROOT}" DIRECTORY)
  283. endif()
  284. endif()
  285. set(LAPACK_mkl_LIB_PATH_SUFFIXES
  286. "compiler/lib" "compiler/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}"
  287. "compiler/lib/${LAPACK_mkl_ARCH_NAME}"
  288. "mkl/lib" "mkl/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}"
  289. "mkl/lib/${LAPACK_mkl_ARCH_NAME}"
  290. "lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}")
  291. # First try empty lapack libs
  292. if(NOT ${_LIBRARIES})
  293. check_lapack_libraries(
  294. ${_LIBRARIES}
  295. LAPACK
  296. ${LAPACK_mkl_SEARCH_SYMBOL}
  297. ""
  298. ""
  299. "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}"
  300. "${LAPACK_mkl_MKLROOT}"
  301. "${LAPACK_mkl_LIB_PATH_SUFFIXES}"
  302. "${_BLAS_LIBRARIES}"
  303. )
  304. endif()
  305. # Then try the search libs
  306. foreach(IT ${LAPACK_SEARCH_LIBS})
  307. string(REPLACE " " ";" SEARCH_LIBS ${IT})
  308. if(NOT ${_LIBRARIES})
  309. check_lapack_libraries(
  310. ${_LIBRARIES}
  311. LAPACK
  312. ${LAPACK_mkl_SEARCH_SYMBOL}
  313. ""
  314. "${SEARCH_LIBS}"
  315. "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}"
  316. "${LAPACK_mkl_MKLROOT}"
  317. "${LAPACK_mkl_LIB_PATH_SUFFIXES}"
  318. "${_BLAS_LIBRARIES}"
  319. )
  320. endif()
  321. endforeach()
  322. unset(LAPACK_mkl_ILP_MODE)
  323. unset(LAPACK_mkl_SEARCH_SYMBOL)
  324. unset(LAPACK_mkl_LM)
  325. unset(LAPACK_mkl_LDL)
  326. unset(LAPACK_mkl_MKLROOT)
  327. unset(LAPACK_mkl_ARCH_NAME)
  328. unset(LAPACK_mkl_OS_NAME)
  329. unset(LAPACK_mkl_LIB_PATH_SUFFIXES)
  330. endif()
  331. # gotoblas? (http://www.tacc.utexas.edu/tacc-projects/gotoblas2)
  332. if(NOT LAPACK_LIBRARIES
  333. AND (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All"))
  334. check_lapack_libraries(
  335. LAPACK_LIBRARIES
  336. LAPACK
  337. cheev
  338. ""
  339. "goto2"
  340. ""
  341. ""
  342. ""
  343. "${BLAS_LIBRARIES}"
  344. )
  345. endif()
  346. # FlexiBLAS? (http://www.mpi-magdeburg.mpg.de/mpcsc/software/FlexiBLAS/)
  347. if(NOT LAPACK_LIBRARIES
  348. AND (BLA_VENDOR STREQUAL "FlexiBLAS" OR BLA_VENDOR STREQUAL "All"))
  349. check_lapack_libraries(
  350. LAPACK_LIBRARIES
  351. LAPACK
  352. cheev
  353. ""
  354. "flexiblas"
  355. ""
  356. ""
  357. ""
  358. "${BLAS_LIBRARIES}"
  359. )
  360. endif()
  361. # OpenBLAS? (http://www.openblas.net)
  362. if(NOT LAPACK_LIBRARIES
  363. AND (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All"))
  364. check_lapack_libraries(
  365. LAPACK_LIBRARIES
  366. LAPACK
  367. cheev
  368. ""
  369. "openblas"
  370. ""
  371. ""
  372. ""
  373. "${BLAS_LIBRARIES}"
  374. )
  375. endif()
  376. # ArmPL? (https://developer.arm.com/tools-and-software/server-and-hpc/compile/arm-compiler-for-linux/arm-performance-libraries)
  377. if(NOT LAPACK_LIBRARIES
  378. AND (BLA_VENDOR MATCHES "Arm" OR BLA_VENDOR STREQUAL "All"))
  379. # Check for 64bit Integer support
  380. if(BLA_VENDOR MATCHES "_ilp64")
  381. set(LAPACK_armpl_LIB "armpl_ilp64")
  382. else()
  383. set(LAPACK_armpl_LIB "armpl_lp64")
  384. endif()
  385. # Check for OpenMP support, VIA BLA_VENDOR of Arm_mp or Arm_ipl64_mp
  386. if(BLA_VENDOR MATCHES "_mp")
  387. set(LAPACK_armpl_LIB "${LAPACK_armpl_LIB}_mp")
  388. endif()
  389. check_lapack_libraries(
  390. LAPACK_LIBRARIES
  391. LAPACK
  392. cheev
  393. ""
  394. "${LAPACK_armpl_LIB}"
  395. ""
  396. ""
  397. ""
  398. "${BLAS_LIBRARIES}"
  399. )
  400. endif()
  401. # FLAME's blis library? (https://github.com/flame/blis)
  402. if(NOT LAPACK_LIBRARIES
  403. AND (BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All"))
  404. check_lapack_libraries(
  405. LAPACK_LIBRARIES
  406. LAPACK
  407. cheev
  408. ""
  409. "flame"
  410. ""
  411. ""
  412. ""
  413. "${BLAS_LIBRARIES}"
  414. )
  415. endif()
  416. # BLAS in acml library?
  417. if(BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All")
  418. if(BLAS_LIBRARIES MATCHES ".+acml.+")
  419. set(LAPACK_LIBRARIES ${BLAS_LIBRARIES})
  420. endif()
  421. endif()
  422. # Apple LAPACK library?
  423. if(NOT LAPACK_LIBRARIES
  424. AND (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All"))
  425. check_lapack_libraries(
  426. LAPACK_LIBRARIES
  427. LAPACK
  428. cheev
  429. ""
  430. "Accelerate"
  431. ""
  432. ""
  433. ""
  434. "${BLAS_LIBRARIES}"
  435. )
  436. endif()
  437. # Apple NAS (vecLib) library?
  438. if(NOT LAPACK_LIBRARIES
  439. AND (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All"))
  440. check_lapack_libraries(
  441. LAPACK_LIBRARIES
  442. LAPACK
  443. cheev
  444. ""
  445. "vecLib"
  446. ""
  447. ""
  448. ""
  449. "${BLAS_LIBRARIES}"
  450. )
  451. endif()
  452. # Elbrus Math Library?
  453. if(NOT LAPACK_LIBRARIES
  454. AND (BLA_VENDOR MATCHES "EML" OR BLA_VENDOR STREQUAL "All"))
  455. set(LAPACK_EML_LIB "eml")
  456. # Check for OpenMP support, VIA BLA_VENDOR of eml_mt
  457. if(BLA_VENDOR MATCHES "_mt")
  458. set(LAPACK_EML_LIB "${LAPACK_EML_LIB}_mt")
  459. endif()
  460. check_lapack_libraries(
  461. LAPACK_LIBRARIES
  462. LAPACK
  463. cheev
  464. ""
  465. "${LAPACK_EML_LIB}"
  466. ""
  467. ""
  468. ""
  469. "${BLAS_LIBRARIES}"
  470. )
  471. endif()
  472. # Fujitsu SSL2 Library?
  473. if(NOT LAPACK_LIBRARIES
  474. AND BLA_VENDOR MATCHES "Fujitsu_SSL2" OR BLA_VENDOR STREQUAL "All")
  475. if(BLA_VENDOR STREQUAL "Fujitsu_SSL2BLAMP")
  476. set(_ssl2_suffix BLAMP)
  477. else()
  478. set(_ssl2_suffix)
  479. endif()
  480. set(_ssl2_blas)
  481. if(BLAS_LIBRARIES STREQUAL "")
  482. set(_ssl2_blas "${BLAS_LINKER_FLAGS}")
  483. else()
  484. set(_ssl2_blas "${BLAS_LIBRARIES} ${BLAS_LINKER_FLAGS}")
  485. endif()
  486. check_lapack_libraries(
  487. LAPACK_LIBRARIES
  488. LAPACK
  489. cheev
  490. "-SSL2${_ssl2_suffix}"
  491. ""
  492. ""
  493. ""
  494. ""
  495. "${_ssl2_blas}"
  496. )
  497. if(LAPACK_LIBRARIES)
  498. set(LAPACK_LINKER_FLAGS "-SSL2${_ssl2_suffix}")
  499. set(_lapack_fphsa_req_var LAPACK_LINKER_FLAGS)
  500. endif()
  501. unset(_ssl2_suffix)
  502. endif()
  503. # NVHPC Library?
  504. if(NOT LAPACK_LIBRARIES
  505. AND BLA_VENDOR MATCHES "NVHPC" OR BLA_VENDOR STREQUAL "All")
  506. check_lapack_libraries(
  507. LAPACK_LIBRARIES
  508. LAPACK
  509. cheev
  510. ""
  511. "lapack"
  512. "-fortranlibs"
  513. ""
  514. ""
  515. "${BLAS_LIBRARIES}"
  516. )
  517. endif()
  518. # Generic LAPACK library?
  519. if(NOT LAPACK_LIBRARIES
  520. AND (BLA_VENDOR STREQUAL "Generic"
  521. OR BLA_VENDOR STREQUAL "ATLAS"
  522. OR BLA_VENDOR STREQUAL "All"))
  523. if(BLA_STATIC)
  524. # We do not know for sure how the LAPACK reference implementation
  525. # is built on this host. Guess typical dependencies.
  526. set(_lapack_generic_deps "-lgfortran;-lm")
  527. else()
  528. set(_lapack_generic_deps "")
  529. endif()
  530. check_lapack_libraries(
  531. LAPACK_LIBRARIES
  532. LAPACK
  533. cheev
  534. ""
  535. "lapack"
  536. "${_lapack_generic_deps}"
  537. ""
  538. ""
  539. "${BLAS_LIBRARIES}"
  540. )
  541. unset(_lapack_generic_deps)
  542. endif()
  543. endif()
  544. if(BLA_F95)
  545. set(LAPACK_LIBRARIES "${LAPACK95_LIBRARIES}")
  546. endif()
  547. if(LAPACK_NOT_FOUND_MESSAGE)
  548. set(LAPACK_NOT_FOUND_MESSAGE
  549. REASON_FAILURE_MESSAGE ${LAPACK_NOT_FOUND_MESSAGE})
  550. endif()
  551. find_package_handle_standard_args(LAPACK REQUIRED_VARS ${_lapack_fphsa_req_var}
  552. ${LAPACK_NOT_FOUND_MESSAGE})
  553. unset(LAPACK_NOT_FOUND_MESSAGE)
  554. if(BLA_F95)
  555. set(LAPACK95_FOUND ${LAPACK_FOUND})
  556. endif()
  557. # On compilers that implicitly link LAPACK (such as ftn, cc, and CC on Cray HPC machines)
  558. # we used a placeholder for empty LAPACK_LIBRARIES to get through our logic above.
  559. if(LAPACK_LIBRARIES STREQUAL "LAPACK_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
  560. set(LAPACK_LIBRARIES "")
  561. endif()
  562. _add_lapack_target()