-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
129 lines (98 loc) · 4.83 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
cmake_minimum_required(VERSION 3.21)
project(lime LANGUAGES CXX VERSION 6.1)
# --------------------------------------------------------------------------------------------------------
# Library options
# --------------------------------------------------------------------------------------------------------
option(lime_tests "Build tests" OFF)
option(lime_no_alloc2 "Disables VirtualAlloc2" OFF)
option(lime_static_entrypoint "Use platform independent entrypoint implementation" OFF)
# --------------------------------------------------------------------------------------------------------
# CMake options
# --------------------------------------------------------------------------------------------------------
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# --------------------------------------------------------------------------------------------------------
# Setup library
# --------------------------------------------------------------------------------------------------------
add_library(${PROJECT_NAME} STATIC)
add_library(cr::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON)
if (NOT MSVC)
if (PROJECT_IS_TOP_LEVEL AND NOT CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror -pedantic -pedantic-errors -Wfatal-errors)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(${PROJECT_NAME} PUBLIC -Wno-attributes=lime::)
else()
target_compile_options(${PROJECT_NAME} PUBLIC -Wno-unknown-attributes)
endif()
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-unknown-warning-option)
endif()
# --------------------------------------------------------------------------------------------------------
# Setup includes
# --------------------------------------------------------------------------------------------------------
target_include_directories(${PROJECT_NAME} PUBLIC "include")
target_include_directories(${PROJECT_NAME} PRIVATE "private" "include/lime")
# --------------------------------------------------------------------------------------------------------
# Setup sources
# --------------------------------------------------------------------------------------------------------
target_sources(${PROJECT_NAME} PRIVATE
"src/disasm.cpp"
"src/address.cpp"
"src/hooks.hook.cpp"
"src/instruction.cpp"
"src/utils.signature.cpp"
)
# --------------------------------------------------------------------------------------------------------
# Setup cmake exports
# --------------------------------------------------------------------------------------------------------
include("cmake/proxy.cmake")
# --------------------------------------------------------------------------------------------------------
# Setup required libraries
# --------------------------------------------------------------------------------------------------------
include("cmake/cpm.cmake")
CPMAddPackage(
NAME Zydis
VERSION 4.1.0
GIT_REPOSITORY "https://github.com/zyantific/zydis"
)
CPMAddPackage(
NAME flagpp
VERSION 2.1
GIT_REPOSITORY "https://github.com/Curve/flagpp"
)
CPMAddPackage(
NAME expected
VERSION 1.1.0
GIT_REPOSITORY "https://github.com/TartanLlama/expected"
OPTIONS "EXPECTED_BUILD_TESTS OFF"
)
target_link_libraries(${PROJECT_NAME} PRIVATE Zydis)
target_link_libraries(${PROJECT_NAME} PUBLIC cr::flagpp tl::expected)
# --------------------------------------------------------------------------------------------------------
# Setup backends
# --------------------------------------------------------------------------------------------------------
if (UNIX AND NOT MINGW)
file(GLOB src "src/*.linux*.cpp")
endif()
if (WIN32)
file(GLOB src "src/*.win*.cpp")
target_compile_definitions(${PROJECT_NAME} PRIVATE NOMINMAX)
endif()
target_sources(${PROJECT_NAME} PRIVATE ${src})
# --------------------------------------------------------------------------------------------------------
# Setup compile definitions
# --------------------------------------------------------------------------------------------------------
if (lime_static_entrypoint)
target_compile_definitions(${PROJECT_NAME} PUBLIC LIME_STATIC_ENTRYPOINT)
endif()
if (lime_no_alloc2)
target_compile_definitions(${PROJECT_NAME} PUBLIC LIME_DISABLE_ALLOC2)
endif()
# --------------------------------------------------------------------------------------------------------
# Setup tests
# --------------------------------------------------------------------------------------------------------
if (lime_tests)
message(STATUS "[lime] Building tests")
add_subdirectory(tests)
endif()