xmake.lua 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package("cwt-cucumber")
  2. set_homepage("https://github.com/ThoSe1990/cwt-cucumber")
  3. set_description("A C++ Cucumber interpreter")
  4. set_license("MIT")
  5. add_urls("https://github.com/ThoSe1990/cwt-cucumber/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/ThoSe1990/cwt-cucumber.git")
  7. add_versions("2.6", "1896f695b06dccf30d030ea819f693e4324bbd2f38f336aa36cf6fa87be3dfbd")
  8. add_versions("2.5", "793d07c2f1989a2943befd4344cb8a49f36d39bdc0d596dbebbbc50e25fa3bc5")
  9. add_deps("cmake")
  10. add_deps("nlohmann_json", {configs = {cmake = true}})
  11. on_check("android", function (package)
  12. local ndk = package:toolchain("ndk"):config("ndkver")
  13. assert(ndk and tonumber(ndk) > 22, "package(cwt-cucumber) require ndk version > 22")
  14. end)
  15. on_check("macosx", function (package)
  16. if macos.version():le("14") then
  17. raise("package(cwt-cucumber): requires macOS version >= 14.5")
  18. end
  19. end)
  20. on_install(function (package)
  21. io.replace("CMakeLists.txt", "add_subdirectory(${PROJECT_SOURCE_DIR}/examples)", "", {plain = true})
  22. io.replace("CMakeLists.txt", "add_subdirectory(${PROJECT_SOURCE_DIR}/gtest)", "", {plain = true})
  23. local configs = {}
  24. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  25. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  26. if package:config("shared") and package:is_plat("windows") then
  27. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  28. end
  29. import("package.tools.cmake").install(package, configs)
  30. end)
  31. on_test(function (package)
  32. assert(package:check_cxxsnippets({test = [[
  33. struct foo {
  34. std::string word;
  35. std::string anonymous;
  36. };
  37. WHEN(word_anonymous_given, "A {word} and {}") {
  38. std::string word = CUKE_ARG(1);
  39. cuke::context<foo>().word = word;
  40. std::string anonymous = CUKE_ARG(2);
  41. cuke::context<foo>().anonymous = anonymous;
  42. }
  43. THEN(word_anonymous_then, "They will match {string} and {string}") {
  44. std::string expected_word = CUKE_ARG(1);
  45. std::string expected_anonymous = CUKE_ARG(2);
  46. cuke::equal(expected_word, cuke::context<foo>().word);
  47. cuke::equal(expected_anonymous, cuke::context<foo>().anonymous);
  48. }
  49. ]]}, {configs = {languages = "c++20"}, includes = {"cwt-cucumber/cucumber.hpp"}}))
  50. end)