xmake.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package("clean-test")
  2. set_homepage("https://clean-test.dev")
  3. set_description("A modern C++-20 testing framework.")
  4. set_license("BSL-1.0")
  5. add_urls("https://github.com/clean-test/clean-test.git")
  6. add_versions("2023.05.15", "d99321c97ba51c26397114ce535be4d1d9174693")
  7. if is_plat("linux", "bsd") then
  8. add_syslinks("pthread")
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. elseif is_plat("macosx", "iphoneos") then
  11. add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})
  12. end
  13. add_deps("cmake")
  14. on_install("windows", "linux", "bsd", "mingw", "msys", "cross", function (package)
  15. local configs = {"-DCLEANTEST_TEST=OFF"}
  16. if package:config("shared") then
  17. table.insert(configs, "-DCLEANTEST_BUILD_STATIC=OFF")
  18. table.insert(configs, "-DCLEANTEST_BUILD_SHARED=ON")
  19. else
  20. table.insert(configs, "-DCLEANTEST_BUILD_STATIC=ON")
  21. table.insert(configs, "-DCLEANTEST_BUILD_SHARED=OFF")
  22. end
  23. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  24. import("package.tools.cmake").install(package, configs)
  25. end)
  26. on_test(function (package)
  27. assert(package:check_cxxsnippets({test = [[
  28. #include <clean-test/clean-test.h>
  29. constexpr auto sum(auto... vs) { return (0 + ... + vs); }
  30. namespace ct = clean_test;
  31. using namespace ct::literals;
  32. void test() {
  33. auto const suite = ct::Suite{"sum", [] {
  34. "0"_test = [] { ct::expect(sum() == 0_i); };
  35. }};
  36. }
  37. ]]}, {configs = {languages = "c++20"}}))
  38. end)