-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
335 lines (305 loc) · 9.32 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
cmake_minimum_required (VERSION 3.5)
project (decomp)
ENABLE_LANGUAGE(ASM_MASM)
SET(CMAKE_WARN_VS6 CACHE BOOL OFF)
add_library (mss32 SHARED
Source/3rdParty/mss.h
Source/3rdParty/mss.cpp
)
target_compile_definitions(mss32 PRIVATE BUILD_MSS)
#add_custom_command (
# TARGET mss32
# POST_BUILD
# COMMAND del $(TargetPath)
#)
# we build the code 3 times as:
# a static lib where by we link it to an exe that is supposed to match the OG as closely as possible
# a dll that contains the global vars as being exported and no functions exported
# a dll that contains the global vars as being imported and all functions exported
# this is so that for the hook dll we can redirect importing the vars from the 2nd copy of the dll
# to the actual executable data/vars
set(gta2_lib_src
Source/angle.cpp
Source/angle.hpp
Source/crt_stubs.cpp
Source/crt_stubs.hpp
Source/Globals.cpp
Source/Globals.hpp
Source/3rdParty/mss.h
Source/types.hpp
Source/winmain.cpp
Source/frosty_pasteur_0xC1EA8.hpp
Source/frosty_pasteur_0xC1EA8.cpp
Source/map_0x370.hpp
Source/map_0x370.cpp
Source/nostalgic_ellis_0x28.hpp
Source/nostalgic_ellis_0x28.cpp
Source/BitSet32.hpp
Source/fix16.hpp
Source/fix16.cpp
Source/ang16.hpp
Source/ang16.cpp
Source/error.hpp
Source/error.cpp
Source/memory.hpp
Source/memory.cpp
Source/chunk.hpp
Source/keybrd_0x204.hpp
Source/keybrd_0x204.cpp
Source/debug.hpp
Source/debug.cpp
Source/cSampleManager.hpp
Source/cSampleManager.cpp
Source/sound_obj.hpp
Source/sound_obj.cpp
Source/dma_video.hpp
Source/dma_video.cpp
Source/magical_germain_0x8EC.hpp
Source/magical_germain_0x8EC.cpp
Source/sharp_pare_0x15D8.hpp
Source/sharp_pare_0x15D8.cpp
Source/Bink.hpp
Source/Bink.cpp
Source/gbh_graphics.hpp
Source/gbh_graphics.cpp
Source/text_0x14.hpp
Source/text_0x14.cpp
Source/root_sound.hpp
Source/root_sound.cpp
Source/angry_lewin_0x85C.hpp
Source/angry_lewin_0x85C.cpp
Source/laughing_blackwell_0x1EB54.hpp
Source/laughing_blackwell_0x1EB54.cpp
Source/Game_0x40.hpp
Source/Game_0x40.cpp
Source/jolly_poitras_0x2BC0.hpp
Source/jolly_poitras_0x2BC0.cpp
Source/goofy_thompson.hpp
Source/goofy_thompson.cpp
Source/input.hpp
Source/input.cpp
Source/lucid_hamilton.hpp
Source/lucid_hamilton.cpp
Source/registry.hpp
Source/registry.cpp
Source/file.hpp
Source/file.cpp
Source/sharp_bose_0x54.hpp
Source/sharp_bose_0x54.cpp
Source/distracted_einstein_0xC.hpp
Source/distracted_einstein_0xC.cpp
Source/gtx_0x106C.hpp
Source/gtx_0x106C.cpp
Source/Function.hpp
Source/DrawUnk_0xBC.hpp
Source/DrawUnk_0xBC.cpp
Source/cool_nash_0x294.hpp
Source/cool_nash_0x294.cpp
Source/Car_BC.hpp
Source/Car_BC.cpp
Source/Car_10.hpp
Source/Car_10.cpp
Source/Ped_Unknown_4.hpp
Source/Ped_Unknown_4.cpp
Source/zealous_borg.hpp
Source/zealous_borg.cpp
Source/infallible_turing.hpp
Source/infallible_turing.cpp
Source/sad_mirzakhani.hpp
Source/sad_mirzakhani.cpp
Source/Zones_CA8.hpp
Source/Zones_CA8.cpp
Source/youthful_einstein.hpp
Source/youthful_einstein.cpp
Source/xenodochial_morse.hpp
Source/xenodochial_morse.cpp
Source/sleepy_stonebraker_0x6C.hpp
Source/sleepy_stonebraker_0x6C.cpp
Source/miss2_0x11C.hpp
Source/miss2_0x11C.cpp
Source/miss2_8.hpp
Source/miss2_8.cpp
Source/BurgerKing_67F8B0.hpp
Source/BurgerKing_67F8B0.cpp
Source/Garox_2B00.hpp
Source/Garox_2B00.cpp
Source/Nanobotz.hpp
Source/Nanobotz.cpp
Source/Montana.hpp
Source/Montana.cpp
Source/Mike_A80.hpp
Source/Mike_A80.cpp
Source/Frismo_25C.hpp
Source/Frismo_25C.cpp
Source/sprite.hpp
Source/sprite.cpp
Source/char.hpp
Source/char.cpp
Source/collide.hpp
Source/collide.cpp
Source/Phi_8CA8.hpp
Source/Phi_8CA8.cpp
Source/Object_5C.hpp
Source/Object_5C.cpp
Source/Varrok_7F8.hpp
Source/Varrok_7F8.cpp
Source/TileAnim_2.hpp
Source/TileAnim_2.cpp
Source/Weapon_8.hpp
Source/Weapon_8.cpp
Source/Door_4D4.hpp
Source/Door_4D4.cpp
Source/jawwie_110.hpp
Source/jawwie_110.cpp
Source/Sero_181C.hpp
Source/Sero_181C.cpp
Source/Taxi_4.hpp
Source/Taxi_4.cpp
Source/TrafficLights_194.hpp
Source/TrafficLights_194.cpp
Source/Soula_CC68.hpp
Source/Soula_CC68.cpp
Source/Marz_1D7E.hpp
Source/Marz_1D7E.cpp
Source/Orca_2FD4.hpp
Source/Orca_2FD4.cpp
Source/Monster_808.hpp
Source/Monster_808.cpp
Source/Particle_8.hpp
Source/Particle_8.cpp
Source/Wolfy_3D4.hpp
Source/Wolfy_3D4.cpp
Source/Zheal_D9C.hpp
Source/Zheal_D9C.cpp
Source/Snooky_94.hpp
Source/Snooky_94.cpp
Source/Maccies_14AC.hpp
Source/Maccies_14AC.cpp
Source/Kfc_1E0.hpp
Source/Kfc_1E0.cpp
Source/Police_7B8.hpp
Source/Police_7B8.cpp
Source/Light_1D4CC.hpp
Source/Light_1D4CC.cpp
Source/ChickenLegend_48.hpp
Source/ChickenLegend_48.cpp
Source/Hamburger_500.hpp
Source/Hamburger_500.cpp
Source/CokeZero_100.hpp
Source/CokeZero_100.cpp
Source/Shooey_CC.hpp
Source/Shooey_CC.cpp
Source/Tango_28.hpp
Source/Tango_28.cpp
Source/Rozza_C88.hpp
Source/Rozza_C88.cpp
Source/PurpleDoom.hpp
Source/PurpleDoom.cpp
Source/Network_20324.hpp
Source/Network_20324.cpp
Source/Mouze_44.hpp
Source/Mouze_44.cpp
Source/rng.hpp
Source/rng.cpp
Source/eager_benz.hpp
Source/eager_benz.cpp
Source/thirsty_lamarr.hpp
Source/thirsty_lamarr.cpp
Source/enums.hpp
Source/Car_B0.hpp
Source/Car_B0.cpp
Source/Miss2_25C.hpp
Source/Miss2_25C.cpp
Source/Object_8.hpp
Source/Object_8.cpp
Source/Object_226C.hpp
Source/Object_226C.cpp
Source/Object_5A40.hpp
Source/Object_5A40.cpp
Source/Object_3C.hpp
Source/Object_3C.cpp
Source/Object_29178.hpp
Source/Object_29178.cpp
Source/Particle_4C.hpp
Source/Particle_4C.cpp
Source/keen_bhaskara_0x30.hpp
Source/keen_bhaskara_0x30.cpp
)
# turn off intrinsic functions so we actually get a call to strcpy, enable stdcall calling convention
# else static methods don't match (and I doubt they manually annotated them with __stdcall)
set_source_files_properties(Source/Network_20324.cpp PROPERTIES COMPILE_FLAGS "/Oi- /Gz")
set_source_files_properties(Source/miss2_0x11C.cpp PROPERTIES COMPILE_FLAGS "/GX-")
set_source_files_properties(Source/sharp_bose_0x54.cpp PROPERTIES COMPILE_FLAGS "/GX-")
# global include dirs
include_directories(Source)
include_directories(${decomp_SOURCE_DIR})
include_directories(3rdParty/gta2_re_compile_tools)
# global lib dirs
#link_directories(${CMAKE_SOURCE_DIR}/gta2_lib)
set(dplay_libs
${CMAKE_SOURCE_DIR}/3rdParty/gta2_re_compile_tools/VC98/Lib/DPLAYX.lib)
add_library (gta2_lib ${gta2_lib_src})
target_compile_definitions(gta2_lib PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NON_CONFORMING_SWPRINTFS)
target_link_libraries(gta2_lib)
add_library (gta2_dll_exports SHARED ${gta2_lib_src})
target_compile_definitions(gta2_dll_exports PRIVATE EXPORT_VARS _CRT_SECURE_NO_WARNINGS _CRT_NON_CONFORMING_SWPRINTFS)
target_link_libraries(gta2_dll_exports mss32 Winmm ${dplay_libs})
add_library (gta2_dll_imports SHARED ${gta2_lib_src} Source/WinMainProxy.cpp)
target_compile_definitions(gta2_dll_imports PRIVATE IMPORT_VARS EXPORT_FUNCS _CRT_SECURE_NO_WARNINGS _CRT_NON_CONFORMING_SWPRINTFS)
target_link_libraries(gta2_dll_imports gta2_dll_exports mss32 Winmm ${dplay_libs})
add_library(HookLoader SHARED
Source/HookLoader.cpp
Source/3rdParty/Detours/src/detours.cpp
Source/3rdParty/Detours/src/disasm.cpp
"Source/3rdParty/Manual-DLL-Loader/Source/Manual Loader/Loader.cpp"
)
target_compile_definitions(HookLoader PRIVATE DETOURS_X86 DETOURS_32BIT)
add_executable (ExePatcher
Source/ExePatcher.cpp)
add_executable (decomp_main WIN32
test.cpp
StdAfx.cpp
resources.rc)
target_link_libraries(decomp_main mss32 gta2_lib ${dplay_libs})
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS")
# NOICF is required because skip_ovly_5AAE20 and skip_psxt_5AAE30 have identical bodies and the linker will make them one and the same
# however the real binary does have 2 copies. NOREF keeps functions that are not yet called so we can diff the content against the original.
if (${MSVC_VERSION} GREATER 1200)
set (CMAKE_EXE_LINKER_FLAGS "/MAP:output.map /OPT:NOICF,NOREF /SAFESEH:NO" )
else()
set (CMAKE_EXE_LINKER_FLAGS "/MAP:output.map /OPT:NOICF,NOREF" )
endif()
set (CMAKE_SHARED_LINKER_FLAGS "/OPT:NOICF,NOREF")
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
if (${MSVC_VERSION} EQUAL 1200)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/ML /W3 /GX" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/Zi" "/Z7" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/Ob2" "" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/GR" "/EHsc" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
endif()
message(STATUS "${MSVC_VERSION}=${${MSVC_VERSION}}")
if (${MSVC_VERSION} GREATER 1200)
SET ( CMAKE_SHARED_LINKER_FLAGS /MANIFEST:NO )
if (NOT DEFINED ENV{CI})
add_custom_command(TARGET decomp_main POST_BUILD
COMMAND python build.py
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running build.py (VC6 build)")
endif()
endif()
#install (TARGETS decomp_main DESTINATION bin)