diff --git a/recipes/dbus/1.x.x/CMakeLists.txt b/recipes/dbus/1.x.x/CMakeLists.txt deleted file mode 100644 index b117333a50..0000000000 --- a/recipes/dbus/1.x.x/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -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 782da97eb7..15c5df2d70 100644 --- a/recipes/dbus/1.x.x/conandata.yml +++ b/recipes/dbus/1.x.x/conandata.yml @@ -10,12 +10,8 @@ sources: 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_file: "patches/0001-cmake-project.patch" + - patch_file: "patches/0002-cmake_configure_checks_list_separator.patch" 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 06afef2d16..78abe21349 100644 --- a/recipes/dbus/1.x.x/conanfile.py +++ b/recipes/dbus/1.x.x/conanfile.py @@ -1,14 +1,13 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, mkdir, rename, replace_in_file, rmdir, save +from conan.tools.scm import Version import os import textwrap -from conan import ConanFile -from conan.tools.files import apply_conandata_patches, copy, get, mkdir, rename, rmdir, save, rm -from conan.errors import ConanInvalidConfiguration -from conan.tools.apple import is_apple_os -from conan.tools.scm import Version -from conans import CMake - -required_conan_version = ">=1.51.3" +required_conan_version = ">=1.52.0" class DbusConan(ConanFile): @@ -21,12 +20,12 @@ class DbusConan(ConanFile): settings = "os", "arch", "compiler", "build_type" options = { - "system_socket": "ANY", - "system_pid_file": "ANY", + "system_socket": ["ANY"], + "system_pid_file": ["ANY"], "with_x11": [True, False], "with_glib": [True, False], "with_selinux": [True, False], - "session_socket_dir": "ANY", + "session_socket_dir": ["ANY"], } default_options = { "system_socket": "", @@ -37,29 +36,30 @@ class DbusConan(ConanFile): "session_socket_dir": "/tmp", } - generators = "cmake", "cmake_find_package", "VirtualBuildEnv", "VirtualRunEnv" - _cmake = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _build_subfolder(self): - return "build_subfolder" + def export_sources(self): + export_conandata_patches(self) def config_options(self): if self.settings.os not in ("Linux", "FreeBSD"): del self.options.with_x11 def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + cmake_layout(self, src_folder="src") def requirements(self): self.requires("expat/2.4.9") if self.options.with_glib: - self.requires("glib/2.73.3") + self.requires("glib/2.74.0") if self.options.with_selinux: self.requires("selinux/3.3") if self.options.get_safe("with_x11"): @@ -67,52 +67,54 @@ class DbusConan(ConanFile): def validate(self): if Version(self.version) >= "1.14.0": - if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < 7: - raise ConanInvalidConfiguration("dbus requires at least gcc 7.") - if self.settings.os == "Windows": - raise ConanInvalidConfiguration("dbus 1.14.0 does not support windows. contributions are welcome") - - 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)) + if self.info.settings.compiler == "gcc" and Version(self.info.settings.compiler.version) < 7: + raise ConanInvalidConfiguration(f"{self.ref} requires at least gcc 7.") + if self.info.settings.os == "Windows": + raise ConanInvalidConfiguration(f"{self.ref} does not support windows. contributions are welcome") def source(self): - get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) - def _configure_cmake(self): - if not self._cmake: - self._cmake = CMake(self) + def generate(self): + tc = CMakeToolchain(self) + tc.variables["DBUS_BUILD_TESTS"] = False + tc.variables["DBUS_ENABLE_DOXYGEN_DOCS"] = False + tc.variables["DBUS_ENABLE_XML_DOCS"] = False + tc.variables["DBUS_BUILD_X11"] = self.options.get_safe("with_x11", False) + tc.variables["DBUS_WITH_GLIB"] = self.options.with_glib + tc.variables["DBUS_DISABLE_ASSERT"] = is_apple_os(self) + tc.variables["DBUS_DISABLE_CHECKS"] = False + # https://github.com/freedesktop/dbus/commit/e827309976cab94c806fda20013915f1db2d4f5a + tc.variables["DBUS_SESSION_SOCKET_DIR"] = self.options.session_socket_dir + tc.generate() - self._cmake.definitions["DBUS_BUILD_TESTS"] = False - self._cmake.definitions["DBUS_ENABLE_DOXYGEN_DOCS"] = False - self._cmake.definitions["DBUS_ENABLE_XML_DOCS"] = False + deps = CMakeDeps(self) + deps.generate() - 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"] = is_apple_os(self) - self._cmake.definitions["DBUS_DISABLE_CHECKS"] = False - - # 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" - - # https://github.com/freedesktop/dbus/commit/e827309976cab94c806fda20013915f1db2d4f5a - self._cmake.definitions["DBUS_SESSION_SOCKET_DIR"] = self.options.session_socket_dir - - self._cmake.configure(source_folder=self._source_subfolder, - build_folder=self._build_subfolder) - return self._cmake + def _patch_sources(self): + apply_conandata_patches(self) + # Unfortunately, there is currently no other way to force disable + # CMAKE_FIND_PACKAGE_PREFER_CONFIG ON in CMake conan_toolchain. + replace_in_file( + self, + os.path.join(self.generators_folder, "conan_toolchain.cmake"), + "set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)", + "", + strict=False, + ) def build(self): - apply_conandata_patches(self) - cmake = self._configure_cmake() + self._patch_sources() + cmake = CMake(self) + if Version(self.version) < "1.14.0": + cmake.configure(build_script_folder=os.path.join(self.source_folder, "cmake")) + else: + cmake.configure() cmake.build() def package(self): - self.copy(pattern="COPYING", dst="licenses", - src=self._source_subfolder) - cmake = self._configure_cmake() + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() rmdir(self, os.path.join(self.package_folder, "share", "doc")) @@ -123,7 +125,6 @@ class DbusConan(ConanFile): 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")) - rm(self, "*.la", self.package_folder) # TODO: to remove in conan v2 once cmake_find_package_* generators removed self._create_cmake_module_alias_targets( @@ -134,12 +135,12 @@ class DbusConan(ConanFile): def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): - content += textwrap.dedent("""\ + content += textwrap.dedent(f"""\ if(TARGET {aliased} AND NOT TARGET {alias}) add_library({alias} INTERFACE IMPORTED) set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) endif() - """.format(alias=alias, aliased=aliased)) + """) save(self, module_file, content) @property @@ -154,6 +155,7 @@ class DbusConan(ConanFile): os.path.join("include", "dbus-1.0"), os.path.join("lib", "dbus-1.0", "include"), ]) + self.cpp_info.resdirs = ["res"] self.cpp_info.libs = ["dbus-1"] if self.settings.os == "Linux": self.cpp_info.system_libs.append("rt") diff --git a/recipes/dbus/1.x.x/patches/0001-cmake-project.patch b/recipes/dbus/1.x.x/patches/0001-cmake-project.patch new file mode 100644 index 0000000000..2d00f57d33 --- /dev/null +++ b/recipes/dbus/1.x.x/patches/0001-cmake-project.patch @@ -0,0 +1,23 @@ +--- a/cmake/CMakeLists.txt ++++ b/cmake/CMakeLists.txt +@@ -1,10 +1,3 @@ +-# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked +-list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules") +- +-# we do not need to have WIN32 defined +-set(CMAKE_LEGACY_CYGWIN_WIN32 0) +- +-project(dbus) + + # we need to be up to date + CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2 FATAL_ERROR) +@@ -19,6 +12,9 @@ if(CMAKE_MAJOR_VERSION GREATER 2) + cmake_policy(SET CMP0054 NEW) + endif() + endif() ++set(CMAKE_LEGACY_CYGWIN_WIN32 0) ++project(dbus) ++list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules") + + # detect version + include(MacrosAutotools) diff --git a/recipes/dbus/1.x.x/patches/cmake_configure_checks_list_separator.patch b/recipes/dbus/1.x.x/patches/0002-cmake_configure_checks_list_separator.patch similarity index 100% rename from recipes/dbus/1.x.x/patches/cmake_configure_checks_list_separator.patch rename to recipes/dbus/1.x.x/patches/0002-cmake_configure_checks_list_separator.patch 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 deleted file mode 100644 index b4b275a75a..0000000000 --- a/recipes/dbus/1.x.x/patches/cmake_current_source_dir.patch +++ /dev/null @@ -1,112 +0,0 @@ -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