xmake.lua 5.5 KB

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