[polyhook2] Fix static linkage for downstream consumers. (#32455)

This commit is contained in:
Alexander Neumann 2023-07-11 20:57:41 +02:00 committed by GitHub
parent edd88a8448
commit 92bad87dfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 70 additions and 1 deletions

View File

@ -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 $<BUILD_INTERFACE:Zydis>)
target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/zydis/include>)
@@ -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 $<BUILD_INTERFACE:asmjit>)
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${ASMJIT_SRC}>")
@@ -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 $<BUILD_INTERFACE:asmtk>)
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${ASMTK_SRC}>")
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")

View File

@ -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

View File

@ -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",

View File

@ -6410,7 +6410,7 @@
},
"polyhook2": {
"baseline": "2023-05-16",
"port-version": 0
"port-version": 1
},
"polymorphic-value": {
"baseline": "1.3.0",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "4d6b2480d856d0e6009923d176fb68392e201ac8",
"version-date": "2023-05-16",
"port-version": 1
},
{
"git-tree": "3e46e50c70de16dfea86f4a7a8ceea6d19b3c46b",
"version-date": "2023-05-16",