xmake.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package("corrade")
  2. set_homepage("https://magnum.graphics/corrade/")
  3. set_description("Corrade is a multiplatform utility library written in C++11/C++14.")
  4. set_license("MIT")
  5. add_urls("https://github.com/mosra/corrade/archive/refs/tags/$(version).zip",
  6. "https://github.com/mosra/corrade.git")
  7. add_versions("v2020.06", "d89a06128c334920d91fecf23cc1df48fd6be26543dc0ed81b2f819a92d70e72")
  8. add_patches("2020.06", "patches/2020.06/msvc.patch", "af90c9bad846a2cbe834fe270860446f6329636f9b9b7ad23454cf479c1dc05f")
  9. if is_plat("windows") then
  10. add_syslinks("shell32")
  11. elseif is_plat("linux") then
  12. add_syslinks("dl")
  13. end
  14. add_deps("cmake")
  15. on_load("windows", "linux", "macosx", function (package)
  16. if package:is_cross() then
  17. package:add("deps", "corrade", {host = true, private = true})
  18. end
  19. end)
  20. on_install("windows", "linux", "macosx", function (package)
  21. io.replace("src/Corrade/Utility/StlForwardTuple.h", "__tuple", "tuple")
  22. local configs = {"-DBUILD_TESTS=OFF", "-DLIB_SUFFIX="}
  23. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  24. table.insert(configs, "-DCORRADE_BUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
  25. table.insert(configs, "-DBUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
  26. import("package.tools.cmake").install(package, configs)
  27. if package:is_cross() then
  28. os.rm(path.join(package:installdir("bin"), "*"))
  29. else
  30. package:addenv("PATH", "bin")
  31. end
  32. end)
  33. on_test(function (package)
  34. if not package:is_cross() then
  35. os.vrun("corrade-rc --help")
  36. end
  37. assert(package:check_cxxsnippets({test = [[
  38. #include <string>
  39. void test() {
  40. Corrade::Utility::Resource rs{"data"};
  41. rs.get(std::string("license.txt"));
  42. }
  43. ]]}, {configs = {languages = "c++14"}, includes = "Corrade/Utility/Resource.h"}))
  44. end)