diff --git a/ports/clapack/FindLAPACK.cmake b/ports/clapack/FindLAPACK.cmake index 0ab751a1d97f88..0ad0d579658429 100644 --- a/ports/clapack/FindLAPACK.cmake +++ b/ports/clapack/FindLAPACK.cmake @@ -70,53 +70,56 @@ include(${CMAKE_ROOT}/Modules/CMakeFindDependencyMacro.cmake) set(CLAPACK_VERSION "3.2.1") +set(CMAKE_THREAD_PREFER_PTHREAD TRUE) +find_dependency(Threads) + if(UNIX) find_library(ADDITIONAL_LAPACK_LIBRARY m) + set(PTHREAD_LINK_NAME "-pthread") endif() -set(CMAKE_THREAD_PREFER_PTHREAD TRUE) -find_dependency(Threads) - if(NOT F2C_LIBRARY) find_library(F2C_LIBRARY_RELEASE NAMES f2c libf2c) find_library(F2C_LIBRARY_DEBUG NAMES f2cd libf2cd) + select_library_configurations(F2C) + + #keep a list of "pure" f2c libs, without dependencies set(oF2C_LIBRARY_RELEASE ${F2C_LIBRARY_RELEASE}) set(oF2C_LIBRARY_DEBUG ${F2C_LIBRARY_DEBUG}) - list(APPEND F2C_LIBRARY_RELEASE ${ADDITIONAL_LAPACK_LIBRARY}) - list(APPEND F2C_LIBRARY_DEBUG ${ADDITIONAL_LAPACK_LIBRARY}) - select_library_configurations(oF2C) - select_library_configurations(F2C) + set(oF2C_LIBRARY ${F2C_LIBRARY}) + + list(APPEND F2C_LIBRARY ${ADDITIONAL_LAPACK_LIBRARY}) endif() if(NOT LAPACK_LIBRARY) find_library(LAPACK_LIBRARY_RELEASE NAMES lapack) find_library(LAPACK_LIBRARY_DEBUG NAMES lapackd) + + #keep a list of "pure" lapack libs, without dependencies set(oLAPACK_LIBRARY_RELEASE ${LAPACK_LIBRARY_RELEASE}) set(oLAPACK_LIBRARY_DEBUG ${LAPACK_LIBRARY_DEBUG}) + select_library_configurations(oLAPACK) + list(APPEND LAPACK_LIBRARY_RELEASE ${F2C_LIBRARY_RELEASE}) list(APPEND LAPACK_LIBRARY_DEBUG ${F2C_LIBRARY_DEBUG}) - if(UNIX AND NOT APPLE) - find_dependency(OpenBLAS) - find_dependency(Threads) + find_dependency(OpenBLAS) + get_property(_loc TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_IMPLIB_RELEASE) + if(NOT _loc) get_property(_loc TARGET OpenBLAS::OpenBLAS PROPERTY LOCATION_RELEASE) - set(LAPACK_BLAS_LIBRARY_RELEASE ${_loc}) - set(oLAPACK_BLAS_LIBRARY_RELEASE ${_loc}) + endif() + set(LAPACK_BLAS_LIBRARY_RELEASE ${_loc}) + get_property(_loc TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_IMPLIB_DEBUG) + if(NOT _loc) get_property(_loc TARGET OpenBLAS::OpenBLAS PROPERTY LOCATION_DEBUG) - set(LAPACK_BLAS_LIBRARY_DEBUG ${_loc}) - set(oLAPACK_BLAS_LIBRARY_DEBUG ${_loc}) - list(APPEND LAPACK_LIBRARY_RELEASE ${LAPACK_BLAS_LIBRARY_RELEASE} Threads::Threads) - list(APPEND LAPACK_LIBRARY_DEBUG ${LAPACK_BLAS_LIBRARY_DEBUG} Threads::Threads) - select_library_configurations(oLAPACK_BLAS) - select_library_configurations(LAPACK_BLAS) - else() - find_dependency(BLAS) - set(LAPACK_LIBRARY_RELEASE ${BLAS_LIBRARIES}) - set(LAPACK_LIBRARY_DEBUG ${BLAS_LIBRARIES}) endif() + set(LAPACK_BLAS_LIBRARY_DEBUG ${_loc}) + select_library_configurations(LAPACK_BLAS) + list(APPEND LAPACK_LIBRARY_RELEASE ${LAPACK_BLAS_LIBRARY_RELEASE}) + list(APPEND LAPACK_LIBRARY_DEBUG ${LAPACK_BLAS_LIBRARY_DEBUG}) - select_library_configurations(oLAPACK) select_library_configurations(LAPACK) + list(APPEND LAPACK_LIBRARY Threads::Threads) endif() if(NOT F2C_INCLUDE_DIR) @@ -128,6 +131,7 @@ if(NOT LAPACK_INCLUDE_DIR) endif() list(APPEND LAPACK_INCLUDE_DIR ${F2C_INCLUDE_DIR}) +set(LAPACK_INCLUDE_DIR "${LAPACK_INCLUDE_DIR}" CACHE PATH "" FORCE) set(LAPACK_INCLUDE_DIRS "${LAPACK_INCLUDE_DIR}" CACHE PATH "" FORCE) set(CLAPACK_INCLUDE_DIR "${LAPACK_INCLUDE_DIR}" CACHE PATH "" FORCE) set(CLAPACK_INCLUDE_DIRS "${LAPACK_INCLUDE_DIR}" CACHE PATH "" FORCE) @@ -169,9 +173,9 @@ if(CLAPACK_FOUND AND NOT TARGET clapack::clapack) add_library(clapack::clapack SHARED IMPORTED) set_target_properties(clapack::clapack PROPERTIES IMPORTED_LOCATION_RELEASE "${LAPACK_LIBRARY_RELEASE_DLL}" - IMPORTED_IMPLIB "${oLAPACK_LIBRARY_RELEASE}" + IMPORTED_IMPLIB_RELEASE "${oLAPACK_LIBRARY_RELEASE}" INTERFACE_INCLUDE_DIRECTORIES "${LAPACK_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "$<$>:${oF2C_LIBRARY_RELEASE}>;$<$:${oF2C_LIBRARY_DEBUG}>;$<$>:${oLAPACK_BLAS_LIBRARY_RELEASE}>;$<$:${oLAPACK_BLAS_LIBRARY_DEBUG}>;$;$" + INTERFACE_LINK_LIBRARIES "$<$>:${oF2C_LIBRARY_RELEASE}>;$<$:${oF2C_LIBRARY_DEBUG}>;$<$>:${LAPACK_BLAS_LIBRARY_RELEASE}>;$<$:${LAPACK_BLAS_LIBRARY_DEBUG}>;$;$" IMPORTED_CONFIGURATIONS Release IMPORTED_LINK_INTERFACE_LANGUAGES "C") if(EXISTS "${LAPACK_LIBRARY_DEBUG_DLL}") @@ -185,7 +189,7 @@ if(CLAPACK_FOUND AND NOT TARGET clapack::clapack) set_target_properties(clapack::clapack PROPERTIES IMPORTED_LOCATION_RELEASE "${oLAPACK_LIBRARY_RELEASE}" INTERFACE_INCLUDE_DIRECTORIES "${LAPACK_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "$<$>:${oF2C_LIBRARY_RELEASE}>;$<$:${oF2C_LIBRARY_DEBUG}>;$<$>:${oLAPACK_BLAS_LIBRARY_RELEASE}>;$<$:${oLAPACK_BLAS_LIBRARY_DEBUG}>;$;$" + INTERFACE_LINK_LIBRARIES "$<$>:${oF2C_LIBRARY_RELEASE}>;$<$:${oF2C_LIBRARY_DEBUG}>;$<$>:${LAPACK_BLAS_LIBRARY_RELEASE}>;$<$:${LAPACK_BLAS_LIBRARY_DEBUG}>;$;$" IMPORTED_CONFIGURATIONS Release IMPORTED_LINK_INTERFACE_LANGUAGES "C") if(EXISTS "${LAPACK_LIBRARY_DEBUG}") @@ -201,9 +205,9 @@ if(CLAPACK_FOUND AND NOT TARGET lapack) add_library(lapack SHARED IMPORTED) set_target_properties(lapack PROPERTIES IMPORTED_LOCATION_RELEASE "${LAPACK_LIBRARY_RELEASE_DLL}" - IMPORTED_IMPLIB "${oLAPACK_LIBRARY_RELEASE}" + IMPORTED_IMPLIB_RELEASE "${oLAPACK_LIBRARY_RELEASE}" INTERFACE_INCLUDE_DIRECTORIES "${LAPACK_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "$<$>:${oF2C_LIBRARY_RELEASE}>;$<$:${oF2C_LIBRARY_DEBUG}>;$<$>:${oLAPACK_BLAS_LIBRARY_RELEASE}>;$<$:${oLAPACK_BLAS_LIBRARY_DEBUG}>;$;$" + INTERFACE_LINK_LIBRARIES "$<$>:${oF2C_LIBRARY_RELEASE}>;$<$:${oF2C_LIBRARY_DEBUG}>;$<$>:${LAPACK_BLAS_LIBRARY_RELEASE}>;$<$:${LAPACK_BLAS_LIBRARY_DEBUG}>;$;$" IMPORTED_CONFIGURATIONS Release IMPORTED_LINK_INTERFACE_LANGUAGES "C") if(EXISTS "${LAPACK_LIBRARY_DEBUG_DLL}") @@ -218,7 +222,7 @@ if(CLAPACK_FOUND AND NOT TARGET lapack) IMPORTED_LOCATION_RELEASE "${oLAPACK_LIBRARY_RELEASE}" INTERFACE_INCLUDE_DIRECTORIES "${LAPACK_INCLUDE_DIR}" IMPORTED_CONFIGURATIONS Release - INTERFACE_LINK_LIBRARIES "$<$>:${oF2C_LIBRARY_RELEASE}>;$<$:${oF2C_LIBRARY_DEBUG}>;$<$>:${oLAPACK_BLAS_LIBRARY_RELEASE}>;$<$:${oLAPACK_BLAS_LIBRARY_DEBUG}>;$;$" + INTERFACE_LINK_LIBRARIES "$<$>:${oF2C_LIBRARY_RELEASE}>;$<$:${oF2C_LIBRARY_DEBUG}>;$<$>:${LAPACK_BLAS_LIBRARY_RELEASE}>;$<$:${LAPACK_BLAS_LIBRARY_DEBUG}>;$;$" IMPORTED_LINK_INTERFACE_LANGUAGES "C") if(EXISTS "${LAPACK_LIBRARY_DEBUG}") set_property(TARGET lapack APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug) diff --git a/ports/openblas/vcpkg-cmake-wrapper.cmake b/ports/openblas/vcpkg-cmake-wrapper.cmake index 9178836b3ba7e8..94cfc6e8bf9d9c 100644 --- a/ports/openblas/vcpkg-cmake-wrapper.cmake +++ b/ports/openblas/vcpkg-cmake-wrapper.cmake @@ -5,6 +5,8 @@ list(REMOVE_ITEM ARGS "NO_MODULE") list(REMOVE_ITEM ARGS "CONFIG") list(REMOVE_ITEM ARGS "MODULE") if(NOT BLAS_LIBRARY OR BLAS_LIBRARIES OR OpenBLAS_LIBRARY OR OpenBLAS_LIBRARIES OR BLAS_LIB OR BLAS_LIBS) + include(${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake) + _find_package(OpenBLAS CONFIG ${ARGS}) set(CMAKE_THREAD_PREFER_PTHREAD TRUE) @@ -12,9 +14,15 @@ if(NOT BLAS_LIBRARY OR BLAS_LIBRARIES OR OpenBLAS_LIBRARY OR OpenBLAS_LIBRARIES get_property(_loc TARGET OpenBLAS::OpenBLAS PROPERTY INTERFACE_INCLUDE_DIRECTORIES) set(BLAS_INCLUDE_DIR ${_loc}) - get_property(_loc TARGET OpenBLAS::OpenBLAS PROPERTY LOCATION_RELEASE) + get_property(_loc TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_IMPLIB_RELEASE) + if(NOT _loc) + get_property(_loc TARGET OpenBLAS::OpenBLAS PROPERTY LOCATION_RELEASE) + endif() set(BLAS_LIBRARY_RELEASE ${_loc}) - get_property(_loc TARGET OpenBLAS::OpenBLAS PROPERTY LOCATION_DEBUG) + get_property(_loc TARGET OpenBLAS::OpenBLAS PROPERTY IMPORTED_IMPLIB_DEBUG) + if(NOT _loc) + get_property(_loc TARGET OpenBLAS::OpenBLAS PROPERTY LOCATION_DEBUG) + endif() set(BLAS_LIBRARY_DEBUG ${_loc}) list(APPEND BLAS_LIBRARY_RELEASE Threads::Threads) list(APPEND BLAS_LIBRARY_DEBUG Threads::Threads)