xmake.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package("cryptopp")
  2. set_homepage("https://cryptopp.com/")
  3. set_description("free C++ class library of cryptographic schemes")
  4. add_urls("https://github.com/weidai11/cryptopp/archive/CRYPTOPP_$(version).tar.gz", {version = function (version) return version:gsub("%.", "_") end})
  5. add_versions("8.6.0", "9304625f4767a13e0a5f26d0f019d78cf9375604a33e5391c3bf2e81399dfeb8")
  6. add_versions("8.5.0", "8f64cf09cf4f61d5d74bca53574b8cc9959186cc0f072a2e6597e4999d6ad5db")
  7. add_versions("8.4.0", "6687dfc1e33b084aeab48c35a8550b239ee5f73a099a3b6a0918d70b8a89e654")
  8. add_resources("8.6.0", "cryptopp_cmake", "https://github.com/noloader/cryptopp-cmake/archive/CRYPTOPP_8_6_0.tar.gz", "970b20d55dbf9d6335485e72c9f8967d878bf64bbd3de6aa28436beb6799c493")
  9. add_resources("8.5.0", "cryptopp_cmake", "https://github.com/noloader/cryptopp-cmake/archive/CRYPTOPP_8_5_0.tar.gz", "10685209405e676993873fcf638ade5f8f99d7949afa6b2045289ce9cc6d90ac")
  10. add_resources("8.4.0", "cryptopp_cmake", "https://github.com/noloader/cryptopp-cmake/archive/CRYPTOPP_8_4_0.tar.gz", "b850070141f6724fce640e4e2cfde433ec5b2d99d4386d29ba9255167bc4b4f0")
  11. add_deps("cmake")
  12. on_install("windows", "macosx", "linux", "bsd", "iphoneos", function (package)
  13. local cryptopp_cmake = package:resourcedir("cryptopp_cmake")
  14. os.cp(path.join(cryptopp_cmake, "*", "CMakeLists.txt"), ".")
  15. os.cp(path.join(cryptopp_cmake, "*", "cryptopp-config.cmake"), ".")
  16. -- fix unresolved external symbol PadLastBlock
  17. -- @see https://github.com/weidai11/cryptopp/issues/358
  18. io.replace("iterhash.h", "CRYPTOPP_NO_VTABLE", "CRYPTOPP_DLL CRYPTOPP_NO_VTABLE")
  19. local configs = {"-DBUILD_TESTING=OFF"}
  20. table.insert(configs, "-DBUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
  21. table.insert(configs, "-DBUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
  22. local cxflags
  23. if package:is_plat("windows") and package:config("shared") then
  24. cxflags = "-DCRYPTOPP_EXPORTS"
  25. end
  26. import("package.tools.cmake").install(package, configs, {cxflags = cxflags})
  27. end)
  28. on_test(function (package)
  29. assert(package:check_cxxsnippets({test = [[
  30. #include <cryptopp/cryptlib.h>
  31. #include <cryptopp/aes.h>
  32. #include <cryptopp/modes.h>
  33. using namespace CryptoPP;
  34. void test() {
  35. unsigned char key[] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08, 0x01,0x02, 0x03,0x04,0x05,0x06,0x07,0x08};
  36. unsigned char iv[] = {0x01,0x02,0x03,0x03,0x03,0x03,0x03,0x03, 0x03,0x03, 0x01,0x02,0x03,0x03,0x03,0x03};
  37. CTR_Mode<AES>::Encryption Encryptor2(key, 16, iv);
  38. }
  39. ]]}, {configs = {languages = "c++11"}}))
  40. end)