xmake.lua 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package("mariadb-connector-c")
  2. set_homepage("https://github.com/mariadb-corporation/mariadb-connector-c")
  3. set_description("MariaDB Connector/C is used to connect applications developed in C/C++ to MariaDB and MySQL databases.")
  4. set_license("LGPL-2.1")
  5. add_urls("https://github.com/mariadb-corporation/mariadb-connector-c/archive/refs/tags/v$(version).tar.gz")
  6. add_versions("3.1.13", "361136e9c365259397190109d50f8b6a65c628177792273b4acdb6978942b5e7")
  7. add_deps("cmake")
  8. if is_plat("windows") then
  9. add_links("libmariadb")
  10. else
  11. add_links("mariadb")
  12. end
  13. add_linkdirs("lib/mariadb")
  14. add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})
  15. if is_plat("windows") then
  16. add_configs("iconv", {description = "Enables character set conversion.", default = false, type = "boolean"})
  17. add_configs("msi", {description = "Build MSI installation package.", default = false, type = "boolean"})
  18. add_configs("rtc", {description = "Enables runtime checks for debug builds.", default = false, type = "boolean"})
  19. add_configs("signcode", {description = "Digitally sign files.", default = false, type = "boolean"})
  20. end
  21. if not is_plat("windows") then
  22. add_configs("mysqlcompat", {description = "Creates libmysql* symbolic links.", default = false, type = "boolean"})
  23. end
  24. if not is_plat("bsd") then
  25. add_configs("ssl", {description = "Enables use of TLS/SSL library.", default = true, type = "boolean"})
  26. end
  27. add_configs("dyncol", {description = "Enables support of dynamic columns.", default = true, type = "boolean"})
  28. add_configs("curl", {description = "Enables use of curl.", default = true, type = "boolean"})
  29. add_configs("external_zlib", {description = "Enables use of external zlib.", default = false, type = "boolean"})
  30. add_configs("unit_tests", {description = "Build test suite.", default = false, type = "boolean"})
  31. on_load(function (package)
  32. local configdeps = {external_zlib = "zlib",
  33. ssl = "openssl"}
  34. for name, dep in pairs(configdeps) do
  35. if package:config(name) then
  36. package:add("deps", dep)
  37. end
  38. end
  39. end)
  40. on_install("bsd", "linux", "windows", function(package)
  41. local configs = {}
  42. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  43. for name, enabled in pairs(package:configs()) do
  44. if not package:extraconf("configs", name, "builtin") then
  45. if enabled then
  46. table.insert(configs, "-DWITH_" .. name:upper() .. "=ON")
  47. else
  48. table.insert(configs, "-DWITH_" .. name:upper() .. "=OFF")
  49. end
  50. end
  51. end
  52. import("package.tools.cmake").install(package, configs)
  53. os.trycp(path.join(package:installdir("lib"), "mariadb", "*.dll"), package:installdir("bin"))
  54. os.trycp(path.join(package:installdir("lib"), "mariadb", "*.so"), package:installdir("bin"))
  55. os.cp(path.join(package:installdir("lib"), "mariadb", "plugin"), package:installdir("bin"))
  56. end)
  57. on_test(function (package)
  58. assert(package:has_cxxfuncs("mysql_init", {includes = "mariadb/mysql.h"}))
  59. end)