xmake.lua 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package("upa-url")
  2. set_homepage("https://upa-url.github.io/docs/")
  3. set_description("An implementation of the WHATWG URL Standard in C++")
  4. set_license("BSD-2-Clause")
  5. add_urls("https://github.com/upa-url/upa/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/upa-url/upa.git", {submodules = false})
  7. add_versions("v1.0.0", "9ad14357c177f7c038a447996a065995e074eb5447015467687726c5d221b5f4")
  8. add_configs("tools", {description = "Build tools", default = false, type = "boolean"})
  9. add_deps("cmake")
  10. on_install(function (package)
  11. if package:is_plat("windows") and package:config("shared") then
  12. io.writefile("xmake.lua", [[
  13. add_rules("mode.debug", "mode.release")
  14. set_languages("c++11")
  15. target("upa_url")
  16. set_kind("$(kind)")
  17. add_files("src/*.cpp")
  18. add_includedirs("include")
  19. add_headerfiles("include/(upa/*.h)")
  20. if is_plat("windows") and is_kind("shared") then
  21. add_rules("utils.symbols.export_all", {export_classes = true})
  22. end
  23. ]])
  24. import("package.tools.xmake").install(package)
  25. else
  26. io.replace("CMakeLists.txt", "STATIC", "", {plain = true})
  27. local configs = {"-DURL_BUILD_TESTS=OFF", "-DUPA_BUILD_TESTS=OFF"}
  28. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  29. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  30. table.insert(configs, "-DUPA_BUILD_TOOLS=" .. (package:config("tools") and "ON" or "OFF"))
  31. import("package.tools.cmake").install(package, configs)
  32. end
  33. end)
  34. on_test(function (package)
  35. assert(package:check_cxxsnippets({test = [[
  36. void test() {
  37. upa::url url{"https://xmake.io/"};
  38. }
  39. ]]}, {configs = {languages = "c++11"}, includes = "upa/url.h"}))
  40. end)