xmake.lua 2.4 KB

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