diff --git a/ports/armadillo/portfile.cmake b/ports/armadillo/portfile.cmake index 54295f1c244236..0e62964a18c7fd 100644 --- a/ports/armadillo/portfile.cmake +++ b/ports/armadillo/portfile.cmake @@ -28,7 +28,12 @@ vcpkg_cmake_configure( ) vcpkg_cmake_install() -vcpkg_cmake_config_fixup(CONFIG_PATH share/Armadillo/CMake) + +vcpkg_cmake_config_fixup(PACKAGE_NAME Armadillo CONFIG_PATH share/Armadillo/CMake) +vcpkg_replace_string( "${CURRENT_PACKAGES_DIR}/share/Armadillo/ArmadilloConfig.cmake" + [[include("${VCPKG_IMPORT_PREFIX}/share/Armadillo/ArmadilloLibraryDepends.cmake")]] + "include(CMakeFindDependencyMacro)\nfind_dependency(LAPACK)\ninclude(\"\${VCPKG_IMPORT_PREFIX}/share/Armadillo/ArmadilloLibraryDepends.cmake\")" + ) vcpkg_fixup_pkgconfig() vcpkg_copy_pdbs() diff --git a/ports/armadillo/vcpkg.json b/ports/armadillo/vcpkg.json index 92050bc826ace2..8500a173af19fe 100644 --- a/ports/armadillo/vcpkg.json +++ b/ports/armadillo/vcpkg.json @@ -1,6 +1,7 @@ { "name": "armadillo", "version": "12.6.6", + "port-version": 1, "description": "Armadillo is a high quality linear algebra library (matrix maths) for the C++ language, aiming towards a good balance between speed and ease of use", "homepage": "https://arma.sourceforge.net/", "license": "Apache-2.0", diff --git a/ports/blas/blas.pc.in b/ports/blas/blas.pc.in new file mode 100644 index 00000000000000..49f7f103dc1420 --- /dev/null +++ b/ports/blas/blas.pc.in @@ -0,0 +1,8 @@ +prefix=${pcfiledir}/../.. + +Name: BLAS +Description: Implementation of BLAS +Version: +Requires: @requires@ +Libs: @libs@ +Cflags: @cflags@ diff --git a/ports/blas/portfile.cmake b/ports/blas/portfile.cmake index d92af5c328163c..af565beb9d6a00 100644 --- a/ports/blas/portfile.cmake +++ b/ports/blas/portfile.cmake @@ -1,15 +1,72 @@ -SET(VCPKG_POLICY_EMPTY_PACKAGE enabled) - -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/blas") - -# Make sure BLAS can be found -vcpkg_list(SET CMAKE_IGNORE_PATH) -if(NOT DEFINED ENV{MKLROOT}) - list(APPEND CMAKE_IGNORE_PATH "${CURRENT_INSTALLED_DIR}/lib/intel64") -endif() -vcpkg_cmake_configure( - SOURCE_PATH "${CURRENT_PORT_DIR}" - OPTIONS - "-DCMAKE_PREFIX_PATH=${CURRENT_PACKAGES_DIR}" - "-DCMAKE_IGNORE_PATH=${CMAKE_IGNORE_PATH}" -) +SET(VCPKG_POLICY_EMPTY_PACKAGE enabled) + +# Due to the interaction between BLAS and LAPACK, we need to choose implementations consistent with +# each other. +# +# First, if we are on Apple, we use the Accelerate framework. +# +# Then, we prefer to use openblas and lapack-reference for blas and lapack, respectively, but +# sometimes are unable. +# +# If we are on Windows and arm or uwp, that we use gfortran as our fortran compiler creates an issue +# because there is no available libgfortran. This means ew can't use lapack-reference at all. +# +# If we are on Windows and static, there is a linking problem caused by static gfortran in the same +# link as openblas, so we have to use the blas implementation from lapack-reference. +# +# That results in roughly the following decision tree: +# +# no_libgfortran = (uwp || (windows && arm)) +# can_link_mixed_static_libgfortran = !windows || !static +# +# if (no_libgfortran) { +# return { +# "blas": "openblas", +# "lapack": "clapack" +# }; +# } else if (can_link_mixed_static_libgfortran) { +# return { +# "blas": "openblas", +# "lapack": "lapack-reference[noblas]" +# }; +# } else { +# return { +# "blas": "lapack-reference[blas]", +# "lapack": "lapack-reference[blas]" +# }; +# } +# +# Scoping this to just the 'can use openblas' question, we get: +# uwp || (windows && arm) || !windows || !static +# and for lapack-reference[blas], the DeMorgan'd inverse of that: +# !uwp && !(windows && arm) && windows && static + +if(VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_IOS) + # Use Apple's accelerate framework where available + set(BLA_VENDOR Apple) + set(requires "") + set(libs "-framework Accelerate") + set(cflags "-framework Accelerate") +elseif(VCPKG_TARGET_IS_UWP + OR (VCPKG_TARGET_IS_WINDOWS AND VCPKG_TARGET_ARCHITECTURE MATCHES "arm") + OR NOT VCPKG_TARGET_IS_WINDOWS + OR NOT (VCPKG_LIBRARY_LINKAGE STREQUAL "static")) + set(BLA_VENDOR OpenBLAS) + set(requires openblas) +else() + set(BLA_VENDOR Generic) + set(requires "blas-reference") +endif() + +configure_file("${CMAKE_CURRENT_LIST_DIR}/blas.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/blas.pc" @ONLY) +if(NOT VCPKG_BUILD_TYPE) + configure_file("${CMAKE_CURRENT_LIST_DIR}/blas.pc.in" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/blas.pc" @ONLY) +endif() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + set(BLA_STATIC ON) +else() + set(BLA_STATIC OFF) +endif() + +configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/blas/vcpkg-cmake-wrapper.cmake" @ONLY) diff --git a/ports/blas/vcpkg-cmake-wrapper.cmake b/ports/blas/vcpkg-cmake-wrapper.cmake deleted file mode 100644 index e152e8c87c3e41..00000000000000 --- a/ports/blas/vcpkg-cmake-wrapper.cmake +++ /dev/null @@ -1,9 +0,0 @@ -if(NOT DEFINED ENV{MKLROOT}) - set(z_vcpkg_blas_ignore_path "${CMAKE_IGNORE_PATH}") - list(APPEND CMAKE_IGNORE_PATH "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/intel64") -endif() -_find_package(${ARGS}) -if(NOT DEFINED ENV{MKLROOT}) - set(CMAKE_IGNORE_PATH "${z_vcpkg_blas_ignore_path}") - unset(z_vcpkg_blas_ignore_path) -endif() diff --git a/ports/blas/vcpkg-cmake-wrapper.cmake.in b/ports/blas/vcpkg-cmake-wrapper.cmake.in new file mode 100644 index 00000000000000..67b63bc3d7dc5b --- /dev/null +++ b/ports/blas/vcpkg-cmake-wrapper.cmake.in @@ -0,0 +1,9 @@ +# BLA_VENDOR and BLA_STATIC are documented at: +# * https://cmake.org/cmake/help/latest/module/FindBLAS.html +# * https://cmake.org/cmake/help/latest/module/FindLAPACK.html + +set(BLA_VENDOR @BLA_VENDOR@) +set(BLA_STATIC @BLA_STATIC@) +_find_package(${ARGS}) +unset(BLA_VENDOR) +unset(BLA_STATIC) diff --git a/ports/blas/vcpkg.json b/ports/blas/vcpkg.json index 979381198851d4..cea6737c4552bc 100644 --- a/ports/blas/vcpkg.json +++ b/ports/blas/vcpkg.json @@ -1,10 +1,21 @@ { + "$comment": "Keep the platform expressions in sync with the wrappers installed by the portfiles!", "name": "blas", - "version-date": "2023-03-25", + "version-date": "2023-04-14", "description": "Metapackage for packages which provide BLAS", "license": null, "dependencies": [ - "openblas", + { + "name": "lapack-reference", + "features": [ + "cblas" + ], + "platform": "!osx & !ios & !uwp & !(windows & arm) & windows & static" + }, + { + "name": "openblas", + "platform": "!osx & !ios & (uwp | (windows & arm) | !windows | !static)" + }, { "name": "vcpkg-cmake", "host": true diff --git a/ports/cblas/cblas.pc.in b/ports/cblas/cblas.pc.in new file mode 100644 index 00000000000000..b73e7f6f416e65 --- /dev/null +++ b/ports/cblas/cblas.pc.in @@ -0,0 +1,8 @@ +prefix=${pcfiledir}/../.. + +Name: CBLAS +Description: Implementation of CBLAS +Version: +Requires: @requires@ +Libs: @libs@ +Cflags: @cflags@ diff --git a/ports/cblas/portfile.cmake b/ports/cblas/portfile.cmake new file mode 100644 index 00000000000000..743b7f7dcbfa6c --- /dev/null +++ b/ports/cblas/portfile.cmake @@ -0,0 +1,24 @@ +SET(VCPKG_POLICY_EMPTY_PACKAGE enabled) + +# This block should be kept in sync with the port 'blas' +if(VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_IOS) + # Use Apple's accelerate framework where available + set(BLA_VENDOR Apple) + set(requires "") + set(libs "-framework Accelerate") + set(cflags "-framework Accelerate") +elseif(VCPKG_TARGET_IS_UWP + OR (VCPKG_TARGET_IS_WINDOWS AND VCPKG_TARGET_ARCHITECTURE MATCHES "arm") + OR NOT VCPKG_TARGET_IS_WINDOWS + OR NOT (VCPKG_LIBRARY_LINKAGE STREQUAL "static")) + set(BLA_VENDOR OpenBLAS) + set(requires openblas) +else() + set(BLA_VENDOR Generic) + set(requires "cblas-reference") +endif() + +configure_file("${CMAKE_CURRENT_LIST_DIR}/cblas.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/cblas.pc" @ONLY) +if(NOT VCPKG_BUILD_TYPE) + configure_file("${CMAKE_CURRENT_LIST_DIR}/cblas.pc.in" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/cblas.pc" @ONLY) +endif() diff --git a/ports/cblas/vcpkg.json b/ports/cblas/vcpkg.json new file mode 100644 index 00000000000000..76d00780a77979 --- /dev/null +++ b/ports/cblas/vcpkg.json @@ -0,0 +1,24 @@ +{ + "$comment": "Keep the platform expressions in sync with the wrappers installed by the portfiles!", + "name": "cblas", + "version-date": "2024-03-19", + "description": "Metapackage for packages which provide CBLAS", + "license": null, + "dependencies": [ + { + "name": "lapack-reference", + "features": [ + "cblas" + ], + "platform": "!osx & !ios & !uwp & !(windows & arm) & windows & static" + }, + { + "name": "openblas", + "platform": "!osx & !ios & (uwp | (windows & arm) | !windows | !static)" + }, + { + "name": "vcpkg-cmake", + "host": true + } + ] +} diff --git a/ports/clapack/FindLAPACK.cmake b/ports/clapack/FindLAPACK.cmake index 56913183d5078c..8516fc78d42052 100644 --- a/ports/clapack/FindLAPACK.cmake +++ b/ports/clapack/FindLAPACK.cmake @@ -2,246 +2,50 @@ # clapack config for vcpkg # ------------ # -# Find the clapack includes and library. +# Find clapack as a valid LAPACK implementation. # -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This script defines the following variables: -# -# ``CLAPACK_FOUND`` -# True if clapack library found -# -# ``CLAPACK_VERSION`` -# Containing the clapack version tag (manually defined) -# -# ``CLAPACK_INCLUDE_DIR`` -# Location of clapack headers -# -# ``CLAPACK_LIBRARY`` -# List of libraries to link with when using clapack -# -# Result Targets -# ^^^^^^^^^^^^^^ -# -# This script defines the following targets: -# -# ``clapack::clapack`` -# Target to use clapack -# -# Compatibility Variables -# ^^^^^^^^^^^^^^^^^^^^^^^ -# -# This script defines the following variables for compatibility reasons: -# -# ``F2C_FOUND`` -# True if f2c (fortran-to-c wrap layer) library found -# -# ``F2C_INCLUDE_DIR`` -# Location of clapack headers -# -# ``F2C_LIBRARY`` -# Library containing the fortran-to-c wrap layer, necessary for clapack and automatically included when used -# -# ``LAPACK_FOUND`` -# True if clapack library found -# -# ``LAPACK_VERSION`` -# Containing the clapack version tag (manually defined) -# -# ``LAPACK_INCLUDE_DIR`` -# Location of clapack headers -# -# ``LAPACK_LIBRARY`` -# List of libraries to link with when using clapack -# -# Compatibility Targets -# ^^^^^^^^^^^^^^ -# -# This script defines the following targets for compatibility reasons: -# -# ``lapack`` -# Target to use lapack +# The module defines the same outputs as FindLAPACK by cmake include(${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake) -include(${CMAKE_ROOT}/Modules/CheckSymbolExists.cmake) include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) -include(${CMAKE_ROOT}/Modules/CMakeFindDependencyMacro.cmake) set(CLAPACK_VERSION "3.2.1") +set(LAPACK_VERSION "${CLAPACK_VERSION}") +#set(CMAKE_THREAD_PREFER_PTHREAD TRUE) +find_package(Threads) -set(CMAKE_THREAD_PREFER_PTHREAD TRUE) -find_dependency(Threads) +find_package(clapack CONFIG REQUIRED) # This will be found ! -if(UNIX) - find_library(ADDITIONAL_LAPACK_LIBRARY m) - set(PTHREAD_LINK_NAME "-pthread") +if(NOT TARGET lapack) + message(FATAL_ERROR "Target lapack was not created by find_package(clapack)!") endif() -if(NOT F2C_LIBRARY) - find_library(F2C_LIBRARY_RELEASE NAMES f2c libf2c) - find_library(F2C_LIBRARY_DEBUG NAMES f2cd libf2cd) - select_library_configurations(F2C) +if(NOT TARGET LAPACK::LAPACK) + add_library(LAPACK::LAPACK INTERFACE IMPORTED) + target_link_libraries(LAPACK::LAPACK INTERFACE lapack) - #keep a list of "pure" f2c libs, without dependencies - set(oF2C_LIBRARY_RELEASE ${F2C_LIBRARY_RELEASE}) - set(oF2C_LIBRARY_DEBUG ${F2C_LIBRARY_DEBUG}) - set(oF2C_LIBRARY ${F2C_LIBRARY}) + set(lib_prop IMPORTED_LOCATION) + #if(@VCPKG_LIBRARY_LINKAGE@ STREQUAL "dynamic" AND WIN32) + # set(lib_prop IMPORTED_IMPLIB) + #endif() - list(APPEND F2C_LIBRARY ${ADDITIONAL_LAPACK_LIBRARY}) -endif() + get_property(LAPACK_LIBRARY_RELEASE TARGET lapack PROPERTY ${lib_prop}_RELEASE) + get_property(LAPACK_LIBRARY_DEBUG TARGET lapack PROPERTY ${lib_prop}_DEBUG) -if(NOT LAPACK_LIBRARY) - find_library(LAPACK_LIBRARY_RELEASE NAMES lapack) - find_library(LAPACK_LIBRARY_DEBUG NAMES lapackd) + get_property(LAPACK_INCLUDE_DIR TARGET lapack PROPERTY INTERFACE_INCLUDE_DIRECTORIES) # Doesn't make much sense but ok. + select_library_configurations(LAPACK) - #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}) - - 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) - 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) - 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(LAPACK) - if(UNIX) - list(APPEND LAPACK_LIBRARY ${PTHREAD_LINK_NAME}) - endif() -endif() - -if(NOT F2C_INCLUDE_DIR) - find_path(F2C_INCLUDE_DIR NAMES f2c.h) -endif() - -if(NOT LAPACK_INCLUDE_DIR) - find_path(LAPACK_INCLUDE_DIR NAMES clapack.h) -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) -set(F2C_INCLUDE_DIRS "${F2C_INCLUDE_DIR}" CACHE PATH "" FORCE) - -set(LAPACK_DLL_DIR ${LAPACK_INCLUDE_DIR}) -list(TRANSFORM LAPACK_DLL_DIR APPEND "/../bin") -message(STATUS "LAPACK_DLL_DIR: ${LAPACK_DLL_DIR}") - -if(WIN32) - find_file(LAPACK_LIBRARY_RELEASE_DLL NAMES lapack.dll PATHS ${LAPACK_DLL_DIR}) - find_file(LAPACK_LIBRARY_DEBUG_FOLDER NAMES lapackd.dll PATHS ${LAPACK_DLL_DIR}) - find_file(F2C_LIBRARY_RELEASE_DLL NAMES f2c.dll libf2c.dll PATHS ${LAPACK_DLL_DIR}) - find_file(F2C_LIBRARY_DEBUG_DLL NAMES f2cd.dll libf2cd.dll PATHS ${LAPACK_DLL_DIR}) -endif() - -set(LAPACK_BLAS_LIBRARY "${LAPACK_BLAS_LIBRARY}" CACHE STRING "" FORCE) -set(F2C_LIBRARIES "${F2C_LIBRARY}" CACHE STRING "" FORCE) -set(LAPACK_VERSION "${CLAPACK_VERSION}" CACHE STRING "" FORCE) -set(LAPACK_LIBRARIES "${LAPACK_LIBRARY}" CACHE STRING "" FORCE) -set(CLAPACK_LIBRARY "${LAPACK_LIBRARY}" CACHE STRING "" FORCE) -set(CLAPACK_LIBRARIES "${LAPACK_LIBRARY}" CACHE STRING "" FORCE) - -set(LAPACK_LIBRARY "${LAPACK_LIBRARY}" CACHE STRING "" FORCE) -set(F2C_LIBRARY "${F2C_LIBRARY}" CACHE STRING "" FORCE) -set(LAPACK_LIBRARY_RELEASE "${LAPACK_LIBRARY_RELEASE}" CACHE STRING "" FORCE) -set(LAPACK_LIBRARY_DEBUG "${LAPACK_LIBRARY_DEBUG}" CACHE STRING "" FORCE) -set(F2C_LIBRARY_RELEASE "${F2C_LIBRARY_RELEASE}" CACHE STRING "" FORCE) -set(F2C_LIBRARY_DEBUG "${F2C_LIBRARY_DEBUG}" CACHE STRING "" FORCE) - -find_package_handle_standard_args(LAPACK DEFAULT_MSG LAPACK_LIBRARY LAPACK_INCLUDE_DIR) -mark_as_advanced(LAPACK_INCLUDE_DIR LAPACK_LIBRARY) -set(CLAPACK_FOUND "${LAPACK_FOUND}" CACHE STRING "" FORCE) - -set(oF2C_LIBRARY_RELEASE "${oF2C_LIBRARY_RELEASE}" CACHE STRING "" FORCE) -set(oF2C_LIBRARY_DEBUG "${oF2C_LIBRARY_DEBUG}" CACHE STRING "" FORCE) -set(oLAPACK_LIBRARY_RELEASE "${oLAPACK_LIBRARY_RELEASE}" CACHE STRING "" FORCE) -set(oLAPACK_LIBRARY_DEBUG "${oLAPACK_LIBRARY_DEBUG}" CACHE STRING "" FORCE) -set(LAPACK_BLAS_LIBRARY_RELEASE "${LAPACK_BLAS_LIBRARY_RELEASE}" CACHE STRING "" FORCE) -set(LAPACK_BLAS_LIBRARY_DEBUG "${LAPACK_BLAS_LIBRARY_DEBUG}" CACHE STRING "" FORCE) - -#TARGETS -if(CLAPACK_FOUND AND NOT TARGET clapack::clapack) - if(EXISTS "${LAPACK_LIBRARY_RELEASE_DLL}") - add_library(clapack::clapack SHARED IMPORTED) - set_target_properties(clapack::clapack PROPERTIES - IMPORTED_LOCATION_RELEASE "${LAPACK_LIBRARY_RELEASE_DLL}" - IMPORTED_IMPLIB_RELEASE "${oLAPACK_LIBRARY_RELEASE}" - INTERFACE_INCLUDE_DIRECTORIES "${LAPACK_INCLUDE_DIR}" - 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}") - set_property(TARGET clapack::clapack APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug) - set_target_properties(clapack::clapack PROPERTIES - IMPORTED_LOCATION_DEBUG "${LAPACK_LIBRARY_DEBUG_DLL}" - IMPORTED_IMPLIB_DEBUG "${oLAPACK_LIBRARY_DEBUG}") - endif() - else() - add_library(clapack::clapack UNKNOWN IMPORTED) - 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}>;$<$>:${LAPACK_BLAS_LIBRARY_RELEASE}>;$<$:${LAPACK_BLAS_LIBRARY_DEBUG}>;$;$" - IMPORTED_CONFIGURATIONS Release - IMPORTED_LINK_INTERFACE_LANGUAGES "C") - if(EXISTS "${LAPACK_LIBRARY_DEBUG}") - set_property(TARGET clapack::clapack APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug) - set_target_properties(clapack::clapack PROPERTIES - IMPORTED_LOCATION_DEBUG "${oLAPACK_LIBRARY_DEBUG}") - endif() - endif() -endif() - -# Ensure consistency with both CMake's vanilla as well as lapack-reference's FindLAPACK.cmake module and register the LAPACK::LAPACK target -if(CLAPACK_FOUND AND NOT TARGET LAPACK::LAPACK) - if(EXISTS "${LAPACK_LIBRARY_RELEASE_DLL}") - add_library(LAPACK::LAPACK SHARED IMPORTED) - set_target_properties(LAPACK::LAPACK PROPERTIES - IMPORTED_LOCATION_RELEASE "${LAPACK_LIBRARY_RELEASE_DLL}" - IMPORTED_IMPLIB_RELEASE "${oLAPACK_LIBRARY_RELEASE}" - INTERFACE_INCLUDE_DIRECTORIES "${LAPACK_INCLUDE_DIR}" - 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}") - set_property(TARGET LAPACK::LAPACK APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug) - set_target_properties(LAPACK::LAPACK PROPERTIES - IMPORTED_LOCATION_DEBUG "${LAPACK_LIBRARY_DEBUG_DLL}" - IMPORTED_IMPLIB_DEBUG "${oLAPACK_LIBRARY_DEBUG}") - endif() - else() - add_library(LAPACK::LAPACK UNKNOWN IMPORTED) - set_target_properties(LAPACK::LAPACK PROPERTIES - IMPORTED_LOCATION_RELEASE "${oLAPACK_LIBRARY_RELEASE}" - INTERFACE_INCLUDE_DIRECTORIES "${LAPACK_INCLUDE_DIR}" - IMPORTED_CONFIGURATIONS Release - 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::LAPACK APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug) - set_target_properties(LAPACK::LAPACK PROPERTIES - IMPORTED_LOCATION_DEBUG "${oLAPACK_LIBRARY_DEBUG}") - endif() - endif() -endif() + get_property(LAPACK_LINKER_FLAGS_RELEASE TARGET lapack PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE) + get_property(LAPACK_LINKER_FLAGS_DEBUG TARGET lapack PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG) + list(TRANSFORM LAPACK_LINKER_FLAGS_DEBUG PREPEND "$<$:") + list(TRANSFORM LAPACK_LINKER_FLAGS_DEBUG APPEND ">") + list(TRANSFORM LAPACK_LINKER_FLAGS_RELEASE PREPEND "$<$>:") + list(TRANSFORM LAPACK_LINKER_FLAGS_RELEASE APPEND ">") -# Preserve backwards compatibility and also register the 'lapack' target -if(CLAPACK_FOUND AND NOT TARGET lapack) - add_library(lapack ALIAS LAPACK::LAPACK) + set(LAPACK_LIBRARIES "${LAPACK_LIBRARIES};${LAPACK_LINKER_FLAGS_DEBUG};${LAPACK_LINKER_FLAGS_RELEASE}") + set(LAPACK95_LIBRARIES "${LAPACK_LIBRARIES}") + set(LAPACK95_FOUND "TRUE") + set(LAPACK_LINKER_FLAGS "${LAPACK_LIBRARIES}") endif() +find_package_handle_standard_args(LAPACK DEFAULT_MSG LAPACK_LIBRARY LAPACK_INCLUDE_DIR ) +mark_as_advanced(LAPACK_INCLUDE_DIR LAPACK_LIBRARY) \ No newline at end of file diff --git a/ports/clapack/portfile.cmake b/ports/clapack/portfile.cmake index e956275bf5fdb6..ab670c62c3eb0f 100644 --- a/ports/clapack/portfile.cmake +++ b/ports/clapack/portfile.cmake @@ -47,7 +47,6 @@ endif() vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS - -DCMAKE_DEBUG_POSTFIX=d ${ARITH_PATH} ) @@ -60,7 +59,7 @@ vcpkg_cmake_config_fixup(CONFIG_PATH share/clapack) file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") # Install clapack wrappers. -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/lapack") -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/FindLAPACK.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/lapack") -# Handle copyright +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}/wrapper") +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/FindLAPACK.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") + file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/ports/clapack/vcpkg.json b/ports/clapack/vcpkg.json index ec85ad4f1a8f16..42091fd81abc06 100644 --- a/ports/clapack/vcpkg.json +++ b/ports/clapack/vcpkg.json @@ -1,9 +1,10 @@ { "name": "clapack", "version": "3.2.1", - "port-version": 22, + "port-version": 23, "description": "CLAPACK (f2c'ed version of LAPACK)", - "homepage": "https://www.netlib.org/clapack", + "homepage": "https://netlib.org/lapack/", + "license": null, "dependencies": [ "blas", { diff --git a/ports/lapack-reference/FindLAPACK.cmake b/ports/lapack-reference/FindLAPACK.cmake index f4d25477d8dad4..fe9b3748392b02 100644 --- a/ports/lapack-reference/FindLAPACK.cmake +++ b/ports/lapack-reference/FindLAPACK.cmake @@ -1,559 +1,559 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindLAPACK ----------- - -Find Linear Algebra PACKage (LAPACK) library - -This module finds an installed Fortran library that implements the -LAPACK linear-algebra interface (see http://www.netlib.org/lapack/). - -The approach follows that taken for the ``autoconf`` macro file, -``acx_lapack.m4`` (distributed at -http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html). - -Input Variables -^^^^^^^^^^^^^^^ - -The following variables may be set to influence this module's behavior: - -``BLA_STATIC`` - if ``ON`` use static linkage - -``BLA_VENDOR`` - If set, checks only the specified vendor, if not set checks all the - possibilities. List of vendors valid in this module: - - * ``OpenBLAS`` - * ``FLAME`` - * ``Intel10_32`` (intel mkl v10 32 bit) - * ``Intel10_64lp`` (intel mkl v10+ 64 bit, threaded code, lp64 model) - * ``Intel10_64lp_seq`` (intel mkl v10+ 64 bit, sequential code, lp64 model) - * ``Intel10_64ilp`` (intel mkl v10+ 64 bit, threaded code, ilp64 model) - * ``Intel10_64ilp_seq`` (intel mkl v10+ 64 bit, sequential code, ilp64 model) - * ``Intel10_64_dyn`` (intel mkl v10+ 64 bit, single dynamic library) - * ``Intel`` (obsolete versions of mkl 32 and 64 bit) - * ``ACML`` - * ``Apple`` - * ``NAS`` - * ``Arm`` - * ``Arm_mp`` - * ``Arm_ilp64`` - * ``Arm_ilp64_mp`` - * ``Generic`` - -``BLA_F95`` - if ``ON`` tries to find the BLAS95/LAPACK95 interfaces - -Imported targets -^^^^^^^^^^^^^^^^ - -This module defines the following :prop_tgt:`IMPORTED` target: - -``LAPACK::LAPACK`` - The libraries to use for LAPACK, if found. - -Result Variables -^^^^^^^^^^^^^^^^ - -This module defines the following variables: - -``LAPACK_FOUND`` - library implementing the LAPACK interface is found -``LAPACK_LINKER_FLAGS`` - uncached list of required linker flags (excluding ``-l`` and ``-L``). -``LAPACK_LIBRARIES`` - uncached list of libraries (using full path name) to link against - to use LAPACK -``LAPACK95_LIBRARIES`` - uncached list of libraries (using full path name) to link against - to use LAPACK95 -``LAPACK95_FOUND`` - library implementing the LAPACK95 interface is found - -.. note:: - - C, CXX or Fortran must be enabled to detect a BLAS/LAPACK library. - C or CXX must be enabled to use Intel Math Kernel Library (MKL). - - For example, to use Intel MKL libraries and/or Intel compiler: - - .. code-block:: cmake - - set(BLA_VENDOR Intel10_64lp) - find_package(LAPACK) -#]=======================================================================] - -enable_language(C) -# Check the language being used -if(NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED)) - if(LAPACK_FIND_REQUIRED) - message(FATAL_ERROR "FindLAPACK requires Fortran, C, or C++ to be enabled.") - else() - message(STATUS "Looking for LAPACK... - NOT found (Unsupported languages)") - return() - endif() -endif() - -if(CMAKE_Fortran_COMPILER_LOADED) - include(${CMAKE_ROOT}/Modules/CheckFortranFunctionExists.cmake) -else() - include(${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) -endif() -include(${CMAKE_ROOT}/Modules/CMakePushCheckState.cmake) - -cmake_push_check_state() -set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY}) - -set(LAPACK_FOUND FALSE) -set(LAPACK95_FOUND FALSE) - -# store original values for CMAKE_FIND_LIBRARY_SUFFIXES -set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) -if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .so.3gfs .so.3 .so.4 .so.5) -endif() - -# TODO: move this stuff to a separate module - -macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _addlibdir _subdirs _blas) - # This macro checks for the existence of the combination of fortran libraries - # given by _list. If the combination is found, this macro checks (using the - # Check_Fortran_Function_Exists macro) whether can link against that library - # combination using the name of a routine given by _name using the linker - # flags given by _flags. If the combination of libraries is found and passes - # the link test, LIBRARIES is set to the list of complete library paths that - # have been found. Otherwise, LIBRARIES is set to FALSE. - - # N.B. _prefix is the prefix applied to the names of all cached variables that - # are generated internally and marked advanced by this macro. - # _addlibdir is a list of additional search paths. _subdirs is a list of path - # suffixes to be used by find_library(). - - set(_libraries_work TRUE) - set(${LIBRARIES}) - set(_combined_name) - - set(_extaddlibdir "${_addlibdir}") - if(WIN32) - list(APPEND _extaddlibdir ENV LIB) - elseif(APPLE) - list(APPEND _extaddlibdir ENV DYLD_LIBRARY_PATH) - else() - list(APPEND _extaddlibdir ENV LD_LIBRARY_PATH) - endif() - list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - - foreach(_library ${_list}) - if(_library MATCHES "^-Wl,--(start|end)-group$") - # Respect linker flags like --start/end-group (required by MKL) - set(${LIBRARIES} ${${LIBRARIES}} "${_library}") - else() - set(_combined_name ${_combined_name}_${_library}) - if(_libraries_work) - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - PATHS ${_extaddlibdir} - PATH_SUFFIXES ${_subdirs} - ) - #message("DEBUG: find_library(${_library}) got ${${_prefix}_${_library}_LIBRARY}") - mark_as_advanced(${_prefix}_${_library}_LIBRARY) - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) - endif() - endif() - endforeach() - - if(_libraries_work) - # Test this combination of libraries. - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threadlibs}) - #message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") - if(CMAKE_Fortran_COMPILER_LOADED) - check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) - else() - check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) - endif() - set(CMAKE_REQUIRED_LIBRARIES) - set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) - endif() - - if(_libraries_work) - if("${_list}${_blas}" STREQUAL "") - set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") - else() - set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threadlibs}) - endif() - else() - set(${LIBRARIES} FALSE) - endif() - #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}") -endmacro() - -set(LAPACK_LINKER_FLAGS) -set(LAPACK_LIBRARIES) -set(LAPACK95_LIBRARIES) - -include(CMakeFindDependencyMacro) -find_dependency(BLAS) - -if(BLAS_FOUND) - set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS}) - if(NOT $ENV{BLA_VENDOR} STREQUAL "") - set(BLA_VENDOR $ENV{BLA_VENDOR}) - else() - if(NOT BLA_VENDOR) - set(BLA_VENDOR "All") - endif() - endif() - - # LAPACK in the Intel MKL 10+ library? - if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - if(CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) - # System-specific settings - if(NOT WIN32) - set(LAPACK_mkl_LM "-lm") - set(LAPACK_mkl_LDL "-ldl") - endif() - - if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) - find_package(Threads) - else() - find_package(Threads REQUIRED) - endif() - - if(BLA_VENDOR MATCHES "_64ilp") - set(LAPACK_mkl_ILP_MODE "ilp64") - else() - set(LAPACK_mkl_ILP_MODE "lp64") - endif() - - set(LAPACK_SEARCH_LIBS "") - - if(BLA_F95) - set(LAPACK_mkl_SEARCH_SYMBOL "cheev_f95") - set(_LIBRARIES LAPACK95_LIBRARIES) - set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) - - # old - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack95") - # new >= 10.3 - list(APPEND LAPACK_SEARCH_LIBS - "mkl_intel_c") - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack95_${LAPACK_mkl_ILP_MODE}") - else() - set(LAPACK_mkl_SEARCH_SYMBOL "cheev") - set(_LIBRARIES LAPACK_LIBRARIES) - set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) - - # old and new >= 10.3 - list(APPEND LAPACK_SEARCH_LIBS - "mkl_lapack") - endif() - - # MKL uses a multitude of partially platform-specific subdirectories: - if(BLA_VENDOR STREQUAL "Intel10_32") - set(LAPACK_mkl_ARCH_NAME "ia32") - else() - set(LAPACK_mkl_ARCH_NAME "intel64") - endif() - if(WIN32) - set(LAPACK_mkl_OS_NAME "win") - elseif(APPLE) - set(LAPACK_mkl_OS_NAME "mac") - else() - set(LAPACK_mkl_OS_NAME "lin") - endif() - if(DEFINED ENV{MKLROOT}) - file(TO_CMAKE_PATH "$ENV{MKLROOT}" LAPACK_mkl_MKLROOT) - # If MKLROOT points to the subdirectory 'mkl', use the parent directory instead - # so we can better detect other relevant libraries in 'compiler' or 'tbb': - get_filename_component(LAPACK_mkl_MKLROOT_LAST_DIR "${LAPACK_mkl_MKLROOT}" NAME) - if(LAPACK_mkl_MKLROOT_LAST_DIR STREQUAL "mkl") - get_filename_component(LAPACK_mkl_MKLROOT "${LAPACK_mkl_MKLROOT}" DIRECTORY) - endif() - endif() - set(LAPACK_mkl_LIB_PATH_SUFFIXES - "compiler/lib" "compiler/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}" - "mkl/lib" "mkl/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}" - "lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}") - - # First try empty lapack libs - if(NOT ${_LIBRARIES}) - check_lapack_libraries( - ${_LIBRARIES} - LAPACK - ${LAPACK_mkl_SEARCH_SYMBOL} - "" - "" - "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" - "${LAPACK_mkl_MKLROOT}" - "${LAPACK_mkl_LIB_PATH_SUFFIXES}" - "${_BLAS_LIBRARIES}" - ) - endif() - - # Then try the search libs - foreach(IT ${LAPACK_SEARCH_LIBS}) - string(REPLACE " " ";" SEARCH_LIBS ${IT}) - if(NOT ${_LIBRARIES}) - check_lapack_libraries( - ${_LIBRARIES} - LAPACK - ${LAPACK_mkl_SEARCH_SYMBOL} - "" - "${SEARCH_LIBS}" - "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" - "${LAPACK_mkl_MKLROOT}" - "${LAPACK_mkl_LIB_PATH_SUFFIXES}" - "${_BLAS_LIBRARIES}" - ) - endif() - endforeach() - - unset(LAPACK_mkl_ILP_MODE) - unset(LAPACK_mkl_SEARCH_SYMBOL) - unset(LAPACK_mkl_LM) - unset(LAPACK_mkl_LDL) - unset(LAPACK_mkl_MKLROOT) - unset(LAPACK_mkl_ARCH_NAME) - unset(LAPACK_mkl_OS_NAME) - unset(LAPACK_mkl_LIB_PATH_SUFFIXES) - endif() - endif() - endif() - - # gotoblas? (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) - if(BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "goto2" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() - endif() - - # OpenBLAS? (http://www.openblas.net) - if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "openblas" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() - endif() - - # ArmPL? (https://developer.arm.com/tools-and-software/server-and-hpc/compile/arm-compiler-for-linux/arm-performance-libraries) - if(BLA_VENDOR MATCHES "Arm" OR BLA_VENDOR STREQUAL "All") - - # Check for 64bit Integer support - if(BLA_VENDOR MATCHES "_ilp64") - set(LAPACK_armpl_LIB "armpl_ilp64") - else() - set(LAPACK_armpl_LIB "armpl_lp64") - endif() - - # Check for OpenMP support, VIA BLA_VENDOR of Arm_mp or Arm_ipl64_mp - if(BLA_VENDOR MATCHES "_mp") - set(LAPACK_armpl_LIB "${LAPACK_armpl_LIB}_mp") - endif() - - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "${LAPACK_armpl_LIB}" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() - endif() - - # FLAME's blis library? (https://github.com/flame/blis) - if(BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "flame" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() - endif() - - # BLAS in acml library? - if(BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All") - if(BLAS_LIBRARIES MATCHES ".+acml.+") - set(LAPACK_LIBRARIES ${BLAS_LIBRARIES}) - endif() - endif() - - # Apple LAPACK library? - if(BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "Accelerate" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() - endif() - - # Apple NAS (vecLib) library? - if(BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "vecLib" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() - endif() - - # Generic LAPACK library? - if(BLA_VENDOR STREQUAL "Generic" OR - BLA_VENDOR STREQUAL "ATLAS" OR - BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "lapack" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() - if(NOT LAPACK_LIBRARIES AND NOT WIN32) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "lapack;m;gfortran" - "" - "" - "" - "${BLAS_LIBRARIES}" - ) - endif() - endif() -else() - message(STATUS "LAPACK requires BLAS") -endif() - -if(BLA_F95) - if(LAPACK95_LIBRARIES) - set(LAPACK95_FOUND TRUE) - else() - set(LAPACK95_FOUND FALSE) - endif() - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK95_FOUND) - message(STATUS "A library with LAPACK95 API found.") - else() - if(LAPACK_FIND_REQUIRED) - message(FATAL_ERROR - "A required library with LAPACK95 API not found. Please specify library location." - ) - else() - message(STATUS - "A library with LAPACK95 API not found. Please specify library location." - ) - endif() - endif() - endif() - set(LAPACK_FOUND "${LAPACK95_FOUND}") - set(LAPACK_LIBRARIES "${LAPACK95_LIBRARIES}") -else() - if(LAPACK_LIBRARIES) - set(LAPACK_FOUND TRUE) - else() - set(LAPACK_FOUND FALSE) - endif() - - if(NOT LAPACK_FIND_QUIETLY) - if(LAPACK_FOUND) - message(STATUS "A library with LAPACK API found.") - else() - if(LAPACK_FIND_REQUIRED) - message(FATAL_ERROR - "A required library with LAPACK API not found. Please specify library location." - ) - else() - message(STATUS - "A library with LAPACK API not found. Please specify library location." - ) - endif() - endif() - endif() -endif() - -# On compilers that implicitly link LAPACK (such as ftn, cc, and CC on Cray HPC machines) -# we used a placeholder for empty LAPACK_LIBRARIES to get through our logic above. -if(LAPACK_LIBRARIES STREQUAL "LAPACK_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES") - set(LAPACK_LIBRARIES "") -endif() - -if(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}") - endif() - - if(_lapack_libs) - set_target_properties(LAPACK::LAPACK PROPERTIES - INTERFACE_LINK_LIBRARIES "${_lapack_libs}" - ) - endif() - unset(_lapack_libs) -endif() - -cmake_pop_check_state() -# restore original values for CMAKE_FIND_LIBRARY_SUFFIXES -set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindLAPACK +---------- + +Find Linear Algebra PACKage (LAPACK) library + +This module finds an installed Fortran library that implements the +LAPACK linear-algebra interface (see http://www.netlib.org/lapack/). + +The approach follows that taken for the ``autoconf`` macro file, +``acx_lapack.m4`` (distributed at +http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html). + +Input Variables +^^^^^^^^^^^^^^^ + +The following variables may be set to influence this module's behavior: + +``BLA_STATIC`` + if ``ON`` use static linkage + +``BLA_VENDOR`` + If set, checks only the specified vendor, if not set checks all the + possibilities. List of vendors valid in this module: + + * ``OpenBLAS`` + * ``FLAME`` + * ``Intel10_32`` (intel mkl v10 32 bit) + * ``Intel10_64lp`` (intel mkl v10+ 64 bit, threaded code, lp64 model) + * ``Intel10_64lp_seq`` (intel mkl v10+ 64 bit, sequential code, lp64 model) + * ``Intel10_64ilp`` (intel mkl v10+ 64 bit, threaded code, ilp64 model) + * ``Intel10_64ilp_seq`` (intel mkl v10+ 64 bit, sequential code, ilp64 model) + * ``Intel10_64_dyn`` (intel mkl v10+ 64 bit, single dynamic library) + * ``Intel`` (obsolete versions of mkl 32 and 64 bit) + * ``ACML`` + * ``Apple`` + * ``NAS`` + * ``Arm`` + * ``Arm_mp`` + * ``Arm_ilp64`` + * ``Arm_ilp64_mp`` + * ``Generic`` + +``BLA_F95`` + if ``ON`` tries to find the BLAS95/LAPACK95 interfaces + +Imported targets +^^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` target: + +``LAPACK::LAPACK`` + The libraries to use for LAPACK, if found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +``LAPACK_FOUND`` + library implementing the LAPACK interface is found +``LAPACK_LINKER_FLAGS`` + uncached list of required linker flags (excluding ``-l`` and ``-L``). +``LAPACK_LIBRARIES`` + uncached list of libraries (using full path name) to link against + to use LAPACK +``LAPACK95_LIBRARIES`` + uncached list of libraries (using full path name) to link against + to use LAPACK95 +``LAPACK95_FOUND`` + library implementing the LAPACK95 interface is found + +.. note:: + + C, CXX or Fortran must be enabled to detect a BLAS/LAPACK library. + C or CXX must be enabled to use Intel Math Kernel Library (MKL). + + For example, to use Intel MKL libraries and/or Intel compiler: + + .. code-block:: cmake + + set(BLA_VENDOR Intel10_64lp) + find_package(LAPACK) +#]=======================================================================] + +enable_language(C) +# Check the language being used +if(NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED)) + if(LAPACK_FIND_REQUIRED) + message(FATAL_ERROR "FindLAPACK requires Fortran, C, or C++ to be enabled.") + else() + message(STATUS "Looking for LAPACK... - NOT found (Unsupported languages)") + return() + endif() +endif() + +if(CMAKE_Fortran_COMPILER_LOADED) + include(${CMAKE_ROOT}/Modules/CheckFortranFunctionExists.cmake) +else() + include(${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) +endif() +include(${CMAKE_ROOT}/Modules/CMakePushCheckState.cmake) + +cmake_push_check_state() +set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY}) + +set(LAPACK_FOUND FALSE) +set(LAPACK95_FOUND FALSE) + +# store original values for CMAKE_FIND_LIBRARY_SUFFIXES +set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) +if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .so.3gfs .so.3 .so.4 .so.5) +endif() + +# TODO: move this stuff to a separate module + +macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _addlibdir _subdirs _blas) + # This macro checks for the existence of the combination of fortran libraries + # given by _list. If the combination is found, this macro checks (using the + # Check_Fortran_Function_Exists macro) whether can link against that library + # combination using the name of a routine given by _name using the linker + # flags given by _flags. If the combination of libraries is found and passes + # the link test, LIBRARIES is set to the list of complete library paths that + # have been found. Otherwise, LIBRARIES is set to FALSE. + + # N.B. _prefix is the prefix applied to the names of all cached variables that + # are generated internally and marked advanced by this macro. + # _addlibdir is a list of additional search paths. _subdirs is a list of path + # suffixes to be used by find_library(). + + set(_libraries_work TRUE) + set(${LIBRARIES}) + set(_combined_name) + + set(_extaddlibdir "${_addlibdir}") + if(WIN32) + list(APPEND _extaddlibdir ENV LIB) + elseif(APPLE) + list(APPEND _extaddlibdir ENV DYLD_LIBRARY_PATH) + else() + list(APPEND _extaddlibdir ENV LD_LIBRARY_PATH) + endif() + list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") + + foreach(_library ${_list}) + if(_library MATCHES "^-Wl,--(start|end)-group$") + # Respect linker flags like --start/end-group (required by MKL) + set(${LIBRARIES} ${${LIBRARIES}} "${_library}") + else() + set(_combined_name ${_combined_name}_${_library}) + if(_libraries_work) + find_library(${_prefix}_${_library}_LIBRARY + NAMES ${_library} + PATHS ${_extaddlibdir} + PATH_SUFFIXES ${_subdirs} + ) + #message("DEBUG: find_library(${_library}) got ${${_prefix}_${_library}_LIBRARY}") + mark_as_advanced(${_prefix}_${_library}_LIBRARY) + set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + endif() + endif() + endforeach() + + if(_libraries_work) + # Test this combination of libraries. + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threadlibs}) + #message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") + if(CMAKE_Fortran_COMPILER_LOADED) + check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) + else() + check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) + endif() + set(CMAKE_REQUIRED_LIBRARIES) + set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) + endif() + + if(_libraries_work) + if("${_list}${_blas}" STREQUAL "") + set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") + else() + set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threadlibs}) + endif() + else() + set(${LIBRARIES} FALSE) + endif() + #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}") +endmacro() + +set(LAPACK_LINKER_FLAGS) +set(LAPACK_LIBRARIES) +set(LAPACK95_LIBRARIES) + +include(CMakeFindDependencyMacro) +find_dependency(BLAS) + +if(BLAS_FOUND) + set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS}) + if(NOT $ENV{BLA_VENDOR} STREQUAL "") + set(BLA_VENDOR $ENV{BLA_VENDOR}) + else() + if(NOT BLA_VENDOR) + set(BLA_VENDOR "All") + endif() + endif() + + # LAPACK in the Intel MKL 10+ library? + if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + if(CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED) + # System-specific settings + if(NOT WIN32) + set(LAPACK_mkl_LM "-lm") + set(LAPACK_mkl_LDL "-ldl") + endif() + + if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) + find_package(Threads) + else() + find_package(Threads REQUIRED) + endif() + + if(BLA_VENDOR MATCHES "_64ilp") + set(LAPACK_mkl_ILP_MODE "ilp64") + else() + set(LAPACK_mkl_ILP_MODE "lp64") + endif() + + set(LAPACK_SEARCH_LIBS "") + + if(BLA_F95) + set(LAPACK_mkl_SEARCH_SYMBOL "cheev_f95") + set(_LIBRARIES LAPACK95_LIBRARIES) + set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES}) + + # old + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack95") + # new >= 10.3 + list(APPEND LAPACK_SEARCH_LIBS + "mkl_intel_c") + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack95_${LAPACK_mkl_ILP_MODE}") + else() + set(LAPACK_mkl_SEARCH_SYMBOL "cheev") + set(_LIBRARIES LAPACK_LIBRARIES) + set(_BLAS_LIBRARIES ${BLAS_LIBRARIES}) + + # old and new >= 10.3 + list(APPEND LAPACK_SEARCH_LIBS + "mkl_lapack") + endif() + + # MKL uses a multitude of partially platform-specific subdirectories: + if(BLA_VENDOR STREQUAL "Intel10_32") + set(LAPACK_mkl_ARCH_NAME "ia32") + else() + set(LAPACK_mkl_ARCH_NAME "intel64") + endif() + if(WIN32) + set(LAPACK_mkl_OS_NAME "win") + elseif(APPLE) + set(LAPACK_mkl_OS_NAME "mac") + else() + set(LAPACK_mkl_OS_NAME "lin") + endif() + if(DEFINED ENV{MKLROOT}) + file(TO_CMAKE_PATH "$ENV{MKLROOT}" LAPACK_mkl_MKLROOT) + # If MKLROOT points to the subdirectory 'mkl', use the parent directory instead + # so we can better detect other relevant libraries in 'compiler' or 'tbb': + get_filename_component(LAPACK_mkl_MKLROOT_LAST_DIR "${LAPACK_mkl_MKLROOT}" NAME) + if(LAPACK_mkl_MKLROOT_LAST_DIR STREQUAL "mkl") + get_filename_component(LAPACK_mkl_MKLROOT "${LAPACK_mkl_MKLROOT}" DIRECTORY) + endif() + endif() + set(LAPACK_mkl_LIB_PATH_SUFFIXES + "compiler/lib" "compiler/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}" + "mkl/lib" "mkl/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}" + "lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}") + + # First try empty lapack libs + if(NOT ${_LIBRARIES}) + check_lapack_libraries( + ${_LIBRARIES} + LAPACK + ${LAPACK_mkl_SEARCH_SYMBOL} + "" + "" + "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" + "${LAPACK_mkl_MKLROOT}" + "${LAPACK_mkl_LIB_PATH_SUFFIXES}" + "${_BLAS_LIBRARIES}" + ) + endif() + + # Then try the search libs + foreach(IT ${LAPACK_SEARCH_LIBS}) + string(REPLACE " " ";" SEARCH_LIBS ${IT}) + if(NOT ${_LIBRARIES}) + check_lapack_libraries( + ${_LIBRARIES} + LAPACK + ${LAPACK_mkl_SEARCH_SYMBOL} + "" + "${SEARCH_LIBS}" + "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}" + "${LAPACK_mkl_MKLROOT}" + "${LAPACK_mkl_LIB_PATH_SUFFIXES}" + "${_BLAS_LIBRARIES}" + ) + endif() + endforeach() + + unset(LAPACK_mkl_ILP_MODE) + unset(LAPACK_mkl_SEARCH_SYMBOL) + unset(LAPACK_mkl_LM) + unset(LAPACK_mkl_LDL) + unset(LAPACK_mkl_MKLROOT) + unset(LAPACK_mkl_ARCH_NAME) + unset(LAPACK_mkl_OS_NAME) + unset(LAPACK_mkl_LIB_PATH_SUFFIXES) + endif() + endif() + endif() + + # gotoblas? (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) + if(BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "goto2" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() + endif() + + # OpenBLAS? (http://www.openblas.net) + if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "openblas" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() + endif() + + # ArmPL? (https://developer.arm.com/tools-and-software/server-and-hpc/compile/arm-compiler-for-linux/arm-performance-libraries) + if(BLA_VENDOR MATCHES "Arm" OR BLA_VENDOR STREQUAL "All") + + # Check for 64bit Integer support + if(BLA_VENDOR MATCHES "_ilp64") + set(LAPACK_armpl_LIB "armpl_ilp64") + else() + set(LAPACK_armpl_LIB "armpl_lp64") + endif() + + # Check for OpenMP support, VIA BLA_VENDOR of Arm_mp or Arm_ipl64_mp + if(BLA_VENDOR MATCHES "_mp") + set(LAPACK_armpl_LIB "${LAPACK_armpl_LIB}_mp") + endif() + + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "${LAPACK_armpl_LIB}" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() + endif() + + # FLAME's blis library? (https://github.com/flame/blis) + if(BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "flame" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() + endif() + + # BLAS in acml library? + if(BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All") + if(BLAS_LIBRARIES MATCHES ".+acml.+") + set(LAPACK_LIBRARIES ${BLAS_LIBRARIES}) + endif() + endif() + + # Apple LAPACK library? + if(BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "Accelerate" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() + endif() + + # Apple NAS (vecLib) library? + if(BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "vecLib" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() + endif() + + # Generic LAPACK library? + if(BLA_VENDOR STREQUAL "Generic" OR + BLA_VENDOR STREQUAL "ATLAS" OR + BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "lapack" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() + if(NOT LAPACK_LIBRARIES AND NOT WIN32) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "lapack;m;gfortran" + "" + "" + "" + "${BLAS_LIBRARIES}" + ) + endif() + endif() +else() + message(STATUS "LAPACK requires BLAS") +endif() + +if(BLA_F95) + if(LAPACK95_LIBRARIES) + set(LAPACK95_FOUND TRUE) + else() + set(LAPACK95_FOUND FALSE) + endif() + if(NOT LAPACK_FIND_QUIETLY) + if(LAPACK95_FOUND) + message(STATUS "A library with LAPACK95 API found.") + else() + if(LAPACK_FIND_REQUIRED) + message(FATAL_ERROR + "A required library with LAPACK95 API not found. Please specify library location." + ) + else() + message(STATUS + "A library with LAPACK95 API not found. Please specify library location." + ) + endif() + endif() + endif() + set(LAPACK_FOUND "${LAPACK95_FOUND}") + set(LAPACK_LIBRARIES "${LAPACK95_LIBRARIES}") +else() + if(LAPACK_LIBRARIES) + set(LAPACK_FOUND TRUE) + else() + set(LAPACK_FOUND FALSE) + endif() + + if(NOT LAPACK_FIND_QUIETLY) + if(LAPACK_FOUND) + message(STATUS "A library with LAPACK API found.") + else() + if(LAPACK_FIND_REQUIRED) + message(FATAL_ERROR + "A required library with LAPACK API not found. Please specify library location." + ) + else() + message(STATUS + "A library with LAPACK API not found. Please specify library location." + ) + endif() + endif() + endif() +endif() + +# On compilers that implicitly link LAPACK (such as ftn, cc, and CC on Cray HPC machines) +# we used a placeholder for empty LAPACK_LIBRARIES to get through our logic above. +if(LAPACK_LIBRARIES STREQUAL "LAPACK_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES") + set(LAPACK_LIBRARIES "") +endif() + +if(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}") + endif() + + if(_lapack_libs) + set_target_properties(LAPACK::LAPACK PROPERTIES + INTERFACE_LINK_LIBRARIES "${_lapack_libs}" + ) + endif() + unset(_lapack_libs) +endif() + +cmake_pop_check_state() +# restore original values for CMAKE_FIND_LIBRARY_SUFFIXES +set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) diff --git a/ports/lapack-reference/portfile.cmake b/ports/lapack-reference/portfile.cmake index 1eb3401e9d1ac5..85cfc18f16b648 100644 --- a/ports/lapack-reference/portfile.cmake +++ b/ports/lapack-reference/portfile.cmake @@ -1,147 +1,159 @@ -#TODO: Features to add: -# USE_XBLAS??? extended precision blas. needs xblas -# LAPACKE should be its own PORT -# USE_OPTIMIZED_LAPACK (Probably not what we want. Does a find_package(LAPACK): probably for LAPACKE only builds _> own port?) -# LAPACKE Builds LAPACKE -# LAPACKE_WITH_TMG Build LAPACKE with tmglib routines -if(EXISTS "${CURRENT_INSTALLED_DIR}/share/clapack/copyright") - message(FATAL_ERROR "Can't build ${PORT} if clapack is installed. Please remove clapack:${TARGET_TRIPLET}, and try to install ${PORT}:${TARGET_TRIPLET} again.") -endif() - -vcpkg_minimum_required(VERSION 2022-10-12) # for ${VERSION} - -include(vcpkg_find_fortran) -SET(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) -set(VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT enabled) - -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO "Reference-LAPACK/lapack" - REF "v${VERSION}" - SHA512 fc3258b9d91a833149a68a89c5589b5113e90a8f9f41c3a73fbfccb1ecddd92d9462802c0f870f1c3dab392623452de4ef512727f5874ffdcba6a4845f78fc9a - HEAD_REF master - PATCHES - cmake-config.patch - lapacke.patch -) - -if(NOT VCPKG_TARGET_IS_WINDOWS) - set(ENV{FFLAGS} "$ENV{FFLAGS} -fPIC") -endif() - -set(CBLAS OFF) -if("cblas" IN_LIST FEATURES) - set(CBLAS ON) - if("noblas" IN_LIST FEATURES) - message(FATAL_ERROR "Cannot built feature 'cblas' together with feature 'noblas'. cblas requires blas!") - endif() -endif() - -set(USE_OPTIMIZED_BLAS OFF) -if("noblas" IN_LIST FEATURES) - set(USE_OPTIMIZED_BLAS ON) - set(pcfile "${CURRENT_INSTALLED_DIR}/lib/pkgconfig/openblas.pc") - if(EXISTS "${pcfile}") - file(CREATE_LINK "${pcfile}" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/blas.pc" COPY_ON_ERROR) - endif() - set(pcfile "${CURRENT_INSTALLED_DIR}/debug/lib/pkgconfig/openblas.pc") - if(EXISTS "${pcfile}") - file(CREATE_LINK "${pcfile}" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/blas.pc" COPY_ON_ERROR) - endif() -endif() - -set(VCPKG_CRT_LINKAGE_BACKUP ${VCPKG_CRT_LINKAGE}) -vcpkg_find_fortran(FORTRAN_CMAKE) -if(VCPKG_USE_INTERNAL_Fortran) - if(VCPKG_CRT_LINKAGE_BACKUP STREQUAL "static") - # If openblas has been built with static crt linkage we cannot use it with gfortran! - set(USE_OPTIMIZED_BLAS OFF) - #Cannot use openblas from vcpkg if we are building with gfortran here. - if("noblas" IN_LIST FEATURES) - message(FATAL_ERROR "Feature 'noblas' cannot be used without supplying an external fortran compiler") - endif() - endif() -endif() - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - OPTIONS - "-DUSE_OPTIMIZED_BLAS=${USE_OPTIMIZED_BLAS}" - "-DCMAKE_REQUIRE_FIND_PACKAGE_BLAS=${USE_OPTIMIZED_BLAS}" - "-DCBLAS=${CBLAS}" - "-DTEST_FORTRAN_COMPILER=OFF" - ${FORTRAN_CMAKE} - MAYBE_UNUSED_VARIABLES - CMAKE_REQUIRE_FIND_PACKAGE_BLAS -) - -vcpkg_cmake_install() - -vcpkg_cmake_config_fixup(PACKAGE_NAME lapack-${VERSION} CONFIG_PATH lib/cmake/lapack-${VERSION}) #Should the target path be lapack and not lapack-reference? - -set(pcfile "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/lapack.pc") -if(EXISTS "${pcfile}") - file(READ "${pcfile}" _contents) - set(_contents "prefix=${CURRENT_INSTALLED_DIR}\n${_contents}") - file(WRITE "${pcfile}" "${_contents}") -endif() -set(pcfile "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/lapack.pc") -if(EXISTS "${pcfile}") - file(READ "${pcfile}" _contents) - set(_contents "prefix=${CURRENT_INSTALLED_DIR}/debug\n${_contents}") - file(WRITE "${pcfile}" "${_contents}") -endif() -if(NOT USE_OPTIMIZED_BLAS AND NOT (VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "static")) - set(pcfile "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/blas.pc") - if(EXISTS "${pcfile}") - file(READ "${pcfile}" _contents) - set(_contents "prefix=${CURRENT_INSTALLED_DIR}\n${_contents}") - file(WRITE "${pcfile}" "${_contents}") - endif() - set(pcfile "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/blas.pc") - if(EXISTS "${pcfile}") - file(READ "${pcfile}" _contents) - set(_contents "prefix=${CURRENT_INSTALLED_DIR}/debug\n${_contents}") - file(WRITE "${pcfile}" "${_contents}") - endif() -endif() -if("cblas" IN_LIST FEATURES) - set(pcfile "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/cblas.pc") - if(EXISTS "${pcfile}") - file(READ "${pcfile}" _contents) - set(_contents "prefix=${CURRENT_INSTALLED_DIR}\n${_contents}") - file(WRITE "${pcfile}" "${_contents}") - endif() - set(pcfile "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/cblas.pc") - if(EXISTS "${pcfile}") - file(READ "${pcfile}" _contents) - set(_contents "prefix=${CURRENT_INSTALLED_DIR}/debug\n${_contents}") - file(WRITE "${pcfile}" "${_contents}") - endif() -endif() -vcpkg_fixup_pkgconfig() - -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") - -if(VCPKG_TARGET_IS_WINDOWS) - if(EXISTS "${CURRENT_PACKAGES_DIR}/lib/liblapack.lib") - file(RENAME "${CURRENT_PACKAGES_DIR}/lib/liblapack.lib" "${CURRENT_PACKAGES_DIR}/lib/lapack.lib") - endif() - if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/liblapack.lib") - file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/liblapack.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/lapack.lib") - endif() - if(NOT USE_OPTIMIZED_BLAS) - if(EXISTS "${CURRENT_PACKAGES_DIR}/lib/libblas.lib") - file(RENAME "${CURRENT_PACKAGES_DIR}/lib/libblas.lib" "${CURRENT_PACKAGES_DIR}/lib/blas.lib") - endif() - if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/libblas.lib") - file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/libblas.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/blas.lib") - endif() - endif() -endif() - -file(COPY "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/lapack") -file(COPY "${CMAKE_CURRENT_LIST_DIR}/FindLAPACK.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/lapack") - -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +#TODO: Features to add: +# USE_XBLAS??? extended precision blas. needs xblas +# LAPACKE should be its own PORT +# USE_OPTIMIZED_LAPACK (Probably not what we want. Does a find_package(LAPACK): probably for LAPACKE only builds _> own port?) +# LAPACKE Builds LAPACKE +# LAPACKE_WITH_TMG Build LAPACKE with tmglib routines +if(EXISTS "${CURRENT_INSTALLED_DIR}/share/clapack/copyright") + message(FATAL_ERROR "Can't build ${PORT} if clapack is installed. Please remove clapack:${TARGET_TRIPLET}, and try to install ${PORT}:${TARGET_TRIPLET} again.") +endif() + +vcpkg_minimum_required(VERSION 2022-10-12) # for ${VERSION} + +include(vcpkg_find_fortran) +SET(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) +set(VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT enabled) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO "Reference-LAPACK/lapack" + REF "v${VERSION}" + SHA512 fc3258b9d91a833149a68a89c5589b5113e90a8f9f41c3a73fbfccb1ecddd92d9462802c0f870f1c3dab392623452de4ef512727f5874ffdcba6a4845f78fc9a + HEAD_REF master + PATCHES + cmake-config.patch + lapacke.patch +) + +if(NOT VCPKG_TARGET_IS_WINDOWS) + set(ENV{FFLAGS} "$ENV{FFLAGS} -fPIC") # should come from toolchain +endif() + +set(CBLAS OFF) +if("cblas" IN_LIST FEATURES) + set(CBLAS ON) + if("noblas" IN_LIST FEATURES) + message(FATAL_ERROR "Cannot built feature 'cblas' together with feature 'noblas'. cblas requires blas!") + endif() +endif() + +set(USE_OPTIMIZED_BLAS OFF) +if("noblas" IN_LIST FEATURES) + set(USE_OPTIMIZED_BLAS ON) +endif() + +set(VCPKG_CRT_LINKAGE_BACKUP ${VCPKG_CRT_LINKAGE}) +vcpkg_find_fortran(FORTRAN_CMAKE) +if(VCPKG_USE_INTERNAL_Fortran) + if(VCPKG_CRT_LINKAGE_BACKUP STREQUAL "static") + # If openblas has been built with static crt linkage we cannot use it with gfortran! + set(USE_OPTIMIZED_BLAS OFF) + #Cannot use openblas from vcpkg if we are building with gfortran here. + if("noblas" IN_LIST FEATURES) + message(FATAL_ERROR "Feature 'noblas' cannot be used without supplying an external fortran compiler") + endif() + endif() +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + "-DUSE_OPTIMIZED_BLAS=${USE_OPTIMIZED_BLAS}" + "-DCMAKE_REQUIRE_FIND_PACKAGE_BLAS=${USE_OPTIMIZED_BLAS}" + "-DCBLAS=${CBLAS}" + "-DTEST_FORTRAN_COMPILER=OFF" + ${FORTRAN_CMAKE} + MAYBE_UNUSED_VARIABLES + CMAKE_REQUIRE_FIND_PACKAGE_BLAS +) + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup(PACKAGE_NAME lapack-${VERSION} CONFIG_PATH lib/cmake/lapack-${VERSION}) #Should the target path be lapack and not lapack-reference? + +set(pcfile "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/lapack.pc") +if(EXISTS "${pcfile}") + file(READ "${pcfile}" _contents) + file(WRITE "${pcfile}" "prefix=${CURRENT_INSTALLED_DIR}\n${_contents}") +endif() +set(pcfile "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/lapack.pc") +if(EXISTS "${pcfile}") + file(READ "${pcfile}" _contents) + file(WRITE "${pcfile}" "prefix=${CURRENT_INSTALLED_DIR}/debug\n${_contents}") +endif() + +if(NOT USE_OPTIMIZED_BLAS AND NOT (VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "static")) + set(pcfile "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/blas.pc") + if(EXISTS "${pcfile}") + file(READ "${pcfile}" _contents) + file(WRITE "${pcfile}" "prefix=${CURRENT_INSTALLED_DIR}\n${_contents}") + endif() + set(pcfile "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/blas.pc") + if(EXISTS "${pcfile}") + file(READ "${pcfile}" _contents) + file(WRITE "${pcfile}" "prefix=${CURRENT_INSTALLED_DIR}/debug\n${_contents}") + endif() +endif() +if("cblas" IN_LIST FEATURES) + set(pcfile "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/cblas.pc") + if(EXISTS "${pcfile}") + file(READ "${pcfile}" _contents) + file(WRITE "${pcfile}" "prefix=${CURRENT_INSTALLED_DIR}\n${_contents}") + endif() + set(pcfile "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/cblas.pc") + if(EXISTS "${pcfile}") + file(READ "${pcfile}" _contents) + file(WRITE "${pcfile}" "prefix=${CURRENT_INSTALLED_DIR}/debug\n${_contents}") + endif() +endif() +vcpkg_fixup_pkgconfig() + +file(RENAME "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/lapack.pc" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/lapack-reference.pc") +if(NOT VCPKG_BUILD_TYPE) + file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/lapack.pc" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/lapack-reference.pc") +endif() + +if(NOT "noblas" IN_LIST FEATURES) + file(RENAME "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/blas.pc" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/blas-reference.pc") + if(NOT VCPKG_BUILD_TYPE) + file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/blas.pc" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/blas-reference.pc") + endif() + if("cblas" IN_LIST FEATURES) + file(RENAME "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/cblas.pc" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/cblas-reference.pc") + if(NOT VCPKG_BUILD_TYPE) + file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/cblas.pc" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/cblas-reference.pc") + endif() + endif() +endif() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +if(VCPKG_TARGET_IS_WINDOWS) + if(EXISTS "${CURRENT_PACKAGES_DIR}/lib/liblapack.lib") + file(RENAME "${CURRENT_PACKAGES_DIR}/lib/liblapack.lib" "${CURRENT_PACKAGES_DIR}/lib/lapack.lib") + endif() + if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/liblapack.lib") + file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/liblapack.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/lapack.lib") + endif() + if(NOT USE_OPTIMIZED_BLAS) + if(EXISTS "${CURRENT_PACKAGES_DIR}/lib/libblas.lib") + file(RENAME "${CURRENT_PACKAGES_DIR}/lib/libblas.lib" "${CURRENT_PACKAGES_DIR}/lib/blas.lib") + endif() + if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/libblas.lib") + file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/libblas.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/blas.lib") + endif() + endif() +endif() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + set(BLA_STATIC ON) +else() + set(BLA_STATIC OFF) +endif() +set(BLA_VENDOR Generic) + +configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/${PORT}/wrapper/vcpkg-cmake-wrapper.cmake" @ONLY) +file(COPY "${CMAKE_CURRENT_LIST_DIR}/FindLAPACK.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/ports/lapack-reference/vcpkg-cmake-wrapper.cmake b/ports/lapack-reference/vcpkg-cmake-wrapper.cmake deleted file mode 100644 index b3a7128fff0150..00000000000000 --- a/ports/lapack-reference/vcpkg-cmake-wrapper.cmake +++ /dev/null @@ -1,11 +0,0 @@ -message(STATUS "Using VCPKG FindLAPACK from package 'lapack-reference'") -set(LAPACK_PREV_MODULE_PATH ${CMAKE_MODULE_PATH}) -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) - -list(REMOVE_ITEM ARGS "NO_MODULE") -list(REMOVE_ITEM ARGS "CONFIG") -list(REMOVE_ITEM ARGS "MODULE") - -_find_package(${ARGS}) - -set(CMAKE_MODULE_PATH ${LAPACK_PREV_MODULE_PATH}) diff --git a/ports/lapack-reference/vcpkg-cmake-wrapper.cmake.in b/ports/lapack-reference/vcpkg-cmake-wrapper.cmake.in new file mode 100644 index 00000000000000..5bf051a3aa8a51 --- /dev/null +++ b/ports/lapack-reference/vcpkg-cmake-wrapper.cmake.in @@ -0,0 +1,31 @@ +message(STATUS "Using VCPKG FindLAPACK from package 'lapack-reference'") +set(LAPACK_PREV_MODULE_PATH "${CMAKE_MODULE_PATH}") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + +list(REMOVE_ITEM ARGS "NO_MODULE") +list(REMOVE_ITEM ARGS "CONFIG") +list(REMOVE_ITEM ARGS "MODULE") + +if(@USE_OPTIMIZED_BLAS@) + _find_package(BLAS) +endif() + +# BLA_VENDOR and BLA_STATIC are documented at: +# * https://cmake.org/cmake/help/latest/module/FindBLAS.html +# * https://cmake.org/cmake/help/latest/module/FindLAPACK.html + +set(BLA_VENDOR @BLA_VENDOR@) +set(BLA_STATIC @BLA_STATIC@) +_find_package(${ARGS}) +unset(BLA_VENDOR) +unset(BLA_STATIC) + +if(@CBLAS@) + include(SelectLibraryConfigurations) + find_library(CBLAS_LIBRARY_RELEASE NAMES libcblas PATHS "${CURRENT_PACKAGES_DIR}/lib" NO_DEFAULT_PATH) + find_library(CBLAS_LIBRARY_DEBUG NAMES libcblas PATHS "${CURRENT_PACKAGES_DIR}/debug/lib" NO_DEFAULT_PATH) + select_library_configurations(CBLAS) + set(LAPACK_LIBRARIES ${CBLAS_LIBRARIES} ${LAPACK_LIBRARIES}) +endif() + +set(CMAKE_MODULE_PATH "${LAPACK_PREV_MODULE_PATH}") diff --git a/ports/lapack-reference/vcpkg.json b/ports/lapack-reference/vcpkg.json index 6f30ae7a6a5b01..fbd3cb8313abbf 100644 --- a/ports/lapack-reference/vcpkg.json +++ b/ports/lapack-reference/vcpkg.json @@ -1,9 +1,9 @@ { "name": "lapack-reference", "version": "3.11.0", - "port-version": 2, + "port-version": 3, "description": "LAPACK - Linear Algebra PACKage", - "homepage": "http://www.netlib.org/lapack/", + "homepage": "https://netlib.org/lapack/", "license": "BSD-3-Clause-Open-MPI", "dependencies": [ { @@ -41,6 +41,7 @@ }, "noblas": { "description": "Use external optimized BLAS", + "supports": "!windows | !static", "dependencies": [ "blas" ] diff --git a/ports/lapack/lapack.pc.in b/ports/lapack/lapack.pc.in new file mode 100644 index 00000000000000..055123058520b5 --- /dev/null +++ b/ports/lapack/lapack.pc.in @@ -0,0 +1,9 @@ +prefix=${pcfiledir}/../.. +libdir=${prefix}/lib + +Name: LAPACK +Description: Implementation of LAPACK +Version: +Requires: @requires@ +Libs: @libs@ +Cflags: @cflags@ diff --git a/ports/lapack/portfile.cmake b/ports/lapack/portfile.cmake index ea9381244793a8..e3feaf7460c908 100644 --- a/ports/lapack/portfile.cmake +++ b/ports/lapack/portfile.cmake @@ -1,5 +1,42 @@ -SET(VCPKG_POLICY_EMPTY_PACKAGE enabled) - -# Make sure LAPACK can be found -vcpkg_cmake_configure(SOURCE_PATH "${CURRENT_PORT_DIR}" - OPTIONS "-DCMAKE_PREFIX_PATH=${CURRENT_PACKAGES_DIR}") +SET(VCPKG_POLICY_EMPTY_PACKAGE enabled) + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + set(BLA_STATIC ON) +else() + set(BLA_STATIC OFF) +endif() + +# See explanation of which lapack implementation is chosen in portfile.cmake in the blas port + +set(BLA_VENDOR Generic) +set(installed_wrapper "${CURRENT_INSTALLED_DIR}/share/lapack/vcpkg-cmake-wrapper.cmake") +set(installed_module "${CURRENT_INSTALLED_DIR}/share/lapack/FindLAPACK.cmake") +if(VCPKG_TARGET_IS_OSX OR VCPKG_TARGET_IS_IOS) + # Use Apple's accelerate framework where available + set(BLA_VENDOR Apple) + configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in" "${CURRENT_PACKAGES_DIR}/share/lapack/vcpkg-cmake-wrapper.cmake" @ONLY) + set(libs "-framework Accelerate") + set(cflags "-framework Accelerate") + configure_file("${CMAKE_CURRENT_LIST_DIR}/lapack.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/lapack.pc" @ONLY) + if(NOT VCPKG_BUILD_TYPE) + configure_file("${CMAKE_CURRENT_LIST_DIR}/lapack.pc.in" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/lapack.pc" @ONLY) + endif() + unset(installed_module) +elseif(VCPKG_TARGET_IS_UWP OR (VCPKG_TARGET_IS_WINDOWS AND VCPKG_TARGET_ARCHITECTURE MATCHES "arm")) + configure_file("${CURRENT_INSTALLED_DIR}/share/clapack/wrapper/vcpkg-cmake-wrapper.cmake" "${CURRENT_PACKAGES_DIR}/share/lapack/vcpkg-cmake-wrapper.cmake" COPYONLY) + configure_file("${CURRENT_INSTALLED_DIR}/share/clapack/FindLAPACK.cmake" "${CURRENT_PACKAGES_DIR}/share/lapack/FindLAPACK.cmake" COPYONLY) + set(libs "-llapack -llibf2c") + configure_file("${CMAKE_CURRENT_LIST_DIR}/lapack.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/lapack.pc" @ONLY) + if(NOT VCPKG_BUILD_TYPE) + set(libs "-llapack -llibf2c") + configure_file("${CMAKE_CURRENT_LIST_DIR}/lapack.pc.in" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/lapack.pc" @ONLY) + endif() +else() + configure_file("${CURRENT_INSTALLED_DIR}/share/lapack-reference/wrapper/vcpkg-cmake-wrapper.cmake" "${CURRENT_PACKAGES_DIR}/share/lapack/vcpkg-cmake-wrapper.cmake" COPYONLY) + configure_file("${CURRENT_INSTALLED_DIR}/share/lapack-reference/FindLAPACK.cmake" "${CURRENT_PACKAGES_DIR}/share/lapack/FindLAPACK.cmake" COPYONLY) + set(requires "lapack-reference") + configure_file("${CMAKE_CURRENT_LIST_DIR}/lapack.pc.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/lapack.pc" @ONLY) + if(NOT VCPKG_BUILD_TYPE) + configure_file("${CMAKE_CURRENT_LIST_DIR}/lapack.pc.in" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/lapack.pc" @ONLY) + endif() +endif() diff --git a/ports/lapack/vcpkg-cmake-wrapper.cmake.in b/ports/lapack/vcpkg-cmake-wrapper.cmake.in new file mode 100644 index 00000000000000..04d636a2fe6551 --- /dev/null +++ b/ports/lapack/vcpkg-cmake-wrapper.cmake.in @@ -0,0 +1,10 @@ +# BLA_VENDOR and BLA_STATIC are documented at: +# * https://cmake.org/cmake/help/latest/module/FindBLAS.html +# * https://cmake.org/cmake/help/latest/module/FindLAPACK.html + +_find_package(BLAS) # Find BLAS before setting BLA_VENDOR (Will set/unset BLA_VENDOR itself) +set(BLA_VENDOR @BLA_VENDOR@) +set(BLA_STATIC @BLA_STATIC@) +_find_package(${ARGS}) +unset(BLA_VENDOR) +unset(BLA_STATIC) diff --git a/ports/lapack/vcpkg.json b/ports/lapack/vcpkg.json index 5112e419d3b1e3..2d7925d007b2fa 100644 --- a/ports/lapack/vcpkg.json +++ b/ports/lapack/vcpkg.json @@ -1,17 +1,17 @@ { + "$comment": "Keep the platform expressions in sync with the wrappers installed by the portfiles!", "name": "lapack", - "version-date": "2022-02-22", - "port-version": 2, + "version-date": "2023-06-10", "description": "Metapackage for packages which provide LAPACK", "license": null, "dependencies": [ { "name": "clapack", - "platform": "(arm & windows) | uwp" + "platform": "uwp | (arm & windows)" }, { "name": "lapack-reference", - "platform": "!((arm & windows) | uwp)" + "platform": "!osx & !ios & !uwp & !(arm & windows)" }, { "name": "vcpkg-cmake", diff --git a/ports/shogun/fix-cblas-path.patch b/ports/shogun/fix-cblas-path.patch deleted file mode 100644 index e21a3723c48a40..00000000000000 --- a/ports/shogun/fix-cblas-path.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/src/shogun/mathematics/lapack.h b/src/shogun/mathematics/lapack.h -index 6ba466f..f5de479 100644 ---- a/src/shogun/mathematics/lapack.h -+++ b/src/shogun/mathematics/lapack.h -@@ -38,7 +38,7 @@ extern "C" { - #include - #endif - #else --#include -+#include - #endif - - #ifdef HAVE_ACML diff --git a/ports/shogun/fix_accelerate_detection.patch b/ports/shogun/fix_accelerate_detection.patch new file mode 100644 index 00000000000000..90bbe9b578a893 --- /dev/null +++ b/ports/shogun/fix_accelerate_detection.patch @@ -0,0 +1,14 @@ +diff --git a/cmake/ShogunFindLAPACK.cmake b/cmake/ShogunFindLAPACK.cmake +index fe3d6db9c2..882a1f4218 100644 +--- a/cmake/ShogunFindLAPACK.cmake ++++ b/cmake/ShogunFindLAPACK.cmake +@@ -6,7 +6,8 @@ IF (LAPACK_FOUND) + SET(HAVE_LAPACK 1) + + # find out the type of Lapack/BLAS implementation we are dealing with +- IF("${LAPACK_LIBRARIES}" MATCHES ".*/Accelerate.framework$") ++ message(STATUS "LAPACK_LIBRARIES:${LAPACK_LIBRARIES}") ++ IF("${LAPACK_LIBRARIES}" MATCHES ".*/Accelerate.framework(;|$)") + # Accelerate.framework we found for LaPack/BLAS + SET(HAVE_MVEC 1) + SET(HAVE_CATLAS 1) diff --git a/ports/shogun/portfile.cmake b/ports/shogun/portfile.cmake index 9b04a2ce64943b..86375b9085d4f4 100644 --- a/ports/shogun/portfile.cmake +++ b/ports/shogun/portfile.cmake @@ -12,13 +12,31 @@ vcpkg_from_github( eigen-3.4.patch fix-dirent.patch fix-ASSERT-not-found.patch - fix-cblas-path.patch + remove_cmake_flags.patch + fix_accelerate_detection.patch ) vcpkg_find_acquire_program(PYTHON3) get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY) vcpkg_add_to_path("${PYTHON3_DIR}") +# Shogun only checks libraries for symbols and assumes everything is fine. +# However openblas requires extra includes and mkl would require extra defines +# So get the needed flags via the pkg-config files. + +x_vcpkg_pkgconfig_get_modules(PREFIX PC_BLAS_LAPACK MODULES lapack blas CFLAGS) + +string(APPEND VCPKG_C_FLAGS_RELEASE " ${PC_BLAS_LAPACK_CFLAGS_RELEASE}") +string(APPEND VCPKG_CXX_FLAGS_RELEASE " ${PC_BLAS_LAPACK_CFLAGS_RELEASE}") + +string(APPEND VCPKG_C_FLAGS_DEBUG " ${PC_BLAS_LAPACK_CFLAGS_DEBUG}") +string(APPEND VCPKG_CXX_FLAGS_DEBUG " ${PC_BLAS_LAPACK_CFLAGS_DEBUG}") + +if(VCPKG_TARGET_IS_OSX) + # Eigen3 and accelerate disagree on prototypes for lapack generating compiler errors + set(extra_opts -DENABLE_EIGEN_LAPACK=OFF) +endif() + vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS @@ -44,6 +62,7 @@ vcpkg_cmake_configure( -DCMAKE_DISABLE_FIND_PACKAGE_CURL=TRUE -DCMAKE_DISABLE_FIND_PACKAGE_OpenMP=TRUE -DINSTALL_TARGETS=shogun-static + ${extra_opts} ) vcpkg_cmake_install() diff --git a/ports/shogun/remove_cmake_flags.patch b/ports/shogun/remove_cmake_flags.patch new file mode 100644 index 00000000000000..f9adeb22ed19bb --- /dev/null +++ b/ports/shogun/remove_cmake_flags.patch @@ -0,0 +1,23 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 94c8389f96..d4d533301a 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -192,12 +192,12 @@ IF(MSVC) + # SET(CMAKE_CXX_FLAGS_DEBUG "/DEBUG /Od /Zi") + add_compile_options("/bigobj") + ELSE() +- SET(CMAKE_C_FLAGS_RELEASE "-O3 ${RELEASE_COMPILER_FLAGS}") +- SET(CMAKE_CXX_FLAGS_RELEASE "-O3 ${RELEASE_COMPILER_FLAGS}") +- SET(CMAKE_C_FLAGS_DISTRIBUTION "-O2") +- SET(CMAKE_CXX_FLAGS_DISTRIBUTION "-O2") +- SET(CMAKE_C_FLAGS_DEBUG "-g") +- SET(CMAKE_CXX_FLAGS_DEBUG "-g") ++ #SET(CMAKE_C_FLAGS_RELEASE "-O3 ${RELEASE_COMPILER_FLAGS}") ++ #SET(CMAKE_CXX_FLAGS_RELEASE "-O3 ${RELEASE_COMPILER_FLAGS}") ++ #SET(CMAKE_C_FLAGS_DISTRIBUTION "-O2") ++ #SET(CMAKE_CXX_FLAGS_DISTRIBUTION "-O2") ++ #SET(CMAKE_C_FLAGS_DEBUG "-g") ++ #SET(CMAKE_CXX_FLAGS_DEBUG "-g") + ENDIF() + + OPTION(ENABLE_COVERAGE "Enable code coverage" OFF) diff --git a/ports/shogun/vcpkg.json b/ports/shogun/vcpkg.json index 2126c253d467cd..b6b62a8c0b463b 100644 --- a/ports/shogun/vcpkg.json +++ b/ports/shogun/vcpkg.json @@ -1,7 +1,7 @@ { "name": "shogun", "version": "6.1.4", - "port-version": 9, + "port-version": 10, "description": "Unified and efficient Machine Learning", "homepage": "https://github.com/shogun-toolbox/shogun", "dependencies": [ @@ -10,6 +10,12 @@ "curl", "dirent", "eigen3", + { + "name": "hdf5", + "default-features": false, + "platform": "!windows" + }, + "lapack", "liblzma", "libxml2", "lzo", @@ -25,6 +31,10 @@ "name": "vcpkg-cmake-config", "host": true }, + { + "name": "vcpkg-pkgconfig-get-modules", + "host": true + }, "zlib" ] } diff --git a/ports/blas/CMakeLists.txt b/scripts/test_ports/blas-test/CMakeLists.txt similarity index 51% rename from ports/blas/CMakeLists.txt rename to scripts/test_ports/blas-test/CMakeLists.txt index 790f79e8baa70e..3d7ebac4028709 100644 --- a/ports/blas/CMakeLists.txt +++ b/scripts/test_ports/blas-test/CMakeLists.txt @@ -1,4 +1,6 @@ -cmake_minimum_required(VERSION 3.17) - -project(Find_BLAS_external) -find_package(BLAS REQUIRED) +cmake_minimum_required(VERSION 3.17) + +project(Find_BLAS_external) +find_package(BLAS REQUIRED) +find_package(PkgConfig REQUIRED) +pkg_check_modules(BLAS_PC REQUIRED IMPORTED_TARGET blas) diff --git a/scripts/test_ports/blas-test/portfile.cmake b/scripts/test_ports/blas-test/portfile.cmake new file mode 100644 index 00000000000000..b6904bf78302d0 --- /dev/null +++ b/scripts/test_ports/blas-test/portfile.cmake @@ -0,0 +1,5 @@ +SET(VCPKG_POLICY_EMPTY_PACKAGE enabled) + +# Make sure BLAS can be found +vcpkg_cmake_configure(SOURCE_PATH "${CURRENT_PORT_DIR}" + OPTIONS -DVCPKG_HOST_TRIPLET=${HOST_TRIPLET}) diff --git a/scripts/test_ports/blas-test/vcpkg.json b/scripts/test_ports/blas-test/vcpkg.json new file mode 100644 index 00000000000000..ab9615c3e9ef07 --- /dev/null +++ b/scripts/test_ports/blas-test/vcpkg.json @@ -0,0 +1,19 @@ +{ + "$comment": "Keep the platform expressions in sync with the wrappers installed by the portfiles!", + "name": "blas-test", + "version-date": "2022-04-22", + "description": "Metapackage for packages which provide BLAS", + "license": null, + "dependencies": [ + "blas", + { + "name": "pkgconf", + "host": true, + "platform": "windows" + }, + { + "name": "vcpkg-cmake", + "host": true + } + ] +} diff --git a/scripts/test_ports/cblas-test/CMakeLists.txt b/scripts/test_ports/cblas-test/CMakeLists.txt new file mode 100644 index 00000000000000..743ddb643d9084 --- /dev/null +++ b/scripts/test_ports/cblas-test/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.17) + +project(Find_CBLAS_external) +find_package(PkgConfig REQUIRED) +pkg_check_modules(CBLAS_PC REQUIRED IMPORTED_TARGET cblas) diff --git a/scripts/test_ports/cblas-test/portfile.cmake b/scripts/test_ports/cblas-test/portfile.cmake new file mode 100644 index 00000000000000..b6904bf78302d0 --- /dev/null +++ b/scripts/test_ports/cblas-test/portfile.cmake @@ -0,0 +1,5 @@ +SET(VCPKG_POLICY_EMPTY_PACKAGE enabled) + +# Make sure BLAS can be found +vcpkg_cmake_configure(SOURCE_PATH "${CURRENT_PORT_DIR}" + OPTIONS -DVCPKG_HOST_TRIPLET=${HOST_TRIPLET}) diff --git a/scripts/test_ports/cblas-test/vcpkg.json b/scripts/test_ports/cblas-test/vcpkg.json new file mode 100644 index 00000000000000..6b1df977ba7877 --- /dev/null +++ b/scripts/test_ports/cblas-test/vcpkg.json @@ -0,0 +1,19 @@ +{ + "$comment": "Keep the platform expressions in sync with the wrappers installed by the portfiles!", + "name": "cblas-test", + "version-date": "2022-04-22", + "description": "Metapackage for packages which provide BLAS", + "license": null, + "dependencies": [ + "cblas", + { + "name": "pkgconf", + "host": true, + "platform": "windows" + }, + { + "name": "vcpkg-cmake", + "host": true + } + ] +} diff --git a/ports/lapack/CMakeLists.txt b/scripts/test_ports/lapack-test/CMakeLists.txt similarity index 51% rename from ports/lapack/CMakeLists.txt rename to scripts/test_ports/lapack-test/CMakeLists.txt index ddd7883b1632eb..1874911a97e79a 100644 --- a/ports/lapack/CMakeLists.txt +++ b/scripts/test_ports/lapack-test/CMakeLists.txt @@ -1,4 +1,6 @@ -cmake_minimum_required(VERSION 3.17) - -project(Find_LAPACK_external) -find_package(LAPACK REQUIRED) +cmake_minimum_required(VERSION 3.17) + +project(Find_LAPACK_external) +find_package(LAPACK REQUIRED) +find_package(PkgConfig REQUIRED) +pkg_check_modules(LAPACK_PC REQUIRED IMPORTED_TARGET lapack) diff --git a/scripts/test_ports/lapack-test/portfile.cmake b/scripts/test_ports/lapack-test/portfile.cmake new file mode 100644 index 00000000000000..28b2faa0c9e33c --- /dev/null +++ b/scripts/test_ports/lapack-test/portfile.cmake @@ -0,0 +1,5 @@ +SET(VCPKG_POLICY_EMPTY_PACKAGE enabled) + +# Make sure LAPACK can be found +vcpkg_cmake_configure(SOURCE_PATH "${CURRENT_PORT_DIR}" + OPTIONS -DVCPKG_HOST_TRIPLET=${HOST_TRIPLET}) diff --git a/scripts/test_ports/lapack-test/vcpkg.json b/scripts/test_ports/lapack-test/vcpkg.json new file mode 100644 index 00000000000000..00c2832d328cf3 --- /dev/null +++ b/scripts/test_ports/lapack-test/vcpkg.json @@ -0,0 +1,19 @@ +{ + "$comment": "Keep the platform expressions in sync with the wrappers installed by the portfiles!", + "name": "lapack-test", + "version-date": "2022-02-22", + "description": "Metapackage for packages which provide LAPACK", + "license": null, + "dependencies": [ + "lapack", + { + "name": "pkgconf", + "host": true, + "platform": "windows" + }, + { + "name": "vcpkg-cmake", + "host": true + } + ] +} diff --git a/versions/a-/armadillo.json b/versions/a-/armadillo.json index ea55c14c0101bc..fc556bb92d1fe7 100644 --- a/versions/a-/armadillo.json +++ b/versions/a-/armadillo.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "c2aff7478c5ce43b743299048915610189b0cece", + "version": "12.6.6", + "port-version": 1 + }, { "git-tree": "c47c5cebd38878763558370cea0db1d527f2fc0a", "version": "12.6.6", diff --git a/versions/b-/blas.json b/versions/b-/blas.json index 20a9eb299a3219..d9c9b1dd3b17b8 100644 --- a/versions/b-/blas.json +++ b/versions/b-/blas.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "02dbca6ca7e22e44f5445b10f74e63644779eefd", + "version-date": "2023-04-14", + "port-version": 0 + }, { "git-tree": "0fe7611c8bb3098083440074a6c59f35bfee4f99", "version-date": "2023-03-25", diff --git a/versions/baseline.json b/versions/baseline.json index dbbbce5e4ccb5d..9ca1fdc1a8948d 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -230,7 +230,7 @@ }, "armadillo": { "baseline": "12.6.6", - "port-version": 0 + "port-version": 1 }, "arpack-ng": { "baseline": "3.9.0", @@ -661,7 +661,7 @@ "port-version": 0 }, "blas": { - "baseline": "2023-03-25", + "baseline": "2023-04-14", "port-version": 0 }, "blaze": { @@ -1492,6 +1492,10 @@ "baseline": "3.5.3", "port-version": 0 }, + "cblas": { + "baseline": "2024-03-19", + "port-version": 0 + }, "cccapstone": { "baseline": "9b4128ee1153e78288a1b5433e2c06a0d47a4c4e", "port-version": 2 @@ -1630,7 +1634,7 @@ }, "clapack": { "baseline": "3.2.1", - "port-version": 22 + "port-version": 23 }, "clara": { "baseline": "1.1.5", @@ -4053,12 +4057,12 @@ "port-version": 0 }, "lapack": { - "baseline": "2022-02-22", - "port-version": 2 + "baseline": "2023-06-10", + "port-version": 0 }, "lapack-reference": { "baseline": "3.11.0", - "port-version": 2 + "port-version": 3 }, "lastools": { "baseline": "2.0.2+20230206", @@ -8042,7 +8046,7 @@ }, "shogun": { "baseline": "6.1.4", - "port-version": 9 + "port-version": 10 }, "si": { "baseline": "2.5.1", diff --git a/versions/c-/cblas.json b/versions/c-/cblas.json new file mode 100644 index 00000000000000..067bf5bfbac0dd --- /dev/null +++ b/versions/c-/cblas.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "6a032c6c0adaaff9972edc4d05b0a8e3d189e810", + "version-date": "2024-03-19", + "port-version": 0 + } + ] +} diff --git a/versions/c-/clapack.json b/versions/c-/clapack.json index 02e660a7d605b9..fe49646fda3247 100644 --- a/versions/c-/clapack.json +++ b/versions/c-/clapack.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "42a62cb53a007074bab56cc3086796b291428b4b", + "version": "3.2.1", + "port-version": 23 + }, { "git-tree": "0736bfcd19b6aaa7f1c75c10122433d4b4cc50a9", "version": "3.2.1", diff --git a/versions/l-/lapack-reference.json b/versions/l-/lapack-reference.json index 1cd14ec48e6144..fa6b0a81d2ca2b 100644 --- a/versions/l-/lapack-reference.json +++ b/versions/l-/lapack-reference.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "415dc49800a66d2b211f2d16326d0bdfa1b2e665", + "version": "3.11.0", + "port-version": 3 + }, { "git-tree": "34ccaaa835e90fc739829db6ea9b72c58151960e", "version": "3.11.0", diff --git a/versions/l-/lapack.json b/versions/l-/lapack.json index fedbceca301bf1..1439406162d613 100644 --- a/versions/l-/lapack.json +++ b/versions/l-/lapack.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "aa3ae151bb1436d57dff18e7503fc19d58b45f51", + "version-date": "2023-06-10", + "port-version": 0 + }, { "git-tree": "7c892b58c70ebc7d83444c4e727272cad40e28c2", "version-date": "2022-02-22", diff --git a/versions/s-/shogun.json b/versions/s-/shogun.json index ad4f7c93a09d68..956ba87e79d48b 100644 --- a/versions/s-/shogun.json +++ b/versions/s-/shogun.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "1492ad59069309d6872f7cf6df5640dcd1d8e4b4", + "version": "6.1.4", + "port-version": 10 + }, { "git-tree": "66286469fa661da12735a2f8267a293bd63117a8", "version": "6.1.4",