diff --git a/recipes/libsm/all/conandata.yml b/recipes/libsm/all/conandata.yml new file mode 100644 index 0000000000000..8c9cf8a1800e4 --- /dev/null +++ b/recipes/libsm/all/conandata.yml @@ -0,0 +1,6 @@ +sources: + "1.2.4": + url: + - "https://www.x.org/archive/individual/lib/libSM-1.2.4.tar.xz" + - "https://xorg.freedesktop.org/releases/individual/lib/libSM-1.2.4.tar.xz" + sha256: "fdcbe51e4d1276b1183da77a8a4e74a137ca203e0bcfb20972dd5f3347e97b84" diff --git a/recipes/libsm/all/conanfile.py b/recipes/libsm/all/conanfile.py new file mode 100644 index 0000000000000..40c58357dc788 --- /dev/null +++ b/recipes/libsm/all/conanfile.py @@ -0,0 +1,97 @@ +import os + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import fix_apple_shared_install_name +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rm, rmdir +from conan.tools.gnu import PkgConfigDeps, AutotoolsToolchain, Autotools +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc + +required_conan_version = ">=1.53.0" + + +class LibSmConan(ConanFile): + name = "libsm" + description = "X11 Session Management library" + license = "MIT AND MIT-open-group" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://gitlab.freedesktop.org/xorg/lib/libsm" + topics = ("xorg", "x11") + + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("libice/1.1.1", transitive_headers=True) + self.requires("xorg-proto/2024.1", transitive_headers=True) + self.requires("xtrans/1.5.0") + self.requires("util-linux-libuuid/2.39.2") + + def validate(self): + if is_msvc(self): + raise ConanInvalidConfiguration("MSVC is not supported.") + + def build_requirements(self): + if not self.conf.get("tools.gnu:pkg_config", check_type=str): + self.tool_requires("pkgconf/[>=2.2 <3]") + if self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + self.tool_requires("xorg-macros/1.20.0") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + VirtualBuildEnv(self).generate() + tc = AutotoolsToolchain(self) + tc.generate() + deps = PkgConfigDeps(self) + deps.generate() + + def build(self): + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) + autotools = Autotools(self) + autotools.install() + # rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + # rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + fix_apple_shared_install_name(self) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "sm") + self.cpp_info.set_property("cmake_target_name", "X11::SM") + self.cpp_info.libs = ["SM"] diff --git a/recipes/libsm/all/test_package/conanfile.py b/recipes/libsm/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0496fd8621e7e --- /dev/null +++ b/recipes/libsm/all/test_package/conanfile.py @@ -0,0 +1,32 @@ +from conan import ConanFile +from conan.tools.build import can_run +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 = "PkgConfigDeps", "MesonToolchain", "VirtualRunEnv", "VirtualBuildEnv" + 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/[>=1.2.3 <2]") + if not self.conf.get("tools.gnu:pkg_config", default=False, check_type=str): + self.tool_requires("pkgconf/[>=2.2 <3]") + + def build(self): + meson = Meson(self) + meson.configure() + meson.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libsm/all/test_package/meson.build b/recipes/libsm/all/test_package/meson.build new file mode 100644 index 0000000000000..2e3ab6f7ae654 --- /dev/null +++ b/recipes/libsm/all/test_package/meson.build @@ -0,0 +1,5 @@ +project('test_package', 'c') +package_dep = dependency('sm') +executable('test_package', + sources : ['test_package.c'], + dependencies : [package_dep]) diff --git a/recipes/libsm/all/test_package/test_package.c b/recipes/libsm/all/test_package/test_package.c new file mode 100644 index 0000000000000..5cf6dc02def07 --- /dev/null +++ b/recipes/libsm/all/test_package/test_package.c @@ -0,0 +1,8 @@ +#include + +#include + +int main() { + SmProp *prop = malloc(sizeof(SmProp)); + SmFreeProperty(prop); +} diff --git a/recipes/libsm/config.yml b/recipes/libsm/config.yml new file mode 100644 index 0000000000000..5c12183246809 --- /dev/null +++ b/recipes/libsm/config.yml @@ -0,0 +1,3 @@ +versions: + "1.2.4": + folder: all