Repository: conan-io/conan-center-index

Issue:
[request] flint/2.6.3
### Package Details
  * Package Name/Version: **flint/2.6.3**
  * Website: **http://www.flintlib.org/**
  * Source code: **http://www.flintlib.org/flint-2.6.3.tar.gz** (or on GitHub: **https://github.com/wbhart/flint2/archive/v2.6.3.tar.gz**)


### Description Of The Library / Tool

FLINT is a C library for doing number theory


Discussion:

Resolving patch:
diff --git a/recipes/flint/all/conanfile.py b/recipes/flint/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/flint/all/conanfile.py
@@ -0,0 +1,87 @@
+import os
+
+from conans import ConanFile, CMake, tools
+
+required_conan_version = ">=1.33.0"
+
+
+class FlintConan(ConanFile):
+    name = "flint"
+    description = "FLINT (Fast Library for Number Theory)"
+    license = "LGPL-2.1-or-later"
+    topics = ("conan", "math", "numerical")
+    homepage = "https://www.flintlib.org"
+    url = "https://github.com/conan-io/conan-center-index"
+    exports_sources = ["CMakeLists.txt", "patches/**"]
+    generators = "cmake"
+    settings = "os", "arch", "compiler", "build_type"
+    options = {
+        "shared": [True, False],
+        "fPIC": [True, False],
+    }
+    default_options = {
+        "shared": False,
+        "fPIC": True,
+    }
+
+    _cmake = None
+
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
+
+    @property
+    def _build_subfolder(self):
+        return "build_subfolder"
+
+    def config_options(self):
+        if self.settings.os == "Windows":
+            del self.options.fPIC
+
+    def requirements(self):
+        self.requires("gmp/6.2.1")
+        self.requires("mpfr/4.1.0")
+        if self.settings.compiler == "Visual Studio":
+            self.requires("pthreads4w/3.0.0")
+
+    def configure(self):
+        if self.options.shared:
+            del self.options.fPIC
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True)
+
+    def build(self):
+        for patch in self.conan_data.get("patches", {}).get(self.version, []):
+            tools.patch(**patch)
+        cmake = self._configure_cmake()
+        cmake.build()
+
+    def _configure_cmake(self):
+        if self._cmake:
+            return self._cmake
+        self._cmake = CMake(self)
+        self._cmake.definitions["BUILD_TESTING"] = False
+        self._cmake.definitions["BUILD_DOCS"] = False
+        self._cmake.definitions["WITH_NTL"] = False
+        # IPO/LTO breaks clang builds
+        self._cmake.definitions["IPO_SUPPORTED"] = False
+        # No BLAS yet
+        self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_CBLAS"] = True
+        self._cmake.configure(build_folder=self._build_subfolder)
+        return self._cmake
+
+    def package(self):
+        self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
+        cmake = self._configure_cmake()
+        cmake.install()
+
+    def package_info(self):
+        self.cpp_info.names["cmake_find_package"] = "libflint"
+        self.cpp_info.names["cmake_find_package_multi"] = "libflint"
+
+        if self.settings.os in ("FreeBSD", "Linux"):
+            self.cpp_info.system_libs = ["pthread", "m"]
+
+        self.cpp_info.includedirs.append(os.path.join("include", "flint"))
+        self.cpp_info.libs = tools.collect_libs(self)


Test patch:
diff --git a/recipes/flint/all/test_package/CMakeLists.txt b/recipes/flint/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/flint/all/test_package/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.1)
+project(test_package CXX)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup(TARGETS)
+
+find_package(libflint REQUIRED CONFIG)
+
+add_executable(${PROJECT_NAME} test_package.cpp)
+target_link_libraries(${PROJECT_NAME} libflint::libflint)
diff --git a/recipes/flint/all/test_package/conanfile.py b/recipes/flint/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/flint/all/test_package/conanfile.py
@@ -0,0 +1,17 @@
+import os
+
+from conans import ConanFile, CMake, tools
+
+class TestPackageConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+    generators = "cmake", "cmake_find_package_multi"
+
+    def build(self):
+        cmake = CMake(self)
+        cmake.configure()
+        cmake.build()
+
+    def test(self):
+        if not tools.cross_building(self.settings):
+            bin_path = os.path.join("bin", "test_package")
+            self.run(bin_path, run_environment=True)
diff --git a/recipes/flint/all/test_package/test_package.cpp b/recipes/flint/all/test_package/test_package.cpp
new file mode 100644
--- /dev/null
+++ b/recipes/flint/all/test_package/test_package.cpp
@@ -0,0 +1,6 @@
+#include <flint.h>
+
+int main() {
+  flint_printf("OK\n");
+  return 0;
+}