2024-04-09 02:15:54 +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
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 (
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 "
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
H E A D _ R E F m a s t e r
P A T C H E S
c m a k e - c o n f i g . p a t c h
l a p a c k e . p a t c h
2024-04-25 00:40:43 +08:00
f i x _ p r e f i x . p a t c h
2024-04-09 02:15:54 +08:00
)
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 (
S O U R C E _ P A T H " $ { S O U R C E _ P A T H } "
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 } "
" - 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 } "
" - D C B L A S = $ { C B L A S } "
" - D T E S T _ F O R T R A N _ C O M P I L E R = O F F "
$ { F O R T R A N _ C M A K E }
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
)
vcpkg_cmake_install ( )
2024-04-25 00:40:43 +08:00
vcpkg_cmake_config_fixup ( PACKAGE_NAME ${ PORT } CONFIG_PATH lib/cmake/lapack- ${ VERSION } ) #Should the target path be lapack and not lapack-reference?
2024-04-09 02:15:54 +08:00
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 ( 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}" )
2024-04-25 00:40:43 +08:00
vcpkg_install_copyright ( FILE_LIST "${SOURCE_PATH}/LICENSE" )