xmake.lua 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package("polyhook2")
  2. set_homepage("https://github.com/stevemk14ebr/PolyHook_2_0")
  3. set_description("C++20, x86/x64 Hooking Libary v2.0")
  4. set_license("MIT")
  5. add_urls("https://github.com/stevemk14ebr/PolyHook_2_0.git")
  6. add_versions("2023.7.15", "0d4d90e35ecc8ead9940c23cd29e7d8952b1bcb6")
  7. add_versions("2024.8.1", "19e7cec8cce4a0068f6db04b6d3680c078183002")
  8. add_configs("shared_deps", {description = "Use shared library for dependency", default = false, type = "boolean"})
  9. add_deps("cmake")
  10. on_install("windows|x86", "windows|x64", "linux|i386", "linux|x86_64", function (package)
  11. local configs = {}
  12. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  13. table.insert(configs, "-DPOLYHOOK_BUILD_SHARED_LIB=" .. (package:config("shared") and "ON" or "OFF"))
  14. if package:is_plat("windows") then
  15. local static_runtime = package:has_runtime("MT", "MTd")
  16. table.insert(configs, "-DPOLYHOOK_BUILD_STATIC_RUNTIME=" .. (static_runtime and "ON" or "OFF"))
  17. if not static_runtime then
  18. table.insert(configs, "-DPOLYHOOK_BUILD_SHARED_ASMTK=ON")
  19. table.insert(configs, "-DPOLYHOOK_BUILD_SHARED_ASMJIT=ON")
  20. end
  21. end
  22. if package:config("shared_deps") then
  23. if not package:is_plat("windows") then
  24. table.insert(configs, "-DPOLYHOOK_BUILD_SHARED_ASMTK=ON")
  25. table.insert(configs, "-DPOLYHOOK_BUILD_SHARED_ASMJIT=ON")
  26. end
  27. table.insert(configs, "-DPOLYHOOK_BUILD_SHARED_ZYDIS=ON")
  28. end
  29. import("package.tools.cmake").install(package, configs, {buildir = "build"})
  30. package:add("links", "PolyHook_2", "asmtk", "asmjit", "Zycore", "Zydis")
  31. end)
  32. on_test(function (package)
  33. assert(package:check_cxxsnippets({test = [[
  34. #include <iostream>
  35. static void test() {
  36. PLH::NatDetour detour(0, 0, nullptr);
  37. }
  38. ]]}, {includes = "polyhook2/Detour/NatDetour.hpp", configs={languages = "c++17"}}))
  39. end)