diff --git a/CMakeLists.txt b/CMakeLists.txt index 65f3c73..586d582 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -209,14 +209,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 $) @@ -229,10 +223,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 "$") @@ -244,10 +236,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 709f8b5..599d1f7 100644 --- a/polyhook_2-config.cmake.in +++ b/polyhook_2-config.cmake.in @@ -10,5 +10,14 @@ 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) +if(POLYHOOK_FEATURE_DETOURS) + find_dependency(asmjit) +endif() +if(POLYHOOK_FEATURE_INLINENTD) + find_dependency(asmtk) +endif() + get_filename_component(POLYHOOK_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) include("${POLYHOOK_CMAKE_DIR}/PolyHook_2-targets.cmake")