2020-08-13 01:28:41 +08:00
#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
2020-09-01 08:12:01 +08:00
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 ( )
2023-01-05 04:37:43 +08:00
vcpkg_minimum_required ( VERSION 2022-10-12 ) # for ${VERSION}
2020-08-13 01:28:41 +08:00
include ( vcpkg_find_fortran )
SET ( VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled )
2023-02-25 03:57:40 +08:00
set ( VCPKG_POLICY_ALLOW_OBSOLETE_MSVCRT enabled )
2020-08-13 01:28:41 +08:00
vcpkg_from_github (
O U T _ S O U R C E _ P A T H S O U R C E _ P A T H
R E P O " R e f e r e n c e - L A P A C K / l a p a c k "
2023-01-05 04:37:43 +08:00
R E F " v $ { V E R S I O N } "
S H A 5 1 2 f c 3 2 5 8 b 9 d 9 1 a 8 3 3 1 4 9 a 6 8 a 8 9 c 5 5 8 9 b 5 1 1 3 e 9 0 a 8 f 9 f 4 1 c 3 a 7 3 f b f c c b 1 e c d d d 9 2 d 9 4 6 2 8 0 2 c 0 f 8 7 0 f 1 c 3 d a b 3 9 2 6 2 3 4 5 2 d e 4 e f 5 1 2 7 2 7 f 5 8 7 4 f f d c b a 6 a 4 8 4 5 f 7 8 f c 9 a
2020-08-13 01:28:41 +08:00
H E A D _ R E F m a s t e r
2022-05-24 04:42:19 +08:00
P A T C H E S
2023-01-05 04:37:43 +08:00
c m a k e - c o n f i g . p a t c h
2022-05-24 04:42:19 +08:00
l a p a c k e . p a t c h
2020-08-13 01:28:41 +08:00
)
if ( NOT VCPKG_TARGET_IS_WINDOWS )
set ( ENV{FFLAGS} "$ENV{FFLAGS} -fPIC" )
endif ( )
set ( CBLAS OFF )
if ( "cblas" IN_LIST FEATURES )
set ( CBLAS ON )
2020-08-26 09:55:54 +08:00
if ( "noblas" IN_LIST FEATURES )
message ( FATAL_ERROR "Cannot built feature 'cblas' together with feature 'noblas'. cblas requires blas!" )
endif ( )
2020-08-13 01:28:41 +08:00
endif ( )
2023-02-25 03:57:40 +08:00
set ( USE_OPTIMIZED_BLAS OFF )
2020-08-13 01:28:41 +08:00
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 )
2023-02-25 03:57:40 +08:00
if ( VCPKG_CRT_LINKAGE_BACKUP STREQUAL "static" )
2020-08-13 01:28:41 +08:00
# If openblas has been built with static crt linkage we cannot use it with gfortran!
2023-02-25 03:57:40 +08:00
set ( USE_OPTIMIZED_BLAS OFF )
#Cannot use openblas from vcpkg if we are building with gfortran here.
2020-08-13 01:28:41 +08:00
if ( "noblas" IN_LIST FEATURES )
message ( FATAL_ERROR "Feature 'noblas' cannot be used without supplying an external fortran compiler" )
endif ( )
endif ( )
endif ( )
2021-08-28 08:02:02 +08:00
2022-02-25 02:47:52 +08:00
vcpkg_cmake_configure (
S O U R C E _ P A T H " $ { S O U R C E _ P A T H } "
2021-08-28 08:02:02 +08:00
O P T I O N S
" - D U S E _ O P T I M I Z E D _ B L A S = $ { U S E _ O P T I M I Z E D _ B L A S } "
2023-01-05 04:37:43 +08:00
" - D C M A K E _ R E Q U I R E _ F I N D _ P A C K A G E _ B L A S = $ { U S E _ O P T I M I Z E D _ B L A S } "
2021-08-28 08:02:02 +08:00
" - D C B L A S = $ { C B L A S } "
2024-01-05 04:04:39 +08:00
" - D T E S T _ F O R T R A N _ C O M P I L E R = O F F "
2021-08-28 08:02:02 +08:00
$ { F O R T R A N _ C M A K E }
2023-01-05 04:37:43 +08:00
M A Y B E _ U N U S E D _ V A R I A B L E S
C M A K E _ R E Q U I R E _ F I N D _ P A C K A G E _ B L A S
2021-08-28 08:02:02 +08:00
)
2020-08-13 01:28:41 +08:00
2022-02-25 02:47:52 +08:00
vcpkg_cmake_install ( )
2021-08-28 08:02:02 +08:00
2023-01-05 04:37:43 +08:00
vcpkg_cmake_config_fixup ( PACKAGE_NAME lapack- ${ VERSION } CONFIG_PATH lib/cmake/lapack- ${ VERSION } ) #Should the target path be lapack and not lapack-reference?
2020-08-13 01:28:41 +08:00
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 ( )
2021-08-28 08:02:02 +08:00
if ( NOT USE_OPTIMIZED_BLAS AND NOT ( VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "static" ) )
2020-08-13 01:28:41 +08:00
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 ( )
2020-08-26 09:55:54 +08:00
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 ( )
2020-08-13 01:28:41 +08:00
vcpkg_fixup_pkgconfig ( )
2023-01-05 04:37:43 +08:00
file ( REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" )
2020-08-13 01:28:41 +08:00
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 ( )
2023-01-05 04:37:43 +08:00
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 )