xmake.lua 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package("simdutf")
  2. set_homepage("https://simdutf.github.io/simdutf/")
  3. set_description("Unicode routines (UTF8, UTF16, UTF32): billions of characters per second using SSE2, AVX2, NEON, AVX-512. Part of Node.js.")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/simdutf/simdutf/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/simdutf/simdutf.git")
  7. add_versions("v5.2.3", "dfa55d85c3ee51e9b52e55c02701b16f83dcf1921e1075b67f99b1036df5adb8")
  8. add_versions("v4.0.9", "599e6558fc8d06f8346e5f210564f8b18751c93d83bce1a40a0e6a326c57b61e")
  9. add_versions("v3.2.17", "c24e3eec1e08522a09b33e603352e574f26d367a7701bf069a65881f64acd519")
  10. add_configs("iconv", {description = "Whether to use iconv as part of the CMake build if available.", default = false, type = "boolean"})
  11. add_deps("cmake")
  12. on_load(function (package)
  13. if package:config("iconv") then
  14. package:add("deps", "libiconv")
  15. end
  16. end)
  17. on_install(function (package)
  18. local configs = {"-DSIMDUTF_TESTS=OFF", "-DSIMDUTF_BENCHMARKS=OFF", "-DSIMDUTF_TOOLS=OFF", }
  19. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  20. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  21. table.insert(configs, "-DSIMDUTF_ICONV=" .. (package:config("iconv") and "ON" or "OFF"))
  22. io.replace("CMakeLists.txt", "add_subdirectory(singleheader)", "", {plain = true})
  23. io.replace("src/CMakeLists.txt", "/WX", "", {plain = true})
  24. import("package.tools.cmake").install(package, configs)
  25. end)
  26. on_test(function (package)
  27. assert(package:check_cxxsnippets({test = [[
  28. #include <simdutf.h>
  29. void test() {
  30. bool validutf8 = simdutf::validate_utf8("1234", 4);
  31. }
  32. ]]}, {configs = {languages = "c++11"}}))
  33. end)