Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libmem] add new port #41345

Draft
wants to merge 188 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 182 commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
5854d4d
Added Libmem port
luadebug Oct 5, 2024
330f665
Update portfile.cmake
luadebug Oct 9, 2024
b4a5d8c
Added keystone & capstone deps
luadebug Oct 9, 2024
1bbcb62
Use NMake only for windows
luadebug Oct 11, 2024
c46ded1
Create fix_DLL.patch
luadebug Oct 13, 2024
43ae8e3
Fixed deps in portfile.cmake
luadebug Oct 13, 2024
e99c133
Fixed deps in vcpkg.json
luadebug Oct 13, 2024
988041c
Fixed existing CMakeLists.txt
luadebug Oct 13, 2024
0aba543
Update portfile.cmake
luadebug Oct 13, 2024
48dc9a6
Update portfile.cmake
luadebug Oct 13, 2024
42ee8d7
Fixup vcpkg.json llvm
luadebug Oct 14, 2024
bd16c73
added zstd dependency. fixed missing x64-OSX LLVM dep. cmkelist.txt &…
luadebug Oct 14, 2024
ef98d5e
Fixed typo
luadebug Oct 14, 2024
fad0af5
Merged x86 platforms in 1 for LLVM vcpkg.json.
luadebug Oct 14, 2024
1e55991
ZSTD Fixup
luadebug Oct 14, 2024
4ac29bf
fixup ZSTD new
luadebug Oct 14, 2024
a44bc3e
Turn off MSVC_STATIC_CRT for Windows
luadebug Oct 14, 2024
74407d4
Enforce Unix Makefiles for OS X
luadebug Oct 14, 2024
651a353
Enforce Unix Makefiles for IOS
luadebug Oct 14, 2024
113b730
Fix for LM_EXPORT
luadebug Oct 15, 2024
22814df
Fix for LM_EXPORT
luadebug Oct 15, 2024
358dec1
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 15, 2024
7ddafd0
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 15, 2024
ce80cab
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 15, 2024
9b8bbbd
Enforce link CRT off
luadebug Oct 15, 2024
d1b23bc
Enforce link CRT off
luadebug Oct 15, 2024
777714c
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 15, 2024
b49c861
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 15, 2024
5d9846d
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 15, 2024
38b7e9e
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 15, 2024
10257f0
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 15, 2024
1bb7c3a
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 15, 2024
49489c5
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 15, 2024
1197980
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 15, 2024
a3a25d4
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 15, 2024
d978d52
removed features to rely over core
luadebug Oct 16, 2024
68d9eae
Update portfile.cmake
luadebug Oct 16, 2024
83f1222
Update portfile.cmake
luadebug Oct 16, 2024
283e640
Update portfile.cmake
luadebug Oct 16, 2024
f2c2938
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 16, 2024
34e2b31
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 16, 2024
23ad7b5
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 16, 2024
ac7eb67
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 16, 2024
10ec98e
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 16, 2024
a15366c
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 16, 2024
3eceb9b
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 16, 2024
2ac6e14
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 16, 2024
3f8155c
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 17, 2024
e563e61
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 17, 2024
a8e15aa
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 17, 2024
e7483ce
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 17, 2024
f1cec88
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 17, 2024
f687bf8
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 17, 2024
84d614d
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 17, 2024
aabc663
Update CMakeLists.txt
luadebug Oct 18, 2024
539fe2d
Update CMakeLists.txt
luadebug Oct 20, 2024
b87201c
Update portfile.cmake
luadebug Oct 20, 2024
5db9d36
Update portfile.cmake
luadebug Oct 21, 2024
19462a0
Update portfile.cmake
luadebug Oct 21, 2024
20854e6
Update CMakeLists.txt
luadebug Oct 21, 2024
8ccdcd5
Update CMakeLists.txt
luadebug Oct 22, 2024
e006912
Update portfile.cmake
luadebug Oct 22, 2024
573bf19
Update CMakeLists.txt
luadebug Oct 22, 2024
a865db5
Update vcpkg.json
luadebug Oct 22, 2024
40fa09f
Update CMakeLists.txt
luadebug Oct 23, 2024
7ef45f3
Update CMakeLists.txt
luadebug Oct 25, 2024
8f9571c
Update portfile.cmake
luadebug Oct 25, 2024
dcbdd6d
Update CMakeLists.txt
luadebug Oct 26, 2024
b99f61b
Update CMakeLists.txt
luadebug Oct 27, 2024
1b5873d
Update CMakeLists.txt
luadebug Oct 27, 2024
703a626
Update CMakeLists.txt
luadebug Oct 27, 2024
229089d
Update portfile.cmake
luadebug Oct 27, 2024
21ff1d9
Update CMakeLists.txt
luadebug Oct 27, 2024
a24e068
Update portfile.cmake
luadebug Oct 28, 2024
eb8a5dc
Update portfile.cmake
luadebug Oct 28, 2024
6b22b8e
Update portfile.cmake
luadebug Oct 28, 2024
47c18a2
Update portfile.cmake
luadebug Oct 28, 2024
89ebc21
Update CMakeLists.txt
luadebug Oct 28, 2024
08b217b
Delete ports/libmem/fix_DLL.patch
luadebug Oct 30, 2024
8b6c877
Update portfile.cmake
luadebug Oct 30, 2024
ab1589d
Update CMakeLists.txt
luadebug Oct 30, 2024
349e992
Update CMakeLists.txt
luadebug Oct 30, 2024
81b472a
Update CMakeLists.txt
luadebug Oct 30, 2024
9fe961f
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 30, 2024
cbbaa9a
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 30, 2024
8de3b74
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 30, 2024
e6258ff
Bump version
luadebug Oct 30, 2024
47f5f73
Bump version
luadebug Oct 30, 2024
4d84f8a
upd
luadebug Oct 30, 2024
7d19c7a
Swap to unofficial
luadebug Oct 31, 2024
860136d
Swap to unofficial
luadebug Oct 31, 2024
ad6c2cd
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 31, 2024
f913a12
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 31, 2024
333f14e
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 31, 2024
fb86cd8
Fix namespace in CMakeLists
luadebug Oct 31, 2024
62716d9
Fix namespace in CMakeLists
luadebug Oct 31, 2024
c49d509
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 31, 2024
56100e5
clean
luadebug Oct 31, 2024
27e2db3
clean
luadebug Oct 31, 2024
5c3eb51
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 31, 2024
02ff164
clean
luadebug Oct 31, 2024
908710d
test
luadebug Oct 31, 2024
071988c
test
luadebug Oct 31, 2024
e6f6a20
empty PreLoad.cmake
luadebug Oct 31, 2024
bc2dd64
empty PreLoad.cmake
luadebug Oct 31, 2024
979c2c3
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 31, 2024
8e50d2e
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 31, 2024
d105a33
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 31, 2024
e8f1339
Working removing mechanism
luadebug Oct 31, 2024
e11ed33
Working removing mechanism
luadebug Oct 31, 2024
ef53742
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 31, 2024
5d8ebf5
clean
luadebug Oct 31, 2024
069e77a
clean
luadebug Oct 31, 2024
9829a5e
clean
luadebug Oct 31, 2024
ea253de
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 31, 2024
5224f33
fixup usage install
luadebug Oct 31, 2024
cc464c3
fixup usage install
luadebug Oct 31, 2024
225ee8c
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Oct 31, 2024
2c10019
Update ports/libmem/CMakeLists.txt
luadebug Nov 1, 2024
d263d8c
Update ports/libmem/portfile.cmake
luadebug Nov 1, 2024
3968914
Update ports/libmem/portfile.cmake
luadebug Nov 1, 2024
486676f
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 1, 2024
7888415
Syslinks & Pub h
luadebug Nov 3, 2024
9cc1210
Syslinks & Pub h
luadebug Nov 3, 2024
87456bc
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 3, 2024
6810922
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 3, 2024
f52714f
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 3, 2024
223d9dd
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 3, 2024
06697f3
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 3, 2024
f59eb1b
version
luadebug Nov 3, 2024
1a58eb4
version
luadebug Nov 3, 2024
dcd839e
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 3, 2024
082b59a
LLVM link fix & find keystone MSVC fix.
luadebug Nov 4, 2024
ffcd888
fix path
luadebug Nov 5, 2024
8721bb5
Using existing LLVMDemangler from src
luadebug Nov 5, 2024
2e0a13d
Using existing LLVMDemangler from src
luadebug Nov 5, 2024
eabaffc
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 5, 2024
6cdf4ea
Androidx86 test fix
luadebug Nov 5, 2024
710df5e
Androidx86 test fix
luadebug Nov 5, 2024
659a08f
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 5, 2024
3a48ea3
exclude android & ios
luadebug Nov 5, 2024
5439382
exclude android & ios
luadebug Nov 5, 2024
a7130ea
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 5, 2024
9aeb56a
Findcpstone & DLL fix
luadebug Nov 5, 2024
b2eeca3
Findcpstone & DLL fix
luadebug Nov 5, 2024
736ac42
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 5, 2024
a2c644d
Follow upstream by using api.h of recent commits.
luadebug Nov 6, 2024
5f92cb2
Follow upstream by using api.h of recent commits.
luadebug Nov 6, 2024
718725e
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 6, 2024
fafd45d
CmakeLists.txt patch & using libmem::libmem & remove Findcapstone
luadebug Nov 7, 2024
c9efa71
CmakeLists.txt patch & using libmem::libmem & remove Findcapstone
luadebug Nov 7, 2024
b7d485d
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 7, 2024
a7c45ca
Update ports/libmem/usage
luadebug Nov 7, 2024
e549b09
Update ports/libmem/vcpkg.json
luadebug Nov 7, 2024
bdba5fe
Fix according dg0yt changes
luadebug Nov 7, 2024
feab298
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 7, 2024
53ea731
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 7, 2024
c8c66cc
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 7, 2024
3342a61
trimmed cmakelists.txt
luadebug Nov 8, 2024
b398229
trimmed cmakelists.txt
luadebug Nov 8, 2024
e4225df
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 8, 2024
8aac5db
fix trim diff
luadebug Nov 8, 2024
7d1052b
fix trim diff
luadebug Nov 8, 2024
7b2d43d
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 8, 2024
d7a28be
fix
luadebug Nov 8, 2024
f65880d
fix
luadebug Nov 8, 2024
dc90205
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 8, 2024
e31c2a5
fix2
luadebug Nov 8, 2024
38c3e65
fix2
luadebug Nov 8, 2024
247a2b0
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 8, 2024
41d64f3
fix3
luadebug Nov 8, 2024
45b4763
fix3
luadebug Nov 8, 2024
342696c
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 8, 2024
a9d76e2
upd
luadebug Nov 8, 2024
8bc4453
upd
luadebug Nov 8, 2024
95f9341
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 8, 2024
9679376
Removed findkeystone & rely over pkgconfig
luadebug Nov 10, 2024
4cfba38
Removed findkeystone & rely over pkgconfig
luadebug Nov 10, 2024
76e66cd
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 10, 2024
e835401
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 10, 2024
f275d3e
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 10, 2024
ecefcf5
version
luadebug Nov 10, 2024
11d0c96
Tests
luadebug Nov 11, 2024
9806266
Tests
luadebug Nov 11, 2024
e253687
Merge branch 'master' of https://github.com/luadebug/vcpkg
luadebug Nov 11, 2024
22d43e4
Update ports/libmem/0001-CMakeLists.patch
luadebug Nov 14, 2024
df2d3a2
Update ports/libmem/0001-CMakeLists.patch
luadebug Nov 14, 2024
81a202c
Update ports/libmem/libmem-config.cmake.in
luadebug Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 188 additions & 0 deletions ports/libmem/0001-CMakeLists.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.22.1)

