diff --git a/recipes/libobjc2/all/conandata.yml b/recipes/libobjc2/all/conandata.yml new file mode 100644 index 0000000000000..5ac2e6c4e81ca --- /dev/null +++ b/recipes/libobjc2/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.2.1": + url: "https://github.com/gnustep/libobjc2/archive/v2.2.1.zip" + sha256: "b0afc1d98a6f7208fb5ce1fc8b5848b5ba6dba1f4fcd755fbe3fc78b5e4b3308" diff --git a/recipes/libobjc2/all/conanfile.py b/recipes/libobjc2/all/conanfile.py new file mode 100644 index 0000000000000..9bf1e2e49c2e2 --- /dev/null +++ b/recipes/libobjc2/all/conanfile.py @@ -0,0 +1,73 @@ +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 copy, get, replace_in_file, rm, rmdir +import os + +required_conan_version = ">=2.1" + +class PackageConan(ConanFile): + name = "libobjc2" + description = "Objective-C runtime library intended for use with Clang." + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/gnustep/libobjc2" + topics = ("objective-c", "objective-c-plus-plus", "clang", "gnustep", "objective-c-runtime", "runtime-library") + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + implements = ["auto_shared_fpic"] + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("tsl-robin-map/[>=1.2.1 <2]") + + def validate(self): + if self.settings.compiler != "clang": + raise ConanInvalidConfiguration("libobjc2 supports clang only.") + + if is_apple_os(self): + raise ConanInvalidConfiguration("libobjc2 does not support macOS.") + + def build_requirements(self): + self.tool_requires("cmake/[>=3.16]") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "set(CMAKE_CXX_STANDARD 17)", "") + + def generate(self): + tc = CMakeToolchain(self) + # Prevent picking up a default install location through gnustep-config + tc.cache_variables["GNUSTEP_INSTALL_TYPE"] = "NONE" + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.pdb", self.package_folder, recursive=True) + + def package_info(self): + self.cpp_info.libs = ["objc"] + self.cpp_info.set_property("pkg_config_name", "libobjc") diff --git a/recipes/libobjc2/all/test_package/CMakeLists.txt b/recipes/libobjc2/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..dd76ad009d363 --- /dev/null +++ b/recipes/libobjc2/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES C) + +find_package(libobjc2 REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE libobjc2::libobjc2) diff --git a/recipes/libobjc2/all/test_package/conanfile.py b/recipes/libobjc2/all/test_package/conanfile.py new file mode 100644 index 0000000000000..2e77b4246fa81 --- /dev/null +++ b/recipes/libobjc2/all/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.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/libobjc2/all/test_package/test_package.c b/recipes/libobjc2/all/test_package/test_package.c new file mode 100644 index 0000000000000..d46a2eea91e2b --- /dev/null +++ b/recipes/libobjc2/all/test_package/test_package.c @@ -0,0 +1,11 @@ +#include +#include "objc/objc.h" +#include "objc/encoding.h" +#include + +int main(void) { + char type = _C_CLASS; + objc_sizeof_type(&type); + printf("libobjc2 test package successful!\n"); + return EXIT_SUCCESS; +} diff --git a/recipes/libobjc2/config.yml b/recipes/libobjc2/config.yml new file mode 100644 index 0000000000000..a816d92f78ee3 --- /dev/null +++ b/recipes/libobjc2/config.yml @@ -0,0 +1,3 @@ +versions: + "2.2.1": + folder: all