xmake.lua 1.6 KB

1234567891011121314151617181920212223242526272829
  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.7.0", "cfd9e6bcda5da3f602273e55f983bdd747cb93dde0b9ec06560e074939314210")
  7. add_versions("v0.6.5", "4d106d66d211f2bfaf876eb62c84d4b54664e1c2b47eb6138161d3c608c0bc5e")
  8. add_versions("v0.6.4", "1cbb1a79bfe6c37884a538b56504fa0975e78e492aee7c265a42f654c6056cb3")
  9. add_versions("v0.6.3", "da570fdeb450634d84208f203487b2e00633eac505feda5845f6921e811644fc")
  10. add_versions("v0.5.1", "36d62842ef43c749c0ba82237b10ede05b298d79a0e39ef5fd1115ba1ff8e126")
  11. add_deps("cmake")
  12. on_install("windows|x86", "windows|x64", "macosx", "linux", "mingw", function (package)
  13. local configs = {}
  14. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  15. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  16. io.replace("CMakeLists.txt", "add_subdirectory(tests)", "", {plain = true})
  17. if package:is_plat("windows") then
  18. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  19. table.insert(configs, "-DMSVC_CXX_ARCHITECTURE_ID=" .. package:targetarch())
  20. end
  21. import("package.tools.cmake").install(package, configs)
  22. end)
  23. on_test(function (package)
  24. assert(package:has_cfuncs("cpuid_get_vendor", {includes = "libcpuid/libcpuid.h"}))
  25. end)