xmake.lua 1.3 KB

1234567891011121314151617181920212223242526
  1. package("libcpuid")
  2. set_homepage("https://github.com/anrieff/libcpuid")
  3. set_description("a small C library for x86 CPU detection and feature extraction")
  4. add_urls("https://github.com/anrieff/libcpuid/archive/refs/tags/$(version).tar.gz",
  5. "https://github.com/anrieff/libcpuid.git")
  6. add_versions("v0.6.4", "1cbb1a79bfe6c37884a538b56504fa0975e78e492aee7c265a42f654c6056cb3")
  7. add_versions("v0.6.3", "da570fdeb450634d84208f203487b2e00633eac505feda5845f6921e811644fc")
  8. add_versions("v0.5.1", "36d62842ef43c749c0ba82237b10ede05b298d79a0e39ef5fd1115ba1ff8e126")
  9. add_deps("cmake")
  10. on_install("windows", "macosx", "linux", "mingw", function (package)
  11. local configs = {}
  12. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  13. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  14. io.replace("CMakeLists.txt", "add_subdirectory(tests)", "", {plain = true})
  15. if package:is_plat("windows") then
  16. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  17. end
  18. import("package.tools.cmake").install(package, configs)
  19. end)
  20. on_test(function (package)
  21. assert(package:has_cfuncs("cpuid_get_vendor", {includes = "libcpuid/libcpuid.h"}))
  22. end)