xmake.lua 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package("yaml-cpp")
  2. set_homepage("https://github.com/jbeder/yaml-cpp/")
  3. set_description("A YAML parser and emitter in C++")
  4. set_license("MIT")
  5. add_urls("https://github.com/jbeder/yaml-cpp/archive/refs/tags/$(version).tar.gz", {version = function (version)
  6. return version:le("0.7.0") and "yaml-cpp-" .. tostring(version) or version
  7. end})
  8. add_urls("https://github.com/jbeder/yaml-cpp.git")
  9. add_versions("0.6.3", "77ea1b90b3718aa0c324207cb29418f5bced2354c2e483a9523d98c3460af1ed")
  10. add_versions("0.7.0", "43e6a9fcb146ad871515f0d0873947e5d497a1c9c60c58cb102a97b47208b7c3")
  11. add_versions("0.8.0", "fbe74bbdcee21d656715688706da3c8becfd946d92cd44705cc6098bb23b3a16")
  12. add_patches("0.8.0", path.join(os.scriptdir(), "patches", "missing-gcc15-header.diff"), "77187131279f2ef470f473b3d4cf88a3e9075d1650f0abe8a791b260292dd86e")
  13. add_deps("cmake")
  14. on_load("windows", "mingw", function (package)
  15. if not package:config("shared") then
  16. package:add("defines", "YAML_CPP_STATIC_DEFINE")
  17. end
  18. end)
  19. on_install(function (package)
  20. local configs = {"-DYAML_CPP_BUILD_TESTS=OFF"}
  21. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  22. table.insert(configs, "-DYAML_BUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  23. if package:is_plat("windows") then
  24. table.insert(configs, "-DYAML_MSVC_SHARED_RT=" .. (package:config("vs_runtime"):startswith("MT") and "OFF" or "ON"))
  25. end
  26. import("package.tools.cmake").install(package, configs, {buildir = os.tmpfile() .. ".dir"})
  27. package:addenv("PATH", "bin")
  28. end)
  29. on_test(function (package)
  30. assert(package:check_cxxsnippets({test = [[
  31. void test() {
  32. YAML::Load("");
  33. }
  34. ]]}, {configs = {languages = "c++11"}, includes = "yaml-cpp/yaml.h"}))
  35. end)