xmake.lua 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package("gmssl")
  2. set_homepage("https://github.com/guanzhi/GmSSL")
  3. set_description("Password Toolkit supporting National secret chip SM2/SM3/SM4/SM9/SSL")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/guanzhi/GmSSL/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/guanzhi/GmSSL.git")
  7. add_versions("v3.1.0", "a3cdf5df87b07df33cb9e30c35de658fd0c06d5909d4428f4abd181d02567cde")
  8. if is_plat("mingw", "msys") then
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. end
  11. if is_plat("windows", "mingw") then
  12. add_syslinks("ws2_32", "advapi32")
  13. elseif is_plat("linux") then
  14. add_syslinks("dl")
  15. elseif is_plat("macosx") then
  16. add_frameworks("Security")
  17. end
  18. add_deps("cmake")
  19. on_install(function (package)
  20. if package:is_plat("windows") then
  21. local cflags = table.wrap(package:config("cflags"))
  22. table.insert(cflags, "/utf-8")
  23. table.insert(cflags, "-DWIN32")
  24. package:config_set("cflags", cflags)
  25. package:add("defines", "WIN32")
  26. io.replace("CMakeLists.txt", [[set(CMAKE_INSTALL_PREFIX "C:/Program Files/GmSSL")]], "", {plain = true})
  27. end
  28. local configs = {"-DBUILD_TESTING=OFF"}
  29. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  30. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  31. import("package.tools.cmake").install(package, configs)
  32. end)
  33. on_test(function (package)
  34. assert(package:has_cfuncs("base64_encode_init", {includes = "gmssl/base64.h"}))
  35. end)