xmake.lua 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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("windows", "macosx", "linux", 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. if package:is_plat("linux") then
  26. package:add("deps", "openssl")
  27. end
  28. end
  29. if package:config("apps") then
  30. package:addenv("PATH", "bin")
  31. end
  32. end)
  33. on_install("windows", "macosx", "linux", function (package)
  34. -- windows@arm64 cann't generate proj.db
  35. if package:is_plat("windows") and package:is_arch("arm64") then
  36. io.replace("CMakeLists.txt", "add_subdirectory(data)", "", {plain = true})
  37. end
  38. if package:config("curl") and package:is_plat("linux") then
  39. io.replace("src/lib_proj.cmake", "${CURL_LIBRARIES}", "CURL::libcurl ssl crypto", {plain = true})
  40. else
  41. io.replace("src/lib_proj.cmake", "${CURL_LIBRARIES}", "CURL::libcurl", {plain = true})
  42. end
  43. if package:is_plat("windows") and not package:config("shared") then
  44. io.replace("src/proj.h", "#ifndef PROJ_DLL", "#define PROJ_DLL\n#ifndef PROJ_DLL", {plain = true})
  45. end
  46. local configs = {"-DNLOHMANN_JSON_ORIGIN=external", "-DBUILD_TESTING=OFF"}
  47. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  48. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  49. table.insert(configs, "-DBUILD_APPS=" .. (package:config("apps") and "ON" or "OFF"))
  50. table.insert(configs, "-DENABLE_TIFF=" .. (package:config("tiff") and "ON" or "OFF"))
  51. table.insert(configs, "-DENABLE_CURL=" .. (package:config("curl") and "ON" or "OFF"))
  52. table.insert(configs, "-DBUILD_PROJSYNC=" .. (package:config("curl") and "ON" or "OFF"))
  53. if package:config("curl") and package:is_plat("linux") then
  54. import("package.tools.cmake").install(package, configs, {packagedeps = {"openssl"}})
  55. elseif package:config("curl") and package:is_plat("macosx") then
  56. local exflags = {"-framework", "CoreFoundation", "-framework", "Security", "-framework", "SystemConfiguration"}
  57. import("package.tools.cmake").install(package, configs, {shflags = exflags, ldflags = exflags})
  58. else
  59. import("package.tools.cmake").install(package, configs)
  60. end
  61. end)
  62. on_test(function (package)
  63. assert(package:has_cfuncs("proj_context_create", {includes = "proj.h"}))
  64. end)