From 92bad87dfb4e711ac658a9ca33e1183184677020 Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Tue, 11 Jul 2023 20:57:41 +0200 Subject: [PATCH] [polyhook2] Fix static linkage for downstream consumers. (#32455) --- ports/polyhook2/fix-dep.patch | 62 ++++++++++++++++++++++++++++++++++ ports/polyhook2/portfile.cmake | 1 + ports/polyhook2/vcpkg.json | 1 + versions/baseline.json | 2 +- versions/p-/polyhook2.json | 5 +++ 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 ports/polyhook2/fix-dep.patch diff --git a/ports/polyhook2/fix-dep.patch b/ports/polyhook2/fix-dep.patch new file mode 100644 index 0000000000..cd24ccaf10 --- /dev/null +++ b/ports/polyhook2/fix-dep.patch @@ -0,0 +1,62 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index a91480445..c3d432e0b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -211,14 +211,8 @@ endif() + + #DisAsm/Zydis + if (POLYHOOK_USE_EXTERNAL_ZYDIS) +- find_library(ZYDIS_LIBRARY NAMES zydis) +- find_library(ZYCORE_LIBRARY NAMES zycore) +- find_path(ZYDIS_INCLUDE_DIR NAMES zydis/zydis.h) +- find_path(ZYCORE_INCLUDE_DIR NAMES zycore/zycore.h) +- target_link_libraries(${PROJECT_NAME} PUBLIC ${ZYDIS_LIBRARY}) +- target_link_libraries(${PROJECT_NAME} PUBLIC ${ZYCORE_LIBRARY}) +- target_include_directories(${PROJECT_NAME} PUBLIC ${ZYDIS_INCLUDE_DIR}) +- target_include_directories(${PROJECT_NAME} PUBLIC ${ZYCORE_INCLUDE_DIR}) ++ find_package(zydis REQUIRED) ++ target_link_libraries(${PROJECT_NAME} PUBLIC Zydis::Zydis) + else() + target_link_libraries(${PROJECT_NAME} PUBLIC $) + target_include_directories(${PROJECT_NAME} PUBLIC $) +@@ -231,10 +225,8 @@ install(FILES ${PROJECT_SOURCE_DIR}/polyhook2/ZydisDisassembler.hpp DESTINATION + + function(link_asmjit) + if (POLYHOOK_USE_EXTERNAL_ASMJIT) +- find_library(ASMJIT_LIBRARY NAMES asmjit) +- find_path(ASMJIT_INCLUDE_DIR NAMES asmjit/asmjit.h) +- target_link_libraries(${PROJECT_NAME} PRIVATE ${ASMJIT_LIBRARY}) +- target_include_directories(${PROJECT_NAME} PUBLIC ${ASMJIT_INCLUDE_DIR}) ++ find_package(asmjit REQUIRED) ++ target_link_libraries(${PROJECT_NAME} PRIVATE asmjit::asmjit) + else() + target_link_libraries(${PROJECT_NAME} PRIVATE $) + target_include_directories(${PROJECT_NAME} PUBLIC "$") +@@ -238,10 +238,8 @@ if(POLYHOOK_FEATURE_DETOURS) + link_asmjit() + + if (POLYHOOK_USE_EXTERNAL_ASMTK) +- find_library(ASMTK_LIBRARY NAMES asmtk) +- find_path(ASMTK_INCLUDE_DIR NAMES asmtk/asmtk.h) +- target_link_libraries(${PROJECT_NAME} PUBLIC ${ASMTK_LIBRARY}) +- target_include_directories(${PROJECT_NAME} PUBLIC ${ASMTK_INCLUDE_DIR}) ++ find_package(asmtk REQUIRED) ++ target_link_libraries(${PROJECT_NAME} PRIVATE asmjit::asmtk) + else() + target_link_libraries(${PROJECT_NAME} PUBLIC $) + target_include_directories(${PROJECT_NAME} PUBLIC "$") +diff --git a/PolyHook_2-config.cmake.in b/PolyHook_2-config.cmake.in +index 709f8b5d9..3add035e3 100644 +--- a/PolyHook_2-config.cmake.in ++++ b/PolyHook_2-config.cmake.in +@@ -10,5 +10,10 @@ set(POLYHOOK_FEATURE_INLINENTD @POLYHOOK_FEATURE_INLINENTD@) + set(POLYHOOK_FEATURE_PE @POLYHOOK_FEATURE_PE@) + set(POLYHOOK_FEATURE_VIRTUALS @POLYHOOK_FEATURE_VIRTUALS@) + ++include(CMakeFindDependencyMacro) ++find_dependency(Zydis) ++find_dependency(asmjit) ++find_dependency(asmtk) ++ + get_filename_component(POLYHOOK_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + include("${POLYHOOK_CMAKE_DIR}/PolyHook_2-targets.cmake") diff --git a/ports/polyhook2/portfile.cmake b/ports/polyhook2/portfile.cmake index 01923d5460..4a00929289 100644 --- a/ports/polyhook2/portfile.cmake +++ b/ports/polyhook2/portfile.cmake @@ -4,6 +4,7 @@ vcpkg_from_github( REF 1ff1d0285fc28bfd206aa0a38ae93022a5ad9be1 SHA512 056b5ce76683e130e053e1f62ccc3fbd060670ac74e0235f100d16bba36707bad5e84d2100fd2cc3a67a7c294eeaf5fb72a213f3d3af099013fe13c92575cc8b HEAD_REF master + PATCHES fix-dep.patch ) vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS diff --git a/ports/polyhook2/vcpkg.json b/ports/polyhook2/vcpkg.json index 5a5ae96c63..17898381b9 100644 --- a/ports/polyhook2/vcpkg.json +++ b/ports/polyhook2/vcpkg.json @@ -1,6 +1,7 @@ { "name": "polyhook2", "version-date": "2023-05-16", + "port-version": 1, "description": "C++17, x86/x64 Hooking Library v2.0", "homepage": "https://github.com/stevemk14ebr/PolyHook_2_0", "license": "MIT", diff --git a/versions/baseline.json b/versions/baseline.json index c7a54495db..34e5d41e93 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -6410,7 +6410,7 @@ }, "polyhook2": { "baseline": "2023-05-16", - "port-version": 0 + "port-version": 1 }, "polymorphic-value": { "baseline": "1.3.0", diff --git a/versions/p-/polyhook2.json b/versions/p-/polyhook2.json index 6caad9cf4c..f24afaca6c 100644 --- a/versions/p-/polyhook2.json +++ b/versions/p-/polyhook2.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "4d6b2480d856d0e6009923d176fb68392e201ac8", + "version-date": "2023-05-16", + "port-version": 1 + }, { "git-tree": "3e46e50c70de16dfea86f4a7a8ceea6d19b3c46b", "version-date": "2023-05-16",