xmake.lua 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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.3.1", "f9ae374014515a6077df025f8958b7e80ccecd9cf7ee3abd9f17150398eee8db")
  8. add_versions("1.2.5", "87be73638ebf14667ef7dd9e6372faa7ad4fa9b2c6367c844f733469680469a2")
  9. add_versions("1.2.4", "0dbcbd2fa682c9215f049905e9f13be00a6bb6a3c5c4a83704e0237d71dbd23b")
  10. add_versions("1.0.0", "9616a854e5d7d26b9003d1bb0fa1a1e4dba03a6e380b0f71ac989648e452a994")
  11. add_configs("main", {description = "Using your own main function", default = false, type = "boolean"})
  12. add_deps("cmake")
  13. on_install(function (package)
  14. local configs = {"-DSNITCH_DO_TEST=OFF", "-DSNITCH_CREATE_HEADER_ONLY=OFF"}
  15. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  16. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  17. table.insert(configs, "-DSNITCH_DEFINE_MAIN=" .. (package:config("main") and "OFF" or "ON"))
  18. import("package.tools.cmake").install(package, configs)
  19. end)
  20. on_test(function (package)
  21. -- xmake always add main function
  22. if not package:config("main") then
  23. return
  24. end
  25. assert(package:check_cxxsnippets({test = [[
  26. #include <snitch/snitch.hpp>
  27. unsigned int Factorial( unsigned int number ) {
  28. return number <= 1 ? number : Factorial(number-1)*number;
  29. }
  30. TEST_CASE("Factorials are computed", "[factorial]" ) {
  31. REQUIRE( Factorial(0) == 1 ); // this check will fail
  32. REQUIRE( Factorial(1) == 1 );
  33. }
  34. ]]}, {configs = {languages = "c++20"}}))
  35. end)