xmake.lua 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package("cpuinfo")
  2. set_homepage("https://github.com/pytorch/cpuinfo")
  3. set_description("CPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)")
  4. set_license("BSD 2-Clause")
  5. add_urls("https://github.com/pytorch/cpuinfo.git")
  6. add_versions("2022.09.15", "de2fa78ebb431db98489e78603e4f77c1f6c5c57")
  7. add_deps("cmake")
  8. if is_plat("windows") then
  9. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  10. add_configs("vs_runtime", {description = "Set vs compiler runtime.", default = "MT", readonly = true})
  11. end
  12. add_links("cpuinfo", "clog")
  13. if is_plat("linux", "macosx", "bsd") then
  14. add_syslinks("pthread")
  15. end
  16. on_install("windows", "linux", "macosx", "bsd", "android", function (package)
  17. local configs = {"-DCPUINFO_BUILD_TOOLS=OFF",
  18. "-DCPUINFO_BUILD_UNIT_TESTS=OFF",
  19. "-DCPUINFO_BUILD_MOCK_TESTS=OFF",
  20. "-DCPUINFO_BUILD_BENCHMARKS=OFF",
  21. "-DCPUINFO_BUILD_PKG_CONFIG=OFF"}
  22. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  23. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  24. import("package.tools.cmake").install(package, configs)
  25. end)
  26. on_test(function (package)
  27. assert(package:check_cxxsnippets({test = [[
  28. #include <iostream>
  29. void test(int args, char** argv) {
  30. cpuinfo_initialize();
  31. std::cout << "Running on %s CPU " << cpuinfo_get_package(0)->name;
  32. }
  33. ]]}, {configs = {languages = "c++11"}, includes = "cpuinfo.h"}))
  34. end)