-include(ExternalProject)
+

project(libmem
LANGUAGES
@@ -13,23 +13,23 @@ message(STATUS
"[*] Platform: ${CMAKE_SYSTEM_NAME}"
)

-option(LIBMEM_BUILD_TESTS
- "Build tests"
- OFF
-)
-
-option(LIBMEM_DEEP_TESTS
- "Enable extra testing features for deep testing"
- OFF
-)
luadebug marked this conversation as resolved.
Show resolved Hide resolved
+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 +65,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 IMPORTED_TARGET keystone)
luadebug marked this conversation as resolved.
Show resolved Hide resolved
+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,17 +93,14 @@ 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})
-endif()
+ add_library(libmem ${LIBMEM_SRC} ${LLVM_DEM_SRC})
+
target_include_directories(libmem PRIVATE "${LIBMEM_DIR}/src" "${INTERNAL_DIR}" "${COMMON_DIR}")

include_directories(${PROJECT_SOURCE_DIR}
@@ -108,18 +109,21 @@ include_directories(${PROJECT_SOURCE_DIR}
${KEYSTONE_INC}
${LLVM_INC}
)
-
-if (LIBMEM_BUILD_TESTS)
+endif()
+if (0)
luadebug marked this conversation as resolved.
Show resolved Hide resolved
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)
-add_dependencies(libmem
- capstone-engine
- keystone-engine
-)
+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)
+
+
+
+

