xmake.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package("faker-cxx")
  2. set_homepage("https://cieslarmichal.github.io/faker-cxx/")
  3. set_description("C++ Faker library for generating fake (but realistic) data.")
  4. set_license("MIT")
  5. add_urls("https://github.com/cieslarmichal/faker-cxx/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/cieslarmichal/faker-cxx.git")
  7. add_versions("v3.0.0", "63d6846376593e05da690136cabe8e7bf42ddcdd4edad3ae9b48696f86d80468")
  8. add_versions("v2.0.0", "8a7f5441f4453af868444675878a2d9a74918c1595caa65d537d3ea327e46a49")
  9. add_deps("cmake")
  10. add_deps("fmt")
  11. if on_check then
  12. on_check(function (package)
  13. assert(package:check_cxxsnippets({test = [[
  14. #include <concepts>
  15. #include <ranges>
  16. static_assert(std::integral<bool>);
  17. void test() {
  18. const auto v = {4, 1, 3, 2};
  19. auto it = std::ranges::find(v, 3);
  20. }
  21. ]]}, {configs = {languages = "c++20"}}), "package(faker-cxx) Require at least C++20.")
  22. end)
  23. end
  24. on_install(function (package)
  25. local configs = {"-DBUILD_TESTING=OFF", "-DUSE_SYSTEM_DEPENDENCIES=ON", "-DUSE_STD_FORMAT=OFF"}
  26. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  27. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  28. local cxflags
  29. if package:has_tool("cxx", "cl") then
  30. cxflags = "/utf-8"
  31. if package:config("shared") then
  32. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  33. end
  34. end
  35. import("package.tools.cmake").install(package, configs, {cxflags = cxflags})
  36. end)
  37. on_test(function (package)
  38. local includes = "faker-cxx/string.h"
  39. local version = package:version()
  40. if version and version:lt("3.0.0") then
  41. includes = "faker-cxx/String.h"
  42. end
  43. assert(package:check_cxxsnippets({test = [[
  44. void test() {
  45. const auto id = faker::string::uuid();
  46. }
  47. ]]}, {configs = {languages = "c++20"}, includes = includes}))
  48. end)