xmake.lua 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. package("gdal")
  2. set_homepage("https://gdal.org/")
  3. set_description("GDAL is a translator library for raster and vector geospatial data formats by the Open Source Geospatial Foundation")
  4. set_license("MIT")
  5. add_urls("https://github.com/OSGeo/gdal/releases/download/v$(version)/gdal-$(version).tar.gz")
  6. add_versions("3.10.0", "946ef444489bedbc1b04bd4c115d67ae8d3f3e4a5798d5a2f1cb2a11014105b2")
  7. add_versions("3.9.3", "f293d8ccc6b98f617db88f8593eae37f7e4b32d49a615b2cba5ced12c7bebdae")
  8. add_versions("3.9.2", "c9767e79ca7245f704bfbcb47d771b2dc317d743536b78d648c3e92b95fbc21e")
  9. add_versions("3.9.1", "46cd95ad0f270af0cd317ddc28fa5e0a7ad0b0fd160a7bd22909150df53e3418")
  10. add_versions("3.9.0", "3b29b573b60d156cf160805290474b625c4197ca36a79fd14f83ec8f77f29ba0")
  11. add_versions("3.8.5", "0c865c7931c7e9bb4832f50fb53aec8676cbbaccd6e55945011b737fb89a49c2")
  12. add_versions("3.5.1", "7c4406ca010dc8632703a0a326f39e9db25d9f1f6ebaaeca64a963e3fac123d1")
  13. add_deps("cmake")
  14. add_configs("apps", {description = "Build GDAL applications.", default = false, type = "boolean"})
  15. add_configs("curl", {description = "Use CURL.", default = false, type = "boolean"})
  16. add_configs("geos", {description = "Use GEOS.", default = false, type = "boolean"})
  17. add_configs("gif", {description = "Use GIF.", default = false, type = "boolean"})
  18. add_configs("iconv", {description = "Use Iconv.", default = false, type = "boolean"})
  19. add_configs("jpeg", {description = "Use JPEG.", default = false, type = "boolean"})
  20. add_configs("openjpeg", {description = "Use OpenJPEG.", default = true, type = "boolean"}) -- default true to keep compatibility
  21. add_configs("openssl", {description = "Use OpenSSL.", default = false, type = "boolean"})
  22. add_configs("png", {description = "Use PNG.", default = false, type = "boolean"})
  23. add_configs("sqlite3", {description = "Use SQLite3.", default = false, type = "boolean"})
  24. add_configs("xercesc", {description = "Use Xerces-C.", default = false, type = "boolean"})
  25. if is_plat("windows") then
  26. add_syslinks("wsock32", "ws2_32")
  27. end
  28. on_load(function (package)
  29. package:add("deps", "proj", {configs = {curl = package:config("curl")}})
  30. local configdeps = {
  31. curl = "libcurl",
  32. geos = "geos",
  33. gif = "giflib",
  34. iconv = "libiconv",
  35. jpeg = "libjpeg-turbo",
  36. openjpeg = "openjpeg",
  37. openssl = "openssl3",
  38. png = "libpng",
  39. sqlite3 = "sqlite3",
  40. xercesc = "xerces-c",
  41. }
  42. for name, dep in pairs(configdeps) do
  43. if package:config(name) then
  44. package:add("deps", dep)
  45. end
  46. end
  47. end)
  48. on_install("windows|x86", "windows|x64", "macosx", "linux", function (package)
  49. local configs = {
  50. "-DBUILD_TESTING=OFF",
  51. "-DGDAL_USE_EXTERNAL_LIBS=OFF",
  52. "-DBUILD_JAVA_BINDINGS=OFF", "-DBUILD_CSHARP_BINDINGS=OFF", "-DBUILD_PYTHON_BINDINGS=OFF"
  53. }
  54. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  55. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  56. table.insert(configs, "-DBUILD_APPS=" .. (package:config("apps") and "ON" or "OFF"))
  57. local packagedeps = {"proj"}
  58. if package:config("curl") then
  59. table.insert(packagedeps, "libcurl")
  60. table.insert(configs, "-DGDAL_USE_CURL=ON")
  61. if not package:dep("libcurl"):config("shared") then
  62. table.insert(configs, "-DCURL_USE_STATIC_LIBS=ON")
  63. end
  64. end
  65. if package:config("geos") then
  66. table.insert(packagedeps, "geos")
  67. table.insert(configs, "-DGDAL_USE_GEOS=ON")
  68. end
  69. if package:config("gif") then
  70. table.insert(packagedeps, "giflib")
  71. table.insert(configs, "-DGDAL_USE_GIF=ON")
  72. end
  73. if package:config("iconv") then
  74. table.insert(packagedeps, "libiconv")
  75. table.insert(configs, "-DGDAL_USE_ICONV=ON")
  76. end
  77. if package:config("jpeg") then
  78. table.insert(packagedeps, "libjpeg-turbo")
  79. table.insert(configs, "-DGDAL_USE_JPEG=ON")
  80. end
  81. if package:config("openjpeg") then
  82. table.insert(packagedeps, "openjpeg")
  83. table.insert(configs, "-DGDAL_USE_OPENJPEG=ON")
  84. end
  85. if package:config("openssl") then
  86. table.insert(packagedeps, "openssl3")
  87. table.insert(configs, "-DGDAL_USE_OPENSSL=ON")
  88. end
  89. if package:config("png") then
  90. table.insert(packagedeps, "libpng")
  91. table.insert(configs, "-DGDAL_USE_PNG=ON")
  92. end
  93. if package:config("sqlite3") then
  94. table.insert(packagedeps, "sqlite3")
  95. table.insert(configs, "-DGDAL_USE_SQLITE3=ON")
  96. end
  97. if package:config("xercesc") then
  98. table.insert(packagedeps, "xerces-c")
  99. table.insert(configs, "-DGDAL_USE_XERCESC=ON")
  100. end
  101. --fix gdal compile on msvc debug mode
  102. local cxflags
  103. if package:debug() and package:is_plat("windows") then
  104. cxflags = "/FS"
  105. end
  106. import("package.tools.cmake").install(package, configs,
  107. {cxflags = cxflags, packagedeps = packagedeps})
  108. if package:config("apps") then
  109. package:addenv("PATH", "bin")
  110. end
  111. end)
  112. on_test(function (package)
  113. assert(package:has_cxxfuncs("GDALAllRegister", {configs = {languages = "c++11"}, includes = "ogrsf_frmts.h"}))
  114. end)