xmake.lua 2.6 KB

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