From 97daa99ef846fac6cbfd783aa589a9a935153856 Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Thu, 15 Dec 2022 18:02:50 -0500 Subject: [PATCH 01/20] MPC Conan 2.0 Compatibility --- recipes/mpc/all/conandata.yml | 1 - recipes/mpc/all/conanfile.py | 83 +++++++++++-------- recipes/mpc/all/test_package/CMakeLists.txt | 5 +- recipes/mpc/all/test_package/conanfile.py | 18 ++-- .../mpc/all/test_v1_package/CMakeLists.txt | 8 ++ recipes/mpc/all/test_v1_package/conanfile.py | 17 ++++ .../mpc/all/test_v1_package/test_package.c | 16 ++++ 7 files changed, 105 insertions(+), 43 deletions(-) create mode 100644 recipes/mpc/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/mpc/all/test_v1_package/conanfile.py create mode 100644 recipes/mpc/all/test_v1_package/test_package.c diff --git a/recipes/mpc/all/conandata.yml b/recipes/mpc/all/conandata.yml index 007c14f9a1cc4..69b5d3a4c5703 100644 --- a/recipes/mpc/all/conandata.yml +++ b/recipes/mpc/all/conandata.yml @@ -8,4 +8,3 @@ sources: patches: "1.2.0": - patch_file: "patches/1.2.0-0001-asin-missing-limits.patch" - base_path: "source_subfolder" diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index 0d3ae8cad33a5..e8272bee40821 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -1,11 +1,17 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools.files import save, load, chdir, copy, rmdir, rm, apply_conandata_patches +from conan.tools.layout import basic_layout +from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps +from conan.tools.microsoft import unix_path, VCVars, is_msvc +from conan.tools.apple import is_apple_os +from conan.errors import ConanInvalidConfiguration import os -required_conan_version = ">=1.33.0" +required_conan_version = ">=1.53.0" class MpcConan(ConanFile): name = "mpc" + package_type = "library" description = "GNU MPC is a C library for the arithmetic of complex numbers with arbitrarily high precision " \ "and correct rounding of the result" topics = ("conan", "mpc", "multiprecision", "math", "mathematics") @@ -16,65 +22,74 @@ class MpcConan(ConanFile): options = {"shared": [True, False], "fPIC": [True, False]} default_options = {"shared": False, "fPIC": True} exports_sources = "patches/**" - _autotools = None - - @property - def _source_subfolder(self): - return "source_subfolder" def config_options(self): if self.settings.os == 'Windows': - del self.options.fPIC + self.options.rm_safe("fPIC") def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") def requirements(self): - self.requires("mpfr/4.1.0") + self.requires("gmp/6.2.1", transitive_headers=True) + self.requires("mpfr/4.1.0", transitive_headers=True) def validate(self): - # FIXME: add Visual Studio support, upstream has a makefile.vc - if self.settings.compiler == "Visual Studio": - raise ConanInvalidConfiguration("mpc can be built with Visual Studio, but it's not supported yet in this recipe.") + # FIXME: add msvc support, upstream has a makefile.vc + if self.info.settings.compiler == "msvc": + raise ConanInvalidConfiguration("mpc can be built with msvc, but it's not supported yet in this recipe.") @property def _settings_build(self): return getattr(self, "settings_build", self.settings) def build_requirements(self): - if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): + if self._settings_build.os == "Windows" and not os.get_env("CONAN_BASH_PATH"): self.build_requires("msys2/cci.latest") + def layout(self): + basic_layout(self, src_folder="src") + def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - args = [] + def generate(self): + self.win_bash = self._settings_build.os == "Windows" + tc = AutotoolsToolchain(self) + tc.configure_args.append(f'--with-gmp={unix_path(self, self.dependencies["gmp"].package_folder)}') + tc.configure_args.append(f'--with-mpfr={unix_path(self, self.dependencies["mpfr"].package_folder)}') if self.options.shared: - args.extend(["--disable-static", "--enable-shared"]) + tc.configure_args.extend(["--disable-static", "--enable-shared"]) else: - args.extend(["--disable-shared", "--enable-static"]) - self._autotools.configure(args=args, configure_dir=self._source_subfolder) - return self._autotools + tc.configure_args.extend(["--disable-shared", "--enable-static"]) + tc.generate() # Create conanbuild.conf + tc = AutotoolsDeps(self) + tc.generate() def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - autotools = self._configure_autotools() + apply_conandata_patches(self) + with chdir(self, self.source_folder): + if not os.path.exists("configure"): + command = "autoreconf -i" + self.run(command) + autotools = Autotools(self) + autotools.configure() autotools.make() def package(self): - self.copy(pattern="COPYING.LESSER", dst="licenses", src=self._source_subfolder) - autotools = self._configure_autotools() + copy(self, pattern="COPYING.LESSER", dst="licenses", src=self.source_folder) + autotools = Autotools(self) autotools.install() - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True) def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "MPC") + self.cpp_info.set_property("cmake_module_file_name", "mpc") + self.cpp_info.set_property("cmake_target_name", "MPC::MPC") self.cpp_info.libs = ["mpc"] diff --git a/recipes/mpc/all/test_package/CMakeLists.txt b/recipes/mpc/all/test_package/CMakeLists.txt index 7b9b613cbb24a..dbfadb0334699 100644 --- a/recipes/mpc/all/test_package/CMakeLists.txt +++ b/recipes/mpc/all/test_package/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +find_package(MPC REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +target_link_libraries(${PROJECT_NAME} PRIVATE MPC::MPC) diff --git a/recipes/mpc/all/test_package/conanfile.py b/recipes/mpc/all/test_package/conanfile.py index bd7165a553cf4..da190011b6b6d 100644 --- a/recipes/mpc/all/test_package/conanfile.py +++ b/recipes/mpc/all/test_package/conanfile.py @@ -1,10 +1,18 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import cross_building import os class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,6 +20,6 @@ def build(self): 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) + if not cross_building(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/mpc/all/test_v1_package/CMakeLists.txt b/recipes/mpc/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..7b9b613cbb24a --- /dev/null +++ b/recipes/mpc/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/mpc/all/test_v1_package/conanfile.py b/recipes/mpc/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..bd7165a553cf4 --- /dev/null +++ b/recipes/mpc/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + 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/mpc/all/test_v1_package/test_package.c b/recipes/mpc/all/test_v1_package/test_package.c new file mode 100644 index 0000000000000..c2c46b86453e1 --- /dev/null +++ b/recipes/mpc/all/test_v1_package/test_package.c @@ -0,0 +1,16 @@ +/* example was taken from https://www.gnu.org/ghm/2011/paris/slides/andreas-enge-mpc.pdf */ + +#include +#include + +int main (void) { + mpc_t z; + int inex; + mpc_init2 (z, 123); + mpc_set_ui_ui (z, 0, 2, MPC_RNDNN); + inex = mpc_asin (z, z, MPC_RNDNN); + mpc_out_str (stdout, 10, 0, z, MPC_RNDNN); + printf ("\n%i %i\n", MPC_INEX_RE (inex), MPC_INEX_IM (inex)); + mpc_clear (z); + return 0; +} From 96080bcbfe88d392a97b000afde1af7f9075ab04 Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Thu, 15 Dec 2022 18:09:59 -0500 Subject: [PATCH 02/20] Fixed lint errors --- recipes/mpc/all/conanfile.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index e8272bee40821..b894f0fbe9a9f 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -1,9 +1,8 @@ from conan import ConanFile -from conan.tools.files import save, load, chdir, copy, rmdir, rm, apply_conandata_patches +from conan.tools.files import chdir, copy, get, rmdir, rm, apply_conandata_patches from conan.tools.layout import basic_layout from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps -from conan.tools.microsoft import unix_path, VCVars, is_msvc -from conan.tools.apple import is_apple_os +from conan.tools.microsoft import unix_path from conan.errors import ConanInvalidConfiguration import os @@ -47,7 +46,7 @@ def _settings_build(self): return getattr(self, "settings_build", self.settings) def build_requirements(self): - if self._settings_build.os == "Windows" and not os.get_env("CONAN_BASH_PATH"): + if self._settings_build.os == "Windows" and not os.getenv("CONAN_BASH_PATH"): self.build_requires("msys2/cci.latest") def layout(self): From 9f537955132d0744fff77176b7547f2759a15998 Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Thu, 15 Dec 2022 18:48:02 -0500 Subject: [PATCH 03/20] Fixed license copying code --- recipes/mpc/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index b894f0fbe9a9f..ea310920da04f 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -80,7 +80,7 @@ def build(self): autotools.make() def package(self): - copy(self, pattern="COPYING.LESSER", dst="licenses", src=self.source_folder) + copy(self, "COPYING.LESSER", self.source_folder, os.path.join(self.package_folder, "licenses"), keep_path=False) autotools = Autotools(self) autotools.install() rmdir(self, os.path.join(self.package_folder, "share")) From 4cf89fda4ca0736519f518665e9ae6250f39edb0 Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Fri, 23 Dec 2022 10:18:06 -0500 Subject: [PATCH 04/20] Tweaked how win_bash is set --- recipes/mpc/all/conanfile.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index ea310920da04f..aae80dc2c029c 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -46,8 +46,10 @@ def _settings_build(self): return getattr(self, "settings_build", self.settings) def build_requirements(self): - if self._settings_build.os == "Windows" and not os.getenv("CONAN_BASH_PATH"): - self.build_requires("msys2/cci.latest") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") def layout(self): basic_layout(self, src_folder="src") @@ -57,7 +59,6 @@ def source(self): destination=self.source_folder, strip_root=True) def generate(self): - self.win_bash = self._settings_build.os == "Windows" tc = AutotoolsToolchain(self) tc.configure_args.append(f'--with-gmp={unix_path(self, self.dependencies["gmp"].package_folder)}') tc.configure_args.append(f'--with-mpfr={unix_path(self, self.dependencies["mpfr"].package_folder)}') From cc2e77ada27d38a51da9d0ecb765f5d3cd803794 Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Fri, 23 Dec 2022 10:28:29 -0500 Subject: [PATCH 05/20] Added new metadata for patch --- recipes/mpc/all/conandata.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/mpc/all/conandata.yml b/recipes/mpc/all/conandata.yml index 69b5d3a4c5703..cd8f83a739d7d 100644 --- a/recipes/mpc/all/conandata.yml +++ b/recipes/mpc/all/conandata.yml @@ -8,3 +8,5 @@ sources: patches: "1.2.0": - patch_file: "patches/1.2.0-0001-asin-missing-limits.patch" + patch_description: "asin.c needs limits.h" + patch_type: "portability" From 3bbf614c74cd1f095a7b8689e4084225147381b1 Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Sat, 31 Dec 2022 09:54:32 -0500 Subject: [PATCH 06/20] Try adding VirtrualBuildEnv for v1.x --- recipes/mpc/all/conanfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index aae80dc2c029c..7f87f1297ee96 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -1,4 +1,5 @@ from conan import ConanFile +from conan.tools.env import VirtualBuildEnv from conan.tools.files import chdir, copy, get, rmdir, rm, apply_conandata_patches from conan.tools.layout import basic_layout from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps @@ -59,6 +60,9 @@ def source(self): destination=self.source_folder, strip_root=True) def generate(self): + env = VirtualBuildEnv(self) + env.generate() + tc = AutotoolsToolchain(self) tc.configure_args.append(f'--with-gmp={unix_path(self, self.dependencies["gmp"].package_folder)}') tc.configure_args.append(f'--with-mpfr={unix_path(self, self.dependencies["mpfr"].package_folder)}') From e21afa2342b6b5d888ccba2c6e3ffdcee9acad8d Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Mon, 16 Jan 2023 11:14:52 -0500 Subject: [PATCH 07/20] Bump required_conan_version --- recipes/mpc/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index 7f87f1297ee96..a9aa857603c72 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -7,7 +7,7 @@ from conan.errors import ConanInvalidConfiguration import os -required_conan_version = ">=1.53.0" +required_conan_version = ">=1.56.0" class MpcConan(ConanFile): name = "mpc" From 5863930709b0b624cdd518e1ad4a9a9ee020ab0a Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Tue, 17 Jan 2023 22:28:56 -0500 Subject: [PATCH 08/20] Define CL-related flag macro values. --- recipes/mpc/all/conanfile.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index a9aa857603c72..98f3a34f66490 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -70,7 +70,16 @@ def generate(self): tc.configure_args.extend(["--disable-static", "--enable-shared"]) else: tc.configure_args.extend(["--disable-shared", "--enable-static"]) - tc.generate() # Create conanbuild.conf + + env = tc.environment() # Environment must be captured *after* setting extra_cflags, etc. to pick up changes + if is_msvc(self): + ar_wrapper = unix_path(self, self.conf.get("user.automake:lib-wrapper")) + env.define("CC", "cl -nologo") + env.define("CXX", "cl -nologo") + env.define("LD", "link -nologo") + env.define("AR", f'{ar_wrapper} "lib -nologo"') + tc.generate(env) # Create conanbuild.conf + tc = AutotoolsDeps(self) tc.generate() From 02d1618afe74e16fd092303d83f519ed683325b2 Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Tue, 17 Jan 2023 23:03:51 -0500 Subject: [PATCH 09/20] Import is_msvc --- recipes/mpc/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index 98f3a34f66490..1d1b79102b384 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -3,7 +3,7 @@ from conan.tools.files import chdir, copy, get, rmdir, rm, apply_conandata_patches from conan.tools.layout import basic_layout from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps -from conan.tools.microsoft import unix_path +from conan.tools.microsoft import is_msvc, unix_path from conan.errors import ConanInvalidConfiguration import os From fc8e5303d40424f37f92ec831a049408d04707d5 Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Wed, 18 Jan 2023 07:54:10 -0500 Subject: [PATCH 10/20] Add automake as a tool_requires --- recipes/mpc/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index 1d1b79102b384..d0fc8198f4dcc 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -49,6 +49,7 @@ def _settings_build(self): def build_requirements(self): if self._settings_build.os == "Windows": self.win_bash = True + toolb_requires("automake/1.16.5") # Neededfor lib-wrapper if not self.conf.get("tools.microsoft.bash:path", check_type=str): self.tool_requires("msys2/cci.latest") From 6ccb255ab69aeae5bdc641708b396a38bc806873 Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Wed, 18 Jan 2023 10:07:25 -0500 Subject: [PATCH 11/20] Fixed typo --- recipes/mpc/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index d0fc8198f4dcc..988f9b010459b 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -49,7 +49,7 @@ def _settings_build(self): def build_requirements(self): if self._settings_build.os == "Windows": self.win_bash = True - toolb_requires("automake/1.16.5") # Neededfor lib-wrapper + self.tool_requires("automake/1.16.5") # Neededfor lib-wrapper if not self.conf.get("tools.microsoft.bash:path", check_type=str): self.tool_requires("msys2/cci.latest") From 26eedbccf3843b03645452fb52efeab1b56e09ff Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Wed, 18 Jan 2023 13:32:33 -0500 Subject: [PATCH 12/20] Recognize that recipe lacks Visual Studio support --- recipes/mpc/all/conanfile.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index 988f9b010459b..bbac53198cf35 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -39,7 +39,7 @@ def requirements(self): def validate(self): # FIXME: add msvc support, upstream has a makefile.vc - if self.info.settings.compiler == "msvc": + if is_msvc(self): raise ConanInvalidConfiguration("mpc can be built with msvc, but it's not supported yet in this recipe.") @property @@ -49,7 +49,6 @@ def _settings_build(self): def build_requirements(self): if self._settings_build.os == "Windows": self.win_bash = True - self.tool_requires("automake/1.16.5") # Neededfor lib-wrapper if not self.conf.get("tools.microsoft.bash:path", check_type=str): self.tool_requires("msys2/cci.latest") @@ -72,14 +71,7 @@ def generate(self): else: tc.configure_args.extend(["--disable-shared", "--enable-static"]) - env = tc.environment() # Environment must be captured *after* setting extra_cflags, etc. to pick up changes - if is_msvc(self): - ar_wrapper = unix_path(self, self.conf.get("user.automake:lib-wrapper")) - env.define("CC", "cl -nologo") - env.define("CXX", "cl -nologo") - env.define("LD", "link -nologo") - env.define("AR", f'{ar_wrapper} "lib -nologo"') - tc.generate(env) # Create conanbuild.conf + tc.generate() # Create conanbuild.conf tc = AutotoolsDeps(self) tc.generate() From 32cdaccc114c1a5cb4fb79d563fe39684d03eb2d Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Wed, 18 Jan 2023 13:34:45 -0500 Subject: [PATCH 13/20] Formatting tweak --- recipes/mpc/all/conanfile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index bbac53198cf35..6d3288364e8bd 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -70,8 +70,7 @@ def generate(self): tc.configure_args.extend(["--disable-static", "--enable-shared"]) else: tc.configure_args.extend(["--disable-shared", "--enable-static"]) - - tc.generate() # Create conanbuild.conf + tc.generate() tc = AutotoolsDeps(self) tc.generate() From bf850fecbe8af5f7e0b77418f714e152d8b01e6b Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Wed, 18 Jan 2023 23:43:46 -0500 Subject: [PATCH 14/20] Added blank line to trigger CI build --- recipes/mpc/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index 6d3288364e8bd..4907774704430 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -7,6 +7,7 @@ from conan.errors import ConanInvalidConfiguration import os + required_conan_version = ">=1.56.0" class MpcConan(ConanFile): From b3d588e10673af79efb7ad83668aeb1c28b4dfc1 Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Fri, 20 Jan 2023 00:15:22 -0500 Subject: [PATCH 15/20] Use autotools.autoreconf() per review suggestion --- recipes/mpc/all/conanfile.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index 4907774704430..4469c93bb8fbb 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -1,6 +1,6 @@ from conan import ConanFile from conan.tools.env import VirtualBuildEnv -from conan.tools.files import chdir, copy, get, rmdir, rm, apply_conandata_patches +from conan.tools.files import copy, get, rmdir, rm, apply_conandata_patches from conan.tools.layout import basic_layout from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps from conan.tools.microsoft import is_msvc, unix_path @@ -78,11 +78,9 @@ def generate(self): def build(self): apply_conandata_patches(self) - with chdir(self, self.source_folder): - if not os.path.exists("configure"): - command = "autoreconf -i" - self.run(command) autotools = Autotools(self) + if not os.path.exists(os.path.join(self.source_folder, "configure")): + autotools.autoreconf(["-i"]) autotools.configure() autotools.make() From 2040aab892aaee53e14e86dabf9f3f817603add5 Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Fri, 20 Jan 2023 09:10:48 -0500 Subject: [PATCH 16/20] Add "m" as system_libs --- recipes/mpc/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index 4469c93bb8fbb..ae81c13dbd3e1 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -97,3 +97,4 @@ def package_info(self): self.cpp_info.set_property("cmake_module_file_name", "mpc") self.cpp_info.set_property("cmake_target_name", "MPC::MPC") self.cpp_info.libs = ["mpc"] + self.cpp_info.system_libs = ["m"] From 0610f4857600d7f08b7db067eb8cf4021a0e8e20 Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Fri, 20 Jan 2023 18:54:25 -0500 Subject: [PATCH 17/20] Add call to fix_apple_shared_install_name Co-authored-by: Stella Smith <40411082+StellaSmith@users.noreply.github.com> --- recipes/mpc/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index ae81c13dbd3e1..8120152cb12dd 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -4,6 +4,7 @@ from conan.tools.layout import basic_layout from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps from conan.tools.microsoft import is_msvc, unix_path +from conan.tools.apple import fix_apple_shared_install_name from conan.errors import ConanInvalidConfiguration import os @@ -88,6 +89,7 @@ def package(self): copy(self, "COPYING.LESSER", self.source_folder, os.path.join(self.package_folder, "licenses"), keep_path=False) autotools = Autotools(self) autotools.install() + fix_apple_shared_install_name(self) rmdir(self, os.path.join(self.package_folder, "share")) rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True) From d62d2515a60caba4083c81b505bb27f3a7d6761c Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Fri, 20 Jan 2023 18:56:06 -0500 Subject: [PATCH 18/20] Removed setting of shared/static options per code review --- recipes/mpc/all/conanfile.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index 8120152cb12dd..c83f8568d7e6c 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -68,10 +68,6 @@ def generate(self): tc = AutotoolsToolchain(self) tc.configure_args.append(f'--with-gmp={unix_path(self, self.dependencies["gmp"].package_folder)}') tc.configure_args.append(f'--with-mpfr={unix_path(self, self.dependencies["mpfr"].package_folder)}') - if self.options.shared: - tc.configure_args.extend(["--disable-static", "--enable-shared"]) - else: - tc.configure_args.extend(["--disable-shared", "--enable-static"]) tc.generate() tc = AutotoolsDeps(self) From abf0374c443c34ba7dc7b87137992a1cf2cac075 Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Sun, 22 Jan 2023 18:10:22 -0500 Subject: [PATCH 19/20] Incorporate @Spacelm's review feedback Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com> --- recipes/mpc/all/conanfile.py | 21 +++++++++++-------- recipes/mpc/all/test_package/CMakeLists.txt | 4 ++-- .../mpc/all/test_v1_package/CMakeLists.txt | 8 +++---- recipes/mpc/all/test_v1_package/conanfile.py | 2 +- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/recipes/mpc/all/conanfile.py b/recipes/mpc/all/conanfile.py index c83f8568d7e6c..f996155628e5c 100644 --- a/recipes/mpc/all/conanfile.py +++ b/recipes/mpc/all/conanfile.py @@ -1,6 +1,7 @@ from conan import ConanFile -from conan.tools.env import VirtualBuildEnv -from conan.tools.files import copy, get, rmdir, rm, apply_conandata_patches +from conan.tools.build import cross_building +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir from conan.tools.layout import basic_layout from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps from conan.tools.microsoft import is_msvc, unix_path @@ -9,7 +10,7 @@ import os -required_conan_version = ">=1.56.0" +required_conan_version = ">=1.54.0" class MpcConan(ConanFile): name = "mpc" @@ -23,7 +24,9 @@ class MpcConan(ConanFile): settings = "os", "arch", "compiler", "build_type" options = {"shared": [True, False], "fPIC": [True, False]} default_options = {"shared": False, "fPIC": True} - exports_sources = "patches/**" + + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == 'Windows': @@ -64,6 +67,9 @@ def source(self): def generate(self): env = VirtualBuildEnv(self) env.generate() + if not cross_building(self): + env = VirtualRunEnv(self) + env.generate(scope="build") tc = AutotoolsToolchain(self) tc.configure_args.append(f'--with-gmp={unix_path(self, self.dependencies["gmp"].package_folder)}') @@ -90,9 +96,6 @@ def package(self): rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True) def package_info(self): - self.cpp_info.set_property("cmake_find_mode", "both") - self.cpp_info.set_property("cmake_file_name", "MPC") - self.cpp_info.set_property("cmake_module_file_name", "mpc") - self.cpp_info.set_property("cmake_target_name", "MPC::MPC") self.cpp_info.libs = ["mpc"] - self.cpp_info.system_libs = ["m"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["m"] diff --git a/recipes/mpc/all/test_package/CMakeLists.txt b/recipes/mpc/all/test_package/CMakeLists.txt index dbfadb0334699..5167a095daebe 100644 --- a/recipes/mpc/all/test_package/CMakeLists.txt +++ b/recipes/mpc/all/test_package/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package C) -find_package(MPC REQUIRED CONFIG) +find_package(mpc REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} PRIVATE MPC::MPC) +target_link_libraries(${PROJECT_NAME} PRIVATE mpc::mpc) diff --git a/recipes/mpc/all/test_v1_package/CMakeLists.txt b/recipes/mpc/all/test_v1_package/CMakeLists.txt index 7b9b613cbb24a..0d20897301b68 100644 --- a/recipes/mpc/all/test_v1_package/CMakeLists.txt +++ b/recipes/mpc/all/test_v1_package/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.1) -project(test_package C) +project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) -add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/recipes/mpc/all/test_v1_package/conanfile.py b/recipes/mpc/all/test_v1_package/conanfile.py index bd7165a553cf4..7e2dfe859bb27 100644 --- a/recipes/mpc/all/test_v1_package/conanfile.py +++ b/recipes/mpc/all/test_v1_package/conanfile.py @@ -4,7 +4,7 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + generators = "cmake", "cmake_find_package_multi" def build(self): cmake = CMake(self) From b571908a21138112f8be28d3b1c28cfbaae69683 Mon Sep 17 00:00:00 2001 From: System-Arch <33330183+System-Arch@users.noreply.github.com> Date: Sun, 22 Jan 2023 18:11:34 -0500 Subject: [PATCH 20/20] Per review feedback --- recipes/mpc/all/test_v1_package/test_package.c | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 recipes/mpc/all/test_v1_package/test_package.c diff --git a/recipes/mpc/all/test_v1_package/test_package.c b/recipes/mpc/all/test_v1_package/test_package.c deleted file mode 100644 index c2c46b86453e1..0000000000000 --- a/recipes/mpc/all/test_v1_package/test_package.c +++ /dev/null @@ -1,16 +0,0 @@ -/* example was taken from https://www.gnu.org/ghm/2011/paris/slides/andreas-enge-mpc.pdf */ - -#include -#include - -int main (void) { - mpc_t z; - int inex; - mpc_init2 (z, 123); - mpc_set_ui_ui (z, 0, 2, MPC_RNDNN); - inex = mpc_asin (z, z, MPC_RNDNN); - mpc_out_str (stdout, 10, 0, z, MPC_RNDNN); - printf ("\n%i %i\n", MPC_INEX_RE (inex), MPC_INEX_IM (inex)); - mpc_clear (z); - return 0; -}