xmake.lua 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package("proj")
  2. set_homepage("https://proj.org/index.html")
  3. set_description("PROJ is a generic coordinate transformation software that transforms geospatial coordinates from one coordinate reference system (CRS) to another.")
  4. set_license("MIT")
  5. add_urls("https://download.osgeo.org/proj/proj-$(version).tar.gz")
  6. add_versions("9.4.0", "3643b19b1622fe6b2e3113bdb623969f5117984b39f173b4e3fb19a8833bd216")
  7. add_versions("9.0.1", "737eaacbe7906d0d6ff43f0d9ebedc5c734cccc9e6b8d7beefdec3ab22d9a6a3")
  8. add_versions("8.2.1", "76ed3d0c3a348a6693dfae535e5658bbfd47f71cb7ff7eb96d9f12f7e068b1cf")
  9. add_versions("6.3.1", "6de0112778438dcae30fcc6942dee472ce31399b9e5a2b67e8642529868c86f8")
  10. add_patches("6.3.1", path.join(os.scriptdir(), "patches", "6.3.1", "fixes.patch"),
  11. "8e3aa5ff9d10653ed7d8b16513e97eb2ffb39d1c87c1c37684e25336fa14e831")
  12. add_configs("apps", {description = "Build PROJ applications.", default = false, type = "boolean"})
  13. add_configs("tiff", {description = "Enable TIFF support.", default = false, type = "boolean"})
  14. add_configs("curl", {description = "Enable Curl support.", default = false, type = "boolean"})
  15. if is_plat("windows", "mingw") then
  16. add_syslinks("shell32", "ole32")
  17. elseif is_plat("linux", "bsd") then
  18. add_syslinks("dl", "pthread")
  19. end
  20. add_deps("cmake", "sqlite3")
  21. add_deps("nlohmann_json", {configs = {cmake = true}})
  22. on_load(function (package)
  23. if package:config("tiff") then
  24. package:add("deps", "libtiff")
  25. end
  26. if package:config("curl") then
  27. package:add("deps", "libcurl")
  28. end
  29. if package:config("apps") then
  30. package:addenv("PATH", "bin")
  31. end
  32. if not package:config("shared") then
  33. package:add("defines", "PROJ_DLL=")
  34. end
  35. end)
  36. on_install("!wasm and (!android or android@!windows)", function (package)
  37. -- windows@arm64 cann't generate proj.db
  38. if package:is_plat("windows") and package:is_arch("arm64") then
  39. io.replace("CMakeLists.txt", "add_subdirectory(data)", "", {plain = true})
  40. end
  41. if package:config("curl") and (package:version():le("9.4")) then
  42. io.replace("src/lib_proj.cmake", "${CURL_LIBRARIES}", "CURL::libcurl", {plain = true})
  43. end
  44. local configs = {
  45. "-DNLOHMANN_JSON_ORIGIN=external",
  46. "-DBUILD_TESTING=OFF",
  47. "-DPROJ_TESTS=OFF",
  48. }
  49. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  50. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  51. if package:version():ge("8.2") then
  52. table.insert(configs, "-DBUILD_APPS=" .. (package:config("apps") and "ON" or "OFF"))
  53. else
  54. local apps = {"CCT", "CS2CS", "GEOD", "GIE", "PROJ", "PROJINFO"}
  55. for _, v in pairs(apps) do
  56. table.insert(configs, "-DBUILD_" .. v .. "=" .. (package:config("apps") and "ON" or "OFF"))
  57. end
  58. end
  59. table.insert(configs, "-DENABLE_TIFF=" .. (package:config("tiff") and "ON" or "OFF"))
  60. table.insert(configs, "-DENABLE_CURL=" .. (package:config("curl") and "ON" or "OFF"))
  61. table.insert(configs, "-DBUILD_PROJSYNC=" .. (package:config("apps") and package:config("curl") and "ON" or "OFF"))
  62. if package:config("curl") and package:is_plat("macosx") then
  63. local exflags = {"-framework", "CoreFoundation", "-framework", "Security", "-framework", "SystemConfiguration"}
  64. import("package.tools.cmake").install(package, configs, {shflags = exflags, ldflags = exflags})
  65. else
  66. import("package.tools.cmake").install(package, configs)
  67. end
  68. end)
  69. on_test(function (package)
  70. assert(package:has_cfuncs("proj_context_create", {includes = "proj.h"}))
  71. end)