xmake.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package("xerces-c")
  2. set_homepage("https://xerces.apache.org/xerces-c/")
  3. set_description("Xerces-C++ is a validating XML parser written in a portable subset of C++.")
  4. set_license("Apache-2.0")
  5. add_urls("https://archive.apache.org/dist/xerces/c/3/sources/xerces-c-$(version).zip")
  6. add_versions("3.2.5", "4aa0f7ed265a45d253f900fa145cc8cae10414d085695f1de03a2ec141a3358b")
  7. add_versions("3.2.4", "563a668b331ca5d1fc08ed52e5f62a13508b47557f88a068ad1db6f68e1f2eb2")
  8. add_deps("cmake")
  9. if is_plat("windows") then
  10. add_syslinks("advapi32")
  11. elseif is_plat("macosx") then
  12. add_frameworks("CoreFoundation", "CoreServices")
  13. elseif is_plat("android") then
  14. -- for NDK version less than 26
  15. add_patches(">=3.2.4",
  16. path.join(os.scriptdir(), "patches", "patch-android.diff"),
  17. "f58fa2c89e1d4a17d5af193df3e3e5918986b71beb6ce055e9edd1546c20318a")
  18. end
  19. on_install("windows", "macosx", "linux", "android", function (package)
  20. if package:is_plat("android") and package:is_arch("armeabi-v7a") then
  21. import("core.tool.toolchain")
  22. local ndk = toolchain.load("ndk", {plat = package:plat(), arch = package:arch()})
  23. local ndk_sdkver = ndk:config("ndk_sdkver")
  24. assert(ndk_sdkver and tonumber(ndk_sdkver) >= 26, "package(xerces-c): need ndk api level >= 26 for android armeabi-v7a")
  25. end
  26. local configs = {"-Dnetwork=OFF", "-DCMAKE_DISABLE_FIND_PACKAGE_ICU=ON", "-DCMAKE_DISABLE_FIND_PACKAGE_CURL=ON"}
  27. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  28. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  29. if package:config("pic") ~= false then
  30. table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
  31. end
  32. import("package.tools.cmake").install(package, configs)
  33. end)
  34. on_test(function (package)
  35. assert(package:check_cxxsnippets({test = [[
  36. using namespace xercesc;
  37. void test() {
  38. try {
  39. XMLPlatformUtils::Initialize();
  40. }
  41. catch (const XMLException& toCatch) {
  42. return;
  43. }
  44. XMLPlatformUtils::Terminate();
  45. }
  46. ]]}, {configs = {languages = "c++17"}, includes = "xercesc/util/PlatformUtils.hpp"}))
  47. end)