xmake.lua 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package("sqlpp11")
  2. set_kind("library", {headeronly = true})
  3. set_homepage("https://github.com/rbock/sqlpp11")
  4. set_description("A type safe SQL template library for C++")
  5. add_urls("https://github.com/rbock/sqlpp11/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/rbock/sqlpp11.git")
  7. add_versions("0.64", "72e6d37c716cc45b38c3cf4541604f16224aaa3b511d1f1d0be0c49176c3be86")
  8. add_versions("0.61", "d5a95e28ae93930f7701f517b1342ac14bcf33a9b1c5b5f0dff6aea5e315bb50")
  9. add_deps("cmake")
  10. add_configs("sqlite3_connector", { description = "Enable SQlite3 connector.", default = false, type = "boolean"})
  11. add_configs("sqlcipher_connector", { description = "Enable SQlite3 connector with SQLCipher.", default = false, type = "boolean"})
  12. add_configs("mariadb_connector", { description = "Enable MariaDB connector.", default = false, type = "boolean"})
  13. add_configs("postgresql_connector", { description = "Enable PostgreSQL connector.", default = false, type = "boolean"})
  14. add_configs("mysql_connector", { description = "Enable MySQL connector.", default = false, type = "boolean"})
  15. on_load("windows", "linux", "macosx", function (package)
  16. if package:config("mysql_connector") then
  17. package:add("deps", "mysql")
  18. end
  19. end)
  20. on_install("windows", "linux", "macosx", function (package)
  21. local configs = {"-DBUILD_TESTING=OFF"}
  22. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  23. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  24. if package:config("sqlite3_connector") then
  25. table.insert(configs, "-DBUILD_SQLITE3_CONNECTOR=ON")
  26. end
  27. if package:config("sqlcipher_connector") then
  28. table.insert(configs, "-DBUILD_SQLCIPHER_CONNECTOR=ON")
  29. end
  30. if package:config("mariadb_connector") then
  31. table.insert(configs, "-DBUILD_MARIADB_CONNECTOR=ON")
  32. end
  33. -- TODO we need add PostgreSQL deps
  34. if package:config("postgresql_connector") then
  35. table.insert(configs, "-DBUILD_POSTGRESQL_CONNECTOR=ON")
  36. end
  37. -- TODO we need add MySQL deps
  38. if package:config("mysql_connector") then
  39. table.insert(configs, "-DBUILD_MYSQL_CONNECTOR=ON")
  40. local libmysql = package:dep("mysql"):fetch()
  41. if libmysql then
  42. table.insert(configs, "-DMySQL_INCLUDE_DIR=" .. table.concat(libmysql.includedirs or libmysql.sysincludedirs, ";"))
  43. table.insert(configs, "-DMySQL_LIBRARY=" .. table.concat(libmysql.libfiles or {}, ";"))
  44. end
  45. end
  46. import("package.tools.cmake").install(package, configs)
  47. end)
  48. on_test(function (package)
  49. assert(package:check_cxxsnippets({test = [[
  50. void test() {
  51. select(sqlpp::value(false).as(sqlpp::alias::a));
  52. }
  53. ]]}, {configs = {languages = "c++14"}, includes = {"sqlpp11/sqlpp11.h"}}))
  54. end)