xmake.lua 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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://dlcdn.apache.org//xerces/c/3/sources/xerces-c-$(version).zip")
  6. add_versions("3.2.4", "563a668b331ca5d1fc08ed52e5f62a13508b47557f88a068ad1db6f68e1f2eb2")
  7. add_deps("cmake")
  8. if is_plat("windows") then
  9. add_syslinks("advapi32")
  10. elseif is_plat("macosx") then
  11. add_frameworks("CoreFoundation", "CoreServices")
  12. end
  13. on_install("windows", "macosx", "linux", "android", function (package)
  14. if package:is_plat("android") then
  15. import("core.tool.toolchain")
  16. local ndk = toolchain.load("ndk", {plat = package:plat(), arch = package:arch()})
  17. local ndk_sdkver = ndk:config("ndk_sdkver")
  18. assert(ndk_sdkver and tonumber(ndk_sdkver) >= 26, "package(xerces-c): need ndk api level >= 26 for android")
  19. end
  20. local configs = {"-Dnetwork=OFF", "-DCMAKE_DISABLE_FIND_PACKAGE_ICU=ON", "-DCMAKE_DISABLE_FIND_PACKAGE_CURL=ON"}
  21. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  22. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  23. if package:config("pic") ~= false then
  24. table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
  25. end
  26. import("package.tools.cmake").install(package, configs)
  27. end)
  28. on_test(function (package)
  29. assert(package:check_cxxsnippets({test = [[
  30. using namespace xercesc;
  31. void test() {
  32. try {
  33. XMLPlatformUtils::Initialize();
  34. }
  35. catch (const XMLException& toCatch) {
  36. return;
  37. }
  38. XMLPlatformUtils::Terminate();
  39. }
  40. ]]}, {configs = {languages = "c++17"}, includes = "xercesc/util/PlatformUtils.hpp"}))
  41. end)