flint: update to 3.2.1

This commit is contained in:
مهدي شينون (Mehdi Chinoune)
2025-03-17 12:19:45 +01:00
parent 6256459c71
commit 62cdabde19
5 changed files with 6 additions and 598 deletions

View File

@@ -1,11 +0,0 @@
--- a/src/qsieve/factor.c
+++ b/src/qsieve/factor.c
@@ -13,7 +13,7 @@
#define _STDC_FORMAT_MACROS
-#ifdef __GNUC__
+#if defined(__GNUC__) && !(defined(__MINGW32__) && defined(__clang__))
# define strcpy __builtin_strcpy
#else
# include <math.h>

View File

@@ -1,121 +0,0 @@
From 0e00381c5967c8f2e4540394a012eb358ac385b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?=
=?UTF-8?q?=20=28Mehdi=20Chinoune=29?= <mehdi.chinoune@hotmail.com>
Date: Mon, 26 Feb 2024 18:26:36 +0100
Subject: [PATCH] Generate and Install CMake configuration files
Help to find flint with cmake `find_package(flint)` and link to it directly `target_ling_libraries(target flint::flint)`
---
CMakeLists.txt | 48 ++++++++++++++++++++++++++++++++++++--------
flintConfig.cmake.in | 18 +++++++++++++++++
2 files changed, 58 insertions(+), 8 deletions(-)
create mode 100644 flintConfig.cmake.in
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c34047ed4f..c938bd7dcd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,6 +20,7 @@ include(CheckCCompilerFlag)
include(CheckCSourceRuns)
include(CheckIPOSupported)
include(FindPkgConfig)
+include(CMakePackageConfigHelpers)
# Source of truth for project version
file(STRINGS VERSION FLINT_VERSION_FULL)
@@ -72,8 +73,10 @@ endif()
# Find dependencies
find_package(PkgConfig REQUIRED)
-pkg_check_modules(GMP REQUIRED IMPORTED_TARGET gmp>=6.2.1)
-pkg_check_modules(MPFR REQUIRED IMPORTED_TARGET mpfr>=4.1.0)
+set(GMP_MIN_VERSION 6.2.1)
+set(MPFR_MIN_VERSION 4.1.0)
+pkg_check_modules(GMP REQUIRED IMPORTED_TARGET gmp>=${GMP_MIN_VERSION})
+pkg_check_modules(MPFR REQUIRED IMPORTED_TARGET mpfr>=${MPFR_MIN_VERSION})
if (WITH_NTL)
find_package(NTL REQUIRED)
endif()
@@ -357,9 +360,13 @@ endif()
# Include directories
-target_include_directories(flint PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/src ${GMP_INCLUDE_DIRS} ${MPFR_INCLUDE_DIRS}
- ${CMAKE_CURRENT_BINARY_DIR} ${PThreads_INCLUDE_DIRS})
+target_include_directories(flint PUBLIC
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src;${CMAKE_CURRENT_BINARY_DIR}>"
+ "$<INSTALL_INTERFACE:include/flint>"
+ ${GMP_INCLUDE_DIRS}
+ ${MPFR_INCLUDE_DIRS}
+ ${PThreads_INCLUDE_DIRS}
+)
if(FLINT_USES_BLAS)
target_include_directories(flint PUBLIC ${CBLAS_INCLUDE_DIRS})
@@ -437,13 +444,38 @@ endif()
include(GNUInstallDirs)
install(TARGETS flint
- RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}"
- ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
- LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}"
+ EXPORT flintTargets
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
install(FILES ${HEADERS} DESTINATION include/flint)
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/flintConfigVersion.cmake"
+ VERSION "${PROJECT_VERSION}"
+ COMPATIBILITY AnyNewerVersion
+)
+
+configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/flintConfig.cmake.in
+ "${CMAKE_CURRENT_BINARY_DIR}/flintConfig.cmake"
+ INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/flint
+)
+
+install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/flintConfig.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/flintConfigVersion.cmake"
+ "CMake/FindCBLAS.cmake"
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/flint
+)
+
+install(EXPORT flintTargets
+ FILE flintTargets.cmake
+ NAMESPACE flint::
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/flint
+)
+
set_target_properties(flint
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib"
diff --git a/flintConfig.cmake.in b/flintConfig.cmake.in
new file mode 100644
index 0000000000..24336719ac
--- /dev/null
+++ b/flintConfig.cmake.in
@@ -0,0 +1,18 @@
+@PACKAGE_INIT@
+
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(GMP REQUIRED IMPORTED_TARGET gmp>=@GMP_MIN_VERSION@)
+pkg_check_modules(MPFR REQUIRED IMPORTED_TARGET mpfr>=@MPFR_MIN_VERSION@)
+
+if(@CBLAS_FOUND@)
+ find_package(CBLAS REQUIRED)
+endif()
+
+if(NOT MSVC)
+ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
+ find_package(Threads REQUIRED)
+endif()
+
+include("${CMAKE_CURRENT_LIST_DIR}/flintTargets.cmake")
+
+check_required_components(flint)

View File

@@ -1,120 +0,0 @@
From bce3501cee66d73d71217c72404b6f1d1efc2e26 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?=
=?UTF-8?q?=20=28Mehdi=20Chinoune=29?= <mehdi.chinoune@hotmail.com>
Date: Sat, 2 Mar 2024 18:08:55 +0100
Subject: [PATCH] Add CMake options to enable -march=<arch> and AVX*
instructions
---
CMakeLists.txt | 77 +++++++++++++++++++++++++++++++---------
1 file changed, 60 insertions(+), 17 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c938bd7dcd..4a18fe6d92 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,18 +49,50 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
-# Try to enable the fft_small module
-if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
- check_c_compiler_flag("-march=native" HAS_FLAG_GCC_MARCH_NATIVE)
-elseif("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC")
- # Check if AVX2 is available
- check_c_compiler_flag("/arch:AVX2" HAS_FLAG_MSVC_AVX2)
-endif()
-
# Build options
option(BUILD_SHARED_LIBS "Build shared libs" on)
option(WITH_NTL "Build tests for NTL interface or not" off)
+# MSVC has no equivalent to "-march=<arch>"
+if(NOT MSVC)
+ set(ENABLE_ARCH "native" CACHE STRING "Enable and push -march=ARCH option to C compiler")
+ if(NOT "${ENABLE_ARCH}" STREQUAL "NO")
+ check_c_compiler_flag("-march=${ENABLE_ARCH}" HAS_FLAG_ARCH)
+ endif()
+endif()
+
+if(MSVC)
+ set(avx2_flag "/arch:AVX2")
+else()
+ set(avx2_flag "-mavx2")
+endif()
+check_c_compiler_flag("${avx2_flag}" HAS_FLAG_AVX2)
+
+option(ENABLE_AVX2 "Enable AVX2 instructions" ${HAS_FLAG_AVX2})
+option(ENABLE_AVX512 "Enable AVX512 instructions" OFF)
+
+# Check if AVX2 is available
+
+if(ENABLE_AVX2)
+ if(HAS_FLAG_AVX2)
+ check_c_compiler_flag("-mfma" HAS_FLAG_MFMA)
+ else()
+ message(FATAL_ERROR "${CMAKE_C_COMPILER}} does not support the flag ${avx2_flag} needed for AVX2 instructions")
+ endif()
+endif()
+
+if(ENABLE_AVX512)
+ if(MSVC)
+ set(avx512_flag "/arch:AVX512")
+ else()
+ set(avx512_flag "-mavx512f")
+ endif()
+ check_c_compiler_flag("${avx512_flag}" HAS_FLAG_AVX512)
+ if(NOT HAS_FLAG_AVX512)
+ message(FATAL_ERROR "${CMAKE_C_COMPILER}} does not support the flag ${avx512_flag} needed for AVX512 instructions")
+ endif()
+endif()
+
# Check if strongly ordered memory
set(STRONGLY_ORDERED_CPUS x86_64 x86 i386 i586 AMD64)
if(CMAKE_SYSTEM_PROCESSOR IN_LIST STRONGLY_ORDERED_CPUS)
@@ -109,14 +141,14 @@ else()
set(FLINT_USES_PTHREAD ON CACHE BOOL "Use POSIX Threads.")
endif()
-
# Check if fft_small module is available
message(STATUS "Checking whether fft_small module is available")
set(CMAKE_REQUIRED_INCLUDES ${GMP_INCLUDE_DIRS})
-if(HAS_FLAG_GCC_MARCH_NATIVE)
- set(CMAKE_REQUIRED_FLAGS "-march=native")
-elseif(HAS_FLAG_MSVC_AVX2)
- set(CMAKE_REQUIRED_FLAGS "/arch:AVX2")
+if(HAS_FLAG_ARCH)
+ set(CMAKE_REQUIRED_FLAGS "-march=${ENABLE_ARCH}")
+endif()
+if(HAS_FLAG_AVX2)
+ set(CMAKE_REQUIRED_FLAGS "${avx2_flag}")
endif()
check_c_source_compiles([[
#include <gmp.h>
@@ -386,10 +418,21 @@ if (HAS_FLAG_UNROLL_LOOPS)
target_compile_options(flint PUBLIC "-funroll-loops")
endif()
-if(HAS_FLAG_GCC_MARCH_NATIVE)
- target_compile_options(flint PUBLIC "-march=native")
-elseif(HAS_FLAG_MSVC_AVX2)
- target_compile_options(flint PUBLIC "/arch:AVX2")
+if(NOT "${ENABLE_ARCH}" STREQUAL "NO")
+ target_compile_options(flint PUBLIC "-march=${ENABLE_ARCH}")
+endif()
+
+if(ENABLE_AVX2)
+ target_compile_options(flint PUBLIC "${avx2_flag}")
+ target_compile_definitions(flint PUBLIC "FLINT_HAVE_AVX2")
+ if(HAS_FLAG_MFMA)
+ target_compile_options(flint PUBLIC "-mfma")
+ endif()
+endif()
+
+if(ENABLE_AVX512)
+ target_compile_options(flint PUBLIC "${avx512_flag}")
+ target_compile_definitions(flint PUBLIC "FLINT_HAVE_AVX512")
endif()
# Versioning

View File

@@ -1,325 +0,0 @@
From 4fedda50a21b7884897fc7a321554da6a4509a4e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D9=85=D9=87=D8=AF=D9=8A=20=D8=B4=D9=8A=D9=86=D9=88=D9=86?=
=?UTF-8?q?=20=28Mehdi=20Chinoune=29?= <mehdi.chinoune@hotmail.com>
Date: Tue, 5 Mar 2024 07:01:41 +0100
Subject: [PATCH] CMake: Add Find<package>.cmake modules
This is how typically CMake is used to find and link to libraries.
- Linking to an imported target passes all its properties (link flags, compile flags, compile definitions, include directories), no need to add them separately.
- pkgconfig is no longer required.
---
CMake/FindCBLAS.cmake | 33 ++++++++++++++++------
CMake/Findgmp.cmake | 66 +++++++++++++++++++++++++++++++++++++++++++
CMake/Findmpfr.cmake | 57 +++++++++++++++++++++++++++++++++++++
CMakeLists.txt | 27 +++++++++---------
flintConfig.cmake.in | 10 +++----
5 files changed, 166 insertions(+), 27 deletions(-)
create mode 100644 CMake/Findgmp.cmake
create mode 100644 CMake/Findmpfr.cmake
diff --git a/CMake/FindCBLAS.cmake b/CMake/FindCBLAS.cmake
index f5b5b1cdc0..90d796cb5a 100644
--- a/CMake/FindCBLAS.cmake
+++ b/CMake/FindCBLAS.cmake
@@ -2,27 +2,44 @@
#
# Once done this will define
# CBLAS_FOUND - system has a BLAS library
-# CBLAS_INCLUDE_DIRS - the header directory containing cblas.h
-# CBLAS_LIBRARIES - the CBLAS library
+# CBLAS_INCLUDE_DIR - the header directory containing cblas.h
+# CBLAS_LIBRARY - the CBLAS library
# Copyright (c) 2020, Mahrud Sayrafi, <mahrud@umn.edu>
# Redistribution and use is allowed according to the terms of the BSD license.
-find_path(CBLAS_INCLUDE_DIRS NAMES cblas.h
+find_path(CBLAS_INCLUDE_DIR NAMES cblas.h
HINTS CBLAS_ROOT ENV CBLAS_ROOT
PATHS ${INCLUDE_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX}/include
PATH_SUFFIXES openblas cblas blis flexiblas
)
-find_library(CBLAS_LIBRARIES NAMES accelerate openblas cblas blas blis flexiblas
+find_library(CBLAS_LIBRARY NAMES accelerate openblas cblas blas blis flexiblas
HINTS CBLAS_ROOT ENV CBLAS_ROOT
PATHS ${LIB_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX}/lib
PATH_SUFFIXES openblas cblas blis flexiblas
)
include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(CBLAS
- "Could NOT find a BLAS compatible library or 'cblas.h', install BLAS or set CBLAS_ROOT."
- CBLAS_INCLUDE_DIRS CBLAS_LIBRARIES)
+find_package_handle_standard_args( CBLAS
+ FOUND_VAR CBLAS_FOUND
+ REQUIRED_VARS
+ CBLAS_LIBRARY
+ CBLAS_INCLUDE_DIR
+ )
+
+if(CBLAS_FOUND)
+ set(CBLAS_INCLUDE_DIRS ${CBLAS_INCLUDE_DIR})
+ set(CBLAS_LIBRARIES ${CBLAS_LIBRARY})
+ if(NOT TARGET CBLAS::CBLAS)
+ add_library(CBLAS::CBLAS UNKNOWN IMPORTED)
+ set_target_properties( CBLAS::CBLAS
+ PROPERTIES
+ IMPORTED_LOCATION "${CBLAS_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${CBLAS_INCLUDE_DIR}"
+ )
+ endif()
+ mark_as_advanced(CBLAS_ROOT)
+endif()
-mark_as_advanced(CBLAS_LIBRARIES CBLAS_INCLUDE_DIRS)
+mark_as_advanced(CBLAS_LIBRARY CBLAS_INCLUDE_DIR)
diff --git a/CMake/Findgmp.cmake b/CMake/Findgmp.cmake
new file mode 100644
index 0000000000..7f9b6c0cb9
--- /dev/null
+++ b/CMake/Findgmp.cmake
@@ -0,0 +1,66 @@
+
+set(GMP_ROOT_DIR "${GMP_ROOT_DIR}" CACHE PATH "Directory to search for gmp" )
+
+find_package(PkgConfig QUIET)
+if( PkgConfig_FOUND )
+ pkg_search_module(PC_GMP QUIET gmp)
+ if( PC_GMP_FOUND )
+ set( GMP_VERSION ${PC_GMP_VERSION} )
+ endif()
+endif()
+
+find_path( GMP_INCLUDE_DIR
+ NAMES gmp.h
+ PATHS "${GMP_ROOT_DIR}"
+ HINTS ${PC_GMP_INCLUDEDIR} ${PC_GMP_INCLUDE_DIRS}
+ )
+find_library( GMP_LIBRARY
+ NAMES gmp
+ PATHS "${GMP_ROOT_DIR}"
+ HINTS ${PC_GMP_LIBDIR} ${PC_GMP_LIBRARY_DIRS}
+ )
+
+if(NOT PC_GMP_FOUND)
+ set( _VERSION_FILE ${GMP_INCLUDE_DIR}/gmp.h )
+ if( EXISTS ${_VERSION_FILE} )
+ file( STRINGS ${_VERSION_FILE} _VERSION_LINE REGEX "define[ ]+__GNU_MP_VERSION[ ]+" )
+ if( _VERSION_LINE )
+ string( REGEX REPLACE ".*define[ ]+__GNU_MP_VERSION[ ]+(.*)[ ]*" "\\1" GMP_VERSION_MAJOR "${_VERSION_LINE}" )
+ endif()
+ file( STRINGS ${_VERSION_FILE} _VERSION_LINE REGEX "define[ ]+__GNU_MP_VERSION_MINOR[ ]+" )
+ if( _VERSION_LINE )
+ string( REGEX REPLACE ".*define[ ]+__GNU_MP_VERSION_MINOR[ ]+(.*)[ ]*" "\\1" GMP_VERSION_MINOR "${_VERSION_LINE}" )
+ endif()
+ file( STRINGS ${_VERSION_FILE} _VERSION_LINE REGEX "define[ ]+__GNU_MP_VERSION_PATCHLEVEL[ ]+" )
+ if( _VERSION_LINE )
+ string( REGEX REPLACE ".*define[ ]+__GNU_MP_VERSION_PATCHLEVEL[ ]+(.*)[ ]*" "\\1" GMP_VERSION_PATCHLEVEL "${_VERSION_LINE}" )
+ endif()
+ set( GMP_VERSION "${GMP_VERSION_MAJOR}.${GMP_VERSION_MINOR}.${GMP_VERSION_PATCHLEVEL}")
+ endif()
+ unset( _VERSION_FILE )
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args( gmp
+ FOUND_VAR GMP_FOUND
+ REQUIRED_VARS
+ GMP_LIBRARY
+ GMP_INCLUDE_DIR
+ VERSION_VAR GMP_VERSION
+ )
+
+if(GMP_FOUND)
+ set(GMP_INCLUDE_DIRS ${GMP_INCLUDE_DIR})
+ set(GMP_LIBRARIES ${GMP_LIBRARY})
+ if(NOT TARGET gmp::gmp)
+ add_library(gmp::gmp UNKNOWN IMPORTED)
+ set_target_properties( gmp::gmp
+ PROPERTIES
+ IMPORTED_LOCATION "${GMP_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${GMP_INCLUDE_DIR}"
+ )
+ endif()
+ mark_as_advanced(GMP_ROOT_DIR)
+endif()
+
+mark_as_advanced(GMP_INCLUDE_DIR GMP_LIBRARY)
diff --git a/CMake/Findmpfr.cmake b/CMake/Findmpfr.cmake
new file mode 100644
index 0000000000..4bde3e145e
--- /dev/null
+++ b/CMake/Findmpfr.cmake
@@ -0,0 +1,57 @@
+
+set(MPFR_ROOT_DIR "${MPFR_ROOT_DIR}" CACHE PATH "Directory to search for mpfr" )
+
+find_package(PkgConfig QUIET)
+if( PkgConfig_FOUND )
+ pkg_search_module(PC_MPFR QUIET mpfr)
+ if( PC_MPFR_FOUND )
+ set( MPFR_VERSION ${PC_MPFR_VERSION} )
+ endif()
+endif()
+
+find_path( MPFR_INCLUDE_DIR
+ NAMES mpfr.h
+ PATHS "${MPFR_ROOT_DIR}"
+ HINTS ${PC_MPFR_INCLUDEDIR} ${PC_MPFR_INCLUDE_DIRS}
+ )
+find_library( MPFR_LIBRARY
+ NAMES mpfr
+ PATHS "${MPFR_ROOT_DIR}"
+ HINTS ${PC_MPFR_LIBDIR} ${PC_MPFR_LIBRARY_DIRS}
+ )
+
+if(NOT PC_MPFR_FOUND)
+ set( _VERSION_FILE ${MPFR_INCLUDE_DIR}/mpfr.h )
+ if( EXISTS ${_VERSION_FILE} )
+ file( STRINGS ${_VERSION_FILE} _VERSION_LINE REGEX "define[ ]+MPFR_VERSION_STRING" )
+ if( _VERSION_LINE )
+ string( REGEX REPLACE ".*define[ ]+MPFR_VERSION_STRING[ ]+\"([^\"]*)\".*" "\\1" MPFR_VERSION "${_VERSION_LINE}" )
+ endif()
+ endif()
+ unset( _VERSION_FILE )
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args( mpfr
+ FOUND_VAR MPFR_FOUND
+ REQUIRED_VARS
+ MPFR_LIBRARY
+ MPFR_INCLUDE_DIR
+ VERSION_VAR MPFR_VERSION
+ )
+
+if(MPFR_FOUND)
+ set(MPFR_INCLUDE_DIRS ${MPFR_INCLUDE_DIR})
+ set(MPFR_LIBRARIES ${MPFR_LIBRARY})
+ if(NOT TARGET mpfr::mpfr)
+ add_library(mpfr::mpfr UNKNOWN IMPORTED)
+ set_target_properties( mpfr::mpfr
+ PROPERTIES
+ IMPORTED_LOCATION "${MPFR_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${MPFR_INCLUDE_DIR}"
+ )
+ endif()
+ mark_as_advanced(MPFR_ROOT_DIR)
+endif()
+
+mark_as_advanced(MPFR_INCLUDE_DIR MPFR_LIBRARY)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eacd470098..fe1e868f52 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,7 +19,6 @@ endif()
include(CheckCCompilerFlag)
include(CheckCSourceRuns)
include(CheckIPOSupported)
-include(FindPkgConfig)
include(CMakePackageConfigHelpers)
# Source of truth for project version
@@ -107,11 +106,12 @@ else()
endif()
# Find dependencies
-find_package(PkgConfig REQUIRED)
set(GMP_MIN_VERSION 6.2.1)
+find_package(gmp ${GMP_MIN_VERSION} REQUIRED)
+
set(MPFR_MIN_VERSION 4.1.0)
-pkg_check_modules(GMP REQUIRED IMPORTED_TARGET gmp>=${GMP_MIN_VERSION})
-pkg_check_modules(MPFR REQUIRED IMPORTED_TARGET mpfr>=${MPFR_MIN_VERSION})
+find_package(mpfr ${MPFR_MIN_VERSION} REQUIRED)
+
if (WITH_NTL)
find_package(NTL REQUIRED)
endif()
@@ -146,7 +146,7 @@ endif()
# Check if fft_small module is available
message(STATUS "Checking whether fft_small module is available")
-set(CMAKE_REQUIRED_INCLUDES ${GMP_INCLUDE_DIRS})
+set(CMAKE_REQUIRED_LIBRARIES gmp::gmp)
if(HAS_FLAG_ARCH)
set(CMAKE_REQUIRED_FLAGS "-march=${ENABLE_ARCH}")
endif()
@@ -315,7 +315,7 @@ else()
endif()
# gmpcompat.h configuration
-set(CMAKE_REQUIRED_INCLUDES ${GMP_INCLUDE_DIRS})
+set(CMAKE_REQUIRED_LIBRARIES gmp::gmp)
check_c_source_compiles([[#include <gmp.h>
#ifndef _LONG_LONG_LIMB
# error mp_limb_t != unsigned long long limb
@@ -387,10 +387,13 @@ list(APPEND HEADERS ${TEMP})
add_library(flint ${SOURCES})
target_link_libraries(flint PUBLIC
- PkgConfig::GMP PkgConfig::MPFR ${PThreads_LIBRARIES})
+ gmp::gmp
+ mpfr::mpfr
+ ${PThreads_LIBRARIES}
+)
if(FLINT_USES_BLAS)
- target_link_libraries(flint PUBLIC ${CBLAS_LIBRARIES})
+ target_link_libraries(flint PUBLIC CBLAS::CBLAS)
endif()
# Include directories
@@ -398,15 +401,9 @@ endif()
target_include_directories(flint PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src;${CMAKE_CURRENT_BINARY_DIR}>"
"$<INSTALL_INTERFACE:include/flint>"
- ${GMP_INCLUDE_DIRS}
- ${MPFR_INCLUDE_DIRS}
${PThreads_INCLUDE_DIRS}
)
-if(FLINT_USES_BLAS)
- target_include_directories(flint PUBLIC ${CBLAS_INCLUDE_DIRS})
-endif()
-
if(BUILD_SHARED_LIBS AND MSVC)
# Export all functions automatically (except global data)
set_target_properties(flint PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
@@ -513,6 +510,8 @@ install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/flintConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/flintConfigVersion.cmake"
"CMake/FindCBLAS.cmake"
+ "CMake/Findgmp.cmake"
+ "CMake/Findmpfr.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/flint
)
diff --git a/flintConfig.cmake.in b/flintConfig.cmake.in
index 24336719ac..ef558b8e1e 100644
--- a/flintConfig.cmake.in
+++ b/flintConfig.cmake.in
@@ -1,15 +1,15 @@
@PACKAGE_INIT@
-find_package(PkgConfig REQUIRED)
-pkg_check_modules(GMP REQUIRED IMPORTED_TARGET gmp>=@GMP_MIN_VERSION@)
-pkg_check_modules(MPFR REQUIRED IMPORTED_TARGET mpfr>=@MPFR_MIN_VERSION@)
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
-if(@CBLAS_FOUND@)
+find_package(gmp @GMP_MIN_VERSION@ REQUIRED)
+find_package(mpfr @MPFR_MIN_VERSION@ REQUIRED)
+
+if(@FLINT_USES_BLAS@)
find_package(CBLAS REQUIRED)
endif()
if(NOT MSVC)
- list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
find_package(Threads REQUIRED)
endif()

View File

@@ -3,8 +3,8 @@
_realname=flint
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.1.3
pkgrel=2
pkgver=3.2.1
pkgrel=1
pkgdesc="Fast Library for Number Theory (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
@@ -23,19 +23,8 @@ makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
"${MINGW_PACKAGE_PREFIX}-cmake"
"${MINGW_PACKAGE_PREFIX}-ninja"
"${MINGW_PACKAGE_PREFIX}-python")
source=(https://github.com/flintlib/flint/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.xz
001-dont-define-strcpy.patch
# https://github.com/flintlib/flint/commit/0e00381c
002-Generate-and-Install-CMake-configuration-files.patch
# https://github.com/flintlib/flint/commit/bce3501c
003-Add-CMake-options-to-enable-march=arch-and-AVX-instructions.patch
# https://github.com/flintlib/flint/commit/4fedda50
004-Add-Findpackage.cmake-modules.patch)
sha256sums=('0a95fa9252de63aa913c4281b70a709983ead4e1e8bf0874c3ce2e0143ab12ea'
'f1b25323e067f642c1e0ebbd4152b5af683782fa1f08e5e2b2faa2736dbd2a84'
'87953079487eae7ba260a1416947c52df8694330fd0e11fd1a6abb24cb7c1a3f'
'31422bd89012dcc8be8d9aa772e76b670007b5bc3fe03eea5d52727c324a5f81'
'2263a134a812c1b11ce949a67e1a8279bc27d3d1fe50546729423b967a73f877')
source=(https://github.com/flintlib/flint/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.xz)
sha256sums=('822c1776bec8a75f55ed05600a81d8259e1b179775241dcd9933f162b3a0a462')
apply_patch_with_msg() {
for _patch in "$@"
@@ -47,11 +36,6 @@ apply_patch_with_msg() {
prepare() {
cd ${_realname}-${pkgver}
apply_patch_with_msg \
001-dont-define-strcpy.patch \
002-Generate-and-Install-CMake-configuration-files.patch \
003-Add-CMake-options-to-enable-march=arch-and-AVX-instructions.patch \
004-Add-Findpackage.cmake-modules.patch
}
build() {
@@ -97,5 +81,6 @@ check() {
package() {
cd "${srcdir}/build-${MSYSTEM}"
DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake.exe --install .
install -Dm0644 -t "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/ "${srcdir}"/${_realname}-${pkgver}/COPYING*
install -Dm0644 -t "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/ \
"${srcdir}"/${_realname}-${pkgver}/COPYING*
}