diff --git a/recipes/libsystemd/all/conanfile.py b/recipes/libsystemd/all/conanfile.py index 7267a019ded534..4e0dcd367297b8 100644 --- a/recipes/libsystemd/all/conanfile.py +++ b/recipes/libsystemd/all/conanfile.py @@ -22,6 +22,7 @@ class LibsystemdConan(ConanFile): topics = ("systemd", "service", "manager") package_type = "library" settings = "os", "arch", "compiler", "build_type" + provides = "libudev" options = { "shared": [True, False], "fPIC": [True, False], @@ -55,7 +56,7 @@ def requirements(self): self.requires("libcap/2.69") self.requires("libmount/2.39") if Version(self.version) >= "253.6": - self.requires("libxcrypt/4.4.35") + self.requires("libxcrypt/4.4.36") if self.options.with_selinux: self.requires("libselinux/3.3") if self.options.with_lz4: @@ -70,7 +71,7 @@ def validate(self): raise ConanInvalidConfiguration("Only Linux supported") def build_requirements(self): - self.tool_requires("meson/1.2.1") + self.tool_requires("meson/1.2.2") self.tool_requires("m4/1.4.19") self.tool_requires("gperf/3.1") if not self.conf.get("tools.gnu:pkg_config", check_type=str): @@ -104,10 +105,13 @@ def generate(self): if self.options.shared: tc.project_options["static-libsystemd"] = "false" + tc.project_options["static-libudev"] = "false" elif self.options.fPIC: tc.project_options["static-libsystemd"] = "pic" + tc.project_options["static-libudev"] = "pic" else: tc.project_options["static-libsystemd"] = "no-pic" + tc.project_options["static-libudev"] = "no-pic" # options unrelated to libsystemd unrelated = [ @@ -170,32 +174,63 @@ def build(self): meson = Meson(self) meson.configure() - target = ("systemd:shared_library" if self.options.shared + systemd_target = ("systemd:shared_library" if self.options.shared else "systemd:static_library") - meson.build(target=f"version.h {target}") + udev_target = ("udev:shared_library" if self.options.shared + else "udev:static_library") + meson.build(target=f"version.h {systemd_target} {udev_target}") def package(self): copy(self, "LICENSE.LGPL2.1", self.source_folder, os.path.join(self.package_folder, "licenses")) copy(self, "*.h", os.path.join(self.source_folder, "src", "systemd"), os.path.join(self.package_folder, "include", "systemd")) + copy(self, "libudev.h", os.path.join(self.source_folder, "src", "libudev"), + os.path.join(self.package_folder, "include")) if self.options.shared: copy(self, "libsystemd.so", self.build_folder, os.path.join(self.package_folder, "lib")) copy(self, "libsystemd.so.{}".format(self._so_version.split('.')), self.build_folder, os.path.join(self.package_folder, "lib")) - copy(self, "libsystemd.so.{}".format(self._so_version), + copy(self, f"libsystemd.so.{self._so_version}", + self.build_folder, os.path.join(self.package_folder, "lib")) + copy(self, "libudev.so", self.build_folder, + os.path.join(self.package_folder, "lib")) + copy(self, "libudev.so.{}".format(self._so_version.split('.')), + self.build_folder, os.path.join(self.package_folder, "lib")) + copy(self, f"libudev.so.{self._so_version}", self.build_folder, os.path.join(self.package_folder, "lib")) else: copy(self, "libsystemd.a", self.build_folder, os.path.join(self.package_folder, "lib")) + copy(self, "libudev.a", self.build_folder, + os.path.join(self.package_folder, "lib")) def package_info(self): - self.cpp_info.set_property("pkg_config_name", "libsystemd") - self.cpp_info.set_property("component_version", str(Version(self.version).major)) - self.cpp_info.libs = ["systemd"] - self.cpp_info.system_libs = ["rt", "pthread", "dl"] + self.cpp_info.components["libsystemd"].libs = ["systemd"] + self.cpp_info.components["libsystemd"].requires = ["libcap::cap", "libmount::libmount"] + if Version(self.version) >= "253.6": + self.cpp_info.components["libsystemd"].requires.append("libxcrypt::libxcrypt") + if self.options.with_selinux: + self.cpp_info.components["libsystemd"].requires.append("libselinux::selinux") + if self.options.with_lz4: + self.cpp_info.components["libsystemd"].requires.append("lz4::lz4") + if self.options.with_xz: + self.cpp_info.components["libsystemd"].requires.append("xz_utils::xz_utils") + if self.options.with_zstd: + self.cpp_info.components["libsystemd"].requires.append("zstd::zstdlib") + self.cpp_info.components["libsystemd"].set_property("pkg_config_name", "libsystemd") + self.cpp_info.components["libsystemd"].set_property("component_version", str(Version(self.version).major)) + self.cpp_info.components["libsystemd"].system_libs = ["rt", "pthread", "dl"] + + # TODO: to remove in conan v2 + self.cpp_info.components["libsystemd"].version = str(Version(self.version).major) + + self.cpp_info.components["libudev"].libs = ["udev"] + self.cpp_info.components["libudev"].requires = ["libcap::cap"] + self.cpp_info.components["libudev"].set_property("pkg_config_name", "libudev") + self.cpp_info.components["libudev"].system_libs = ["rt", "pthread"] # TODO: to remove in conan v2 - self.cpp_info.version = str(Version(self.version).major) + self.cpp_info.components["libudev"].version = str(Version(self.version).major) diff --git a/recipes/libsystemd/all/test_package/CMakeLists.txt b/recipes/libsystemd/all/test_package/CMakeLists.txt index 63d72a88f1cb30..245e951ae047e7 100644 --- a/recipes/libsystemd/all/test_package/CMakeLists.txt +++ b/recipes/libsystemd/all/test_package/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.6) project(test_package LANGUAGES C) find_package(PkgConfig REQUIRED) -pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd) +pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd libudev) add_executable(${PROJECT_NAME} test_package.c) target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::SYSTEMD) diff --git a/recipes/libsystemd/all/test_package/conanfile.py b/recipes/libsystemd/all/test_package/conanfile.py index 4fc0d2de603bc8..0e275799b53e7c 100644 --- a/recipes/libsystemd/all/test_package/conanfile.py +++ b/recipes/libsystemd/all/test_package/conanfile.py @@ -18,7 +18,7 @@ def requirements(self): def build_requirements(self): if not self.conf.get("tools.gnu:pkg_config", check_type=str): - self.tool_requires("pkgconf/1.9.3") + self.tool_requires("pkgconf/2.0.3") def build(self): cmake = CMake(self) diff --git a/recipes/libsystemd/all/test_package/test_package.c b/recipes/libsystemd/all/test_package/test_package.c index 97e8b8389e2a44..b1d51f676962c3 100644 --- a/recipes/libsystemd/all/test_package/test_package.c +++ b/recipes/libsystemd/all/test_package/test_package.c @@ -1,5 +1,6 @@ #include #include +#include #include @@ -11,4 +12,24 @@ int main(void) { } puts("failed"); return EXIT_FAILURE; + +// Test udev + struct udev *udev; + struct udev_enumerate *enumerate; + + udev = udev_new(); + if (!udev) { + fprintf(stderr, "Cannot create udev context.\n"); + return 1; + } + + enumerate = udev_enumerate_new(udev); + if (!enumerate) { + fprintf(stderr, "Cannot create enumerate context.\n"); + } + + udev_enumerate_unref(enumerate); + udev_unref(udev); + + return EXIT_SUCCESS; } diff --git a/recipes/libsystemd/all/test_v1_package/conanfile.py b/recipes/libsystemd/all/test_v1_package/conanfile.py index e6b0fdb8110e8d..b3607270e232e7 100644 --- a/recipes/libsystemd/all/test_v1_package/conanfile.py +++ b/recipes/libsystemd/all/test_v1_package/conanfile.py @@ -7,7 +7,7 @@ class TestPackageConan(ConanFile): generators = "cmake", "pkg_config" def build_requirements(self): - self.build_requires("pkgconf/1.9.3") + self.build_requires("pkgconf/2.0.3") def build(self): cmake = CMake(self)