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