xmake.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package("sqlite_orm")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/fnc12/sqlite_orm")
  4. set_description("SQLite ORM light header only library for modern C++")
  5. add_urls("https://github.com/fnc12/sqlite_orm/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/fnc12/sqlite_orm.git")
  7. add_versions("v1.9.1", "de2db80e4f716a27c4e1f4cb8a356394e428676c98c90b0577b0431107d3cccf")
  8. add_versions("v1.9", "a2fa433e24f6873a9e8cd9dd7e49d2d12640b458f3f6f941163cf60f6673b8a2")
  9. add_versions("v1.8.2", "56e0c7729800637a8061658d0fdad4424d2cdde77b063d23cc1b76aa20339072")
  10. add_deps("cmake")
  11. add_deps("sqlite3")
  12. on_install(function (package)
  13. local configs = {"-DBUILD_TESTING=OFF"}
  14. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  15. import("package.tools.cmake").install(package, configs)
  16. end)
  17. on_test(function (package)
  18. assert(package:check_cxxsnippets({test = [[
  19. #include "sqlite_orm/sqlite_orm.h"
  20. using namespace sqlite_orm;
  21. struct User{
  22. int id;
  23. std::string firstName;
  24. std::string lastName;
  25. int birthDate;
  26. std::unique_ptr<std::string> imageUrl;
  27. int typeId;
  28. };
  29. struct UserType {
  30. int id;
  31. std::string name;
  32. };
  33. void test() {
  34. auto storage = make_storage("db.sqlite",
  35. make_table("users",
  36. make_column("id", &User::id, primary_key().autoincrement()),
  37. make_column("first_name", &User::firstName),
  38. make_column("last_name", &User::lastName),
  39. make_column("birth_date", &User::birthDate),
  40. make_column("image_url", &User::imageUrl),
  41. make_column("type_id", &User::typeId)),
  42. make_table("user_types",
  43. make_column("id", &UserType::id, primary_key().autoincrement()),
  44. make_column("name", &UserType::name, default_value("name_placeholder"))));
  45. }
  46. ]]}, {configs = {languages = "c++17"}}))
  47. end)