xmake.lua 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package("liboqs")
  2. set_homepage("https://openquantumsafe.org")
  3. set_description("C library for prototyping and experimenting with quantum-resistant cryptography")
  4. set_license("MIT")
  5. add_urls("https://github.com/open-quantum-safe/liboqs/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/open-quantum-safe/liboqs.git")
  7. add_versions("0.11.0", "f77b3eff7dcd77c84a7cd4663ef9636c5c870f30fd0a5b432ad72f7b9516b199")
  8. add_versions("0.10.1", "00ca8aba65cd8c8eac00ddf978f4cac9dd23bb039f357448b60b7e3eed8f02da")
  9. if is_plat("windows", "mingw") then
  10. add_syslinks("advapi32")
  11. end
  12. add_deps("cmake")
  13. if on_check then
  14. on_check("windows", function (package)
  15. local vs_toolset = package:toolchain("msvc"):config("vs_toolset")
  16. if vs_toolset then
  17. local vs_toolset_ver = import("core.base.semver").new(vs_toolset)
  18. local minor = vs_toolset_ver:minor()
  19. assert(minor and minor >= 30, "package(liboqs) require vs_toolset >= 14.3")
  20. end
  21. end)
  22. end
  23. on_install("!windows or windows|!arm64", function (package)
  24. io.replace(".CMake/compiler_opts.cmake", "add_compile_options(/MT)", "", {plain = true})
  25. local configs = {"-DOQS_BUILD_ONLY_LIB=ON", "-DOQS_USE_OPENSSL=OFF"}
  26. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  27. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  28. if package:is_plat("cross", "iphoneos") or (package:is_plat("mingw") and package:is_arch("i386")) then
  29. table.insert(configs, "-DOQS_PERMIT_UNSUPPORTED_ARCHITECTURE=ON")
  30. end
  31. if package:is_plat("windows") then
  32. table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=.")
  33. end
  34. import("package.tools.cmake").install(package, configs)
  35. if package:is_plat("windows") and package:is_debug() then
  36. local dir = package:config("shared") and "bin" or "lib"
  37. os.vcp(path.join(package:buildir(), dir, "*.pdb"), package:installdir(dir))
  38. end
  39. end)
  40. on_test(function (package)
  41. assert(package:has_cfuncs("OQS_SIG_keypair", {includes = "oqs/oqs.h"}))
  42. end)