mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-27 10:21:07 +08:00
[libmem] add new port (#41345)
Co-authored-by: Cheney Wang <38240633+Cheney-W@users.noreply.github.com> Co-authored-by: Kai Pastor <dg0yt@darc.de> Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
This commit is contained in:
parent
c2681c76cf
commit
199ea6e76a
171
ports/libmem/0001-CMakeLists.patch
Normal file
171
ports/libmem/0001-CMakeLists.patch
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
--- a/CMakeLists.txt
|
||||||
|
+++ b/CMakeLists.txt
|
||||||
|
@@ -1,6 +1,6 @@
|
||||||
|
cmake_minimum_required(VERSION 3.22.1)
|
||||||
|
|
||||||
|
-include(ExternalProject)
|
||||||
|
+
|
||||||
|
|
||||||
|
project(libmem
|
||||||
|
LANGUAGES
|
||||||
|
@@ -23,13 +23,23 @@ option(LIBMEM_DEEP_TESTS
|
||||||
|
OFF
|
||||||
|
)
|
||||||
|
|
||||||
|
+set(CMAKE_CXX_STANDARD 17)
|
||||||
|
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
+set(targets_export_name libmem-target)
|
||||||
|
+
|
||||||
|
+if (MSVC AND NOT(BUILD_SHARED_LIBS))
|
||||||
|
+ add_definitions(/DLM_EXPORT)
|
||||||
|
+elseif(NOT(MSVC) AND BUILD_SHARED_LIBS)
|
||||||
|
+ add_definitions(-DLM_EXPORT)
|
||||||
|
+endif()
|
||||||
|
+if(0)
|
||||||
|
option(LIBMEM_BUILD_STATIC
|
||||||
|
"Build a static library"
|
||||||
|
OFF
|
||||||
|
)
|
||||||
|
-
|
||||||
|
+endif()
|
||||||
|
set(LIBMEM_ARCH ${CMAKE_SYSTEM_PROCESSOR} CACHE STRING "Force a specific architecture")
|
||||||
|
-
|
||||||
|
+if(0)
|
||||||
|
message(STATUS
|
||||||
|
"[*] Architecture: ${LIBMEM_ARCH}"
|
||||||
|
)
|
||||||
|
@@ -65,13 +75,17 @@ add_library(capstone STATIC IMPORTED)
|
||||||
|
set_target_properties(capstone PROPERTIES IMPORTED_LOCATION ${CAPSTONE_IMPORT_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}capstone${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||||
|
add_library(keystone STATIC IMPORTED)
|
||||||
|
set_target_properties(keystone PROPERTIES IMPORTED_LOCATION ${KEYSTONE_IMPORT_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}keystone${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||||
|
+endif()
|
||||||
|
+find_package(PkgConfig)
|
||||||
|
+pkg_check_modules(keystone REQUIRED keystone)
|
||||||
|
+find_package(capstone CONFIG REQUIRED)
|
||||||
|
# End of external dependencies
|
||||||
|
-
|
||||||
|
set(LIBMEM_DIR "${PROJECT_SOURCE_DIR}")
|
||||||
|
+set(LLVM_DEM_DIR "${LIBMEM_DIR}/external/llvm")
|
||||||
|
set(LIBMEM_INC "${LIBMEM_DIR}/include")
|
||||||
|
set(INTERNAL_DIR "${LIBMEM_DIR}/internal")
|
||||||
|
set(COMMON_DIR "${LIBMEM_DIR}/src/common")
|
||||||
|
-
|
||||||
|
+file(GLOB_RECURSE LLVM_DEM_SRC "${LLVM_DEM_DIR}/lib/*.cpp")
|
||||||
|
if(${CMAKE_SYSTEM_NAME} STREQUAL Windows OR ${CMAKE_SYSTEM_NAME} STREQUAL CYGWIN)
|
||||||
|
file(GLOB_RECURSE LIBMEM_SRC "${LIBMEM_DIR}/src/win/*.c" "${LIBMEM_DIR}/src/common/*.c" "${LIBMEM_DIR}/src/common/*.cpp" "${INTERNAL_DIR}/winutils/*.c" "${INTERNAL_DIR}/demangler/*.cpp")
|
||||||
|
elseif(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
|
||||||
|
@@ -89,16 +103,13 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD)
|
||||||
|
endif()
|
||||||
|
file(GLOB LIBMEM_SRC ${LIBMEM_ARCH_SRC} "${LIBMEM_DIR}/src/freebsd/*.c" "${LIBMEM_DIR}/src/freebsd/ptrace/*.c" "${LIBMEM_DIR}/src/common/*.c" "${LIBMEM_DIR}/src/common/*.cpp" "${INTERNAL_DIR}/posixutils/*.c" "${INTERNAL_DIR}/elfutils/*.c" "${INTERNAL_DIR}/demangler/*.cpp")
|
||||||
|
endif()
|
||||||
|
-set(LIBMEM_DEPS
|
||||||
|
- capstone
|
||||||
|
- keystone
|
||||||
|
- llvm
|
||||||
|
-)
|
||||||
|
|
||||||
|
-if (LIBMEM_BUILD_STATIC)
|
||||||
|
+file(GLOB_RECURSE LIBMEM_PUBLIC_HEADERS "${LIBMEM_INC}/libmem/*.h" "${LIBMEM_INC}/libmem/*.hpp")
|
||||||
|
+
|
||||||
|
+if (0)
|
||||||
|
add_library(libmem STATIC ${LIBMEM_SRC})
|
||||||
|
else()
|
||||||
|
- add_library(libmem SHARED ${LIBMEM_SRC})
|
||||||
|
+ add_library(libmem ${LIBMEM_SRC} ${LLVM_DEM_SRC})
|
||||||
|
endif()
|
||||||
|
target_include_directories(libmem PRIVATE "${LIBMEM_DIR}/src" "${INTERNAL_DIR}" "${COMMON_DIR}")
|
||||||
|
|
||||||
|
@@ -109,17 +120,16 @@ include_directories(${PROJECT_SOURCE_DIR}
|
||||||
|
${LLVM_INC}
|
||||||
|
)
|
||||||
|
|
||||||
|
-if (LIBMEM_BUILD_TESTS)
|
||||||
|
+if (0)
|
||||||
|
set(TESTS_DIR "${PROJECT_SOURCE_DIR}/tests")
|
||||||
|
add_subdirectory(${TESTS_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
-set_target_properties(libmem PROPERTIES POSITION_INDEPENDENT_CODE True INCLUDES ${LIBMEM_INC})
|
||||||
|
+set_target_properties(libmem PROPERTIES POSITION_INDEPENDENT_CODE True PUBLIC_HEADER "${LIBMEM_PUBLIC_HEADERS}")
|
||||||
|
+target_compile_features(libmem PUBLIC cxx_std_17)
|
||||||
|
+target_compile_definitions(libmem PUBLIC LM_EXPORT)
|
||||||
|
+target_include_directories(libmem PRIVATE "${LLVM_DEM_DIR}/include" "${LIBMEM_DIR}/src" "${INTERNAL_DIR}" "${COMMON_DIR}" "${LIBMEM_INC}" INTERFACE $<INSTALL_INTERFACE:include>)
|
||||||
|
target_compile_definitions(libmem PUBLIC LM_EXPORT)
|
||||||
|
-add_dependencies(libmem
|
||||||
|
- capstone-engine
|
||||||
|
- keystone-engine
|
||||||
|
-)
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM_NAME} STREQUAL Windows OR ${CMAKE_SYSTEM_NAME} STREQUAL CYGWIN)
|
||||||
|
set(LIBMEM_DEPS
|
||||||
|
@@ -151,8 +161,8 @@ else()
|
||||||
|
message(FATAL_ERROR "[!] Unsupported platform")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
-target_link_libraries(libmem ${LIBMEM_DEPS})
|
||||||
|
-if(LIBMEM_BUILD_STATIC)
|
||||||
|
+target_link_libraries(libmem PRIVATE ${LIBMEM_DEPS} ${keystone_LINK_LIBRARIES} capstone::capstone)
|
||||||
|
+if(0)
|
||||||
|
# Create a bundled static library containing all dependencies (to mimic the shared library behavior)
|
||||||
|
set_target_properties(libmem PROPERTIES OUTPUT_NAME "libmem_partial")
|
||||||
|
set(libmem_bundle_files "$<TARGET_FILE:libmem>")
|
||||||
|
@@ -193,7 +203,7 @@ if(LIBMEM_BUILD_STATIC)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
-if(${CMAKE_SYSTEM_NAME} STREQUAL Windows OR ${CMAKE_SYSTEM_NAME} STREQUAL CYGWIN)
|
||||||
|
+if(0)
|
||||||
|
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL CYGWIN)
|
||||||
|
cmake_path(SET CMAKE_INSTALL_PREFIX "$ENV{ProgramFiles}")
|
||||||
|
else()
|
||||||
|
@@ -202,14 +212,44 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL Windows OR ${CMAKE_SYSTEM_NAME} STREQUAL CYGWIN
|
||||||
|
endif()
|
||||||
|
set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/libmem")
|
||||||
|
execute_process(COMMAND mkdir "${CMAKE_INSTALL_PREFIX}")
|
||||||
|
-else()
|
||||||
|
+elseif(0)
|
||||||
|
set(CMAKE_INSTALL_PREFIX "/usr")
|
||||||
|
endif()
|
||||||
|
-
|
||||||
|
install(TARGETS libmem
|
||||||
|
- LIBRARY DESTINATION lib)
|
||||||
|
+ EXPORT ${targets_export_name}
|
||||||
|
+ LIBRARY DESTINATION lib
|
||||||
|
+ ARCHIVE DESTINATION lib
|
||||||
|
+ PUBLIC_HEADER DESTINATION include/libmem
|
||||||
|
+ RUNTIME DESTINATION bin
|
||||||
|
+)
|
||||||
|
|
||||||
|
-install(TARGETS libmem
|
||||||
|
- RUNTIME DESTINATION lib)
|
||||||
|
+# Install the export file, which allows users to find the target
|
||||||
|
+install(
|
||||||
|
+ EXPORT ${targets_export_name}
|
||||||
|
+ NAMESPACE libmem::
|
||||||
|
+ FILE ${targets_export_name}.cmake
|
||||||
|
+ DESTINATION share/libmem
|
||||||
|
+)
|
||||||
|
|
||||||
|
-install(DIRECTORY ${LIBMEM_INC}/libmem DESTINATION include)
|
||||||
|
+# Config and version files for the package
|
||||||
|
+include(CMakePackageConfigHelpers)
|
||||||
|
+
|
||||||
|
+configure_package_config_file(
|
||||||
|
+ ${CMAKE_CURRENT_SOURCE_DIR}/libmem-config.cmake.in
|
||||||
|
+ ${CMAKE_CURRENT_BINARY_DIR}/libmem-config.cmake
|
||||||
|
+ INSTALL_DESTINATION share/libmem
|
||||||
|
+)
|
||||||
|
+
|
||||||
|
+write_basic_package_version_file(
|
||||||
|
+ "${CMAKE_CURRENT_BINARY_DIR}/libmem-config-version.cmake"
|
||||||
|
+ VERSION 5.0.2
|
||||||
|
+ COMPATIBILITY SameMajorVersion
|
||||||
|
+)
|
||||||
|
+
|
||||||
|
+# Install the config and version files
|
||||||
|
+install(
|
||||||
|
+ FILES
|
||||||
|
+ ${CMAKE_CURRENT_BINARY_DIR}/libmem-config.cmake
|
||||||
|
+ ${CMAKE_CURRENT_BINARY_DIR}/libmem-config-version.cmake
|
||||||
|
+ DESTINATION share/libmem
|
||||||
|
+)
|
7
ports/libmem/libmem-config.cmake.in
Normal file
7
ports/libmem/libmem-config.cmake.in
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
include(CMakeFindDependencyMacro)
|
||||||
|
find_dependency(capstone CONFIG)
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/libmem-target.cmake")
|
||||||
|
check_required_components(libmem)
|
44
ports/libmem/portfile.cmake
Normal file
44
ports/libmem/portfile.cmake
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
vcpkg_download_distfile(
|
||||||
|
EXPORT_SURFACE_PATCH
|
||||||
|
URLS https://github.com/rdbo/libmem/commit/04830fb5a6dd6c81843c1b54bd61dac5bd202b9a.patch?full_index=1
|
||||||
|
FILENAME libmem-export-surface-04830fb5a6dd6c81843c1b54bd61dac5bd202b9a.patch
|
||||||
|
SHA512 9060f86514f866a24a61b6cd51ee524f169b23781969b5f47f6fa5d2144369e7648658848fb2e00e9f0aed72119c4ab20842ba5afe9b0a485eea15ff63934596
|
||||||
|
)
|
||||||
|
|
||||||
|
vcpkg_from_github(
|
||||||
|
OUT_SOURCE_PATH SOURCE_PATH
|
||||||
|
REPO rdbo/libmem
|
||||||
|
REF ${VERSION}
|
||||||
|
SHA512 d7c5a1a42d65a00ed3aa8ba8f6974650801d3436ae90e072fea29d4dcb32a3963e2610c89a16b87d94a9613c8f2f0e8deb83b673a1771a9cd1eb716a56106a16
|
||||||
|
HEAD_REF master
|
||||||
|
PATCHES
|
||||||
|
0001-CMakeLists.patch
|
||||||
|
"${EXPORT_SURFACE_PATCH}"
|
||||||
|
)
|
||||||
|
|
||||||
|
message(WARNING "Removing PreLoad.cmake")
|
||||||
|
file(REMOVE "${SOURCE_PATH}/PreLoad.cmake")
|
||||||
|
|
||||||
|
file(MAKE_DIRECTORY "${SOURCE_PATH}/cmake")
|
||||||
|
|
||||||
|
file(COPY "${CMAKE_CURRENT_LIST_DIR}/libmem-config.cmake.in"
|
||||||
|
DESTINATION "${SOURCE_PATH}"
|
||||||
|
)
|
||||||
|
|
||||||
|
vcpkg_find_acquire_program(PKGCONFIG)
|
||||||
|
vcpkg_cmake_configure(
|
||||||
|
SOURCE_PATH "${SOURCE_PATH}"
|
||||||
|
OPTIONS
|
||||||
|
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"
|
||||||
|
)
|
||||||
|
|
||||||
|
vcpkg_cmake_install()
|
||||||
|
vcpkg_cmake_config_fixup()
|
||||||
|
vcpkg_copy_pdbs()
|
||||||
|
|
||||||
|
file(REMOVE_RECURSE
|
||||||
|
"${CURRENT_PACKAGES_DIR}/debug/include"
|
||||||
|
"${CURRENT_PACKAGES_DIR}/debug/share"
|
||||||
|
)
|
||||||
|
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
|
||||||
|
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
|
4
ports/libmem/usage
Normal file
4
ports/libmem/usage
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
libmem provides CMake targets:
|
||||||
|
|
||||||
|
find_package(libmem CONFIG REQUIRED)
|
||||||
|
target_link_libraries(main PRIVATE libmem::libmem)
|
28
ports/libmem/vcpkg.json
Normal file
28
ports/libmem/vcpkg.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"name": "libmem",
|
||||||
|
"version": "5.0.2",
|
||||||
|
"description": "Advanced Game Hacking Library for C, Modern C++, Rust and Python (Windows/Linux/FreeBSD) (Process/Memory Hacking) (Hooking/Detouring) (Cross Platform) (x86/x64/ARM/ARM64) (DLL/SO Injection) (Internal/External) (Assembler/Disassembler)",
|
||||||
|
"homepage": "https://github.com/rdbo/libmem",
|
||||||
|
"license": "AGPL-3.0-only",
|
||||||
|
"supports": "!uwp & !xbox & !osx & !arm & !android & !ios",
|
||||||
|
"dependencies": [
|
||||||
|
"capstone",
|
||||||
|
"keystone",
|
||||||
|
{
|
||||||
|
"name": "vcpkg-cmake",
|
||||||
|
"host": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "vcpkg-cmake-config",
|
||||||
|
"host": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "vcpkg-cmake-get-vars",
|
||||||
|
"host": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "vcpkg-pkgconfig-get-modules",
|
||||||
|
"host": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -4796,6 +4796,10 @@
|
|||||||
"baseline": "24.11",
|
"baseline": "24.11",
|
||||||
"port-version": 0
|
"port-version": 0
|
||||||
},
|
},
|
||||||
|
"libmem": {
|
||||||
|
"baseline": "5.0.2",
|
||||||
|
"port-version": 0
|
||||||
|
},
|
||||||
"libmesh": {
|
"libmesh": {
|
||||||
"baseline": "1.5.0",
|
"baseline": "1.5.0",
|
||||||
"port-version": 6
|
"port-version": 6
|
||||||
|
9
versions/l-/libmem.json
Normal file
9
versions/l-/libmem.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"versions": [
|
||||||
|
{
|
||||||
|
"git-tree": "f594eb800c0b265eaa3bc2d96c383bc16f851305",
|
||||||
|
"version": "5.0.2",
|
||||||
|
"port-version": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user