FindLAPACK.cmake 19 KB

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