xmake.lua 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_configs("apps", {description = "Build PROJ applications.", default = false, type = "boolean"})
  10. add_configs("tiff", {description = "Enable TIFF support.", default = false, type = "boolean"})
  11. add_configs("curl", {description = "Enable Curl support.", default = false, type = "boolean"})
  12. add_deps("cmake", "sqlite3")
  13. add_deps("nlohmann_json", {configs = {cmake = true}})
  14. if is_plat("windows") then
  15. add_syslinks("shell32", "ole32")
  16. elseif is_plat("linux") then
  17. add_syslinks("pthread")
  18. end
  19. on_load(function (package)
  20. if package:config("tiff") then
  21. package:add("deps", "libtiff")
  22. end
  23. if package:config("curl") then
  24. package:add("deps", "libcurl")
  25. end
  26. if package:config("apps") then
  27. package:addenv("PATH", "bin")
  28. end
  29. end)
  30. on_install("!wasm and (!android or android@!windows)", function (package)
  31. -- windows@arm64 cann't generate proj.db
  32. if package:is_plat("windows") and package:is_arch("arm64") then
  33. io.replace("CMakeLists.txt", "add_subdirectory(data)", "", {plain = true})
  34. end
  35. if package:config("curl") and (package:version():le(9.4)) then
  36. io.replace("src/lib_proj.cmake", "${CURL_LIBRARIES}", "CURL::libcurl", {plain = true})
  37. end
  38. local configs = {"-DNLOHMANN_JSON_ORIGIN=external", "-DBUILD_TESTING=OFF"}
  39. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  40. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  41. table.insert(configs, "-DBUILD_APPS=" .. (package:config("apps") and "ON" or "OFF"))
  42. table.insert(configs, "-DENABLE_TIFF=" .. (package:config("tiff") and "ON" or "OFF"))
  43. table.insert(configs, "-DENABLE_CURL=" .. (package:config("curl") and "ON" or "OFF"))
  44. table.insert(configs, "-DBUILD_PROJSYNC=" .. (package:config("curl") and "ON" or "OFF"))
  45. if package:config("curl") and package:is_plat("macosx") then
  46. local exflags = {"-framework", "CoreFoundation", "-framework", "Security", "-framework", "SystemConfiguration"}
  47. import("package.tools.cmake").install(package, configs, {shflags = exflags, ldflags = exflags})
  48. else
  49. import("package.tools.cmake").install(package, configs)
  50. end
  51. if not package:config("shared") then
  52. -- public compile definitions in CMake
  53. package:add("defines", "PROJ_DLL=")
  54. end
  55. end)
  56. on_test(function (package)
  57. assert(package:has_cfuncs("proj_context_create", {includes = "proj.h"}))
  58. end)