-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
528 lines (454 loc) · 11.7 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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
set(CMAKE_C_STANDARD 11)
if("${TARGET}" STREQUAL "Pico")
cmake_minimum_required(VERSION 3.12)
set(CMAKE_CXX_STANDARD 17)
set(PICO_BOARD vgaboard)
# Pull in PICO SDK (must be before project)
include(pico_sdk_import.cmake)
# We also need PICO EXTRAS
include(pico_extras_import.cmake)
project(memu C CXX)
# Initialize the Pico SDK
pico_sdk_init()
add_executable(memu-pico)
# add_compile_options(-Werror -Wall -Wextra -Wnull-dereference)
# add_link_options(-g)
target_compile_options(memu-pico PUBLIC -O1 -g)
target_link_options(memu-pico PUBLIC -g)
target_compile_definitions(memu-pico PUBLIC
-DPICO_SCANVIDEO_MAX_SCANLINE_BUFFER_WORDS=322
-DPICO_SCANVIDEO_SCANLINE_BUFFER_COUNT=8
-DLSB_FIRST
-D__Pico__
-DPICO_PANIC_FUNCTION=fatal
-DSMALL_MEM
-DHAVE_SID
-DDYNAMIC_ROMS
-DALT_EXIT=exit_pico
-DHAVE_CONFIG
-DALT_OPTIONS=cfg_options
-DALT_USAGE=cfg_usage
-DALT_PRINTF=printf_pico
-DROM_PATCH_KBD
-DROM_PATCH_TAPE
-DMAP_PATH
-DHAVE_VDEB
-DHAVE_DISASS
-DZ80_DEBUG
)
if (SERIAL_DIAG)
pico_enable_stdio_uart(memu-pico 1)
target_compile_definitions(memu-pico PUBLIC -DSERIAL_DIAG=1)
else ()
pico_enable_stdio_uart(memu-pico 0)
endif ()
pico_enable_stdio_usb(memu-pico 0)
pico_add_extra_outputs(memu-pico)
target_link_libraries(memu-pico PUBLIC
memu_src
Z80_emu
fatfs
pico_stdlib
pico_sd_card
pico_scanvideo_dpi
pico_multicore
tinyusb_host
)
elseif("${TARGET}" STREQUAL "XWin")
set(src_defs
-DLSB_FIRST
-DDYNAMIC_ROMS
-DHAVE_CONFIG
-DUNIX
-DHAVE_AUTOTYPE
-DHAVE_CFX2
-DHAVE_CONSOLE
-DHAVE_DART
-DHAVE_DISASS
-DHAVE_JOY
-DHAVE_MFX
-DMAP_PATH
-DHAVE_OSFS
-DHAVE_SID
-DHAVE_SPEC
-DHAVE_UI
-DHAVE_VDEB
-DHAVE_VGA
-DHAVE_NFX
-DZ80_DEBUG
)
set (HAVE_HW FALSE)
if(HW_GPIO)
list(APPEND src_defs
-DHAVE_HW_GPIO=1
)
set (HAVE_HW TRUE)
endif()
if(HW_23017)
list(APPEND src_defs
-DHAVE_HW_MCP23017=1
)
set (HAVE_HW TRUE)
endif()
if(HAVE_HW)
list(APPEND src_defs
-DALT_HANDLE_EVENTS=hw_handle_events
-DALT_KBD_SENSE1=hw_kbd_sense_1
-DALT_KBD_SENSE2=hw_kbd_sense_2
-DALT_OPTIONS=hw_options
-DALT_USAGE=hw_usage
-DALT_Z80_OUT=hw_Z80_out
-DALT_Z80_IN=hw_Z80_in
)
else()
list(APPEND src_defs
-DALT_OPTIONS=cfg_options
-DALT_USAGE=cfg_usage
)
endif()
if(NOT (${CMAKE_VERSION} VERSION_LESS "3.12.0"))
project(memu C)
add_executable(memu-x)
set_target_properties(memu-x PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/run_time
)
target_compile_options(memu-x PUBLIC -g)
target_link_options(memu-x PUBLIC -g)
# target_compile_options(memu-x PUBLIC -fsanitize=address -fsanitize=leak)
# target_link_options(memu-x PUBLIC -fsanitize=address -fsanitize=leak -static-libasan)
target_compile_definitions(memu-x PUBLIC ${src_defs})
target_link_libraries(memu-x PUBLIC
memu_src
Z80_emu
portaudio
mcheck
X11
m
)
endif()
elseif("${TARGET}" STREQUAL "FBuf")
set(src_defs
-DLSB_FIRST
-DDYNAMIC_ROMS
-DHAVE_CONFIG
-DUNIX
-DHAVE_CFX2
-DHAVE_CONSOLE
-DHAVE_DART
-DHAVE_DISASS
-DHAVE_JOY
-DMAP_PATH
-DHAVE_OSFS
-DHAVE_SID
-DHAVE_SPEC
-DHAVE_UI
-DHAVE_VDEB
-DHAVE_VGA
-DHAVE_NFX
-DZ80_DEBUG
)
set (HAVE_HW FALSE)
if(HW_GPIO)
list(APPEND src_defs
-DHAVE_HW_GPIO=1
)
set (HAVE_HW TRUE)
endif()
if(HW_23017)
list(APPEND src_defs
-DHAVE_HW_MCP23017=1
)
set (HAVE_HW TRUE)
endif()
if(HAVE_HW)
list(APPEND src_defs
-DALT_HANDLE_EVENTS=hw_handle_events
-DALT_KBD_SENSE1=hw_kbd_sense_1
-DALT_KBD_SENSE2=hw_kbd_sense_2
-DALT_OPTIONS=hw_options
-DALT_USAGE=hw_usage
-DALT_Z80_OUT=hw_Z80_out
-DALT_Z80_IN=hw_Z80_in
)
else()
list(APPEND src_defs
-DALT_OPTIONS=cfg_options
-DALT_USAGE=cfg_usage
)
endif()
if(NOT (${CMAKE_VERSION} VERSION_LESS "3.12.0"))
project(memu C)
add_executable(memu-fb)
set_target_properties(memu-fb PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/run_time
)
# add_compile_options(-g)
# add_link_options(-g)
target_compile_definitions(memu-fb PUBLIC ${src_defs})
target_link_libraries(memu-fb PUBLIC
memu_src
Z80_emu
portaudio
m
)
endif()
elseif("${TARGET}" STREQUAL "RPi")
project(memu C)
add_executable(memu-pi)
set_target_properties(memu-pi PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/run_time
)
# add_compile_options(-g)
# add_link_options(-g)
target_include_directories(memu-pi PUBLIC
/opt/vc/include
/opt/vc/include/interface/vcos/pthreads
/opt/vc/include/interface/vmcs_host/linux
)
target_compile_definitions(memu-pi PUBLIC
-DLSB_FIRST
-DDYNAMIC_ROMS
-DALT_HANDLE_EVENTS=hw_handle_events
-DALT_KBD_SENSE1=hw_kbd_sense_1
-DALT_KBD_SENSE2=hw_kbd_sense_2
-DHAVE_CONFIG
-DALT_OPTIONS=hw_options
-DALT_USAGE=hw_usage
-DALT_Z80_OUT=hw_Z80_out
-DALT_Z80_IN=hw_Z80_in
-DUNIX
-DHAVE_CFX2
-DHAVE_CONSOLE
-DHAVE_DART
-DHAVE_DISASS
-DHAVE_JOY
-DMAP_PATH
-DHAVE_OSFS
-DHAVE_SID
-DHAVE_SPEC
-DHAVE_UI
-DHAVE_VDEB
-DHAVE_VGA
-DZ80_DEBUG
)
target_link_options(memu-pi PUBLIC -L/opt/vc/lib)
target_link_libraries(memu-pi PUBLIC
memu_src
Z80_emu
portaudio
bcm_host
vcos
vchostif
vchiq_arm
m
)
elseif("${TARGET}" STREQUAL "Win")
set(src_defs
-D_CRT_SECURE_NO_WARNINGS
-DLSB_FIRST
-DDYNAMIC_ROMS
-DHAVE_CONFIG
-DALT_OPTIONS=cfg_options
-DALT_USAGE=cfg_usage
-DWIN32
-DHAVE_AUTOTYPE
-DHAVE_CFX2
-DHAVE_CONSOLE
-DHAVE_DISASS
-DHAVE_JOY
-DHAVE_MFX
-DMAP_PATH
-DHAVE_OSFS
-DHAVE_SID
-DHAVE_SPEC
-DHAVE_UI
-DHAVE_VDEB
-DHAVE_VGA
-DZ80_DEBUG
)
project(memu C)
add_executable(memu-win)
set_target_properties(memu-win PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_LIST_DIR}/run_time
)
add_subdirectory(../portaudio portaudio EXCLUDE_FROM_ALL)
set_target_properties(portaudio PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_LIST_DIR}/run_time
)
# add_compile_options(-g)
# add_link_options(-g)
target_compile_definitions(memu-win PUBLIC ${src_defs})
target_link_libraries(memu-win PUBLIC
memu_src
Z80_emu
portaudio
winmm
dinput8
Shcore
)
elseif("${TARGET}" STREQUAL "Circle")
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 14)
project(memu C CXX ASM)
set(CIRCLE_DIR ${CMAKE_CURRENT_LIST_DIR}/../circle)
set(CMAKE_LINKER ld)
set(CMAKE_CXX_LINK_EXECUTABLE
"<CMAKE_LINKER> -o <TARGET> <LINK_FLAGS> <OBJECTS> --start-group <LINK_LIBRARIES> --end-group")
if (NOT DEFINED RPI)
message(FATAL_ERROR "No Raspberry Pi version specified, use -DRPI=...")
elseif (${RPI} EQUAL 1)
set(ARCH -DAARCH=32 -mcpu=arm1176jzf-s -marm -mfpu=vfp -mfloat-abi=hard)
add_compile_definitions(RASPPI=1)
set(KERNEL kernel.img)
elseif (${RPI} EQUAL 2)
set(ARCH -DAARCH=32 -mcpu=cortex-a7 -marm -mfpu=neon-vfpv4 -mfloat-abi=hard)
add_compile_definitions(RASPPI=2)
set(KERNEL kernel7.img)
elseif (${RPI} EQUAL 3)
set(ARCH -DAARCH=32 -mcpu=cortex-a53 -marm -mfpu=neon-fp-armv8 -mfloat-abi=hard)
add_compile_definitions(RASPPI=3)
set(KERNEL kernel8-32.img)
elseif (${RPI} EQUAL 4)
set(ARCH -DAARCH=32 -mcpu=cortex-a72 -marm -mfpu=neon-fp-armv8 -mfloat-abi=hard)
add_compile_definitions(RASPPI=4)
set(KERNEL kernel7l.img)
else()
message(FATAL_ERROR "Invalid Raspberry Pi version")
endif()
add_compile_definitions(__circle__)
add_compile_options(${ARCH})
# add_compile_options(-nostdinc)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-nostdinc++>)
add_compile_options(-O2)
add_compile_options(-Wall -fsigned-char -ffreestanding)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-std=c++14>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-aligned-new>)
add_link_options(--section-start=.init=0x8000)
add_link_options(-T ${CIRCLE_DIR}/circle.ld)
add_compile_definitions(
STDLIB_SUPPORT=1
__VCCOREVER__=0x04000000
)
add_compile_options(
-U__unix__
-U__linux__
)
execute_process(COMMAND ${CMAKE_C_COMPILER} ${ARCH} -print-file-name=libgcc.a
OUTPUT_VARIABLE LIBGCC_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${CMAKE_C_COMPILER} ${ARCH} -print-file-name=libm.a
OUTPUT_VARIABLE LIBM_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE)
add_executable(memu-circle)
# add_compile_options(-g)
# add_link_options(-g)
target_compile_definitions(memu-circle PUBLIC
-DAARCH=32
-D__circle__
-DUNIX
-DLINUX
-DLSB_FIRST
-DDYNAMIC_ROMS
-DHAVE_AUTOTYPE
-DHAVE_CFX2
-DHAVE_DISASS
-DHAVE_OSFS
-DHAVE_SID
-DHAVE_SPEC
-DHAVE_UI
-DHAVE_VDEB
-DHAVE_VGA
-DALT_EXIT=hw_exit
-DALT_INIT=hw_init
-DHAVE_CONFIG
-DALT_OPTIONS=hw_options
-DALT_USAGE=hw_usage
-DALT_Z80_OUT=hw_Z80_out
-DALT_Z80_IN=hw_Z80_in
-DALT_KBD_SENSE1=hw_kbd_sense_1
-DALT_KBD_SENSE2=hw_kbd_sense_2
-DALT_KEYIN=hw_key_scan
-DALT_HANDLE_EVENTS=hw_handle_events
-DALT_PRINTF=printf_circle
-DUSE_VCHIQ_SOUND=1
-DZ80_DEBUG
)
include_directories(
${CMAKE_CURRENT_LIST_DIR}/src/circle/include
${CIRCLE_DIR}/include
${CIRCLE_DIR}/addon
)
target_link_libraries(memu-circle PUBLIC
memu_src
Z80_emu
fatfs
memu_cir
circle_fs
circle_sdcard
circle_sound
circle_vchiq
circle_usb
circle_input
circle_sched
circle_linux
circle_lib
${LIBM_PATH}
${LIBGCC_PATH}
)
add_custom_command(TARGET memu-circle POST_BUILD
COMMAND objcopy memu-circle -O binary ${KERNEL}
)
elseif("${TARGET}" STREQUAL "SDL")
set (SDL2_DIR "/usr/lib/x86_64-linux-gnu/cmake/SDL2/")
find_package(SDL2 REQUIRED)
set(src_defs
-DLSB_FIRST
-DDYNAMIC_ROMS
-DHAVE_CONFIG
-DALT_OPTIONS=cfg_options
-DALT_USAGE=cfg_usage
-DUNIX
-DHAVE_AUTOTYPE
-DHAVE_CFX2
-DHAVE_CONSOLE
-DHAVE_DART
-DHAVE_DISASS
-DHAVE_JOY
-DHAVE_MFX
-DMAP_PATH
-DHAVE_OSFS
-DHAVE_SID
-DHAVE_SPEC
-DHAVE_UI
-DHAVE_VDEB
-DHAVE_VGA
-DHAVE_NFX
-DZ80_DEBUG
)
if(NOT (${CMAKE_VERSION} VERSION_LESS "3.12.0"))
project(memu C)
add_executable(memu-sdl)
set_target_properties(memu-sdl PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/run_time
)
target_compile_options(memu-sdl PUBLIC -g)
target_link_options(memu-sdl PUBLIC -g)
# target_compile_options(memu-sdl PUBLIC -fsanitize=address -fsanitize=leak)
# target_link_options(memu-sdl PUBLIC -fsanitize=address -fsanitize=leak -static-libasan)
target_compile_definitions(memu-sdl PUBLIC ${src_defs})
target_link_libraries(memu-sdl PUBLIC
memu_src
Z80_emu
portaudio
${SDL2_LIBRARIES}
SDL2_net
m
)
endif()
else()
message(FATAL_ERROR "No valid target specified in MEMU/CMakeLists.txt")
endif()
# Specify the source files
add_subdirectory(src)