From ca56ee53987a4c7454876544913b5df2ad7f5671 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 1 Feb 2023 22:00:19 +0000 Subject: [PATCH 01/17] [cairomm] port to v2 toolchain, add 1.16.2 --- recipes/cairomm/all/conandata.yml | 5 +- recipes/cairomm/all/conanfile.py | 92 +++++++++---------- .../cairomm/all/test_package/CMakeLists.txt | 3 - recipes/cairomm/all/test_package/conanfile.py | 19 +++- .../all/test_v1_package/CMakeLists.txt | 16 ++++ .../cairomm/all/test_v1_package/conanfile.py | 18 ++++ recipes/cairomm/config.yml | 2 + 7 files changed, 97 insertions(+), 58 deletions(-) create mode 100644 recipes/cairomm/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/cairomm/all/test_v1_package/conanfile.py diff --git a/recipes/cairomm/all/conandata.yml b/recipes/cairomm/all/conandata.yml index e9529d1b4235f..f4e1ff00b7424 100644 --- a/recipes/cairomm/all/conandata.yml +++ b/recipes/cairomm/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.16.2": + url: "https://cairographics.org/releases/cairomm-1.16.2.tar.xz" + sha256: "6a63bf98a97dda2b0f55e34d1b5f3fb909ef8b70f9b8d382cb1ff3978e7dc13f" "1.16.1": url: "https://cairographics.org/releases/cairomm-1.16.1.tar.xz" sha256: "6f6060d8e98dd4b8acfee2295fddbdd38cf487c07c26aad8d1a83bb9bff4a2c6" @@ -9,7 +12,5 @@ sources: patches: "1.16.1": - patch_file: "patches/enable_static_lib_1_16_1.patch" - base_path: "source_subfolder" "1.14.3": - patch_file: "patches/enable_static_lib_1_14_3.patch" - base_path: "source_subfolder" diff --git a/recipes/cairomm/all/conanfile.py b/recipes/cairomm/all/conanfile.py index 8a403a49b992b..c42a872d6e4c8 100644 --- a/recipes/cairomm/all/conanfile.py +++ b/recipes/cairomm/all/conanfile.py @@ -1,7 +1,14 @@ -from conans import ConanFile, Meson, tools -from conan.tools.files import rename +from conan import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.build import cross_building, check_min_cppstd +from conan.tools.files import rename, apply_conandata_patches, replace_in_file, get, copy, rm, rmdir, export_conandata_patches +from conan.tools.gnu import PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain from conan.tools.microsoft import is_msvc -from conans.errors import ConanInvalidConfiguration +from conan.errors import ConanInvalidConfiguration +from conan.tools.scm import Version + import glob import os import shutil @@ -25,46 +32,35 @@ class CairommConan(ConanFile): "fPIC": True, } - generators = "pkg_config" - exports_sources = "patches/**" short_paths = True def _abi_version(self): - return "1.16" if tools.Version(self.version) >= "1.16.0" else "1.0" + return "1.16" if Version(self.version) >= "1.16.0" else "1.0" def validate(self): - if hasattr(self, "settings_build") and tools.cross_building(self): + if hasattr(self, "settings_build") and cross_building(self): raise ConanInvalidConfiguration("Cross-building not implemented") if self.settings.compiler.get_safe("cppstd"): if self._abi_version() == "1.16": - tools.check_min_cppstd(self, 17) + check_min_cppstd(self, 17) else: - tools.check_min_cppstd(self, 11) + check_min_cppstd(self, 11) if self.options.shared and not self.options["cairo"].shared: raise ConanInvalidConfiguration( "Linking against static cairo would cause shared cairomm to link " "against static glib which can cause problems." ) - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) + apply_conandata_patches(self) if is_msvc(self): # when using cpp_std=c++11 the /permissive- flag is added which # attempts enforcing standard conformant c++ code # the problem is that older versions of Windows SDK is not standard # conformant! see: # https://developercommunity.visualstudio.com/t/error-c2760-in-combaseapih-with-windows-sdk-81-and/185399 - tools.replace_in_file( - os.path.join(self._source_subfolder, "meson.build"), + replace_in_file(self, + os.path.join(self.source_folder, "meson.build"), "cpp_std=c++", "cpp_std=vc++") def config_options(self): @@ -78,54 +74,54 @@ def configure(self): self.options["cairo"].shared = True def build_requirements(self): - self.build_requires("meson/0.59.1") - self.build_requires("pkgconf/1.7.4") + self.build_requires("meson/1.0.0") + self.build_requires("pkgconf/1.9.3") def requirements(self): - self.requires("cairo/1.17.4") + self.requires("cairo/1.17.6") if self._abi_version() == "1.16": self.requires("libsigcpp/3.0.7") else: self.requires("libsigcpp/2.10.8") + def export_sources(self): + export_conandata_patches(self) + def source(self): - tools.get( + get(self, **self.conan_data["sources"][self.version], - strip_root=True, - destination=self._source_subfolder, + strip_root=True ) + def layout(self): + basic_layout(self, src_folder="src") + def build(self): self._patch_sources() - with tools.environment_append(tools.RunEnvironment(self).vars): - meson = self._configure_meson() - meson.build() - - def _configure_meson(self): meson = Meson(self) - defs = { + meson.configure() + meson.build() + + def generate(self): + PkgConfigDeps(self).generate() + + tc = MesonToolchain(self) + tc.project_options.update({ "build-examples": "false", "build-documentation": "false", "build-tests": "false", "msvc14x-parallel-installable": "false", "default_library": "shared" if self.options.shared else "static", - } - meson.configure( - defs=defs, - build_folder=self._build_subfolder, - source_folder=self._source_subfolder, - pkg_config_paths=[self.install_folder], - ) - return meson + }) + tc.generate() def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) - meson = self._configure_meson() + copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) + meson = Meson(self) meson.install() if is_msvc(self): - tools.remove_files_by_mask( - os.path.join(self.package_folder, "bin"), "*.pdb") + rm(self, "*.pdb",os.path.join(self.package_folder, "bin"), recursive=True) if not self.options.shared: rename( self, @@ -157,7 +153,7 @@ def package(self): ) for dir_to_remove in ["pkgconfig", f"cairomm-{self._abi_version()}"]: - tools.rmdir(os.path.join(self.package_folder, "lib", + rmdir(self, os.path.join(self.package_folder, "lib", dir_to_remove)) def package_info(self): @@ -171,7 +167,7 @@ def package_info(self): self.cpp_info.components["cairomm-1.16"].requires = [ "libsigcpp::sigc++", "cairo::cairo_" ] - if tools.is_apple_os(self.settings.os): + if is_apple_os(self): self.cpp_info.components["cairomm-1.16"].frameworks = [ "CoreFoundation" ] @@ -185,7 +181,7 @@ def package_info(self): self.cpp_info.components["cairomm-1.0"].requires = [ "libsigcpp::sigc++-2.0", "cairo::cairo_" ] - if tools.is_apple_os(self.settings.os): + if is_apple_os(self): self.cpp_info.components["cairomm-1.0"].frameworks = [ "CoreFoundation" ] diff --git a/recipes/cairomm/all/test_package/CMakeLists.txt b/recipes/cairomm/all/test_package/CMakeLists.txt index 366e829c2704c..e3851665d1f40 100644 --- a/recipes/cairomm/all/test_package/CMakeLists.txt +++ b/recipes/cairomm/all/test_package/CMakeLists.txt @@ -1,9 +1,6 @@ cmake_minimum_required(VERSION 3.6) project(test_package) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGET) - add_executable(${PROJECT_NAME} test_package.cpp) find_package(cairomm REQUIRED CONFIG) diff --git a/recipes/cairomm/all/test_package/conanfile.py b/recipes/cairomm/all/test_package/conanfile.py index a691174f8ed16..ab1850a98179c 100644 --- a/recipes/cairomm/all/test_package/conanfile.py +++ b/recipes/cairomm/all/test_package/conanfile.py @@ -1,10 +1,19 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeDeps", "CMakeToolchain" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,7 +21,7 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/cairomm/all/test_v1_package/CMakeLists.txt b/recipes/cairomm/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..366e829c2704c --- /dev/null +++ b/recipes/cairomm/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.6) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGET) + +add_executable(${PROJECT_NAME} test_package.cpp) + +find_package(cairomm REQUIRED CONFIG) +if (TARGET cairomm::cairomm-1.16) + set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) + target_link_libraries(${PROJECT_NAME} cairomm::cairomm-1.16) +else() + set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) + target_link_libraries(${PROJECT_NAME} cairomm::cairomm-1.0) +endif() diff --git a/recipes/cairomm/all/test_v1_package/conanfile.py b/recipes/cairomm/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..a691174f8ed16 --- /dev/null +++ b/recipes/cairomm/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + 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): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) + diff --git a/recipes/cairomm/config.yml b/recipes/cairomm/config.yml index cc2573070ee79..089ccdbd5de45 100644 --- a/recipes/cairomm/config.yml +++ b/recipes/cairomm/config.yml @@ -1,4 +1,6 @@ versions: + "1.16.2": + folder: "all" "1.16.1": folder: "all" "1.14.3": From fed9eb3d57d37b1a3d7eed667f38228c4a76d814 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 4 Feb 2023 11:08:41 +0000 Subject: [PATCH 02/17] [cairomm] reorder methods --- recipes/cairomm/all/conanfile.py | 118 ++++++++++++++++--------------- 1 file changed, 61 insertions(+), 57 deletions(-) diff --git a/recipes/cairomm/all/conanfile.py b/recipes/cairomm/all/conanfile.py index c42a872d6e4c8..d0599954526de 100644 --- a/recipes/cairomm/all/conanfile.py +++ b/recipes/cairomm/all/conanfile.py @@ -1,12 +1,22 @@ from conan import ConanFile +from conan.errors import ConanInvalidConfiguration from conan.tools.apple import is_apple_os from conan.tools.build import cross_building, check_min_cppstd -from conan.tools.files import rename, apply_conandata_patches, replace_in_file, get, copy, rm, rmdir, export_conandata_patches +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import ( + apply_conandata_patches, + copy, + export_conandata_patches, + get, + rename, + replace_in_file, + rm, + rmdir +) from conan.tools.gnu import PkgConfigDeps from conan.tools.layout import basic_layout from conan.tools.meson import Meson, MesonToolchain from conan.tools.microsoft import is_msvc -from conan.errors import ConanInvalidConfiguration from conan.tools.scm import Version import glob @@ -21,7 +31,6 @@ class CairommConan(ConanFile): license = "LGPL-2.0" description = "cairomm is a C++ wrapper for the cairo graphics library." topics = ["cairo", "wrapper", "graphics"] - settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -31,37 +40,10 @@ class CairommConan(ConanFile): "shared": False, "fPIC": True, } - short_paths = True - def _abi_version(self): - return "1.16" if Version(self.version) >= "1.16.0" else "1.0" - - def validate(self): - if hasattr(self, "settings_build") and cross_building(self): - raise ConanInvalidConfiguration("Cross-building not implemented") - if self.settings.compiler.get_safe("cppstd"): - if self._abi_version() == "1.16": - check_min_cppstd(self, 17) - else: - check_min_cppstd(self, 11) - if self.options.shared and not self.options["cairo"].shared: - raise ConanInvalidConfiguration( - "Linking against static cairo would cause shared cairomm to link " - "against static glib which can cause problems." - ) - - def _patch_sources(self): - apply_conandata_patches(self) - if is_msvc(self): - # when using cpp_std=c++11 the /permissive- flag is added which - # attempts enforcing standard conformant c++ code - # the problem is that older versions of Windows SDK is not standard - # conformant! see: - # https://developercommunity.visualstudio.com/t/error-c2760-in-combaseapih-with-windows-sdk-81-and/185399 - replace_in_file(self, - os.path.join(self.source_folder, "meson.build"), - "cpp_std=c++", "cpp_std=vc++") + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -69,41 +51,51 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC + self.options.rm_safe("fPIC") if self.options.shared: - self.options["cairo"].shared = True + self.dependencies["cairo"].options.shared = True - def build_requirements(self): - self.build_requires("meson/1.0.0") - self.build_requires("pkgconf/1.9.3") + def layout(self): + basic_layout(self, src_folder="src") + + def _abi_version(self): + return "1.16" if Version(self.version) >= "1.16.0" else "1.0" def requirements(self): self.requires("cairo/1.17.6") - if self._abi_version() == "1.16": self.requires("libsigcpp/3.0.7") else: self.requires("libsigcpp/2.10.8") - def export_sources(self): - export_conandata_patches(self) + def package_id(self): + self.info.requires["cairo"].full_package_mode() - def source(self): - get(self, - **self.conan_data["sources"][self.version], - strip_root=True - ) + def validate(self): + if hasattr(self, "settings_build") and cross_building(self): + raise ConanInvalidConfiguration("Cross-building not implemented") + if self.settings.compiler.get_safe("cppstd"): + if self._abi_version() == "1.16": + check_min_cppstd(self, 17) + else: + check_min_cppstd(self, 11) + if self.options.shared and not self.dependencies["cairo"].options.shared: + raise ConanInvalidConfiguration( + "Linking against static cairo would cause shared cairomm to link " + "against static glib which can cause problems." + ) - def layout(self): - basic_layout(self, src_folder="src") + def build_requirements(self): + self.tool_requires("meson/1.0.0") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/1.9.3") - def build(self): - self._patch_sources() - meson = Meson(self) - meson.configure() - meson.build() + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) def generate(self): + VirtualBuildEnv(self).generate() + PkgConfigDeps(self).generate() tc = MesonToolchain(self) @@ -111,11 +103,26 @@ def generate(self): "build-examples": "false", "build-documentation": "false", "build-tests": "false", - "msvc14x-parallel-installable": "false", - "default_library": "shared" if self.options.shared else "static", + "msvc14x-parallel-installable": "false" }) tc.generate() + def _patch_sources(self): + apply_conandata_patches(self) + if is_msvc(self): + # when using cpp_std=c++11 the /permissive- flag is added which + # attempts enforcing standard conformant c++ code + # the problem is that older versions of Windows SDK is not standard + # conformant! see: + # https://developercommunity.visualstudio.com/t/error-c2760-in-combaseapih-with-windows-sdk-81-and/185399 + replace_in_file(self, os.path.join(self.source_folder, "meson.build"), "cpp_std=c++", "cpp_std=vc++") + + def build(self): + self._patch_sources() + meson = Meson(self) + meson.configure() + meson.build() + def package(self): copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) meson = Meson(self) @@ -185,6 +192,3 @@ def package_info(self): self.cpp_info.components["cairomm-1.0"].frameworks = [ "CoreFoundation" ] - - def package_id(self): - self.info.requires["cairo"].full_package_mode() From 676b25734859c079a73496e30d6e3fa83c164f6c Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 4 Feb 2023 11:14:11 +0000 Subject: [PATCH 03/17] [cairomm] update test packages --- .../cairomm/all/test_package/CMakeLists.txt | 13 ----------- recipes/cairomm/all/test_package/conanfile.py | 23 +++++++++++-------- recipes/cairomm/all/test_package/meson.build | 5 ++++ .../all/test_v1_package/CMakeLists.txt | 16 ------------- .../cairomm/all/test_v1_package/conanfile.py | 20 +++++++++------- 5 files changed, 31 insertions(+), 46 deletions(-) delete mode 100644 recipes/cairomm/all/test_package/CMakeLists.txt create mode 100644 recipes/cairomm/all/test_package/meson.build delete mode 100644 recipes/cairomm/all/test_v1_package/CMakeLists.txt diff --git a/recipes/cairomm/all/test_package/CMakeLists.txt b/recipes/cairomm/all/test_package/CMakeLists.txt deleted file mode 100644 index e3851665d1f40..0000000000000 --- a/recipes/cairomm/all/test_package/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.6) -project(test_package) - -add_executable(${PROJECT_NAME} test_package.cpp) - -find_package(cairomm REQUIRED CONFIG) -if (TARGET cairomm::cairomm-1.16) - set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) - target_link_libraries(${PROJECT_NAME} cairomm::cairomm-1.16) -else() - set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) - target_link_libraries(${PROJECT_NAME} cairomm::cairomm-1.0) -endif() diff --git a/recipes/cairomm/all/test_package/conanfile.py b/recipes/cairomm/all/test_package/conanfile.py index ab1850a98179c..533c0c2b3e454 100644 --- a/recipes/cairomm/all/test_package/conanfile.py +++ b/recipes/cairomm/all/test_package/conanfile.py @@ -1,27 +1,32 @@ from conan import ConanFile from conan.tools.build import can_run -from conan.tools.cmake import cmake_layout, CMake -import os +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson +import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "CMakeDeps", "CMakeToolchain" + generators = "PkgConfigDeps", "MesonToolchain", "VirtualRunEnv", "VirtualBuildEnv" test_type = "explicit" + def layout(self): + basic_layout(self) + def requirements(self): self.requires(self.tested_reference_str) - def layout(self): - cmake_layout(self) + def build_requirements(self): + self.tool_requires("meson/0.63.3") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/1.9.3") def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() + meson = Meson(self) + meson.configure() + meson.build() def test(self): if can_run(self): bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") self.run(bin_path, env="conanrun") - diff --git a/recipes/cairomm/all/test_package/meson.build b/recipes/cairomm/all/test_package/meson.build new file mode 100644 index 0000000000000..40a4b1f353b09 --- /dev/null +++ b/recipes/cairomm/all/test_package/meson.build @@ -0,0 +1,5 @@ +project('test_package', 'cpp') +package_dep = dependency('cairomm') +executable('test_package', + sources : ['test_package.cpp'], + dependencies : [package_dep]) diff --git a/recipes/cairomm/all/test_v1_package/CMakeLists.txt b/recipes/cairomm/all/test_v1_package/CMakeLists.txt deleted file mode 100644 index 366e829c2704c..0000000000000 --- a/recipes/cairomm/all/test_v1_package/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 3.6) -project(test_package) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGET) - -add_executable(${PROJECT_NAME} test_package.cpp) - -find_package(cairomm REQUIRED CONFIG) -if (TARGET cairomm::cairomm-1.16) - set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) - target_link_libraries(${PROJECT_NAME} cairomm::cairomm-1.16) -else() - set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) - target_link_libraries(${PROJECT_NAME} cairomm::cairomm-1.0) -endif() diff --git a/recipes/cairomm/all/test_v1_package/conanfile.py b/recipes/cairomm/all/test_v1_package/conanfile.py index a691174f8ed16..9e33088cb1fee 100644 --- a/recipes/cairomm/all/test_v1_package/conanfile.py +++ b/recipes/cairomm/all/test_v1_package/conanfile.py @@ -1,18 +1,22 @@ -from conans import ConanFile, CMake, tools +from conans import ConanFile, Meson +from conan.tools.build import cross_building import os -class TestPackageConan(ConanFile): +class TestPackageV1Conan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "pkg_config" + + def build_requirements(self): + self.build_requires("meson/0.63.3") + self.build_requires("pkgconf/1.9.3") def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() + meson = Meson(self) + meson.configure(build_folder="bin", source_folder="../test_package") + meson.build() def test(self): - if not tools.cross_building(self): + if not cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) - From 151e639980f7af580688219f9ceeb7573c894bba Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 4 Feb 2023 11:19:09 +0000 Subject: [PATCH 04/17] Revert "[cairomm] update test packages" This reverts commit 676b25734859c079a73496e30d6e3fa83c164f6c. --- .../cairomm/all/test_package/CMakeLists.txt | 13 +++++++++++ recipes/cairomm/all/test_package/conanfile.py | 23 ++++++++----------- recipes/cairomm/all/test_package/meson.build | 5 ---- .../all/test_v1_package/CMakeLists.txt | 16 +++++++++++++ .../cairomm/all/test_v1_package/conanfile.py | 20 +++++++--------- 5 files changed, 46 insertions(+), 31 deletions(-) create mode 100644 recipes/cairomm/all/test_package/CMakeLists.txt delete mode 100644 recipes/cairomm/all/test_package/meson.build create mode 100644 recipes/cairomm/all/test_v1_package/CMakeLists.txt diff --git a/recipes/cairomm/all/test_package/CMakeLists.txt b/recipes/cairomm/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e3851665d1f40 --- /dev/null +++ b/recipes/cairomm/all/test_package/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.6) +project(test_package) + +add_executable(${PROJECT_NAME} test_package.cpp) + +find_package(cairomm REQUIRED CONFIG) +if (TARGET cairomm::cairomm-1.16) + set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) + target_link_libraries(${PROJECT_NAME} cairomm::cairomm-1.16) +else() + set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) + target_link_libraries(${PROJECT_NAME} cairomm::cairomm-1.0) +endif() diff --git a/recipes/cairomm/all/test_package/conanfile.py b/recipes/cairomm/all/test_package/conanfile.py index 533c0c2b3e454..ab1850a98179c 100644 --- a/recipes/cairomm/all/test_package/conanfile.py +++ b/recipes/cairomm/all/test_package/conanfile.py @@ -1,32 +1,27 @@ from conan import ConanFile from conan.tools.build import can_run -from conan.tools.layout import basic_layout -from conan.tools.meson import Meson - +from conan.tools.cmake import cmake_layout, CMake import os + class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "PkgConfigDeps", "MesonToolchain", "VirtualRunEnv", "VirtualBuildEnv" + generators = "CMakeDeps", "CMakeToolchain" test_type = "explicit" - def layout(self): - basic_layout(self) - def requirements(self): self.requires(self.tested_reference_str) - def build_requirements(self): - self.tool_requires("meson/0.63.3") - if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): - self.tool_requires("pkgconf/1.9.3") + def layout(self): + cmake_layout(self) def build(self): - meson = Meson(self) - meson.configure() - meson.build() + cmake = CMake(self) + cmake.configure() + cmake.build() def test(self): if can_run(self): bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") self.run(bin_path, env="conanrun") + diff --git a/recipes/cairomm/all/test_package/meson.build b/recipes/cairomm/all/test_package/meson.build deleted file mode 100644 index 40a4b1f353b09..0000000000000 --- a/recipes/cairomm/all/test_package/meson.build +++ /dev/null @@ -1,5 +0,0 @@ -project('test_package', 'cpp') -package_dep = dependency('cairomm') -executable('test_package', - sources : ['test_package.cpp'], - dependencies : [package_dep]) diff --git a/recipes/cairomm/all/test_v1_package/CMakeLists.txt b/recipes/cairomm/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..366e829c2704c --- /dev/null +++ b/recipes/cairomm/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.6) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGET) + +add_executable(${PROJECT_NAME} test_package.cpp) + +find_package(cairomm REQUIRED CONFIG) +if (TARGET cairomm::cairomm-1.16) + set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) + target_link_libraries(${PROJECT_NAME} cairomm::cairomm-1.16) +else() + set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) + target_link_libraries(${PROJECT_NAME} cairomm::cairomm-1.0) +endif() diff --git a/recipes/cairomm/all/test_v1_package/conanfile.py b/recipes/cairomm/all/test_v1_package/conanfile.py index 9e33088cb1fee..a691174f8ed16 100644 --- a/recipes/cairomm/all/test_v1_package/conanfile.py +++ b/recipes/cairomm/all/test_v1_package/conanfile.py @@ -1,22 +1,18 @@ -from conans import ConanFile, Meson -from conan.tools.build import cross_building +from conans import ConanFile, CMake, tools import os -class TestPackageV1Conan(ConanFile): +class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "pkg_config" - - def build_requirements(self): - self.build_requires("meson/0.63.3") - self.build_requires("pkgconf/1.9.3") + generators = "cmake", "cmake_find_package_multi" def build(self): - meson = Meson(self) - meson.configure(build_folder="bin", source_folder="../test_package") - meson.build() + cmake = CMake(self) + cmake.configure() + cmake.build() def test(self): - if not cross_building(self): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) + From bfcdc981e1406ef31fcf234879699cd10f12b479 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 4 Feb 2023 11:23:28 +0000 Subject: [PATCH 05/17] [cairomm] update test package --- recipes/cairomm/all/test_package/conanfile.py | 1 - .../cairomm/all/test_v1_package/CMakeLists.txt | 16 ++++------------ recipes/cairomm/all/test_v1_package/conanfile.py | 1 - 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/recipes/cairomm/all/test_package/conanfile.py b/recipes/cairomm/all/test_package/conanfile.py index ab1850a98179c..99e892b0aa72f 100644 --- a/recipes/cairomm/all/test_package/conanfile.py +++ b/recipes/cairomm/all/test_package/conanfile.py @@ -24,4 +24,3 @@ def test(self): if can_run(self): bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") self.run(bin_path, env="conanrun") - diff --git a/recipes/cairomm/all/test_v1_package/CMakeLists.txt b/recipes/cairomm/all/test_v1_package/CMakeLists.txt index 366e829c2704c..925ecbe19e448 100644 --- a/recipes/cairomm/all/test_v1_package/CMakeLists.txt +++ b/recipes/cairomm/all/test_v1_package/CMakeLists.txt @@ -1,16 +1,8 @@ -cmake_minimum_required(VERSION 3.6) +cmake_minimum_required(VERSION 3.1) project(test_package) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGET) +conan_basic_setup(TARGETS) -add_executable(${PROJECT_NAME} test_package.cpp) - -find_package(cairomm REQUIRED CONFIG) -if (TARGET cairomm::cairomm-1.16) - set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) - target_link_libraries(${PROJECT_NAME} cairomm::cairomm-1.16) -else() - set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) - target_link_libraries(${PROJECT_NAME} cairomm::cairomm-1.0) -endif() +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/cairomm/all/test_v1_package/conanfile.py b/recipes/cairomm/all/test_v1_package/conanfile.py index a691174f8ed16..38f4483872d47 100644 --- a/recipes/cairomm/all/test_v1_package/conanfile.py +++ b/recipes/cairomm/all/test_v1_package/conanfile.py @@ -15,4 +15,3 @@ def test(self): if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) - From 8bce3076c27c20e1a6d333b81a5d62c03ecfef36 Mon Sep 17 00:00:00 2001 From: Luis Caro Campos <3535649+jcar87@users.noreply.github.com> Date: Thu, 29 Jun 2023 11:15:13 +0100 Subject: [PATCH 06/17] cairomm: fixes --- recipes/cairomm/all/conanfile.py | 2 +- recipes/cairomm/all/test_package/CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/cairomm/all/conanfile.py b/recipes/cairomm/all/conanfile.py index d0599954526de..7cc415c3ecb2a 100644 --- a/recipes/cairomm/all/conanfile.py +++ b/recipes/cairomm/all/conanfile.py @@ -53,7 +53,7 @@ def configure(self): if self.options.shared: self.options.rm_safe("fPIC") if self.options.shared: - self.dependencies["cairo"].options.shared = True + self.options["cairo"].shared = True def layout(self): basic_layout(self, src_folder="src") diff --git a/recipes/cairomm/all/test_package/CMakeLists.txt b/recipes/cairomm/all/test_package/CMakeLists.txt index e3851665d1f40..ffae51a0f26ff 100644 --- a/recipes/cairomm/all/test_package/CMakeLists.txt +++ b/recipes/cairomm/all/test_package/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.6) -project(test_package) +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) add_executable(${PROJECT_NAME} test_package.cpp) From 5866b9676f9dd4e09f636bd6cb707e37d29782c5 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 18 Aug 2022 13:45:13 +0100 Subject: [PATCH 07/17] [cairomm] modernize --- recipes/cairomm/all/conanfile.py | 111 ++++++++++++------------------- 1 file changed, 42 insertions(+), 69 deletions(-) diff --git a/recipes/cairomm/all/conanfile.py b/recipes/cairomm/all/conanfile.py index 8a403a49b992b..662141738c3d0 100644 --- a/recipes/cairomm/all/conanfile.py +++ b/recipes/cairomm/all/conanfile.py @@ -1,11 +1,18 @@ -from conans import ConanFile, Meson, tools -from conan.tools.files import rename -from conan.tools.microsoft import is_msvc -from conans.errors import ConanInvalidConfiguration import glob import os import shutil +from conan import ConanFile +from conan.tools import ( + build, + files, + microsoft, + scm +) +from conan.errors import ConanInvalidConfiguration +from conans import Meson +from conans import tools + class CairommConan(ConanFile): name = "cairomm" @@ -29,17 +36,18 @@ class CairommConan(ConanFile): exports_sources = "patches/**" short_paths = True + @property def _abi_version(self): - return "1.16" if tools.Version(self.version) >= "1.16.0" else "1.0" + return "1.16" if scm.Version(self.version) >= "1.16.0" else "1.0" def validate(self): - if hasattr(self, "settings_build") and tools.cross_building(self): + if hasattr(self, "settings_build") and build.cross_building(self): raise ConanInvalidConfiguration("Cross-building not implemented") if self.settings.compiler.get_safe("cppstd"): - if self._abi_version() == "1.16": - tools.check_min_cppstd(self, 17) + if self._abi_version == "1.16": + build.check_min_cppstd(self, 17) else: - tools.check_min_cppstd(self, 11) + build.check_min_cppstd(self, 11) if self.options.shared and not self.options["cairo"].shared: raise ConanInvalidConfiguration( "Linking against static cairo would cause shared cairomm to link " @@ -55,15 +63,14 @@ def _build_subfolder(self): return "build_subfolder" def _patch_sources(self): - for patch in self.conan_data["patches"][self.version]: - tools.patch(**patch) - if is_msvc(self): + files.apply_conandata_patches(self) + if microsoft.is_msvc(self): # when using cpp_std=c++11 the /permissive- flag is added which # attempts enforcing standard conformant c++ code # the problem is that older versions of Windows SDK is not standard # conformant! see: # https://developercommunity.visualstudio.com/t/error-c2760-in-combaseapih-with-windows-sdk-81-and/185399 - tools.replace_in_file( + files.replace_in_file(self, os.path.join(self._source_subfolder, "meson.build"), "cpp_std=c++", "cpp_std=vc++") @@ -84,17 +91,13 @@ def build_requirements(self): def requirements(self): self.requires("cairo/1.17.4") - if self._abi_version() == "1.16": + if self._abi_version == "1.16": self.requires("libsigcpp/3.0.7") else: self.requires("libsigcpp/2.10.8") def source(self): - tools.get( - **self.conan_data["sources"][self.version], - strip_root=True, - destination=self._source_subfolder, - ) + files.get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) def build(self): self._patch_sources() @@ -123,72 +126,42 @@ def package(self): self.copy("COPYING", dst="licenses", src=self._source_subfolder) meson = self._configure_meson() meson.install() - if is_msvc(self): - tools.remove_files_by_mask( - os.path.join(self.package_folder, "bin"), "*.pdb") + if microsoft.is_msvc(self): + files.rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) if not self.options.shared: - rename( - self, - os.path.join( - self.package_folder, - "lib", - f"libcairomm-{self._abi_version()}.a", - ), - os.path.join(self.package_folder, "lib", - f"cairomm-{self._abi_version()}.lib"), + files.rename(self, + os.path.join( self.package_folder, "lib", f"libcairomm-{self._abi_version}.a"), + os.path.join(self.package_folder, "lib", f"cairomm-{self._abi_version}.lib"), ) for header_file in glob.glob( - os.path.join( - self.package_folder, - "lib", - f"cairomm-{self._abi_version()}", - "include", - "*.h", - )): + os.path.join(self.package_folder, "lib", f"cairomm-{self._abi_version}", "include", "*.h")): shutil.move( header_file, os.path.join( self.package_folder, "include", - f"cairomm-{self._abi_version()}", + f"cairomm-{self._abi_version}", os.path.basename(header_file), ), ) - for dir_to_remove in ["pkgconfig", f"cairomm-{self._abi_version()}"]: - tools.rmdir(os.path.join(self.package_folder, "lib", - dir_to_remove)) + for dir_to_remove in ["pkgconfig", f"cairomm-{self._abi_version}"]: + files.rmdir(self, os.path.join(self.package_folder, "lib", dir_to_remove)) def package_info(self): - if self._abi_version() == "1.16": - self.cpp_info.components["cairomm-1.16"].names[ - "pkg_config"] = "cairomm-1.16" - self.cpp_info.components["cairomm-1.16"].includedirs = [ - os.path.join("include", "cairomm-1.16") - ] - self.cpp_info.components["cairomm-1.16"].libs = ["cairomm-1.16"] - self.cpp_info.components["cairomm-1.16"].requires = [ - "libsigcpp::sigc++", "cairo::cairo_" - ] - if tools.is_apple_os(self.settings.os): - self.cpp_info.components["cairomm-1.16"].frameworks = [ - "CoreFoundation" - ] + cairomm_lib_name = f"cairomm-{self._abi_version}" + self.cpp_info.components[cairomm_lib_name].set_property("pkg_config_name", cairomm_lib_name) + self.cpp_info.components[cairomm_lib_name].includedirs = [os.path.join("include", cairomm_lib_name)] + self.cpp_info.components[cairomm_lib_name].libs = [cairomm_lib_name] + + if tools.is_apple_os(self.settings.os): + self.cpp_info.components[cairomm_lib_name].frameworks = ["CoreFoundation"] + + if self._abi_version == "1.16": + self.cpp_info.components[cairomm_lib_name].requires = ["libsigcpp::sigc++", "cairo::cairo_"] else: - self.cpp_info.components["cairomm-1.0"].names[ - "pkg_config"] = "cairomm-1.0" - self.cpp_info.components["cairomm-1.0"].includedirs = [ - os.path.join("include", "cairomm-1.0") - ] - self.cpp_info.components["cairomm-1.0"].libs = ["cairomm-1.0"] - self.cpp_info.components["cairomm-1.0"].requires = [ - "libsigcpp::sigc++-2.0", "cairo::cairo_" - ] - if tools.is_apple_os(self.settings.os): - self.cpp_info.components["cairomm-1.0"].frameworks = [ - "CoreFoundation" - ] + self.cpp_info.components[cairomm_lib_name].requires = ["libsigcpp::sigc++-2.0", "cairo::cairo_"] def package_id(self): self.info.requires["cairo"].full_package_mode() From fab93d1b56c1043b89f129735edca7b293d9a609 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Fri, 19 Aug 2022 09:52:07 +0100 Subject: [PATCH 08/17] [cairomm] full package mode only for shared cairo --- recipes/cairomm/all/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/cairomm/all/conanfile.py b/recipes/cairomm/all/conanfile.py index 662141738c3d0..90a37fa408dde 100644 --- a/recipes/cairomm/all/conanfile.py +++ b/recipes/cairomm/all/conanfile.py @@ -164,4 +164,5 @@ def package_info(self): self.cpp_info.components[cairomm_lib_name].requires = ["libsigcpp::sigc++-2.0", "cairo::cairo_"] def package_id(self): - self.info.requires["cairo"].full_package_mode() + if not self.options["cairo"].shared: + self.info.requires["cairo"].full_package_mode() From 342efd9936abea2395031ff1efba34f713848ae7 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 1 Sep 2022 12:42:46 +0100 Subject: [PATCH 09/17] [cairomm] use new toolchain --- recipes/cairomm/all/conandata.yml | 2 - recipes/cairomm/all/conanfile.py | 61 +++++++++---------- .../cairomm/all/test_package/CMakeLists.txt | 3 - recipes/cairomm/all/test_package/conanfile.py | 15 +++-- 4 files changed, 39 insertions(+), 42 deletions(-) diff --git a/recipes/cairomm/all/conandata.yml b/recipes/cairomm/all/conandata.yml index e9529d1b4235f..86d1d3bf1766d 100644 --- a/recipes/cairomm/all/conandata.yml +++ b/recipes/cairomm/all/conandata.yml @@ -9,7 +9,5 @@ sources: patches: "1.16.1": - patch_file: "patches/enable_static_lib_1_16_1.patch" - base_path: "source_subfolder" "1.14.3": - patch_file: "patches/enable_static_lib_1_14_3.patch" - base_path: "source_subfolder" diff --git a/recipes/cairomm/all/conanfile.py b/recipes/cairomm/all/conanfile.py index 90a37fa408dde..dd441305547b4 100644 --- a/recipes/cairomm/all/conanfile.py +++ b/recipes/cairomm/all/conanfile.py @@ -4,14 +4,16 @@ from conan import ConanFile from conan.tools import ( + apple, build, files, microsoft, scm ) +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain +from conan.tools.gnu import PkgConfigDeps from conan.errors import ConanInvalidConfiguration -from conans import Meson -from conans import tools class CairommConan(ConanFile): @@ -32,7 +34,6 @@ class CairommConan(ConanFile): "fPIC": True, } - generators = "pkg_config" exports_sources = "patches/**" short_paths = True @@ -54,14 +55,6 @@ def validate(self): "against static glib which can cause problems." ) - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" - def _patch_sources(self): files.apply_conandata_patches(self) if microsoft.is_msvc(self): @@ -85,8 +78,8 @@ def configure(self): self.options["cairo"].shared = True def build_requirements(self): - self.build_requires("meson/0.59.1") - self.build_requires("pkgconf/1.7.4") + self.tool_requires("meson/0.63.1") + self.tool_requires("pkgconf/1.7.4") def requirements(self): self.requires("cairo/1.17.4") @@ -96,34 +89,38 @@ def requirements(self): else: self.requires("libsigcpp/2.10.8") - def source(self): - files.get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + def layout(self): + return basic_layout(self, src_folder="source_subfolder") - def build(self): - self._patch_sources() - with tools.environment_append(tools.RunEnvironment(self).vars): - meson = self._configure_meson() - meson.build() + def generate(self): + deps = PkgConfigDeps(self) + deps.generate() - def _configure_meson(self): - meson = Meson(self) - defs = { + tc = MesonToolchain(self) + tc.project_options.update({ "build-examples": "false", "build-documentation": "false", "build-tests": "false", "msvc14x-parallel-installable": "false", "default_library": "shared" if self.options.shared else "static", - } - meson.configure( - defs=defs, - build_folder=self._build_subfolder, - source_folder=self._source_subfolder, - pkg_config_paths=[self.install_folder], - ) + }) + tc.generate() + + def source(self): + files.get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self.source_folder) + + def build(self): + self._patch_sources() + meson = self._configure_meson() + meson.build() + + def _configure_meson(self): + meson = Meson(self) + meson.configure() return meson def package(self): - self.copy("COPYING", dst="licenses", src=self._source_subfolder) + self.copy("COPYING", dst="licenses", src=self.source_folder) meson = self._configure_meson() meson.install() if microsoft.is_msvc(self): @@ -155,7 +152,7 @@ def package_info(self): self.cpp_info.components[cairomm_lib_name].includedirs = [os.path.join("include", cairomm_lib_name)] self.cpp_info.components[cairomm_lib_name].libs = [cairomm_lib_name] - if tools.is_apple_os(self.settings.os): + if apple.is_apple_os(self): self.cpp_info.components[cairomm_lib_name].frameworks = ["CoreFoundation"] if self._abi_version == "1.16": diff --git a/recipes/cairomm/all/test_package/CMakeLists.txt b/recipes/cairomm/all/test_package/CMakeLists.txt index 366e829c2704c..e3851665d1f40 100644 --- a/recipes/cairomm/all/test_package/CMakeLists.txt +++ b/recipes/cairomm/all/test_package/CMakeLists.txt @@ -1,9 +1,6 @@ cmake_minimum_required(VERSION 3.6) project(test_package) -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGET) - add_executable(${PROJECT_NAME} test_package.cpp) find_package(cairomm REQUIRED CONFIG) diff --git a/recipes/cairomm/all/test_package/conanfile.py b/recipes/cairomm/all/test_package/conanfile.py index a691174f8ed16..7c00a8a985ca9 100644 --- a/recipes/cairomm/all/test_package/conanfile.py +++ b/recipes/cairomm/all/test_package/conanfile.py @@ -1,10 +1,16 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools import build +from conan.tools.cmake import CMake import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" + generators = "CMakeDeps", "CMakeToolchain" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) def build(self): cmake = CMake(self) @@ -12,7 +18,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") + if not build.cross_building(self): + bin_path = os.path.join(self.build_folder, "test_package") self.run(bin_path, run_environment=True) - From 16cf93dc8e4f1bb7defcac40d1b5483efabe922b Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 1 Sep 2022 12:48:18 +0100 Subject: [PATCH 10/17] [cairomm] fix reference to source subfolder --- recipes/cairomm/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cairomm/all/conanfile.py b/recipes/cairomm/all/conanfile.py index dd441305547b4..1485e30f1fc81 100644 --- a/recipes/cairomm/all/conanfile.py +++ b/recipes/cairomm/all/conanfile.py @@ -64,7 +64,7 @@ def _patch_sources(self): # conformant! see: # https://developercommunity.visualstudio.com/t/error-c2760-in-combaseapih-with-windows-sdk-81-and/185399 files.replace_in_file(self, - os.path.join(self._source_subfolder, "meson.build"), + os.path.join(self.source_folder, "meson.build"), "cpp_std=c++", "cpp_std=vc++") def config_options(self): From 034b5189b969958bc2d07d50815c19572cacbd81 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 17 Sep 2023 22:19:30 +0100 Subject: [PATCH 11/17] [cairomm] update for conan 2.0 --- recipes/cairomm/all/conanfile.py | 132 +++++++++--------- .../cairomm/all/test_package/CMakeLists.txt | 4 +- recipes/cairomm/all/test_package/conanfile.py | 4 +- 3 files changed, 73 insertions(+), 67 deletions(-) diff --git a/recipes/cairomm/all/conanfile.py b/recipes/cairomm/all/conanfile.py index 1485e30f1fc81..0897a5016fbaa 100644 --- a/recipes/cairomm/all/conanfile.py +++ b/recipes/cairomm/all/conanfile.py @@ -3,17 +3,16 @@ import shutil from conan import ConanFile -from conan.tools import ( - apple, - build, - files, - microsoft, - scm -) +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name, is_apple_os +from conan.tools.build import check_min_cppstd +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir, rename +from conan.tools.gnu import PkgConfigDeps from conan.tools.layout import basic_layout from conan.tools.meson import Meson, MesonToolchain -from conan.tools.gnu import PkgConfigDeps -from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.scm import Version class CairommConan(ConanFile): @@ -23,7 +22,6 @@ class CairommConan(ConanFile): license = "LGPL-2.0" description = "cairomm is a C++ wrapper for the cairo graphics library." topics = ["cairo", "wrapper", "graphics"] - settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -38,34 +36,21 @@ class CairommConan(ConanFile): short_paths = True @property - def _abi_version(self): - return "1.16" if scm.Version(self.version) >= "1.16.0" else "1.0" + def _min_cppstd(self): + return 17 - def validate(self): - if hasattr(self, "settings_build") and build.cross_building(self): - raise ConanInvalidConfiguration("Cross-building not implemented") - if self.settings.compiler.get_safe("cppstd"): - if self._abi_version == "1.16": - build.check_min_cppstd(self, 17) - else: - build.check_min_cppstd(self, 11) - if self.options.shared and not self.options["cairo"].shared: - raise ConanInvalidConfiguration( - "Linking against static cairo would cause shared cairomm to link " - "against static glib which can cause problems." - ) + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "clang": "7", + "apple-clang": "10", + } + + @property + def _abi_version(self): + return "1.16" if Version(self.version) >= "1.16.0" else "1.0" - def _patch_sources(self): - files.apply_conandata_patches(self) - if microsoft.is_msvc(self): - # when using cpp_std=c++11 the /permissive- flag is added which - # attempts enforcing standard conformant c++ code - # the problem is that older versions of Windows SDK is not standard - # conformant! see: - # https://developercommunity.visualstudio.com/t/error-c2760-in-combaseapih-with-windows-sdk-81-and/185399 - files.replace_in_file(self, - os.path.join(self.source_folder, "meson.build"), - "cpp_std=c++", "cpp_std=vc++") def config_options(self): if self.settings.os == "Windows": @@ -73,29 +58,41 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - if self.options.shared: - self.options["cairo"].shared = True + self.options.rm_safe("fPIC") + self.dependencies["cairo"].options.shared = True - def build_requirements(self): - self.tool_requires("meson/0.63.1") - self.tool_requires("pkgconf/1.7.4") + def layout(self): + basic_layout(self, src_folder="src") def requirements(self): - self.requires("cairo/1.17.4") + self.requires("cairo/1.17.6") if self._abi_version == "1.16": self.requires("libsigcpp/3.0.7") else: self.requires("libsigcpp/2.10.8") - def layout(self): - return basic_layout(self, src_folder="source_subfolder") + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + if self.settings.compiler.get_safe("cppstd"): + if self._abi_version == "1.16": + check_min_cppstd(self, 17) + else: + check_min_cppstd(self, 11) + if self.options.shared and not self.options["cairo"].shared: + raise ConanInvalidConfiguration( + "Linking against static cairo would cause shared cairomm to link " + "against static glib which can cause problems." + ) - def generate(self): - deps = PkgConfigDeps(self) - deps.generate() + def build_requirements(self): + self.tool_requires("meson/1.2.1") + self.tool_requires("pkgconf/2.0.3") + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): tc = MesonToolchain(self) tc.project_options.update({ "build-examples": "false", @@ -106,27 +103,36 @@ def generate(self): }) tc.generate() - def source(self): - files.get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self.source_folder) + PkgConfigDeps(self).generate() + VirtualBuildEnv(self).generate() + + def _patch_sources(self): + apply_conandata_patches(self) + if is_msvc(self): + # when using cpp_std=c++11 the /permissive- flag is added which + # attempts enforcing standard conformant c++ code + # the problem is that older versions of Windows SDK is not standard + # conformant! see: + # https://developercommunity.visualstudio.com/t/error-c2760-in-combaseapih-with-windows-sdk-81-and/185399 + replace_in_file(self, + os.path.join(self.source_folder, "meson.build"), + "cpp_std=c++", "cpp_std=vc++") def build(self): self._patch_sources() - meson = self._configure_meson() - meson.build() - - def _configure_meson(self): meson = Meson(self) meson.configure() - return meson + meson.build() def package(self): - self.copy("COPYING", dst="licenses", src=self.source_folder) - meson = self._configure_meson() + copy(self, pattern="COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + meson = Meson(self) meson.install() - if microsoft.is_msvc(self): - files.rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + + if is_msvc(self): + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) if not self.options.shared: - files.rename(self, + rename(self, os.path.join( self.package_folder, "lib", f"libcairomm-{self._abi_version}.a"), os.path.join(self.package_folder, "lib", f"cairomm-{self._abi_version}.lib"), ) @@ -144,7 +150,7 @@ def package(self): ) for dir_to_remove in ["pkgconfig", f"cairomm-{self._abi_version}"]: - files.rmdir(self, os.path.join(self.package_folder, "lib", dir_to_remove)) + rmdir(self, os.path.join(self.package_folder, "lib", dir_to_remove)) def package_info(self): cairomm_lib_name = f"cairomm-{self._abi_version}" @@ -152,7 +158,7 @@ def package_info(self): self.cpp_info.components[cairomm_lib_name].includedirs = [os.path.join("include", cairomm_lib_name)] self.cpp_info.components[cairomm_lib_name].libs = [cairomm_lib_name] - if apple.is_apple_os(self): + if is_apple_os(self): self.cpp_info.components[cairomm_lib_name].frameworks = ["CoreFoundation"] if self._abi_version == "1.16": @@ -161,5 +167,5 @@ def package_info(self): self.cpp_info.components[cairomm_lib_name].requires = ["libsigcpp::sigc++-2.0", "cairo::cairo_"] def package_id(self): - if not self.options["cairo"].shared: + if not self.dependencies["cairo"].options.shared: self.info.requires["cairo"].full_package_mode() diff --git a/recipes/cairomm/all/test_package/CMakeLists.txt b/recipes/cairomm/all/test_package/CMakeLists.txt index e3851665d1f40..d13009babc4a7 100644 --- a/recipes/cairomm/all/test_package/CMakeLists.txt +++ b/recipes/cairomm/all/test_package/CMakeLists.txt @@ -6,8 +6,8 @@ add_executable(${PROJECT_NAME} test_package.cpp) find_package(cairomm REQUIRED CONFIG) if (TARGET cairomm::cairomm-1.16) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17) - target_link_libraries(${PROJECT_NAME} cairomm::cairomm-1.16) + target_link_libraries(${PROJECT_NAME} PRIVATE cairomm::cairomm-1.16) else() set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) - target_link_libraries(${PROJECT_NAME} cairomm::cairomm-1.0) + target_link_libraries(${PROJECT_NAME} PRIVATE cairomm::cairomm-1.0) endif() diff --git a/recipes/cairomm/all/test_package/conanfile.py b/recipes/cairomm/all/test_package/conanfile.py index 7c00a8a985ca9..e809c41f21dd8 100644 --- a/recipes/cairomm/all/test_package/conanfile.py +++ b/recipes/cairomm/all/test_package/conanfile.py @@ -6,7 +6,7 @@ class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "CMakeDeps", "CMakeToolchain" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv", "VirtualBuildEnv" test_type = "explicit" def requirements(self): @@ -20,4 +20,4 @@ def build(self): def test(self): if not build.cross_building(self): bin_path = os.path.join(self.build_folder, "test_package") - self.run(bin_path, run_environment=True) + self.run(bin_path, env="conanrun") From 75c4abc6e10192d0cedf25b4040e5fa37f67a2f0 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 17 Sep 2023 22:26:03 +0100 Subject: [PATCH 12/17] [cairomm] add v1 test package --- .../cairomm/all/test_v1_package/CMakeLists.txt | 8 ++++++++ .../cairomm/all/test_v1_package/conanfile.py | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 recipes/cairomm/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/cairomm/all/test_v1_package/conanfile.py diff --git a/recipes/cairomm/all/test_v1_package/CMakeLists.txt b/recipes/cairomm/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/cairomm/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/cairomm/all/test_v1_package/conanfile.py b/recipes/cairomm/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/cairomm/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + 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): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) From cbaeeb7943f09037b6b27ce873b15e9fe5a8acad Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 17 Sep 2023 22:26:25 +0100 Subject: [PATCH 13/17] [cairomm] fix libsigcpp requriement --- recipes/cairomm/all/conanfile.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/recipes/cairomm/all/conanfile.py b/recipes/cairomm/all/conanfile.py index 0897a5016fbaa..88efc10e158db 100644 --- a/recipes/cairomm/all/conanfile.py +++ b/recipes/cairomm/all/conanfile.py @@ -157,14 +157,11 @@ def package_info(self): self.cpp_info.components[cairomm_lib_name].set_property("pkg_config_name", cairomm_lib_name) self.cpp_info.components[cairomm_lib_name].includedirs = [os.path.join("include", cairomm_lib_name)] self.cpp_info.components[cairomm_lib_name].libs = [cairomm_lib_name] + self.cpp_info.components[cairomm_lib_name].requires = ["libsigcpp::libsigcpp", "cairo::cairo_"] if is_apple_os(self): self.cpp_info.components[cairomm_lib_name].frameworks = ["CoreFoundation"] - if self._abi_version == "1.16": - self.cpp_info.components[cairomm_lib_name].requires = ["libsigcpp::sigc++", "cairo::cairo_"] - else: - self.cpp_info.components[cairomm_lib_name].requires = ["libsigcpp::sigc++-2.0", "cairo::cairo_"] def package_id(self): if not self.dependencies["cairo"].options.shared: From 02b13d9d429dabc9954553ef953680761e3c27d6 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 17 Sep 2023 23:03:28 +0100 Subject: [PATCH 14/17] [cairomm] add patch description fields --- recipes/cairomm/all/conandata.yml | 4 ++++ recipes/cairomm/all/conanfile.py | 33 ++++++++++++++++++------------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/recipes/cairomm/all/conandata.yml b/recipes/cairomm/all/conandata.yml index f4e1ff00b7424..d4e3614b82bd9 100644 --- a/recipes/cairomm/all/conandata.yml +++ b/recipes/cairomm/all/conandata.yml @@ -12,5 +12,9 @@ sources: patches: "1.16.1": - patch_file: "patches/enable_static_lib_1_16_1.patch" + - patch_description: "enable static library build on MSVC" + - patch_type: "portability" "1.14.3": - patch_file: "patches/enable_static_lib_1_14_3.patch" + - patch_description: "enable static library build on MSVC" + - patch_type: "portability" diff --git a/recipes/cairomm/all/conanfile.py b/recipes/cairomm/all/conanfile.py index 88efc10e158db..1d087b7bb5bd5 100644 --- a/recipes/cairomm/all/conanfile.py +++ b/recipes/cairomm/all/conanfile.py @@ -11,7 +11,7 @@ from conan.tools.gnu import PkgConfigDeps from conan.tools.layout import basic_layout from conan.tools.meson import Meson, MesonToolchain -from conan.tools.microsoft import check_min_vs, is_msvc +from conan.tools.microsoft import is_msvc from conan.tools.scm import Version @@ -31,16 +31,10 @@ class CairommConan(ConanFile): "shared": False, "fPIC": True, } - - exports_sources = "patches/**" short_paths = True @property - def _min_cppstd(self): - return 17 - - @property - def _compilers_minimum_version(self): + def _compilers_minimum_version_17(self): return { "gcc": "7", "clang": "7", @@ -51,6 +45,8 @@ def _compilers_minimum_version(self): def _abi_version(self): return "1.16" if Version(self.version) >= "1.16.0" else "1.0" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": @@ -74,12 +70,19 @@ def requirements(self): def validate(self): if self.settings.compiler.get_safe("cppstd"): - if self.settings.compiler.get_safe("cppstd"): - if self._abi_version == "1.16": - check_min_cppstd(self, 17) - else: - check_min_cppstd(self, 11) - if self.options.shared and not self.options["cairo"].shared: + if self._abi_version == "1.16": + check_min_cppstd(self, 17) + else: + check_min_cppstd(self, 11) + + if not is_msvc(self) and self._abi_version == "1.16": + minimum_version = self._compilers_minimum_version_17.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + + if self.options.shared and not self.dependencies["cairo"].options.shared: raise ConanInvalidConfiguration( "Linking against static cairo would cause shared cairomm to link " "against static glib which can cause problems." @@ -152,6 +155,8 @@ def package(self): for dir_to_remove in ["pkgconfig", f"cairomm-{self._abi_version}"]: rmdir(self, os.path.join(self.package_folder, "lib", dir_to_remove)) + fix_apple_shared_install_name(self) + def package_info(self): cairomm_lib_name = f"cairomm-{self._abi_version}" self.cpp_info.components[cairomm_lib_name].set_property("pkg_config_name", cairomm_lib_name) From 31536239ee9f5ef53770448da6646697a97ddc49 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 17 Sep 2023 23:06:42 +0100 Subject: [PATCH 15/17] [cairomm] fix reference to removed prop in fomrat string --- recipes/cairomm/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cairomm/all/conanfile.py b/recipes/cairomm/all/conanfile.py index 1d087b7bb5bd5..2350b592780a4 100644 --- a/recipes/cairomm/all/conanfile.py +++ b/recipes/cairomm/all/conanfile.py @@ -79,7 +79,7 @@ def validate(self): minimum_version = self._compilers_minimum_version_17.get(str(self.settings.compiler), False) if minimum_version and Version(self.settings.compiler.version) < minimum_version: raise ConanInvalidConfiguration( - f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + f"{self.ref} requires C++17, which your compiler does not support." ) if self.options.shared and not self.dependencies["cairo"].options.shared: From 3f75136c49ac34e8ad3ec81f6aa8f66a93783e78 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 17 Sep 2023 23:22:41 +0100 Subject: [PATCH 16/17] [cairomm] conan v2 support --- recipes/cairomm/all/conanfile.py | 40 +++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/recipes/cairomm/all/conanfile.py b/recipes/cairomm/all/conanfile.py index 2350b592780a4..2d8e92c31596a 100644 --- a/recipes/cairomm/all/conanfile.py +++ b/recipes/cairomm/all/conanfile.py @@ -13,6 +13,7 @@ from conan.tools.meson import Meson, MesonToolchain from conan.tools.microsoft import is_msvc from conan.tools.scm import Version +from conan import __version__ as conan_version class CairommConan(ConanFile): @@ -22,6 +23,7 @@ class CairommConan(ConanFile): license = "LGPL-2.0" description = "cairomm is a C++ wrapper for the cairo graphics library." topics = ["cairo", "wrapper", "graphics"] + package_type = "library" settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], @@ -33,6 +35,18 @@ class CairommConan(ConanFile): } short_paths = True + @property + def _abi_version(self): + return "1.16" if Version(self.version) >= "1.16.0" else "1.0" + + @property + def _min_cppstd(self): + return "17" if self._abi_version == "1.16" else "11" + + @property + def is_conan2(self): + return Version(conan_version) >= "2.0.0" + @property def _compilers_minimum_version_17(self): return { @@ -41,10 +55,6 @@ def _compilers_minimum_version_17(self): "apple-clang": "10", } - @property - def _abi_version(self): - return "1.16" if Version(self.version) >= "1.16.0" else "1.0" - def export_sources(self): export_conandata_patches(self) @@ -61,25 +71,25 @@ def layout(self): basic_layout(self, src_folder="src") def requirements(self): - self.requires("cairo/1.17.6") + self.requires("cairo/1.17.6", transitive_headers=True) + if self.is_conan2: + # TODO remove once cairo has added transitive headers arg + self.requires("freetype/2.13.0", transitive_headers=True) if self._abi_version == "1.16": - self.requires("libsigcpp/3.0.7") + self.requires("libsigcpp/3.0.7", transitive_headers=True) else: - self.requires("libsigcpp/2.10.8") + self.requires("libsigcpp/2.10.8", transitive_headers=True) def validate(self): if self.settings.compiler.get_safe("cppstd"): - if self._abi_version == "1.16": - check_min_cppstd(self, 17) - else: - check_min_cppstd(self, 11) + check_min_cppstd(self, self._min_cppstd) if not is_msvc(self) and self._abi_version == "1.16": minimum_version = self._compilers_minimum_version_17.get(str(self.settings.compiler), False) if minimum_version and Version(self.settings.compiler.version) < minimum_version: raise ConanInvalidConfiguration( - f"{self.ref} requires C++17, which your compiler does not support." + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." ) if self.options.shared and not self.dependencies["cairo"].options.shared: @@ -162,7 +172,11 @@ def package_info(self): self.cpp_info.components[cairomm_lib_name].set_property("pkg_config_name", cairomm_lib_name) self.cpp_info.components[cairomm_lib_name].includedirs = [os.path.join("include", cairomm_lib_name)] self.cpp_info.components[cairomm_lib_name].libs = [cairomm_lib_name] - self.cpp_info.components[cairomm_lib_name].requires = ["libsigcpp::libsigcpp", "cairo::cairo_"] + + component_requires = ["libsigcpp::libsigcpp", "cairo::cairo_"] + if self.is_conan2: + component_requires.append("freetype::freetype") + self.cpp_info.components[cairomm_lib_name].requires = component_requires if is_apple_os(self): self.cpp_info.components[cairomm_lib_name].frameworks = ["CoreFoundation"] From 64cc38ce4e97194a17e81a29365c7d06ad1015c0 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 17 Sep 2023 23:24:19 +0100 Subject: [PATCH 17/17] [cairomm] fix configure --- recipes/cairomm/all/conandata.yml | 8 ++++---- recipes/cairomm/all/conanfile.py | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/recipes/cairomm/all/conandata.yml b/recipes/cairomm/all/conandata.yml index d4e3614b82bd9..38ad049142f8b 100644 --- a/recipes/cairomm/all/conandata.yml +++ b/recipes/cairomm/all/conandata.yml @@ -12,9 +12,9 @@ sources: patches: "1.16.1": - patch_file: "patches/enable_static_lib_1_16_1.patch" - - patch_description: "enable static library build on MSVC" - - patch_type: "portability" + patch_description: "enable static library build on MSVC" + patch_type: "portability" "1.14.3": - patch_file: "patches/enable_static_lib_1_14_3.patch" - - patch_description: "enable static library build on MSVC" - - patch_type: "portability" + patch_description: "enable static library build on MSVC" + patch_type: "portability" diff --git a/recipes/cairomm/all/conanfile.py b/recipes/cairomm/all/conanfile.py index 2d8e92c31596a..9bbe929c7bd44 100644 --- a/recipes/cairomm/all/conanfile.py +++ b/recipes/cairomm/all/conanfile.py @@ -65,7 +65,7 @@ def config_options(self): def configure(self): if self.options.shared: self.options.rm_safe("fPIC") - self.dependencies["cairo"].options.shared = True + self.options["cairo"].shared = True def layout(self): basic_layout(self, src_folder="src") @@ -175,6 +175,8 @@ def package_info(self): component_requires = ["libsigcpp::libsigcpp", "cairo::cairo_"] if self.is_conan2: + # TODO required only because cairo recipe needs updating to declare + # transitive header dependency on freetype component_requires.append("freetype::freetype") self.cpp_info.components[cairomm_lib_name].requires = component_requires