|
| 1 | +from conan import ConanFile |
| 2 | +from conan.errors import ConanInvalidConfiguration |
| 3 | +from conan.tools.build import check_min_cppstd |
| 4 | +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout |
| 5 | +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir |
| 6 | +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime |
| 7 | +import os |
| 8 | + |
| 9 | +required_conan_version = ">=2.0.9" |
| 10 | + |
| 11 | +class PackageConan(ConanFile): |
| 12 | + name = "libobjc2" |
| 13 | + description = "Objective-C runtime library intended for use with Clang." |
| 14 | + license = "MIT" |
| 15 | + url = "https://github.com/conan-io/conan-center-index" |
| 16 | + homepage = "https://github.com/gnustep/libobjc2" |
| 17 | + topics = ("objective-c", "objective-c-plus-plus", "clang", "gnustep", "objective-c-runtime", "runtime-library") |
| 18 | + package_type = "library" |
| 19 | + settings = "os", "arch", "compiler", "build_type" |
| 20 | + options = { |
| 21 | + "shared": [True, False], |
| 22 | + "fPIC": [True, False], |
| 23 | + } |
| 24 | + default_options = { |
| 25 | + "shared": False, |
| 26 | + "fPIC": True, |
| 27 | + } |
| 28 | + |
| 29 | + def export_sources(self): |
| 30 | + export_conandata_patches(self) |
| 31 | + |
| 32 | + def configure(self): |
| 33 | + if self.options.shared: |
| 34 | + self.options.rm_safe("fPIC") |
| 35 | + |
| 36 | + def layout(self): |
| 37 | + cmake_layout(self, src_folder="src") |
| 38 | + |
| 39 | + def requirements(self): |
| 40 | + self.requires("tsl-robin-map/[^1.3.0]") |
| 41 | + |
| 42 | + def validate(self): |
| 43 | + if self.settings.compiler != "apple-clang" and self.settings.compiler != "clang": |
| 44 | + raise ConanInvalidConfiguration("libobjc2 supports clang only.") |
| 45 | + |
| 46 | + def build_requirements(self): |
| 47 | + self.tool_requires("cmake/[>=3.16 <4]") |
| 48 | + |
| 49 | + def source(self): |
| 50 | + get(self, **self.conan_data["sources"][self.version], strip_root=True) |
| 51 | + apply_conandata_patches(self) |
| 52 | + |
| 53 | + def generate(self): |
| 54 | + tc = CMakeToolchain(self) |
| 55 | + # Prevent picking up a default install location through gnustep-config |
| 56 | + tc.variables["GNUSTEP_INSTALL_TYPE"] = "NONE" |
| 57 | + tc.variables["TESTS"] = not self.conf.get("tools.build:skip_test", default=False) |
| 58 | + tc.generate() |
| 59 | + |
| 60 | + deps = CMakeDeps(self) |
| 61 | + deps.generate() |
| 62 | + |
| 63 | + def build(self): |
| 64 | + cmake = CMake(self) |
| 65 | + cmake.configure() |
| 66 | + cmake.build() |
| 67 | + cmake.test() |
| 68 | + |
| 69 | + def package(self): |
| 70 | + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) |
| 71 | + cmake = CMake(self) |
| 72 | + cmake.install() |
| 73 | + |
| 74 | + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) |
| 75 | + rm(self, "*.pdb", self.package_folder, recursive=True) |
| 76 | + |
| 77 | + def package_info(self): |
| 78 | + self.cpp_info.libs = ["objc"] |
0 commit comments