You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

conanfile.py 2.3 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import fnmatch
  2. from conans import ConanFile, CMake, tools
  3. class JsonclibConan(ConanFile):
  4. name = "json-c"
  5. version = "0.13"
  6. description = "JSON-C - A JSON implementation in C"
  7. topics = ("conan", "json-c", "json", "encoding", "decoding", "manipulation")
  8. url = "https://github.com/elear-solutions/json-c"
  9. license = "MIT"
  10. generators = "cmake"
  11. settings = "os", "compiler", "build_type", "arch"
  12. options = {
  13. "shared": [True, False],
  14. "fPIC": [True, False]
  15. }
  16. default_options = {key: False for key in options.keys()}
  17. default_options ["shared"] = False
  18. default_options ["fPIC"] = True
  19. @property
  20. def _targets(self):
  21. return {
  22. "iOS-armv7-*": "arm-apple-darwin",
  23. "iOS-armv8-*": "aarch64-apple-darwin",
  24. "iOS-x86-*": "i386-apple-darwin",
  25. "iOS-x86_64-*": "x86_64-apple-darwin"
  26. }
  27. def config_options(self):
  28. if self.settings.os == "Windows":
  29. del self.options.fPIC
  30. def configure(self):
  31. del self.settings.compiler.libcxx
  32. del self.settings.compiler.cppstd
  33. def _configure_cmake(self):
  34. if tools.cross_building(self.settings) and self.settings.os != "Windows":
  35. if tools.is_apple_os(self.settings.os):
  36. query = "%s-%s-%s" % (self.settings.os, self.settings.arch, self.settings.compiler)
  37. host = next((self._targets[i] for i in self._targets if fnmatch.fnmatch(query, i)), None)
  38. else:
  39. host = tools.get_gnu_triplet(str(self.settings.os), str(self.settings.arch))
  40. tools.replace_in_file("../CMakeLists.txt",
  41. "execute_process(COMMAND ./configure ",
  42. "execute_process(COMMAND ./configure --host %s " % host)
  43. cmake = CMake(self)
  44. cmake.configure(source_folder=".")
  45. return cmake
  46. def build(self):
  47. cmake = self._configure_cmake()
  48. cmake.build()
  49. cmake.install()
  50. def package(self):
  51. self.copy("*.h", dst="include/json-c", src="package/include/json-c")
  52. self.copy("*", dst="lib", src="package/lib", keep_path=False)
  53. def package_info(self):
  54. self.cpp_info.libs = [ "json-c" ]