xmake.lua 3.0 KB

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