xmake.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package("date")
  2. set_homepage("https://github.com/HowardHinnant/date")
  3. set_description("A date and time library for use with C++11 and C++14.")
  4. set_license("MIT")
  5. add_urls("https://github.com/HowardHinnant/date/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/HowardHinnant/date.git")
  7. add_versions("v3.0.3", "30de45a34a2605cca33a993a9ea54e8f140f23b1caf1acf3c2fd436c42c7d942")
  8. add_versions("v3.0.1", "7a390f200f0ccd207e8cff6757e04817c1a0aec3e327b006b7eb451c57ee3538")
  9. if is_plat("windows", "mingw") then
  10. add_syslinks("ole32", "shell32")
  11. elseif is_plat("macosx", "iphoneos") then
  12. add_frameworks("Foundation")
  13. end
  14. add_deps("cmake")
  15. if is_plat("macosx", "iphoneos") then
  16. add_deps("zlib")
  17. end
  18. on_install(function (package)
  19. local configs = {"-DBUILD_TZ_LIB=ON",
  20. "-DUSE_SYSTEM_TZ_DB=ON"}
  21. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  22. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  23. import("package.tools.cmake").install(package, configs)
  24. end)
  25. on_test(function (package)
  26. assert(package:check_cxxsnippets({test = [[
  27. #include <date/date.h>
  28. void test() {
  29. using namespace date;
  30. year_month_weekday_last{year{2015}, month{3u}, weekday_last{weekday{0u}}};
  31. }
  32. ]]}, {configs = {languages = "c++11"}}))
  33. assert(package:check_cxxsnippets({test = [[
  34. #include <date/tz.h>
  35. void test() {
  36. using namespace date;
  37. using namespace std::chrono;
  38. make_zoned(current_zone(), system_clock::now());
  39. }
  40. ]]}, {configs = {languages = "c++11"}}))
  41. end)