Skip to content

Commit

Permalink
[lapack-reference] Update, fixes (microsoft#28679)
Browse files Browse the repository at this point in the history
* [cmake-user] Test FindLAPACK.cmake

* Minor cleanup

* Avoid release-only lib variable

* Fix usage of external blas

* Update to 3.11

* Add usage doc

* Update versions
  • Loading branch information
dg0yt authored Jan 4, 2023
1 parent 1b5f1aa commit 85d7c82
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 17 deletions.
21 changes: 21 additions & 0 deletions ports/lapack-reference/cmake-config.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/CMAKE/lapack-config-install.cmake.in b/CMAKE/lapack-config-install.cmake.in
index 7760960..102eb92 100644
--- a/CMAKE/lapack-config-install.cmake.in
+++ b/CMAKE/lapack-config-install.cmake.in
@@ -12,8 +12,14 @@ unset(_LAPACK_TARGET)
set(LAPACK_Fortran_COMPILER_ID "@CMAKE_Fortran_COMPILER_ID@")

# Report the blas and lapack raw or imported libraries.
-set(LAPACK_blas_LIBRARIES "@BLAS_LIBRARIES@")
+if("@USE_OPTIMIZED_BLAS@")
+ include(CMakeFindDependencyMacro)
+ find_dependency(BLAS) # For current build type
+ set(LAPACK_blas_LIBRARIES "${BLAS_LIBRARIES}")
+else()
+ set(LAPACK_blas_LIBRARIES "@BLASLIB@") # target carries link libraries
+endif()
set(LAPACK_lapack_LIBRARIES "@LAPACK_LIBRARIES@")
-set(LAPACK_LIBRARIES ${LAPACK_blas_LIBRARIES} ${LAPACK_lapack_LIBRARIES})
+set(LAPACK_LIBRARIES ${LAPACK_lapack_LIBRARIES}) # target carries link libraries

unset(_LAPACK_SELF_DIR)
32 changes: 17 additions & 15 deletions ports/lapack-reference/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ 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(lapack_ver 3.10.1)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO "Reference-LAPACK/lapack"
REF "v${lapack_ver}"
SHA512 0500bbbb48483208c0a35b74972ff0059c389da6032824a2079637266a99fa980882eedf7f1fc490219ee4ff27812ac8c6afe118e25f40a9c2387e7b997762fb
REF "v${VERSION}"
SHA512 fc3258b9d91a833149a68a89c5589b5113e90a8f9f41c3a73fbfccb1ecddd92d9462802c0f870f1c3dab392623452de4ef512727f5874ffdcba6a4845f78fc9a
HEAD_REF master
PATCHES
cmake-config.patch
lapacke.patch
)

Expand Down Expand Up @@ -51,29 +52,30 @@ 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(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()
else()
set(USE_OPTIMIZED_BLAS ON)
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}"
${FORTRAN_CMAKE}
MAYBE_UNUSED_VARIABLES
CMAKE_REQUIRE_FIND_PACKAGE_BLAS
)

vcpkg_cmake_install()

vcpkg_cmake_config_fixup(PACKAGE_NAME lapack-${lapack_ver} CONFIG_PATH lib/cmake/lapack-${lapack_ver}) #Should the target path be lapack and not lapack-reference?
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}")
Expand Down Expand Up @@ -117,11 +119,7 @@ if("cblas" IN_LIST FEATURES)
endif()
vcpkg_fixup_pkgconfig()

# Handle copyright
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

# remove debug includes
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

if(VCPKG_TARGET_IS_WINDOWS)
if(EXISTS "${CURRENT_PACKAGES_DIR}/lib/liblapack.lib")
Expand All @@ -140,5 +138,9 @@ if(VCPKG_TARGET_IS_WINDOWS)
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(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)

9 changes: 9 additions & 0 deletions ports/lapack-reference/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
lapack-reference provides CMake targets:

find_package(lapack CONFIG REQUIRED)
target_link_libraries(main PRIVATE lapack)

lapack-reference is compatible with built-in CMake targets:

find_package(LAPACK REQUIRED)
target_link_libraries(main PRIVATE LAPACK::LAPACK)
2 changes: 1 addition & 1 deletion ports/lapack-reference/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lapack-reference",
"version": "3.10.1",
"version": "3.11.0",
"description": "LAPACK - Linear Algebra PACKage",
"homepage": "http://www.netlib.org/lapack/",
"license": "BSD-3-Clause-Open-MPI",
Expand Down
5 changes: 5 additions & 0 deletions scripts/test_ports/cmake-user/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@
"$package": "JPEG",
"name": "libjpeg-turbo"
},
{
"$package": "LAPACK",
"name": "lapack",
"platform": "!(uwp & arm)"
},
{
"$package": "LibLZMA",
"name": "liblzma"
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -3517,7 +3517,7 @@
"port-version": 0
},
"lapack-reference": {
"baseline": "3.10.1",
"baseline": "3.11.0",
"port-version": 0
},
"lastools": {
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/lapack-reference.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "17a29c388c22fa340ab6c87b4df6ba6bad201de4",
"version": "3.11.0",
"port-version": 0
},
{
"git-tree": "44ad48321efe7014cd1dc7ab7b46516309e6c395",
"version": "3.10.1",
Expand Down

0 comments on commit 85d7c82

Please sign in to comment.