xmake.lua 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package("librttopo")
  2. set_homepage("https://git.osgeo.org/gitea/rttopo/librttopo")
  3. set_description("RT Topology Library")
  4. set_license("GPL-2.0-or-later")
  5. add_urls("https://gitlab.com/rttopo/rttopo/-/archive/librttopo-$(version)/rttopo-librttopo-$(version).tar.bz2", {alias = "gitlab"})
  6. add_urls("https://github.com/CGX-GROUP/librttopo.git",
  7. "https://gitlab.com/rttopo/rttopo", {alias = "git"})
  8. add_versions("gitlab:1.1.0", "4b28732c0322849c8754751a384ee3596d06ab316dfc57fe9bbe757c82a27efe")
  9. add_versions("git:1.1.0", "librttopo-1.1.0")
  10. add_deps("geos")
  11. if is_plat("linux", "bsd") then
  12. add_syslinks("m")
  13. end
  14. if on_check then
  15. on_check("android", function (package)
  16. local ndk = package:toolchain("ndk"):config("ndkver")
  17. assert(ndk and tonumber(ndk) > 22, "package(librttopo) dep(geos) require ndk version > 22")
  18. end)
  19. end
  20. on_install(function (package)
  21. local geos_ver = assert(package:dep("geos"):version(), "geos version not found")
  22. os.touch("src/rttopo_config.h")
  23. io.writefile("xmake.lua", string.format([[
  24. option("ver", {default = "%s"})
  25. add_rules("mode.debug", "mode.release")
  26. add_requires("geos")
  27. target("rttopo")
  28. set_kind("$(kind)")
  29. add_files("src/*.c")
  30. add_includedirs("headers")
  31. add_headerfiles("headers/*.h")
  32. add_defines("RTGEOM_DEBUG_LEVEL=0")
  33. if has_config("ver") then
  34. add_defines("LIBRTGEOM_VERSION=\"" .. get_config("ver") .. "\"")
  35. add_defines("RTGEOM_GEOS_VERSION=%s")
  36. set_version(get_config("ver"), {soname = true})
  37. end
  38. set_configdir("headers")
  39. add_configfiles("headers/librttopo_geom.h.in", {pattern = "@(SRID_.-)@"})
  40. -- from https://github.com/conan-io/conan-center-index/blob/fcbc22cd090862c62de0332f9d3aac08620d53ca/recipes/librttopo/all/CMakeLists.txt#L6-L7
  41. set_configvar("SRID_MAX", "999999")
  42. set_configvar("SRID_USR_MAX", "998999")
  43. if is_kind("shared") and is_plat("windows") then
  44. add_rules("utils.symbols.export_all")
  45. end
  46. if is_plat("linux", "bsd") then
  47. add_syslinks("m")
  48. end
  49. add_packages("geos")
  50. ]], package:version_str(), (geos_ver:major() .. geos_ver:minor())))
  51. import("package.tools.xmake").install(package)
  52. end)
  53. on_test(function (package)
  54. assert(package:has_cfuncs("rtgeom_version", {includes = "librttopo.h"}))
  55. end)