Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vcpkg baseline] Re-fix lapack-reference to find blas on windows-static #19608

Closed
wants to merge 16 commits into from
Closed
1,191 changes: 1,191 additions & 0 deletions ports/blas-reference/FindBLAS.cmake

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions ports/blas-reference/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The reference BLAS is a freely-available software package. It is available from netlib via anonymous ftp and the World Wide Web. Thus, it can be included in commercial software packages (and has been). We only ask that proper credit be given to the authors.

Like all software, it is copyrighted. It is not trademarked, but we do ask the following:
If you modify the source for these routines we ask that you change the name of the routine and comment the changes made to the original.
We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support.
13 changes: 13 additions & 0 deletions ports/blas-reference/fix-install.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e8d1c1b..d1f320e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -62,7 +62,7 @@ macro(blas_install_library lib)
EXPORT ${BLAS_INSTALL_EXPORT_NAME}
ARCHIVE DESTINATION lib COMPONENT Development
LIBRARY DESTINATION lib COMPONENT RuntimeLibraries
- RUNTIME DESTINATION lib COMPONENT RuntimeLibraries
+ RUNTIME DESTINATION bin COMPONENT RuntimeLibraries
)
endmacro()

51 changes: 51 additions & 0 deletions ports/blas-reference/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
SET(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)

vcpkg_download_distfile(ARCHIVE
URLS "http://www.netlib.org/blas/blas-3.10.0.tgz"
FILENAME "blas-3.10.0.tgz"
SHA512 1f243ce4f7e0974e62c03c49da2741509662e20e82d0ebb73e10a940cff6458739b9dc238125d5e1ae7c179eaba06155bb502327bd58eaf246c29a16e554eeb0
)

vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
PATCHES fix-install.patch
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
single BUILD_SINGLE
double BUILD_DOUBLE
complex BUILD_COMPLEX
complex16 BUILD_COMPLEX16
)

if (VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(BUILD_X64 ON)
else()
set(BUILD_X64 OFF)
endif()

include(vcpkg_find_fortran)
vcpkg_find_fortran(FORTRAN_CMAKE)

vcpkg_configure_cmake(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use vcpkg-cmake since issue #19818

SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
${FEATURE_OPTIONS}
${FORTRAN_CMAKE}
-DBUILD_INDEX64=${BUILD_X64}
-DBUILD_TESTING=OFF
)

vcpkg_install_cmake()
vcpkg_copy_pdbs()

vcpkg_fixup_pkgconfig()

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/FindBLAS.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/blas")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/blas")

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/copyright" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
5 changes: 5 additions & 0 deletions ports/blas-reference/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Use this package via the module FindBLAS that comes with CMake. To use in your CMakeLists.txt:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not true because we are checking-in our own modified version


find_package(BLAS REQUIRED)
target_compile_options(main PRIVATE ${BLAS_LINKER_FLAGS})
target_link_libraries(main PRIVATE ${BLAS_LIBRARIES})
12 changes: 12 additions & 0 deletions ports/blas-reference/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
message(STATUS "Using VCPKG FindLAPACK from package 'blas-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")

set(BLA_VENDOR "Generic")
_find_package(${ARGS})
Comment on lines +9 to +10
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set(BLA_VENDOR "Generic")
_find_package(${ARGS})
if (WIN32)
set(CMAKE_FIND_LIBRARY_PREFIXES_BAK ${CMAKE_FIND_LIBRARY_PREFIXES})
set(CMAKE_FIND_LIBRARY_PREFIXES lib)
endif()
set(BLA_VENDOR "Generic")
_find_package(${ARGS})
if (WIN32)
set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES})
endif()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In FindBLAS.cmake line 1156:

# Generic BLAS library?
if(BLA_VENDOR STREQUAL "Generic" OR
   BLA_VENDOR STREQUAL "NVHPC" OR
   BLA_VENDOR STREQUAL "All")
  if(NOT BLAS_LIBRARIES)
    check_blas_libraries(
      BLAS_LIBRARIES
      BLAS
      sgemm
      ""
      "blas"
      ""
      ""
      ""
      )
  endif()
endif()

line 275:

function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs)
...
        find_library(${_prefix}_${_lib_var}_LIBRARY
          NAMES ${_library}
          NAMES_PER_DIR
          PATHS ${_extaddlibdir}
          PATH_SUFFIXES ${_subdirs}
        )

Unless we forced the 64bit openblas-reference library name to blas.lib or libblas.lib, we can't search it using FindBLAS.cmake provided by cmake.


