vcpkg/ports/gmp/portfile.cmake
moritz-h f3c8c1cf46
[gmp] update download urls (#32155)
* [gmp] update download urls

* line breaks
2023-06-26 22:17:15 -07:00

125 lines
4.5 KiB
CMake

if(EXISTS "${CURRENT_INSTALLED_DIR}/include/gmp.h" OR "${CURRENT_INSTALLED_DIR}/include/gmpxx.h")
message(FATAL_ERROR "Can't build ${PORT} if mpir is installed. Please remove mpir, and try install ${PORT} again if you need it.")
endif()
vcpkg_minimum_required(VERSION 2022-10-12) # for ${VERSION}
vcpkg_download_distfile(
ARCHIVE
URLS
"https://ftpmirror.gnu.org/gmp/gmp-${VERSION}.tar.xz"
"https://ftp.gnu.org/gnu/gmp/gmp-${VERSION}.tar.xz"
"https://gmplib.org/download/gmp/gmp-${VERSION}.tar.xz"
FILENAME "gmp-${VERSION}.tar.xz"
SHA512 c99be0950a1d05a0297d65641dd35b75b74466f7bf03c9e8a99895a3b2f9a0856cd17887738fa51cf7499781b65c049769271cbcb77d057d2e9f1ec52e07dd84
)
vcpkg_extract_source_archive(SOURCE_PATH
ARCHIVE "${ARCHIVE}"
SOURCE_BASE "v${VERSION}"
PATCHES
asmflags.patch
cross-tools.patch
subdirs.patch
msvc_symbol.patch
arm64-coff.patch
gmp-arm64-asm-fix-5f32dbc41afc.patch # Avoid the x18 register since it is reserved on arm64 osx and windows. Source: https://gmplib.org/repo/gmp/raw-rev/5f32dbc41afc
)
vcpkg_list(SET OPTIONS)
if("fat" IN_LIST FEATURES)
vcpkg_list(APPEND OPTIONS "--enable-fat")
endif()
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
vcpkg_list(APPEND OPTIONS
"ac_cv_func_memset=yes"
"gmp_cv_asm_w32=.word"
)
endif()
set(disable_assembly OFF)
set(ccas "")
set(asmflags "-c")
vcpkg_cmake_get_vars(cmake_vars_file)
include("${cmake_vars_file}")
if(VCPKG_DETECTED_CMAKE_C_COMPILER_ID STREQUAL "MSVC")
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
string(APPEND asmflags " --target=i686-pc-windows-msvc")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
string(APPEND asmflags " --target=x86_64-pc-windows-msvc")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
string(APPEND asmflags " --target=arm64-pc-windows-msvc")
else()
set(disable_assembly ON)
endif()
if(NOT disable_assembly)
vcpkg_find_acquire_program(CLANG)
set(ccas "${CLANG}")
endif()
elseif(VCPKG_TARGET_IS_MINGW AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
# not exporting asm functions
set(disable_assembly ON)
elseif(VCPKG_TARGET_IS_LINUX AND VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
set(ccas "${VCPKG_DETECTED_CMAKE_C_COMPILER}")
vcpkg_list(APPEND OPTIONS "ABI=32")
string(APPEND asmflags " -m32")
else()
set(ccas "${VCPKG_DETECTED_CMAKE_C_COMPILER}")
endif()
if(disable_assembly)
vcpkg_list(APPEND OPTIONS "--enable-assembly=no")
elseif(ccas)
cmake_path(GET ccas PARENT_PATH ccas_dir)
vcpkg_add_to_path("${ccas_dir}")
cmake_path(GET ccas FILENAME ccas_command)
endif()
vcpkg_list(APPEND OPTIONS "CCAS=${ccas_command}" "ASMFLAGS=${asmflags}")
if(VCPKG_CROSSCOMPILING)
set(ENV{HOST_TOOLS_PREFIX} "${CURRENT_HOST_INSTALLED_DIR}/manual-tools/${PORT}")
endif()
vcpkg_configure_make(
SOURCE_PATH "${SOURCE_PATH}"
AUTOCONFIG
OPTIONS
${OPTIONS}
--enable-cxx
--with-pic
--with-readline=no
"gmp_cv_prog_exeext_for_build=${VCPKG_HOST_EXECUTABLE_SUFFIX}"
)
vcpkg_install_make()
vcpkg_fixup_pkgconfig()
if(NOT VCPKG_CROSSCOMPILING)
file(INSTALL
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/gen-bases${VCPKG_HOST_EXECUTABLE_SUFFIX}"
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/gen-fac${VCPKG_HOST_EXECUTABLE_SUFFIX}"
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/gen-fib${VCPKG_HOST_EXECUTABLE_SUFFIX}"
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/gen-jacobitab${VCPKG_HOST_EXECUTABLE_SUFFIX}"
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/gen-psqr${VCPKG_HOST_EXECUTABLE_SUFFIX}"
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/gen-trialdivtab${VCPKG_HOST_EXECUTABLE_SUFFIX}"
DESTINATION "${CURRENT_PACKAGES_DIR}/manual-tools/${PORT}"
USE_SOURCE_PERMISSIONS
)
vcpkg_copy_tool_dependencies("${CURRENT_HOST_INSTALLED_DIR}/manual-tools/${PORT}")
endif()
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/debug/include"
)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(
FILE_LIST
"${SOURCE_PATH}/README"
"${SOURCE_PATH}/COPYING.LESSERv3"
"${SOURCE_PATH}/COPYINGv3"
"${SOURCE_PATH}/COPYINGv2"
)