xmake.lua 2.0 KB

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