set(CMAKE_MODULE_PATH ${LAPACK_PREV_MODULE_PATH})
32 changes: 32 additions & 0 deletions ports/blas-reference/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "blas-reference",
"version-semver": "3.10.0",
"description": "Metapackage for packages which provide BLAS",
"homepage": "http://www.netlib.org/blas/",
"dependencies": [
{
"name": "vcpkg-gfortran",
"platform": "windows"
}
],
"default-features": [
"complex",
"complex16",
"double",
"single"
],
"features": {
"complex": {
"description": "Build single precision complex"
},
"complex16": {
"description": "Build double precision complex"
},
"double": {
"description": "Build double precision real"
},
"single": {
"description": "Build single precision real"
}
}
}
13 changes: 13 additions & 0 deletions ports/lapack-reference/fix-dependency-blas.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index caa0e71..9319694 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -196,7 +196,7 @@ if(BLAS_LIBRARIES)
endif()

# User did not provide a BLAS Library but specified to search for one
-elseif(USE_OPTIMIZED_BLAS)
+elseif (USE_OPTIMIZED_BLAS OR USE_EXTERNAL_BLAS)
find_package(BLAS)
endif()

56 changes: 22 additions & 34 deletions ports/lapack-reference/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ vcpkg_from_github(
REF "v${lapack_ver}"
SHA512 17786cb7306fccdc9b4a242de7f64fc261ebe6a10b6ec55f519deb4cb673cb137e8742aa5698fd2dc52f1cd56d3bd116af3f593a01dcf6770c4dcc86c50b2a7f
HEAD_REF master
PATCHES fix-dependency-blas.patch
)

if(NOT VCPKG_TARGET_IS_WINDOWS)
Expand All @@ -36,22 +37,16 @@ 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(USE_EXTERNAL_BLAS OFF)
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)
set(USE_OPTIMIZED_BLAS OFF)
set(USE_EXTERNAL_BLAS ON)
#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")
Expand All @@ -61,11 +56,22 @@ else()
set(USE_OPTIMIZED_BLAS ON)
endif()

if (USE_EXTERNAL_BLAS)
if (EXISTS "${CURRENT_INSTALLED_DIR}/lib/pkgconfig/blas64.pc")
set(USED_BLAS_NAME "blas64")
else()
set(USED_BLAS_NAME "blas")
endif()
else()
set(USED_BLAS_NAME "openblas")
endif()

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
"-DUSE_OPTIMIZED_BLAS=${USE_OPTIMIZED_BLAS}"
"-DUSE_EXTERNAL_BLAS=${USE_EXTERNAL_BLAS}"
"-DCBLAS=${CBLAS}"
${FORTRAN_CMAKE}
)
Expand All @@ -78,28 +84,16 @@ set(pcfile "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/lapack.pc")
if(EXISTS "${pcfile}")
file(READ "${pcfile}" _contents)
set(_contents "prefix=${CURRENT_INSTALLED_DIR}\n${_contents}")
string(REPLACE "blas" "${USED_BLAS_NAME}" _contents "${_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}")
string(REPLACE "blas" "${USED_BLAS_NAME}" _contents "${_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}")
Expand All @@ -116,9 +110,6 @@ 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)

Expand All @@ -129,15 +120,12 @@ if(VCPKG_TARGET_IS_WINDOWS)
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(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

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)

# Handle copyright
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
6 changes: 5 additions & 1 deletion ports/lapack-reference/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lapack-reference",
"version-semver": "3.8.0",
"port-version": 6,
"port-version": 7,
"description": "LAPACK — Linear Algebra PACKage",
"homepage": "http://www.netlib.org/lapack/",
"dependencies": [
Expand All @@ -21,6 +21,10 @@
"blas-select": {
"description": "Use external optimized BLAS",
"dependencies": [
{
"name": "blas-reference",
"platform": "windows & static"
},
{
"name": "lapack-reference",
"default-features": false,
Expand Down
1 change: 0 additions & 1 deletion scripts/ci.baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ cmcstl2:x86-windows = skip
coin:arm64-windows=fail
coin:arm-uwp=fail
coin:x64-uwp=fail
colmap:x64-windows-static=fail
concurrencpp:x64-linux=fail
concurrencpp:x64-osx=fail
constexpr-contracts:x64-linux=fail
Expand Down
9 changes: 9 additions & 0 deletions versions/b-/blas-reference.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "9eb91f67594d14b2950aa1c2aaeab3f2760f8fa2",
"version-semver": "3.10.0",
"port-version": 0
}
]
}
6 changes: 5 additions & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@
"baseline": "1",
"port-version": 1
},
"blas-reference": {
"baseline": "3.10.0",
"port-version": 0
},
"blaze": {
"baseline": "3.8",
"port-version": 2
Expand Down Expand Up @@ -3066,7 +3070,7 @@
},
"lapack-reference": {
"baseline": "3.8.0",
"port-version": 6
"port-version": 7
},
"lastools": {
"baseline": "2020-05-09",
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": "7f3a5af692431a311e0523036809e3ef1ae9aa77",
"version-semver": "3.8.0",
"port-version": 7
},
{
"git-tree": "10799c7ec42f8369179ba7a8e927235596cb8bb7",
"version-semver": "3.8.0",
Expand Down