@@ -14,7 +14,7 @@ set(CMAKE_C_STANDARD 11)
14
14
15
15
auto_source_group("." "auto-source-group" "\\ .(cc|cpp|c|h)$" )
16
16
17
- # ===== handle option =====
17
+ # --- options
18
18
19
19
option (DOBBY_DEBUG "Enable debug logging" OFF )
20
20
@@ -28,45 +28,54 @@ option(Plugin.ImportTableReplace "Enable import table replace " OFF)
28
28
29
29
option (Plugin.Android.BionicLinkerUtil "Enable android bionic linker util" OFF )
30
30
31
- option (BUILD_EXAMPLE "Build example" OFF )
31
+ option (DOBBY_BUILD_EXAMPLE "Build example" OFF )
32
32
33
- option (BUILD_TEST "Build test" OFF )
33
+ option (DOBBY_BUILD_TEST "Build test" OFF )
34
34
35
- # private
36
- option (Obfuscation "Enable llvm obfuscation " OFF )
35
+ # --- private
36
+ option (DOBBY_BUILD_KERNEL_MODE "Build xnu kernel mode " OFF )
37
37
38
- # private
39
- option (BUILD_KERNEL_MODE "Build xnu kernel mode" OFF )
38
+ option (Private .Obfuscation "Enable llvm obfuscation" OFF )
40
39
41
- # Enable debug will log more information
42
40
if ((NOT DEFINED CMAKE_BUILD_TYPE ) OR (CMAKE_BUILD_TYPE STREQUAL "Debug" ))
43
41
set (DOBBY_DEBUG ON )
44
42
endif ()
45
43
46
- if (DOBBY_DEBUG)
47
- add_definitions (-DDOBBY_DEBUG)
48
- add_definitions (-DLOGGING_DEBUG)
49
- message (STATUS "[Dobby] Enable debug logging" )
50
- endif ()
51
44
52
- # Enable full floating point register pack
45
+ set (compile_definitions "" )
46
+
53
47
# for arm64, allow access q8 - q31
54
48
if (FullFloatingPointRegisterPack)
55
- add_definitions (-DFULL_FLOATING_POINT_REGISTER_PACK)
56
- message (STATUS "[Dobby] Save and pack all floating-point registers" )
49
+ set (compile_definitions "${compile_definitions} -DFULL_FLOATING_POINT_REGISTER_PACK" )
57
50
endif ()
58
51
59
- if (BUILD_KERNEL_MODE)
60
- set (BUILDING_KERNEL ON )
61
- add_definitions (-DBUILDING_KERNEL)
62
- message (STATUS "[Dobby] Build xnu kernel mode" )
52
+ if (DOBBY_BUILD_KERNEL_MODE)
53
+ set (compile_definitions "${compile_definitions} -DBUILDING_KERNEL" )
54
+ endif ()
55
+
56
+ if (DOBBY_DEBUG)
57
+ set (compile_definitions "${compile_definitions} -DDOBBY_DEBUG" )
58
+ else ()
59
+ set (compile_definitions "${compile_definitions} -DDOBBY_LOGGING_DISABLE" )
63
60
endif ()
64
61
65
62
if (CMAKE_GENERATOR STREQUAL Xcode)
66
63
endif ()
67
64
68
65
include (cmake/compiler_and_linker.cmake)
69
66
67
+ message (STATUS "[Dobby] CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE} " )
68
+ message (STATUS "[Dobby] DOBBY_DEBUG: ${DOBBY_DEBUG} " )
69
+ message (STATUS "[Dobby] NearBranch: ${NearBranch} " )
70
+ message (STATUS "[Dobby] FullFloatingPointRegisterPack: ${FullFloatingPointRegisterPack} " )
71
+ message (STATUS "[Dobby] Plugin.SymbolResolver: ${Plugin.SymbolResolver}" )
72
+ message (STATUS "[Dobby] Plugin.ImportTableReplace: ${Plugin.ImportTableReplace}" )
73
+ message (STATUS "[Dobby] Plugin.Android.BionicLinkerUtil: ${Plugin.Android.BionicLinkerUtil}" )
74
+ message (STATUS "[Dobby] DOBBY_BUILD_EXAMPLE: ${DOBBY_BUILD_EXAMPLE} " )
75
+ message (STATUS "[Dobby] DOBBY_BUILD_TEST: ${DOBBY_BUILD_TEST} " )
76
+ message (STATUS "[Dobby] DOBBY_BUILD_KERNEL_MODE: ${DOBBY_BUILD_KERNEL_MODE} " )
77
+ message (STATUS "[Dobby] Private.Obfuscation: ${Private.Obfuscation}" )
78
+
70
79
# ---
71
80
72
81
include_directories (
@@ -81,7 +90,7 @@ include_directories(
81
90
./builtin-plugin
82
91
)
83
92
84
- if (SYSTEM .Darwin AND BUILDING_KERNEL )
93
+ if (SYSTEM .Darwin AND DOBBY_BUILD_KERNEL_MODE )
85
94
include_directories (
86
95
source /Backend/KernelMode
87
96
)
@@ -168,7 +177,7 @@ set(dobby.SOURCE_FILE_LIST ${dobby.SOURCE_FILE_LIST}
168
177
source /InterceptEntry.cpp
169
178
)
170
179
171
- if (SYSTEM .Darwin AND BUILDING_KERNEL )
180
+ if (SYSTEM .Darwin AND DOBBY_BUILD_KERNEL_MODE )
172
181
set (dobby.SOURCE_FILE_LIST ${dobby.SOURCE_FILE_LIST}
173
182
# platform util
174
183
source /Backend/KernelMode/PlatformUtil/Darwin/ProcessRuntimeUtility.cc
@@ -226,11 +235,11 @@ endif ()
226
235
227
236
# ---
228
237
229
- if (0 AND SYSTEM .iOS AND (NOT BUILDING_KERNEL ))
238
+ if (0 AND SYSTEM .iOS AND (NOT DOBBY_BUILD_KERNEL_MODE ))
230
239
include_directories (
231
240
source /Backend/UserMode/ExecMemory/substrated
232
241
)
233
- add_definitions ( -DCODE_PATCH_WITH_SUBSTRATED)
242
+ set ( compile_definitions " ${compile_definitions} -DCODE_PATCH_WITH_SUBSTRATED" )
234
243
set (dobby.SOURCE_FILE_LIST ${dobby.SOURCE_FILE_LIST}
235
244
source /Backend/UserMode/ExecMemory/substrated/mach_interface_support
236
245
)
@@ -251,7 +260,6 @@ endif ()
251
260
# ---
252
261
253
262
if (NearBranch)
254
- message (STATUS "[Dobby] Enable near branch trampoline" )
255
263
set (dobby.SOURCE_FILE_LIST ${dobby.SOURCE_FILE_LIST}
256
264
source /InterceptRouting/RoutingPlugin/NearBranchTrampoline/near_trampoline_arm64.cc
257
265
source /InterceptRouting/RoutingPlugin/NearBranchTrampoline/NearBranchTrampoline.cc
@@ -266,10 +274,10 @@ get_target_property(logging.SOURCE_FILE_LIST logging SOURCES)
266
274
267
275
# add osbase library
268
276
add_subdirectory (external/osbase)
277
+
269
278
# ---
270
279
271
280
if (Plugin.SymbolResolver)
272
- message (STATUS "[Dobby] Enable symbol resolver" )
273
281
include_directories (builtin-plugin/SymbolResolver)
274
282
add_subdirectory (builtin-plugin/SymbolResolver)
275
283
get_target_property (symbol_resolver.SOURCE_FILE_LIST dobby_symbol_resolver SOURCES )
@@ -301,7 +309,7 @@ if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
301
309
endif ()
302
310
endif ()
303
311
set (DOBBY_BUILD_VERSION "Dobby${VERSION_REVISION} " )
304
- add_definitions ( -D__DOBBY_BUILD_VERSION__="${DOBBY_BUILD_VERSION} " )
312
+ set ( compile_definitions " ${compile_definitions} -D__DOBBY_BUILD_VERSION__=\ "${DOBBY_BUILD_VERSION} \" " )
305
313
message (STATUS "[Dobby] ${DOBBY_BUILD_VERSION} " )
306
314
307
315
# ---
@@ -314,7 +322,9 @@ add_library(dobby SHARED
314
322
${dobby.plugin.SOURCE_FILE_LIST}
315
323
)
316
324
317
- target_include_directories (dobby PUBLIC include )
325
+ target_include_directories (dobby PUBLIC
326
+ include
327
+ )
318
328
319
329
# ---
320
330
@@ -326,16 +336,16 @@ add_library(dobby_static STATIC
326
336
${dobby.plugin.SOURCE_FILE_LIST}
327
337
)
328
338
329
- target_include_directories (dobby_static PUBLIC include )
339
+ target_include_directories (dobby_static PUBLIC
340
+ include
341
+ )
330
342
331
- set_target_properties (dobby_static PROPERTIES OUTPUT_NAME "dobby" )
343
+ set_target_properties (dobby_static
344
+ PROPERTIES OUTPUT_NAME "dobby"
345
+ )
332
346
333
347
# ---
334
348
335
- if (Obfuscation)
336
- set (linker_flags "${linker_flags} -Wl,-mllvm -Wl,-obfuscator-conf=all" )
337
- endif ()
338
-
339
349
set_target_properties (dobby
340
350
PROPERTIES
341
351
LINK_FLAGS "${linker_flags} "
@@ -347,6 +357,19 @@ set_target_properties(dobby_static
347
357
COMPILE_FLAGS "${compiler_flags} "
348
358
)
349
359
360
+ target_compile_definitions (dobby PRIVATE
361
+ "COMPILE_DEFINITIONS ${compile_definitions} "
362
+ )
363
+ target_compile_definitions (dobby_static PRIVATE
364
+ "COMPILE_DEFINITIONS ${compile_definitions} "
365
+ )
366
+
367
+ # ---
368
+
369
+ if (Private .Obfuscation)
370
+ set (linker_flags "${linker_flags} -Wl,-mllvm -Wl,-obfuscator-conf=all" )
371
+ endif ()
372
+
350
373
# ---
351
374
352
375
if (SYSTEM .Android)
@@ -369,16 +392,16 @@ endif ()
369
392
370
393
# ---
371
394
372
- if (BUILD_EXAMPLE AND (NOT BUILDING_KERNEL ))
395
+ if (DOBBY_BUILD_EXAMPLE AND (NOT DOBBY_BUILD_KERNEL_MODE ))
373
396
add_subdirectory (examples)
374
397
endif ()
375
398
376
- if (BUILD_TEST AND (NOT BUILDING_KERNEL ))
399
+ if (DOBBY_BUILD_TEST AND (NOT DOBBY_BUILD_KERNEL_MODE ))
377
400
add_subdirectory (tests)
378
401
endif ()
379
402
380
403
# ---
381
404
382
- if (SYSTEM .Darwin AND (NOT BUILDING_KERNEL ))
405
+ if (SYSTEM .Darwin AND (NOT DOBBY_BUILD_KERNEL_MODE ))
383
406
include (cmake/platform/platform-darwin.cmake)
384
407
endif ()
0 commit comments