if(${CMAKE_SYSTEM_NAME} STREQUAL Windows OR ${CMAKE_SYSTEM_NAME} STREQUAL CYGWIN)
set(LIBMEM_DEPS
@@ -151,8 +155,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} PkgConfig::keystone capstone::capstone)
luadebug marked this conversation as resolved.
Show resolved Hide resolved
+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 +197,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 +206,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
+)
55 changes: 55 additions & 0 deletions ports/libmem/api-h.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
--- a/include/libmem/api.h
+++ b/include/libmem/api.h
@@ -0,0 +1,52 @@
+/*
+ * ----------------------------------
+ * | libmem - by rdbo |
+ * | Memory Hacking Library |
+ * ----------------------------------
+ */
+
+/*
+ * Copyright (C) 2023 Rdbo
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License version 3
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBMEM_API_H
+#define LIBMEM_API_H
+
+/* Export prefix for functions */
+#ifdef _MSC_VER
+ /* MSVC */
+# define LM_API_EXPORT __declspec(dllexport)
+#else
+ /* GCC/Clang */
+# define LM_API_EXPORT __attribute__((visibility("default")))
+#endif
+
+/* Import prefix for functions */
+#ifdef _MSC_VER
+# define LM_API_IMPORT __declspec(dllimport)
+#else
+# define LM_API_IMPORT extern
+#endif
+
+/* Resolve import/export */
+#ifdef LM_EXPORT
+# define LM_API LM_API_EXPORT
+#else
+# define LM_API LM_API_IMPORT
+#endif
+
+/* Calling convention */
+#define LM_CALL
+
+#endif
10 changes: 10 additions & 0 deletions ports/libmem/libmem-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)
find_dependency(capstone CONFIG)

