xmake.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package("stduuid")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/mariusbancila/stduuid")
  4. set_description("A C++17 cross-platform implementation for UUIDs")
  5. set_license("MIT")
  6. add_urls("https://github.com/mariusbancila/stduuid/archive/refs/tags/$(version).tar.gz",
  7. "https://github.com/mariusbancila/stduuid.git")
  8. add_versions("v1.2.3", "b1176597e789531c38481acbbed2a6894ad419aab0979c10410d59eb0ebf40d3")
  9. add_configs("system", {description = "Enable operating system uuid generator", default = false, type = "boolean"})
  10. add_configs("time", {description = "Enable experimental time-based uuid generator", default = false, type = "boolean"})
  11. add_deps("cmake")
  12. on_load(function (package)
  13. if package:config("system") then
  14. package:add("defines", "UUID_SYSTEM_GENERATOR")
  15. if package:is_plat("macosx") then
  16. package:add("frameworks", "CoreFoundation")
  17. elseif not package:is_plat("windows") then
  18. package:add("deps", "libuuid")
  19. end
  20. end
  21. if package:config("time") then
  22. package:add("defines", "UUID_TIME_GENERATOR")
  23. end
  24. end)
  25. on_install(function (package)
  26. local configs = {"-DUUID_BUILD_TESTS=OFF", "-DUUID_ENABLE_INSTALL=ON"}
  27. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  28. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  29. import("package.tools.cmake").install(package, configs)
  30. end)
  31. on_test(function (package)
  32. assert(package:check_cxxsnippets({test = [[
  33. using namespace uuids;
  34. void test() {
  35. uuid empty;
  36. }
  37. ]]}, {configs = {languages = "c++17"}, includes = "uuid.h"}))
  38. end)