From 57fae1059e5ce291fa015355b53a708a200ee031 Mon Sep 17 00:00:00 2001 From: rohan-elear <53178851+rohan-elear@users.noreply.github.com> Date: Fri, 25 Sep 2020 18:26:30 +0530 Subject: [PATCH] Adds fix for configure for apple toolchains (#9) --- conanfile.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/conanfile.py b/conanfile.py index 73e4d28..eb3abd5 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,3 +1,4 @@ +import fnmatch from conans import ConanFile, CMake, tools class JsonclibConan(ConanFile): @@ -6,7 +7,7 @@ class JsonclibConan(ConanFile): description = "JSON-C - A JSON implementation in C" topics = ("conan", "json-c", "json", "encoding", "decoding", "manipulation") url = "https://github.com/elear-solutions/json-c" - license = "" + license = "MIT" generators = "cmake" settings = "os", "compiler", "build_type", "arch" options = { @@ -17,6 +18,15 @@ class JsonclibConan(ConanFile): default_options ["shared"] = False default_options ["fPIC"] = True + @property + def _targets(self): + return { + "iOS-armv7-*": "arm-apple-darwin", + "iOS-armv8-*": "aarch64-apple-darwin", + "iOS-x86-*": "i386-apple-darwin", + "iOS-x86_64-*": "x86_64-apple-darwin" + } + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -27,7 +37,11 @@ class JsonclibConan(ConanFile): def _configure_cmake(self): if tools.cross_building(self.settings) and self.settings.os != "Windows": - host = tools.get_gnu_triplet(str(self.settings.os), str(self.settings.arch)) + if tools.is_apple_os(self.settings.os): + query = "%s-%s-%s" % (self.settings.os, self.settings.arch, self.settings.compiler) + host = next((self._targets[i] for i in self._targets if fnmatch.fnmatch(query, i)), None) + else: + host = tools.get_gnu_triplet(str(self.settings.os), str(self.settings.arch)) tools.replace_in_file("../CMakeLists.txt", "execute_process(COMMAND ./configure ", "execute_process(COMMAND ./configure --host %s " % host)