mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-19 11:18:40 +08:00
@@ -72,6 +72,12 @@ The following variables may be set to influence this module's behavior:
|
|||||||
``BLA_F95``
|
``BLA_F95``
|
||||||
if ``ON`` tries to find the BLAS95/LAPACK95 interfaces
|
if ``ON`` tries to find the BLAS95/LAPACK95 interfaces
|
||||||
|
|
||||||
|
``BLA_PREFER_PKGCONFIG``
|
||||||
|
.. versionadded:: 3.20
|
||||||
|
|
||||||
|
if set ``pkg-config`` will be used to search for a LAPACK library first
|
||||||
|
and if one is found that is preferred
|
||||||
|
|
||||||
Imported targets
|
Imported targets
|
||||||
^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
@@ -121,6 +127,26 @@ endif()
|
|||||||
include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
||||||
|
|
||||||
|
function(_add_lapack_target)
|
||||||
|
if(LAPACK_FOUND AND NOT TARGET LAPACK::LAPACK)
|
||||||
|
add_library(LAPACK::LAPACK INTERFACE IMPORTED)
|
||||||
|
set(_lapack_libs "${LAPACK_LIBRARIES}")
|
||||||
|
if(_lapack_libs AND TARGET BLAS::BLAS)
|
||||||
|
# remove the ${BLAS_LIBRARIES} from the interface and replace it
|
||||||
|
# with the BLAS::BLAS target
|
||||||
|
list(REMOVE_ITEM _lapack_libs "${BLAS_LIBRARIES}")
|
||||||
|
list(APPEND _lapack_libs BLAS::BLAS)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(_lapack_libs)
|
||||||
|
set_target_properties(LAPACK::LAPACK PROPERTIES
|
||||||
|
INTERFACE_LINK_LIBRARIES "${_lapack_libs}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
unset(_lapack_libs)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
macro(_lapack_find_library_setup)
|
macro(_lapack_find_library_setup)
|
||||||
cmake_push_check_state()
|
cmake_push_check_state()
|
||||||
set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY})
|
set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY})
|
||||||
@@ -265,6 +291,21 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE)
|
|||||||
_lapack_find_dependency(BLAS)
|
_lapack_find_dependency(BLAS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Search with pkg-config if specified
|
||||||
|
if(BLA_PREFER_PKGCONFIG)
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_check_modules(PKGC_LAPACK lapack)
|
||||||
|
if(PKGC_LAPACK_FOUND)
|
||||||
|
set(LAPACK_FOUND TRUE)
|
||||||
|
set(LAPACK_LIBRARIES "${PKGC_LAPACK_LINK_LIBRARIES}")
|
||||||
|
if (BLAS_LIBRARIES)
|
||||||
|
list(APPEND LAPACK_LIBRARIES "${BLAS_LIBRARIES}")
|
||||||
|
endif()
|
||||||
|
_add_lapack_target()
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# Search for different LAPACK distributions if BLAS is found
|
# Search for different LAPACK distributions if BLAS is found
|
||||||
if(NOT LAPACK_NOT_FOUND_MESSAGE)
|
if(NOT LAPACK_NOT_FOUND_MESSAGE)
|
||||||
set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
|
set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
|
||||||
@@ -585,21 +626,6 @@ if(LAPACK_LIBRARIES STREQUAL "LAPACK_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
|
|||||||
set(LAPACK_LIBRARIES "")
|
set(LAPACK_LIBRARIES "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LAPACK_FOUND AND NOT TARGET LAPACK::LAPACK)
|
_add_lapack_target()
|
||||||
add_library(LAPACK::LAPACK INTERFACE IMPORTED)
|
|
||||||
set(_lapack_libs "${LAPACK_LIBRARIES}")
|
|
||||||
if(_lapack_libs AND TARGET BLAS::BLAS)
|
|
||||||
# remove the ${BLAS_LIBRARIES} from the interface and replace it
|
|
||||||
# with the BLAS::BLAS target
|
|
||||||
list(REMOVE_ITEM _lapack_libs "${BLAS_LIBRARIES}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(_lapack_libs)
|
|
||||||
set_target_properties(LAPACK::LAPACK PROPERTIES
|
|
||||||
INTERFACE_LINK_LIBRARIES "${_lapack_libs}"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
unset(_lapack_libs)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
_lapack_find_library_teardown()
|
_lapack_find_library_teardown()
|
||||||
|
Reference in New Issue
Block a user