diff --git a/recipes/dbus/1.x.x/CMakeLists.txt b/recipes/dbus/1.x.x/CMakeLists.txt new file mode 100644 index 0000000000000..b117333a50fcc --- /dev/null +++ b/recipes/dbus/1.x.x/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(../conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory("cmake") diff --git a/recipes/dbus/1.x.x/conandata.yml b/recipes/dbus/1.x.x/conandata.yml index 427a97ea4efa4..42752d935328d 100644 --- a/recipes/dbus/1.x.x/conandata.yml +++ b/recipes/dbus/1.x.x/conandata.yml @@ -2,3 +2,14 @@ sources: "1.12.20": url: "https://dbus.freedesktop.org/releases/dbus/dbus-1.12.20.tar.gz" sha256: "f77620140ecb4cdc67f37fb444f8a6bea70b5b6461f12f1cbe2cec60fa7de5fe" +patches: + "1.12.20": + - patch_file: "patches/cmake_current_source_dir.patch" + base_path: "source_subfolder" + patch_type: "portability" + patch_source: "https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/332" + - patch_file: "patches/cmake_configure_checks_list_separator.patch" + base_path: "source_subfolder" + patch_type: "portability" + url: "https://gitlab.freedesktop.org/dbus/dbus/-/commit/8cd1c2155252938ed38d2612e4d054c7fc0244c3.patch" + patch_source: "https://gitlab.freedesktop.org/dbus/dbus/-/issues/324" diff --git a/recipes/dbus/1.x.x/conanfile.py b/recipes/dbus/1.x.x/conanfile.py index e20a3dea887e7..be12d0c320dfa 100644 --- a/recipes/dbus/1.x.x/conanfile.py +++ b/recipes/dbus/1.x.x/conanfile.py @@ -1,8 +1,12 @@ -from conans import AutoToolsBuildEnvironment, ConanFile, tools, CMake import os -import shutil import textwrap +from conan import ConanFile +from conan.tools.apple.apple import is_apple_os +from conan.tools.files import apply_conandata_patches, copy, get, mkdir, rename, rmdir, save +from conans import CMake +from conans.tools import remove_files_by_mask + required_conan_version = ">=1.43.0" @@ -30,8 +34,7 @@ class DbusConan(ConanFile): "with_selinux": False, } - generators = "pkg_config", "cmake", "cmake_find_package" - _autotools = None + generators = "cmake", "cmake_find_package", "VirtualBuildEnv", "VirtualRunEnv" _cmake = None @property @@ -58,40 +61,14 @@ def requirements(self): self.requires("selinux/3.3") if self.options.get_safe("with_x11"): self.requires("xorg/system") + + def export_sources(self): + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + copy(self, "CMakeLists.txt", self.recipe_folder, os.path.join(self.export_sources_folder, self._source_subfolder)) def source(self): - tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) - - def _configure_autotools(self): - if not self._autotools: - self._autotools = AutoToolsBuildEnvironment(self) - - args = [] - args.append("--disable-tests") - args.append("--disable-doxygen-docs") - args.append("--disable-xml-docs") - - args.append("--with-x=%s" % ("yes" if self.options.get_safe("with_x11", False) else "no")) - args.append("--%s-x11-autolaunch" % ("enable" if self.options.get_safe("with_x11", False) else "disable")) - args.append("--disable-asserts") - args.append("--disable-checks") - - args.append("--with-systemdsystemunitdir=%s" % os.path.join(self.package_folder, "lib", "systemd", "system")) - args.append("--with-systemduserunitdir=%s" % os.path.join(self.package_folder, "lib", "systemd", "user")) - - if not self.options.with_selinux: - args.append("--disable-selinux") - - if str(self.options.system_socket) != "": - args.append("--with-system-socket=%s" % self.options.system_socket) - if str(self.options.system_pid_file) != "": - args.append("--with-system-pid-file=%s" % self.options.system_pid_file) - - args.append("--disable-launchd") - args.append("--disable-systemd") - - self._autotools.configure(args=args, configure_dir=self._source_subfolder) - return self._autotools + get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) def _configure_cmake(self): if not self._cmake: @@ -103,44 +80,37 @@ def _configure_cmake(self): self._cmake.definitions["DBUS_BUILD_X11"] = self.options.get_safe("with_x11", False) self._cmake.definitions["DBUS_WITH_GLIB"] = self.options.with_glib - self._cmake.definitions["DBUS_DISABLE_ASSERT"] = False + self._cmake.definitions["DBUS_DISABLE_ASSERT"] = is_apple_os(self.settings.os) self._cmake.definitions["DBUS_DISABLE_CHECKS"] = False - path_to_cmake_lists = os.path.join(self._source_subfolder, "cmake") + # Conan does not provide an EXPAT_LIBRARIES CMake variable for the Expat library. + # Define EXPAT_LIBRARIES to be the expat::expat target provided by Conan to fix linking. + self._cmake.definitions["EXPAT_LIBRARIES"] = "expat::expat" - self._cmake.configure(source_folder=path_to_cmake_lists, + self._cmake.configure(source_folder=self._source_subfolder, build_folder=self._build_subfolder) return self._cmake def build(self): - tools.replace_in_file(os.path.join(self._source_subfolder, "cmake", "CMakeLists.txt"), - "project(dbus)", - "project(dbus)\ninclude(../../conanbuildinfo.cmake)\nconan_basic_setup()") - if self.settings.os == "Windows": - cmake = self._configure_cmake() - cmake.build() - else: - autotools = self._configure_autotools() - autotools.make() + apply_conandata_patches(self) + cmake = self._configure_cmake() + cmake.build() def package(self): self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) - if self.settings.os == "Windows": - cmake = self._configure_cmake() - cmake.install() - else: - autotools = self._configure_autotools() - autotools.install() + cmake = self._configure_cmake() + cmake.install() - tools.rmdir(os.path.join(self.package_folder, "share", "doc")) + rmdir(self, os.path.join(self.package_folder, "share", "doc")) + mkdir(self, os.path.join(self.package_folder, "res")) for i in ["var", "share", "etc"]: - shutil.move(os.path.join(self.package_folder, i), os.path.join(self.package_folder, "res", i)) + rename(self, os.path.join(self.package_folder, i), os.path.join(self.package_folder, "res", i)) - tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "lib", "systemd")) - tools.remove_files_by_mask(self.package_folder, "*.la") + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "lib", "systemd")) + remove_files_by_mask(self.package_folder, "*.la") # TODO: to remove in conan v2 once cmake_find_package_* generators removed self._create_cmake_module_alias_targets( @@ -148,8 +118,7 @@ def package(self): {"dbus-1": "dbus-1::dbus-1"} ) - @staticmethod - def _create_cmake_module_alias_targets(module_file, targets): + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): content += textwrap.dedent("""\ @@ -158,7 +127,7 @@ def _create_cmake_module_alias_targets(module_file, targets): set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) endif() """.format(alias=alias, aliased=aliased)) - tools.save(module_file, content) + save(self, module_file, content) @property def _module_file_rel_path(self): @@ -173,6 +142,12 @@ def package_info(self): os.path.join("lib", "dbus-1.0", "include"), ]) self.cpp_info.libs = ["dbus-1"] + if self.settings.os == "Linux": + self.cpp_info.system_libs.append("rt") + if self.settings.os == "Windows": + self.cpp_info.system_libs.extend(["iphlpapi", "ws2_32"]) + else: + self.cpp_info.system_libs.append("pthread") # TODO: to remove in conan v2 once cmake_find_package_* & pkg_config generators removed self.cpp_info.filenames["cmake_find_package"] = "DBus1" diff --git a/recipes/dbus/1.x.x/patches/cmake_configure_checks_list_separator.patch b/recipes/dbus/1.x.x/patches/cmake_configure_checks_list_separator.patch new file mode 100644 index 0000000000000..7c60bf52d5ec2 --- /dev/null +++ b/recipes/dbus/1.x.x/patches/cmake_configure_checks_list_separator.patch @@ -0,0 +1,22 @@ +diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake +index a9a5fc90..1a59461a 100644 +--- a/cmake/ConfigureChecks.cmake ++++ b/cmake/ConfigureChecks.cmake +@@ -43,7 +43,7 @@ check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE) # + check_symbol_exists(getgrouplist "grp.h" HAVE_GETGROUPLIST) # dbus-sysdeps.c + check_symbol_exists(getpeerucred "ucred.h" HAVE_GETPEERUCRED) # dbus-sysdeps.c, dbus-sysdeps-win.c + check_symbol_exists(nanosleep "time.h" HAVE_NANOSLEEP) # dbus-sysdeps.c +-check_symbol_exists(getpwnam_r "errno.h pwd.h" HAVE_POSIX_GETPWNAM_R) # dbus-sysdeps-util-unix.c ++check_symbol_exists(getpwnam_r "errno.h;pwd.h" HAVE_POSIX_GETPWNAM_R) # dbus-sysdeps-util-unix.c + check_symbol_exists(setenv "stdlib.h" HAVE_SETENV) # dbus-sysdeps.c + check_symbol_exists(unsetenv "stdlib.h" HAVE_UNSETENV) # dbus-sysdeps.c + check_symbol_exists(clearenv "stdlib.h" HAVE_CLEARENV) # dbus-sysdeps.c +@@ -66,7 +66,7 @@ check_symbol_exists(getrlimit "sys/resource.h;sys/time.h" HAVE_GETRLIMIT) + check_symbol_exists(prlimit "sys/resource.h;sys/time.h" HAVE_PRLIMIT) + check_symbol_exists(setrlimit "sys/resource.h;sys/time.h" HAVE_SETRLIMIT) + +-check_struct_member(cmsgcred cmcred_pid "sys/types.h sys/socket.h" HAVE_CMSGCRED) # dbus-sysdeps.c ++check_struct_member(cmsgcred cmcred_pid "sys/types.h;sys/socket.h" HAVE_CMSGCRED) # dbus-sysdeps.c + + # missing: + # DBUS_HAVE_GCC33_GCOV diff --git a/recipes/dbus/1.x.x/patches/cmake_current_source_dir.patch b/recipes/dbus/1.x.x/patches/cmake_current_source_dir.patch new file mode 100644 index 0000000000000..b4b275a75ae3d --- /dev/null +++ b/recipes/dbus/1.x.x/patches/cmake_current_source_dir.patch @@ -0,0 +1,112 @@ +diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt +index 3ac71a5a..9d203d5f 100644 +--- a/cmake/CMakeLists.txt ++++ b/cmake/CMakeLists.txt +@@ -1,5 +1,5 @@ + # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked +-list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules") ++list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/modules") + + # we do not need to have WIN32 defined + set(CMAKE_LEGACY_CYGWIN_WIN32 0) +@@ -114,7 +114,7 @@ endif (CYGWIN) + # search for required packages + if (WIN32) + # include local header first to avoid using old installed header +- set (CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/..) ++ set (CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${PROJECT_SOURCE_DIR}/..) + find_package(LibIconv) + include(Win32Macros) + addExplorerWrapper(${CMAKE_PROJECT_NAME}) +@@ -148,7 +148,7 @@ add_definitions(-D_GNU_SOURCE) + INCLUDE(ConfigureChecks.cmake) + + # @TODO: how to remove last dir from ${CMAKE_SOURCE_DIR} ? +-SET(DBUS_SOURCE_DIR ${CMAKE_SOURCE_DIR}/..) ++SET(DBUS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) + + # make some more macros available + include (MacroLibrary) +@@ -281,7 +281,7 @@ endif (WIN32 OR CYGWIN) + set (EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) + + # for including config.h and for includes like