xmake.lua 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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.12.0", "df999915204eb1eba311d89e83d1edd3a514d5a07374745d6a9e5b2dd0d59c08")
  8. add_versions("0.11.0", "f77b3eff7dcd77c84a7cd4663ef9636c5c870f30fd0a5b432ad72f7b9516b199")
  9. add_versions("0.10.1", "00ca8aba65cd8c8eac00ddf978f4cac9dd23bb039f357448b60b7e3eed8f02da")
  10. if is_plat("windows", "mingw") then
  11. add_syslinks("advapi32")
  12. end
  13. add_deps("cmake")
  14. if on_check then
  15. on_check("windows", function (package)
  16. local vs_toolset = package:toolchain("msvc"):config("vs_toolset")
  17. if vs_toolset then
  18. local vs_toolset_ver = import("core.base.semver").new(vs_toolset)
  19. local minor = vs_toolset_ver:minor()
  20. assert(minor and minor >= 30, "package(liboqs) require vs_toolset >= 14.3")
  21. end
  22. end)
  23. end
  24. on_install("!windows or windows|!arm64", function (package)
  25. io.replace(".CMake/compiler_opts.cmake", "add_compile_options(/MT)", "", {plain = true})
  26. local configs = {"-DOQS_BUILD_ONLY_LIB=ON", "-DOQS_USE_OPENSSL=OFF"}
  27. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  28. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  29. if package:is_plat("cross", "iphoneos") or (package:is_plat("mingw") and package:is_arch("i386")) then
  30. table.insert(configs, "-DOQS_PERMIT_UNSUPPORTED_ARCHITECTURE=ON")
  31. end
  32. if package:is_plat("windows") then
  33. table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=.")
  34. end
  35. import("package.tools.cmake").install(package, configs)
  36. if package:is_plat("windows") and package:is_debug() then
  37. local dir = package:config("shared") and "bin" or "lib"
  38. os.vcp(path.join(package:buildir(), dir, "*.pdb"), package:installdir(dir))
  39. end
  40. end)
  41. on_test(function (package)
  42. assert(package:has_cfuncs("OQS_SIG_keypair", {includes = "oqs/oqs.h"}))
  43. end)