From d3e73de323d6b4103788505e2b3442040c1ce715 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Mon, 6 Feb 2023 11:33:50 +0100 Subject: [PATCH 1/6] modernize more --- recipes/cppunit/all/conanfile.py | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/recipes/cppunit/all/conanfile.py b/recipes/cppunit/all/conanfile.py index b78b323595ebf..4d868b2cb9f49 100644 --- a/recipes/cppunit/all/conanfile.py +++ b/recipes/cppunit/all/conanfile.py @@ -1,15 +1,15 @@ from conan import ConanFile from conan.tools.apple import fix_apple_shared_install_name -from conan.tools.env import Environment, VirtualBuildEnv +from conan.tools.build import stdcpp_library +from conan.tools.env import VirtualBuildEnv from conan.tools.files import copy, get, rename, rm, rmdir from conan.tools.gnu import Autotools, AutotoolsToolchain from conan.tools.layout import basic_layout from conan.tools.microsoft import is_msvc, unix_path from conan.tools.scm import Version -from conans import tools as tools_legacy import os -required_conan_version = ">=1.53.0" +required_conan_version = ">=1.54.0" class CppunitConan(ConanFile): @@ -36,10 +36,6 @@ class CppunitConan(ConanFile): def _settings_build(self): return getattr(self, "settings_build", self.settings) - @property - def _user_info_build(self): - return getattr(self, "user_info_build", self.deps_user_info) - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -60,8 +56,7 @@ def build_requirements(self): self.tool_requires("automake/1.16.5") def source(self): - get(self, **self.conan_data["sources"][self.version], - destination=self.source_folder, strip_root=True) + get(self, **self.conan_data["sources"][self.version], strip_root=True) def generate(self): env = VirtualBuildEnv(self) @@ -72,8 +67,8 @@ def generate(self): tc.extra_defines.append("CPPUNIT_BUILD_DLL") if is_msvc(self): tc.extra_cxxflags.append("-EHsc") - if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ - (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): + if (str(self.settings.compiler) == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ + (str(self.settings.compiler) == "msvc" and Version(self.settings.compiler.version) >= "180"): tc.extra_cflags.append("-FS") tc.extra_cxxflags.append("-FS") yes_no = lambda v: "yes" if v else "no" @@ -84,12 +79,10 @@ def generate(self): "--enable-werror=no", "--enable-html-docs=no", ]) - tc.generate() - + env = tc.environment() if is_msvc(self): - env = Environment() - compile_wrapper = unix_path(self, self._user_info_build["automake"].compile) - ar_wrapper = unix_path(self, self._user_info_build["automake"].ar_lib) + compile_wrapper = unix_path(self, self.conf.get("user.automake:compile-wrapper", check_type=str)) + ar_wrapper = unix_path(self, self.conf.get("user.automake:lib-wrapper", check_type=str)) env.define("CC", f"{compile_wrapper} cl -nologo") env.define("CXX", f"{compile_wrapper} cl -nologo") env.define("LD", "link -nologo") @@ -98,7 +91,7 @@ def generate(self): env.define("OBJDUMP", ":") env.define("RANLIB", ":") env.define("STRIP", ":") - env.vars(self).save_script("conanbuild_cppunit_msvc") + tc.generate(env) def build(self): autotools = Autotools(self) @@ -108,8 +101,7 @@ def build(self): def package(self): copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) autotools = Autotools(self) - # TODO: replace by autotools.install() once https://github.com/conan-io/conan/issues/12153 fixed - autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) + autotools.install() if is_msvc(self) and self.options.shared: rename(self, os.path.join(self.package_folder, "lib", "cppunit.dll.lib"), os.path.join(self.package_folder, "lib", "cppunit.lib")) @@ -122,7 +114,7 @@ def package_info(self): self.cpp_info.set_property("pkg_config_name", "cppunit") self.cpp_info.libs = ["cppunit"] if not self.options.shared: - libcxx = tools_legacy.stdcpp_library(self) + libcxx = stdcpp_library(self) if libcxx: self.cpp_info.system_libs.append(libcxx) if self.settings.os in ["Linux", "FreeBSD"]: From fc3e70fb210483bf75182d2468dee30be4b3581a Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Mon, 6 Feb 2023 13:59:16 +0100 Subject: [PATCH 2/6] inject headerpad_max_install_names on Apple --- recipes/cppunit/all/conanfile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/recipes/cppunit/all/conanfile.py b/recipes/cppunit/all/conanfile.py index 4d868b2cb9f49..a289518386836 100644 --- a/recipes/cppunit/all/conanfile.py +++ b/recipes/cppunit/all/conanfile.py @@ -1,5 +1,5 @@ from conan import ConanFile -from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.apple import is_apple_os, fix_apple_shared_install_name from conan.tools.build import stdcpp_library from conan.tools.env import VirtualBuildEnv from conan.tools.files import copy, get, rename, rm, rmdir @@ -71,6 +71,8 @@ def generate(self): (str(self.settings.compiler) == "msvc" and Version(self.settings.compiler.version) >= "180"): tc.extra_cflags.append("-FS") tc.extra_cxxflags.append("-FS") + if is_apple_os(self): + tc.extra_ldflags.append("-headerpad_max_install_names") yes_no = lambda v: "yes" if v else "no" tc.configure_args.extend([ "--enable-debug={}".format(yes_no(self.settings.build_type == "Debug")), From 7591ec4336bbd217cf2a49920c08dee3ae4aa310 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Mon, 6 Feb 2023 16:58:05 +0100 Subject: [PATCH 3/6] add libm to system libs --- recipes/cppunit/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cppunit/all/conanfile.py b/recipes/cppunit/all/conanfile.py index a289518386836..075926da847c9 100644 --- a/recipes/cppunit/all/conanfile.py +++ b/recipes/cppunit/all/conanfile.py @@ -120,6 +120,6 @@ def package_info(self): if libcxx: self.cpp_info.system_libs.append(libcxx) if self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.system_libs.append("dl") + self.cpp_info.system_libs.extend(["dl", "m"]) if self.options.shared and self.settings.os == "Windows": self.cpp_info.defines.append("CPPUNIT_DLL") From 88889949e9d6cdc6bb1849248960774972ebf854 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sun, 12 Feb 2023 11:17:45 +0100 Subject: [PATCH 4/6] use check_min_vs --- recipes/cppunit/all/conanfile.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/recipes/cppunit/all/conanfile.py b/recipes/cppunit/all/conanfile.py index 075926da847c9..285135b6b075b 100644 --- a/recipes/cppunit/all/conanfile.py +++ b/recipes/cppunit/all/conanfile.py @@ -5,11 +5,10 @@ from conan.tools.files import copy, get, rename, rm, rmdir from conan.tools.gnu import Autotools, AutotoolsToolchain from conan.tools.layout import basic_layout -from conan.tools.microsoft import is_msvc, unix_path -from conan.tools.scm import Version +from conan.tools.microsoft import check_min_vs, is_msvc, unix_path import os -required_conan_version = ">=1.54.0" +required_conan_version = ">=1.57.0" class CppunitConan(ConanFile): @@ -67,8 +66,7 @@ def generate(self): tc.extra_defines.append("CPPUNIT_BUILD_DLL") if is_msvc(self): tc.extra_cxxflags.append("-EHsc") - if (str(self.settings.compiler) == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ - (str(self.settings.compiler) == "msvc" and Version(self.settings.compiler.version) >= "180"): + if check_min_vs(self, "180", raise_invalid=False): tc.extra_cflags.append("-FS") tc.extra_cxxflags.append("-FS") if is_apple_os(self): From faf2b69e508b05e7a16a2cdcafaa4cc711bc2e45 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sun, 12 Feb 2023 11:18:28 +0100 Subject: [PATCH 5/6] add package_type --- recipes/cppunit/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/cppunit/all/conanfile.py b/recipes/cppunit/all/conanfile.py index 285135b6b075b..cf5a4afda37de 100644 --- a/recipes/cppunit/all/conanfile.py +++ b/recipes/cppunit/all/conanfile.py @@ -21,6 +21,7 @@ class CppunitConan(ConanFile): license = " LGPL-2.1-or-later" homepage = "https://freedesktop.org/wiki/Software/cppunit/" url = "https://github.com/conan-io/conan-center-index" + package_type = "library" settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], From 576b9855a1a2f5eba3cbaa117844c7bf0ff80157 Mon Sep 17 00:00:00 2001 From: Chris Mc Date: Wed, 15 Feb 2023 22:18:35 -0800 Subject: [PATCH 6/6] Add a comment for tracking --- recipes/cppunit/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/cppunit/all/conanfile.py b/recipes/cppunit/all/conanfile.py index cf5a4afda37de..37927a939aa12 100644 --- a/recipes/cppunit/all/conanfile.py +++ b/recipes/cppunit/all/conanfile.py @@ -71,6 +71,7 @@ def generate(self): tc.extra_cflags.append("-FS") tc.extra_cxxflags.append("-FS") if is_apple_os(self): + # https://github.com/conan-io/conan-center-index/pull/15759#issuecomment-1419046535 tc.extra_ldflags.append("-headerpad_max_install_names") yes_no = lambda v: "yes" if v else "no" tc.configure_args.extend([