From 41c4c735f707270e30bc833eb8d8883ccc4fa8b6 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 1 Sep 2022 09:44:47 +0100 Subject: [PATCH] (#12240) [cairo] v2 support * [cairo] do not rename the parent pkg-config package * [cairo] refactor and simplify package_info method * [cairo] fix v2 linting * [cairo] provide parent pkgconfig and use set_property_name * [cairo] resolve system lib warnings * [cairo] v2 linting * Apply review suggestion Co-authored-by: Uilian Ries * Apply review suggestion Co-authored-by: Uilian Ries * [cairo] bump requirements versions * [cairo] full package mode only for static glib * [cairo] shared glib with static msvcrt is not supported * [cairo] restore old pkg-config file names * [cairo] update source method * [cairo] restore main pkg-config name * [cairo] fix property name typo * [cairo] use tool_requires Co-authored-by: Uilian Ries --- recipes/cairo/all/conanfile.py | 125 ++++++++++------ recipes/cairo/meson/conanfile.py | 242 ++++++++++++++----------------- 2 files changed, 188 insertions(+), 179 deletions(-) diff --git a/recipes/cairo/all/conanfile.py b/recipes/cairo/all/conanfile.py index 458b1f67cd794..363cd49cb6c52 100644 --- a/recipes/cairo/all/conanfile.py +++ b/recipes/cairo/all/conanfile.py @@ -1,8 +1,14 @@ -from conans import ConanFile, AutoToolsBuildEnvironment, tools, VisualStudioBuildEnvironment -from conans.errors import ConanInvalidConfiguration import os import shutil +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools import files, microsoft, scm +from conans import AutoToolsBuildEnvironment, VisualStudioBuildEnvironment +from conans import tools + +required_conan_version = ">=1.50.0" + class CairoConan(ConanFile): name = "cairo" @@ -56,7 +62,7 @@ def config_options(self): if self.settings.os == "Windows": del self.options.fPIC del self.options.with_fontconfig - if self._is_msvc: + if microsoft.is_msvc(self): del self.options.with_freetype del self.options.with_glib if self.settings.os != "Linux": @@ -69,9 +75,16 @@ def configure(self): del self.options.fPIC del self.settings.compiler.cppstd del self.settings.compiler.libcxx - if self._is_msvc: + + def validate(self): + if microsoft.is_msvc(self): if self.settings.build_type not in ["Debug", "Release"]: raise ConanInvalidConfiguration("MSVC build supports only Debug or Release build type") + if self.options.get_safe("with_glib") and self.options["glib"].shared \ + and microsoft.is_msvc_static_runtime(self): + raise ConanInvalidConfiguration( + "Linking shared glib with the MSVC static runtime is not supported" + ) def requirements(self): if self.options.get_safe("with_freetype", True): @@ -89,24 +102,19 @@ def requirements(self): def build_requirements(self): if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/cci.latest") - if not self._is_msvc: - self.build_requires("libtool/2.4.6") - self.build_requires("pkgconf/1.7.4") - self.build_requires("gtk-doc-stub/cci.20181216") - - @property - def _is_msvc(self): - return self.settings.compiler == "Visual Studio" + self.tool_requires("msys2/cci.latest") + if not microsoft.is_msvc(self): + self.tool_requires("libtool/2.4.6") + self.tool_requires("pkgconf/1.7.4") + self.tool_requires("gtk-doc-stub/cci.20181216") def source(self): - tools.get(**self.conan_data["sources"][self.version], + files.get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - if self._is_msvc: + files.apply_conandata_patches(self) + if microsoft.is_msvc(self): self._build_msvc() else: self._build_configure() @@ -115,13 +123,13 @@ def _build_msvc(self): with tools.chdir(self._source_subfolder): # https://cairographics.org/end_to_end_build_for_win32/ win32_common = os.path.join("build", "Makefile.win32.common") - tools.replace_in_file(win32_common, "-MD ", "-%s " % self.settings.compiler.runtime) - tools.replace_in_file(win32_common, "-MDd ", "-%s " % self.settings.compiler.runtime) - tools.replace_in_file(win32_common, "$(ZLIB_PATH)/lib/zlib1.lib", + files.replace_in_file(self, win32_common, "-MD ", f"-{self.settings.compiler.runtime} ") + files.replace_in_file(self, win32_common, "-MDd ", f"-{self.settings.compiler.runtime} ") + files.replace_in_file(self, win32_common, "$(ZLIB_PATH)/lib/zlib1.lib", self.deps_cpp_info["zlib"].libs[0] + ".lib") - tools.replace_in_file(win32_common, "$(LIBPNG_PATH)/lib/libpng16.lib", + files.replace_in_file(self, win32_common, "$(LIBPNG_PATH)/lib/libpng16.lib", self.deps_cpp_info["libpng"].libs[0] + ".lib") - tools.replace_in_file(win32_common, "$(FREETYPE_PATH)/lib/freetype.lib", + files.replace_in_file(self, win32_common, "$(FREETYPE_PATH)/lib/freetype.lib", self.deps_cpp_info["freetype"].libs[0] + ".lib") with tools.vcvars(self.settings): env_msvc = VisualStudioBuildEnvironment(self) @@ -130,13 +138,13 @@ def _build_msvc(self): env_build = AutoToolsBuildEnvironment(self) args=[ "-f", "Makefile.win32", - "CFG={}".format(str(self.settings.build_type).lower()), + f"CFG={str(self.settings.build_type).lower()}", "CAIRO_HAS_FC_FONT=0", - "ZLIB_PATH={}".format(self.deps_cpp_info["zlib"].rootpath), - "LIBPNG_PATH={}".format(self.deps_cpp_info["libpng"].rootpath), - "PIXMAN_PATH={}".format(self.deps_cpp_info["pixman"].rootpath), - "FREETYPE_PATH={}".format(self.deps_cpp_info["freetype"].rootpath), - "GOBJECT_PATH={}".format(self.deps_cpp_info["glib"].rootpath) + f"ZLIB_PATH={self.deps_cpp_info['zlib'].rootpath}", + f"LIBPNG_PATH={self.deps_cpp_info['libpng'].rootpath}", + f"PIXMAN_PATH={self.deps_cpp_info['pixman'].rootpath}", + f"FREETYPE_PATH={self.deps_cpp_info['freetype'].rootpath}", + f"GOBJECT_PATH={self.deps_cpp_info['glib'].rootpath}" ] env_build.make(args=args) @@ -146,18 +154,20 @@ def _configure_autotools(self): if self._autotools: return self._autotools + def boolean(value): + return "yes" if value else "no" + self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - yes_no = lambda v: "yes" if v else "no" configure_args = [ - "--datarootdir={}".format(tools.unix_path(os.path.join(self.package_folder, "res"))), - "--enable-ft={}".format(yes_no(self.options.with_freetype)), - "--enable-gobject={}".format(yes_no(self.options.with_glib)), - "--enable-fc={}".format(yes_no(self.options.get_safe("with_fontconfig"))), - "--enable-xlib={}".format(yes_no(self.options.get_safe("with_xlib"))), - "--enable-xlib_xrender={}".format(yes_no(self.options.get_safe("with_xlib_xrender"))), - "--enable-xcb={}".format(yes_no(self.options.get_safe("xcb"))), - "--enable-shared={}".format(yes_no(self.options.shared)), - "--enable-static={}".format(yes_no(not self.options.shared)), + f"--datarootdir={tools.unix_path(os.path.join(self.package_folder, 'res'))}", + f"--enable-ft={boolean(self.options.with_freetype)}", + f"--enable-gobject={boolean(self.options.with_glib)}", + f"--enable-fc={boolean(self.options.get_safe('with_fontconfig'))}", + f"--enable-xlib={boolean(self.options.get_safe('with_xlib'))}", + f"--enable-xlib_xrender={boolean(self.options.get_safe('with_xlib_xrender'))}", + f"--enable-xcb={boolean(self.options.get_safe('xcb'))}", + f"--enable-shared={boolean(self.options.shared)}", + f"--enable-static={boolean(not self.options.shared)}", "--disable-gtk-doc", ] if self.settings.compiler in ["gcc", "clang", "apple-clang"]: @@ -170,10 +180,10 @@ def _configure_autotools(self): def _build_configure(self): with tools.chdir(self._source_subfolder): # disable build of test suite - tools.replace_in_file(os.path.join("test", "Makefile.am"), "noinst_PROGRAMS = cairo-test-suite$(EXEEXT)", + files.replace_in_file(self, os.path.join("test", "Makefile.am"), "noinst_PROGRAMS = cairo-test-suite$(EXEEXT)", "") if self.options.with_freetype: - tools.replace_in_file(os.path.join(self.source_folder, self._source_subfolder, "src", "cairo-ft-font.c"), + files.replace_in_file(self, os.path.join(self.source_folder, self._source_subfolder, "src", "cairo-ft-font.c"), "#if HAVE_UNISTD_H", "#ifdef HAVE_UNISTD_H") tools.touch(os.path.join("boilerplate", "Makefile.am.features")) @@ -182,7 +192,7 @@ def _build_configure(self): with tools.environment_append({"GTKDOCIZE": "echo"}): self.run( - "{} -fiv".format(tools.get_env("AUTORECONF")), + f"{tools.get_env('AUTORECONF')} -fiv", run_environment=True, win_bash=tools.os_info.is_windows, ) @@ -191,11 +201,11 @@ def _build_configure(self): def package(self): self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) - if self._is_msvc: + if microsoft.is_msvc(self): src = os.path.join(self._source_subfolder, "src") cairo_gobject = os.path.join(self._source_subfolder, "util", "cairo-gobject") inc = os.path.join("include", "cairo") - self.copy(pattern="cairo-version.h", dst=inc, src=(src if tools.Version(self.version) >= "1.17.4" else self._source_subfolder)) + self.copy(pattern="cairo-version.h", dst=inc, src=(src if scm.Version(self.version) >= "1.17.4" else self._source_subfolder)) self.copy(pattern="cairo-features.h", dst=inc, src=src) self.copy(pattern="cairo.h", dst=inc, src=src) self.copy(pattern="cairo-deprecated.h", dst=inc, src=src) @@ -222,14 +232,18 @@ def package(self): tools.remove_files_by_mask(self.package_folder, "*.la") self.copy("COPYING*", src=self._source_subfolder, dst="licenses", keep_path=False) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - + files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) def package_info(self): + self.cpp_info.set_property("pkg_config_name", "cairo-all-do-no-use") + self.cpp_info.names["pkg_config"] = "cairo-all-do-not-use" + + self.cpp_info.components["cairo_"].set_property("pkg_config_name", "cairo") self.cpp_info.components["cairo_"].names["pkg_config"] = "cairo" self.cpp_info.components["cairo_"].libs = ["cairo"] self.cpp_info.components["cairo_"].includedirs.insert(0, os.path.join("include", "cairo")) self.cpp_info.components["cairo_"].requires = ["pixman::pixman", "libpng::libpng", "zlib::zlib"] + if self.options.get_safe("with_freetype", True): self.cpp_info.components["cairo_"].requires.append("freetype::freetype") @@ -242,8 +256,9 @@ def package_info(self): self.cpp_info.components["cairo_"].requires.extend(["glib::gobject-2.0", "glib::glib-2.0"]) if self.options.with_fontconfig: self.cpp_info.components["cairo_"].requires.append("fontconfig::fontconfig") + if self.settings.os == "Linux": - self.cpp_info.components["cairo_"].system_libs = ["pthread"] + self.cpp_info.components["cairo_"].system_libs = ["pthread", "rt"] self.cpp_info.components["cairo_"].cflags = ["-pthread"] self.cpp_info.components["cairo_"].cxxflags = ["-pthread"] if self.options.with_xcb: @@ -252,36 +267,50 @@ def package_info(self): self.cpp_info.components["cairo_"].requires.extend(["xorg::xcb-render"]) if self.options.with_xlib: self.cpp_info.components["cairo_"].requires.extend(["xorg::x11", "xorg::xext"]) + if tools.is_apple_os(self.settings.os): self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") - if self.settings.os == "Windows": + self.cpp_info.components["cairo-win32"].set_property("pkg_config_name", "cairo-win32") self.cpp_info.components["cairo-win32"].names["pkg_config"] = "cairo-win32" self.cpp_info.components["cairo-win32"].requires = ["cairo_", "pixman::pixman", "libpng::libpng"] if self.options.get_safe("with_glib", True): + self.cpp_info.components["cairo-gobject"].set_property("pkg_config_name", "cairo-gobject") self.cpp_info.components["cairo-gobject"].names["pkg_config"] = "cairo-gobject" self.cpp_info.components["cairo-gobject"].libs = ["cairo-gobject"] self.cpp_info.components["cairo-gobject"].requires = ["cairo_", "glib::gobject-2.0", "glib::glib-2.0"] if self.settings.os != "Windows": if self.options.with_fontconfig: + self.cpp_info.components["cairo-fc"].set_property("pkg_config_name", "cairo-fc") self.cpp_info.components["cairo-fc"].names["pkg_config"] = "cairo-fc" self.cpp_info.components["cairo-fc"].requires = ["cairo_", "fontconfig::fontconfig"] if self.options.get_safe("with_freetype", True): + self.cpp_info.components["cairo-ft"].set_property("pkg_config_name", "cairo-ft") self.cpp_info.components["cairo-ft"].names["pkg_config"] = "cairo-ft" self.cpp_info.components["cairo-ft"].requires = ["cairo_", "freetype::freetype"] + + self.cpp_info.components["cairo-pdf"].set_property("pkg_config_name", "cairo-pdf") self.cpp_info.components["cairo-pdf"].names["pkg_config"] = "cairo-pdf" self.cpp_info.components["cairo-pdf"].requires = ["cairo_", "zlib::zlib"] if self.settings.os == "Linux": if self.options.with_xlib: + self.cpp_info.components["cairo-xlib"].set_property("pkg_config_name", "cairo-xlib") self.cpp_info.components["cairo-xlib"].names["pkg_config"] = "cairo-xlib" self.cpp_info.components["cairo-xlib"].requires = ["cairo_", "xorg::x11", "xorg::xext"] if tools.is_apple_os(self.settings.os): + self.cpp_info.components["cairo-quartz"].set_property("pkg_config_name", "cairo-quartz") self.cpp_info.components["cairo-quartz"].names["pkg_config"] = "cairo-quartz" self.cpp_info.components["cairo-quartz"].requires = ["cairo_"] - self.cpp_info.components["cairo-quartz"].frameworks.extend(["CoreFoundation", "CoreGraphics"]) + self.cpp_info.components["cairo-quartz"].frameworks.extend(["CoreFoundation", "CoreGraphics", "ApplicationServices"]) + + self.cpp_info.components["cairo-quartz-font"].set_property("pkg_config_name", "cairo-quartz-font") self.cpp_info.components["cairo-quartz-font"].names["pkg_config"] = "cairo-quartz-font" self.cpp_info.components["cairo-quartz-font"].requires = ["cairo_"] + + def package_id(self): + if self.options.get_safe("with_glib") and not self.options["glib"].shared: + self.info.requires["glib"].full_package_mode() diff --git a/recipes/cairo/meson/conanfile.py b/recipes/cairo/meson/conanfile.py index 3e6bf31ce3bda..ebff14e5fdea3 100644 --- a/recipes/cairo/meson/conanfile.py +++ b/recipes/cairo/meson/conanfile.py @@ -1,10 +1,14 @@ -from conans import ConanFile, tools, Meson, VisualStudioBuildEnvironment -from conans.errors import ConanInvalidConfiguration import contextlib import glob import os -required_conan_version = ">=1.38.0" +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools import files, microsoft +from conans import tools, Meson, VisualStudioBuildEnvironment + +required_conan_version = ">=1.50.0" + class CairoConan(ConanFile): name = "cairo" @@ -103,7 +107,7 @@ def requirements(self): if self.options.with_png: self.requires("libpng/1.6.37") if self.options.with_glib: - self.requires("glib/2.73.0") + self.requires("glib/2.73.3") if self.settings.os == "Linux": if self.options.with_xlib or self.options.with_xlib_xrender or self.options.with_xcb: self.requires("xorg/system") @@ -117,24 +121,26 @@ def requirements(self): self.requires("egl/system") def build_requirements(self): - self.build_requires("meson/0.62.1") - self.build_requires("pkgconf/1.7.4") + self.tool_requires("meson/0.63.1") + self.tool_requires("pkgconf/1.7.4") def validate(self): if self.options.get_safe("with_xlib_xrender") and not self.options.get_safe("with_xlib"): raise ConanInvalidConfiguration("'with_xlib_xrender' option requires 'with_xlib' option to be enabled as well!") - if self.options.with_glib and not self.options["glib"].shared and self.options.shared: - raise ConanInvalidConfiguration( - "Linking a shared library against static glib can cause unexpected behaviour." - ) - - @property - def _is_msvc(self): - return str(self.settings.compiler) in ["msvc", "Visual Studio"] + if self.options.with_glib: + if self.options["glib"].shared: + if microsoft.is_msvc_static_runtime(self): + raise ConanInvalidConfiguration( + "Linking shared glib with the MSVC static runtime is not supported" + ) + elif self.options.shared: + raise ConanInvalidConfiguration( + "Linking a shared library against static glib can cause unexpected behaviour." + ) @contextlib.contextmanager def _build_context(self): - if self._is_msvc: + if microsoft.is_msvc(self): env_build = VisualStudioBuildEnvironment(self) if not self.options.shared: env_build.flags.append("-DCAIRO_WIN32_STATIC_BUILD") @@ -145,23 +151,24 @@ def _build_context(self): yield def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) + files.get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) def _configure_meson(self): - yes_no = lambda v: "enabled" if v else "disabled" + def boolean(value): + return "enabled" if value else "disabled" + meson = Meson(self) defs = dict() defs["tests"] = "disabled" - defs["zlib"] = yes_no(self.options.with_zlib) - defs["png"] = yes_no(self.options.with_png) - defs["freetype"] = yes_no(self.options.with_freetype) - defs["fontconfig"] = yes_no(self.options.with_fontconfig) + defs["zlib"] = boolean(self.options.with_zlib) + defs["png"] = boolean(self.options.with_png) + defs["freetype"] = boolean(self.options.with_freetype) + defs["fontconfig"] = boolean(self.options.with_fontconfig) if self.settings.os == "Linux": - defs["xcb"] = yes_no(self.options.get_safe("with_xcb")) - defs["xlib"] = yes_no(self.options.get_safe("with_xlib")) - defs["xlib-xrender"] = yes_no(self.options.get_safe("with_xlib_xrender")) + defs["xcb"] = boolean(self.options.get_safe("with_xcb")) + defs["xlib"] = boolean(self.options.get_safe("with_xlib")) + defs["xlib-xrender"] = boolean(self.options.get_safe("with_xlib_xrender")) else: defs["xcb"] = "disabled" defs["xlib"] = "disabled" @@ -173,10 +180,10 @@ def _configure_meson(self): defs["gl-backend"] = "glesv3" else: defs["gl-backend"] = "disabled" - defs["glesv2"] = yes_no(self.options.get_safe("with_opengl") == "gles2") - defs["glesv3"] = yes_no(self.options.get_safe("with_opengl") == "gles3") - defs["tee"] = yes_no(self.options.tee) - defs["symbol-lookup"] = yes_no(self.options.get_safe("with_symbol_lookup")) + defs["glesv2"] = boolean(self.options.get_safe("with_opengl") == "gles2") + defs["glesv3"] = boolean(self.options.get_safe("with_opengl") == "gles3") + defs["tee"] = boolean(self.options.tee) + defs["symbol-lookup"] = boolean(self.options.get_safe("with_symbol_lookup")) # future options to add, see meson_options.txt. # for now, disabling explicitly, to avoid non-reproducible auto-detection of system libs @@ -197,25 +204,24 @@ def _configure_meson(self): return meson def build(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) + files.apply_conandata_patches(self) # Dependency freetype2 found: NO found 2.11.0 but need: '>= 9.7.3' if self.options.with_freetype: - tools.replace_in_file("freetype2.pc", - "Version: %s" % self.deps_cpp_info["freetype"].version, + files.replace_in_file(self, "freetype2.pc", + f"Version: {self.deps_cpp_info['freetype'].version}", "Version: 9.7.3") with self._build_context(): meson = self._configure_meson() meson.build() def _fix_library_names(self): - if self._is_msvc: + if microsoft.is_msvc(self): with tools.chdir(os.path.join(self.package_folder, "lib")): for filename_old in glob.glob("*.a"): filename_new = filename_old[3:-2] + ".lib" self.output.info("rename %s into %s" % (filename_old, filename_new)) - tools.rename(filename_old, filename_new) + files.rename(self, filename_old, filename_new) def package(self): self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) @@ -224,166 +230,140 @@ def package(self): meson = self._configure_meson() meson.install() self._fix_library_names() - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"), "*.pdb") + files.rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + files.rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) def package_info(self): + base_requirements = {"pixman::pixman"} + base_system_libs = {} + + def add_component_and_base_requirements(component, requirements, system_libs=None): + self.cpp_info.components[component].set_property("pkg_config_name", component) + self.cpp_info.components[component].names["pkg_config"] = component + self.cpp_info.components[component].requires += ["cairo_"] + requirements + base_requirements.update(set(requirements)) + if system_libs is not None: + self.cpp_info.components[component].system_libs += system_libs + base_system_libs.update(set(system_libs)) + + self.cpp_info.set_property("pkg_config_name", "cairo-all-do-no-use") + self.cpp_info.names["pkg_config"] = "cairo-all-do-no-use" + + self.cpp_info.components["cairo_"].set_property("pkg_config_name", "cairo") self.cpp_info.components["cairo_"].names["pkg_config"] = "cairo" self.cpp_info.components["cairo_"].libs = ["cairo"] self.cpp_info.components["cairo_"].includedirs.insert(0, os.path.join("include", "cairo")) + if self.settings.os == "Linux": self.cpp_info.components["cairo_"].system_libs.extend(["m", "dl", "pthread"]) if self.options.get_safe("with_symbol_lookup"): self.cpp_info.components["cairo_"].system_libs.append("bfd") self.cpp_info.components["cairo_"].cflags = ["-pthread"] self.cpp_info.components["cairo_"].cxxflags = ["-pthread"] + if self.options.with_lzo: self.cpp_info.components["cairo_"].requires.append("lzo::lzo") + if self.options.with_zlib: self.cpp_info.components["cairo_"].requires.append("zlib::zlib") - if self.options.with_png: - self.cpp_info.components["cairo_"].requires.append("libpng::libpng") - if self.options.with_fontconfig: - self.cpp_info.components["cairo_"].requires.append("fontconfig::fontconfig") - if self.options.with_freetype: - self.cpp_info.components["cairo_"].requires.append("freetype::freetype") - if self.options.get_safe("with_xlib"): - self.cpp_info.components["cairo_"].requires.extend(["xorg::x11", "xorg::xext"]) - if self.options.get_safe("with_xlib_xrender"): - self.cpp_info.components["cairo_"].requires.append("xorg::xrender") - if self.options.get_safe("with_xcb"): - self.cpp_info.components["cairo_"].requires.extend(["xorg::xcb", "xorg::xcb-render", "xorg::xcb-shm"]) - if self.options.get_safe("with_xlib") and self.options.get_safe("with_xcb"): - self.cpp_info.components["cairo_"].requires.append("xorg::x11-xcb") - if tools.is_apple_os(self.settings.os): - self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") - if self.settings.os == "Windows": - self.cpp_info.components["cairo_"].system_libs.extend(["gdi32", "msimg32", "user32"]) - if not self.options.shared: - self.cpp_info.components["cairo_"].defines.append("CAIRO_WIN32_STATIC_BUILD=1") - if self.options.get_safe("with_opengl") == "desktop": - self.cpp_info.components["cairo_"].requires.append("opengl::opengl") - if self.settings.os == "Windows": - self.cpp_info.components["cairo_"].requires.extend(["glext::glext", "wglext::wglext", "khrplatform::khrplatform"]) - if self.options.get_safe("with_opengl") and self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["cairo_"].requires.append("egl::egl") - if self.options.get_safe("with_opengl") == "gles2" or self.options.get_safe("with_opengl") == "gles3": - self.cpp_info.components["cairo_"].system_libs.append("GLESv2") - self.cpp_info.components["cairo_"].requires.append("pixman::pixman") - # built-features if self.options.with_png: - self.cpp_info.components["cairo-png"].names["pkg_config"] = "cairo-png" - self.cpp_info.components["cairo-png"].requires = ["cairo_", "libpng::libpng"] - - if self.options.with_png: - self.cpp_info.components["cairo-svg"].names["pkg_config"] = "cairo-svg" - self.cpp_info.components["cairo-svg"].requires = ["cairo_", "libpng::libpng"] + add_component_and_base_requirements("cairo-png", ["libpng::libpng"]) + add_component_and_base_requirements("cairo-svg", ["libpng::libpng"]) if self.options.with_fontconfig: - self.cpp_info.components["cairo-fc"].names["pkg_config"] = "cairo-fc" - self.cpp_info.components["cairo-fc"].requires = ["cairo_", "fontconfig::fontconfig"] + add_component_and_base_requirements("cairo-fc", ["fontconfig::fontconfig"]) if self.options.with_freetype: - self.cpp_info.components["cairo-ft"].names["pkg_config"] = "cairo-ft" - self.cpp_info.components["cairo-ft"].requires = ["cairo_", "freetype::freetype"] + add_component_and_base_requirements("cairo-ft", ["freetype::freetype"]) if self.options.get_safe("with_xlib"): - self.cpp_info.components["cairo-xlib"].names["pkg_config"] = "cairo-xlib" - self.cpp_info.components["cairo-xlib"].requires = ["cairo_", "xorg::x11", "xorg::xext"] + add_component_and_base_requirements("cairo-xlib", ["xorg::x11", "xorg::xext"]) if self.options.get_safe("with_xlib_xrender"): - self.cpp_info.components["cairo-xlib-xrender"].names["pkg_config"] = "cairo-xlib-xrender" - self.cpp_info.components["cairo-xlib-xrender"].requires = ["cairo_", "xorg::xrender"] + add_component_and_base_requirements("cairo-xlib-xrender", ["xorg::xrender"]) if self.options.get_safe("with_xcb"): - self.cpp_info.components["cairo-xcb"].names["pkg_config"] = "cairo-xcb" - self.cpp_info.components["cairo-xcb"].requires = ["cairo_", "xorg::xcb", "xorg::xcb-render"] - - if self.options.get_safe("with_xlib") and self.options.get_safe("with_xcb"): - self.cpp_info.components["cairo-xlib-xcb"].names["pkg_config"] = "cairo-xlib-xcb" - self.cpp_info.components["cairo-xlib-xcb"].requires = ["cairo_", "xorg::x11-xcb"] + add_component_and_base_requirements("cairo-xcb", ["xorg::xcb", "xorg::xcb-render"]) + add_component_and_base_requirements("cairo-xcb-shm", ["xorg::xcb", "xorg::xcb-shm"]) - if self.options.get_safe("with_xcb"): - self.cpp_info.components["cairo-xcb-shm"].names["pkg_config"] = "cairo-xcb-shm" - self.cpp_info.components["cairo-xcb-shm"].requires = ["cairo_", "xorg::xcb-shm"] + if self.options.get_safe("with_xlib"): + add_component_and_base_requirements("cairo-xlib-xcb", ["xorg::x11-xcb"]) if tools.is_apple_os(self.settings.os): + self.cpp_info.components["cairo-quartz"].set_property("pkg_config_name", "cairo-quartz") self.cpp_info.components["cairo-quartz"].names["pkg_config"] = "cairo-quartz" self.cpp_info.components["cairo-quartz"].requires = ["cairo_"] + self.cpp_info.components["cairo-quartz-image"].set_property("pkg_config_name", "cairo-quartz-image") self.cpp_info.components["cairo-quartz-image"].names["pkg_config"] = "cairo-quartz-image" self.cpp_info.components["cairo-quartz-image"].requires = ["cairo_"] + self.cpp_info.components["cairo-quartz-font"].set_property("pkg_config_name", "cairo-quartz-font") self.cpp_info.components["cairo-quartz-font"].names["pkg_config"] = "cairo-quartz-font" self.cpp_info.components["cairo-quartz-font"].requires = ["cairo_"] + self.cpp_info.components["cairo_"].frameworks.append("CoreGraphics") + if self.settings.os == "Windows": + self.cpp_info.components["cairo-win32"].set_property("pkg_config_name", "cairo-win32") self.cpp_info.components["cairo-win32"].names["pkg_config"] = "cairo-win32" self.cpp_info.components["cairo-win32"].requires = ["cairo_"] + self.cpp_info.components["cairo-win32-font"].set_property("pkg_config_name", "cairo-win32-font") self.cpp_info.components["cairo-win32-font"].names["pkg_config"] = "cairo-win32-font" self.cpp_info.components["cairo-win32-font"].requires = ["cairo_"] - if self.options.get_safe("with_opengl") == "desktop": - self.cpp_info.components["cairo-gl"].names["pkg_config"] = "cairo-gl" - self.cpp_info.components["cairo-gl"].requires = ["cairo_", "opengl::opengl"] - - if self.settings.os == "Linux": - self.cpp_info.components["cairo-glx"].names["pkg_config"] = "cairo-glx" - self.cpp_info.components["cairo-glx"].requires = ["cairo_", "opengl::opengl"] - - if self.settings.os == "Windows": - self.cpp_info.components["cairo-wgl"].names["pkg_config"] = "cairo-wgl" - self.cpp_info.components["cairo-wgl"].requires = ["cairo_", "glext::glext", "wglext::wglext"] + self.cpp_info.components["cairo_"].system_libs.extend(["gdi32", "msimg32", "user32"]) - if self.options.get_safe("with_opengl") == "gles2": - self.cpp_info.components["cairo-glesv2"].names["pkg_config"] = "cairo-glesv2" - self.cpp_info.components["cairo-glesv2"].requires = ["cairo_"] - self.cpp_info.components["cairo-glesv2"].system_libs = ["GLESv2"] + if not self.options.shared: + self.cpp_info.components["cairo_"].defines.append("CAIRO_WIN32_STATIC_BUILD=1") - if self.options.get_safe("with_opengl") == "gles3": - self.cpp_info.components["cairo-glesv3"].names["pkg_config"] = "cairo-glesv3" - self.cpp_info.components["cairo-glesv3"].requires = ["cairo_"] - self.cpp_info.components["cairo-glesv3"].system_libs = ["GLESv2"] + if self.options.get_safe("with_opengl"): + if self.options.with_opengl == "desktop": + add_component_and_base_requirements("cairo-gl", ["opengl::opengl"]) - if self.options.get_safe("with_opengl") and self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.components["cairo-egl"].names["pkg_config"] = "cairo-egl" - self.cpp_info.components["cairo-egl"].requires = ["cairo_", "egl::egl"] + if self.settings.os == "Linux": + add_component_and_base_requirements("cairo-glx", ["opengl::opengl"]) - if self.options.with_zlib: - self.cpp_info.components["cairo-script"].names["pkg_config"] = "cairo-script" - self.cpp_info.components["cairo-script"].requires = ["cairo_", "zlib::zlib"] + if self.settings.os == "Windows": + add_component_and_base_requirements("cairo-wgl", ["glext::glext", "wglext::wglext", "khrplatform::khrplatform"]) - if self.options.with_zlib: - self.cpp_info.components["cairo-ps"].names["pkg_config"] = "cairo-ps" - self.cpp_info.components["cairo-ps"].requires = ["cairo_", "zlib::zlib"] + elif self.options.with_opengl == "gles3": + add_component_and_base_requirements("cairo-glesv3", [], ["GLESv2"]) + elif self.options.with_opengl == "gles2": + add_component_and_base_requirements("cairo-glesv2", [], ["GLESv2"]) + if self.settings.os in ["Linux", "FreeBSD"]: + add_component_and_base_requirements("cairo-egl", ["egl::egl"]) if self.options.with_zlib: - self.cpp_info.components["cairo-pdf"].names["pkg_config"] = "cairo-pdf" - self.cpp_info.components["cairo-pdf"].requires = ["cairo_", "zlib::zlib"] + add_component_and_base_requirements("cairo-script", ["zlib::zlib"]) + add_component_and_base_requirements("cairo-ps", ["zlib::zlib"]) + add_component_and_base_requirements("cairo-pdf", ["zlib::zlib"]) + self.cpp_info.components["cairo-script-interpreter"].set_property("pkg_config_name", "cairo-script-interpreter") + self.cpp_info.components["cairo-script-interpreter"].names["pkg_config"] = "cairo-script-interpreter" + self.cpp_info.components["cairo-script-interpreter"].libs = ["cairo-script-interpreter"] + self.cpp_info.components["cairo-script-interpreter"].requires = ["cairo_"] - if self.options.with_zlib and self.options.with_png: - self.cpp_info.components["cairo-xml"].names["pkg_config"] = "cairo-xml" - self.cpp_info.components["cairo-xml"].requires = ["cairo_", "zlib::zlib"] + if self.options.with_png: + add_component_and_base_requirements("cairo-xml", ["zlib::zlib"]) + add_component_and_base_requirements("cairo-util_", ["expat::expat"]) if self.options.tee: + self.cpp_info.components["cairo-tee"].set_property("pkg_config_name", "cairo-tee") self.cpp_info.components["cairo-tee"].names["pkg_config"] = "cairo-tee" self.cpp_info.components["cairo-tee"].requires = ["cairo_"] # util directory if self.options.with_glib: + self.cpp_info.components["cairo-gobject"].set_property("pkg_config_name", "cairo-gobject") self.cpp_info.components["cairo-gobject"].names["pkg_config"] = "cairo-gobject" self.cpp_info.components["cairo-gobject"].libs = ["cairo-gobject"] self.cpp_info.components["cairo-gobject"].requires = ["cairo_", "glib::gobject-2.0", "glib::glib-2.0"] - if self.options.with_zlib: - self.cpp_info.components["cairo-script-interpreter"].libs = ["cairo-script-interpreter"] - self.cpp_info.components["cairo-script-interpreter"].requires = ["cairo_"] - - # binary tools - if self.options.with_zlib and self.options.with_png: - self.cpp_info.components["cairo_util_"].requires.append("expat::expat") # trace-to-xml.c, xml-to-trace.c + self.cpp_info.components["cairo_"].requires += list(base_requirements) + self.cpp_info.components["cairo_"].system_libs += list(base_system_libs) def package_id(self): - self.info.requires["glib"].full_package_mode() + if self.options.get_safe("with_glib") and not self.options["glib"].shared: + self.info.requires["glib"].full_package_mode()