xmake.lua 5.3 KB

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