find_dependency(PkgConfig)
luadebug marked this conversation as resolved.
Show resolved Hide resolved
pkg_check_modules(keystone REQUIRED IMPORTED_TARGET keystone)

luadebug marked this conversation as resolved.
Show resolved Hide resolved
include("${CMAKE_CURRENT_LIST_DIR}/libmem-target.cmake")
check_required_components(libmem)
luadebug marked this conversation as resolved.
Show resolved Hide resolved
35 changes: 35 additions & 0 deletions ports/libmem/libmem-h.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
--- a/include/libmem/libmem.h
+++ b/include/libmem/libmem.h
@@ -23,31 +23,7 @@
#ifndef LIBMEM_H
#define LIBMEM_H

-/* Export prefix for functions */
-#ifdef _MSC_VER
- /* MSVC */
-# define LM_API_EXPORT __declspec(dllexport)
-#else
- /* GCC/Clang */
-# define LM_API_EXPORT __attribute__((visibility("default")))
-#endif
-
-/* Import prefix for functions */
-#ifdef _MSC_VER
-# define LM_API_IMPORT __declspec(dllimport)
-#else
-# define LM_API_IMPORT extern
-#endif
-
-/* Resolve import/export */
-#ifdef LM_EXPORT
-# define LM_API LM_API_EXPORT
-#else
-# define LM_API LM_API_IMPORT
-#endif
-
-/* Calling convention */
-#define LM_CALL
+#include "api.h"

/* Constants */
#define LM_NULL (0)
Loading