xmake.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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_deps("cmake")
  13. on_load("windows", "mingw", function (package)
  14. if not package:config("shared") then
  15. package:add("defines", "YAML_CPP_STATIC_DEFINE")
  16. end
  17. end)
  18. on_install(function (package)
  19. local configs = {"-DYAML_CPP_BUILD_TESTS=OFF"}
  20. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  21. table.insert(configs, "-DYAML_BUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  22. if package:is_plat("windows") then
  23. table.insert(configs, "-DYAML_MSVC_SHARED_RT=" .. (package:config("vs_runtime"):startswith("MT") and "OFF" or "ON"))
  24. end
  25. import("package.tools.cmake").install(package, configs, {buildir = os.tmpfile() .. ".dir"})
  26. package:addenv("PATH", "bin")
  27. end)
  28. on_test(function (package)
  29. assert(package:check_cxxsnippets({test = [[
  30. void test() {
  31. YAML::Load("");
  32. }
  33. ]]}, {configs = {languages = "c++11"}, includes = "yaml-cpp/yaml.h"}))
  34. end)