xmake.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package("snitch")
  2. set_homepage("https://github.com/cschreib/snitch")
  3. set_description("Lightweight C++20 testing framework.")
  4. set_license("BSL-1.0")
  5. add_urls("https://github.com/cschreib/snitch/archive/refs/tags/v$(version).tar.gz",
  6. "https://github.com/cschreib/snitch.git")
  7. add_versions("1.0.0", "9616a854e5d7d26b9003d1bb0fa1a1e4dba03a6e380b0f71ac989648e452a994")
  8. add_configs("main", {description = "Using your own main function", default = false, type = "boolean"})
  9. add_deps("cmake")
  10. on_install(function (package)
  11. local configs = {"-DSNITCH_DO_TEST=OFF", "-DSNITCH_CREATE_HEADER_ONLY=OFF"}
  12. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  13. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  14. table.insert(configs, "-DSNITCH_DEFINE_MAIN=" .. (package:config("main") and "OFF" or "ON"))
  15. import("package.tools.cmake").install(package, configs)
  16. end)
  17. on_test(function (package)
  18. -- xmake always add main function
  19. if not package:config("main") then
  20. return
  21. end
  22. assert(package:check_cxxsnippets({test = [[
  23. #include <snitch/snitch.hpp>
  24. unsigned int Factorial( unsigned int number ) {
  25. return number <= 1 ? number : Factorial(number-1)*number;
  26. }
  27. TEST_CASE("Factorials are computed", "[factorial]" ) {
  28. REQUIRE( Factorial(0) == 1 ); // this check will fail
  29. REQUIRE( Factorial(1) == 1 );
  30. }
  31. ]]}, {configs = {languages = "c++20"}}))
  32. end)