-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
352 lines (288 loc) · 13.4 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
cmake_minimum_required(VERSION 3.5)
include(BundleUtilities)
##########################################################################
##########################################################################
add_executable(b2 MACOSX_BUNDLE
b2.cpp b2.h b2.inl
65link.cpp 65link.h
BeebThread.cpp BeebThread.h BeebThread.inl
BeebWindows.cpp BeebWindows.h
dear_imgui.cpp dear_imgui.h
download.h
filters.cpp filters.h
MemoryDiscImage.cpp MemoryDiscImage.h
misc.cpp misc.h
native_ui.cpp native_ui.h
Remapper.cpp Remapper.h
TVOutput.cpp TVOutput.h TVOutput.inl
keymap.cpp keymap.h
conf.cpp conf.h
keys.cpp keys.h keys.inl
BeebState.cpp BeebState.h
native_ui_noc.h
JobQueue.cpp JobQueue.h
GenerateThumbnailJob.cpp GenerateThumbnailJob.h
BeebWindow.cpp BeebWindow.h BeebWindow.inl
TimelineUI.cpp TimelineUI.h
beeb_events.cpp beeb_events.h beeb_events.inl beeb_events_types.inl
load_save.cpp load_save.h
Messages.cpp Messages.h
ConfigsUI.cpp ConfigsUI.h
BeebConfig.cpp BeebConfig.h
KeymapsUI.cpp KeymapsUI.h
MessagesUI.cpp MessagesUI.h
TraceUI.cpp TraceUI.h TraceUI.inl
DataRateUI.cpp DataRateUI.h
VideoWriter.cpp VideoWriter.h
WriteVideoJob.cpp WriteVideoJob.h
Timeline.cpp Timeline.h
VBlankMonitor.cpp VBlankMonitor.h
VBlankMonitorDefault.cpp VBlankMonitorDefault.h
MessageQueue.cpp MessageQueue.h
BeebKeymap.cpp BeebKeymap.h
commands.cpp commands.h
CommandContextStackUI.cpp CommandContextStackUI.h
CommandKeymapsUI.cpp CommandKeymapsUI.h
SettingsUI.cpp SettingsUI.h
PixelMetadataUI.cpp PixelMetadataUI.h
DearImguiTestUI.cpp DearImguiTestUI.h
debugger.cpp debugger.h debugger.inl
HTTPServer.cpp HTTPServer.h
HTTPMethodsHandler.cpp HTTPMethodsHandler.h
)
##########################################################################
##########################################################################
add_config_define(b2)
##########################################################################
##########################################################################
# Apple-specific general stuff.
if(APPLE)
# There doesn't appear to be any non-hacky way of getting this.
#
# (BundleUtilities has a GET_DOTAPP_DIR function, but it doesn't
# work with generator expressions. Presumably it was written to work
# with the pre-cmake 3.0 target property that has now disappeared.)
set(BUNDLE_CONTENTS_FOLDER $<TARGET_FILE_DIR:b2>/..)
set(ICON_PNG ${CMAKE_SOURCE_DIR}/etc/icon/icon.png)
set(ICONS_TMP ${CMAKE_CURRENT_BINARY_DIR}/b2.iconset)
# https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/OSXHIGuidelines/Designing.html#//apple_ref/doc/uid/20000957-CH87-SW1
# The icons could be different per configuration. The Final build
# icon is the one used for the DMG.
add_custom_command(
OUTPUT b2.icns ${ICONS_TMP}/icon_16x16.png ${ICONS_TMP}/icon_32x32.png ${ICONS_TMP}/icon_64x64.png ${ICONS_TMP}/icon_128x128.png ${ICONS_TMP}/icon_256x256.png ${ICONS_TMP}/icon_512x512.png ${ICONS_TMP}/icon_512x512@2x.png ${ICONS_TMP}/icon_16x16@2x.png ${ICONS_TMP}/icon_32x32@2x.png ${ICONS_TMP}/icon_128x128@2x.png ${ICONS_TMP}/icon_256x256@2x.png
COMMAND ${CMAKE_COMMAND} -E make_directory ${ICONS_TMP}
COMMAND sips -z 16 16 ${ICON_PNG} --out ${ICONS_TMP}/icon_16x16.png
COMMAND sips -z 32 32 ${ICON_PNG} --out ${ICONS_TMP}/icon_32x32.png
COMMAND sips -z 64 64 ${ICON_PNG} --out ${ICONS_TMP}/icon_64x64.png
COMMAND sips -z 128 128 ${ICON_PNG} --out ${ICONS_TMP}/icon_128x128.png
COMMAND sips -z 256 256 ${ICON_PNG} --out ${ICONS_TMP}/icon_256x256.png
COMMAND sips -z 512 512 ${ICON_PNG} --out ${ICONS_TMP}/icon_512x512.png
COMMAND sips -z 1024 1024 ${ICON_PNG} --out ${ICONS_TMP}/icon_512x512@2x.png
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ICONS_TMP}/icon_32x32.png ${ICONS_TMP}/icon_16x16@2x.png
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ICONS_TMP}/icon_64x64.png ${ICONS_TMP}/icon_32x32@2x.png
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ICONS_TMP}/icon_256x256.png ${ICONS_TMP}/icon_128x128@2x.png
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ICONS_TMP}/icon_512x512.png ${ICONS_TMP}/icon_256x256@2x.png
COMMAND iconutil -c icns ${ICONS_TMP}
DEPENDS ${ICON_PNG}
MAIN_DEPENDENCY ${ICON_PNG}
)
set_target_properties(b2
PROPERTIES
MACOSX_BUNDLE_NAME "b2"
MACOSX_BUNDLE_GUI_IDENTIFIER "com.tom-seddon.b2"
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_LIST_DIR}/macos/Info.plist
MACOSX_BUNDLE_ICON_FILE b2.icns
)
target_sources(b2 PRIVATE
b2.icns)
set_source_files_properties(b2.icns PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
endif()
##########################################################################
##########################################################################
# Windows-specific general stuff.
if(WIN32)
set(MAGICK ${CMAKE_SOURCE_DIR}/etc/ImageMagick-7.0.5-4-portable-Q16-x64/magick.exe)
set(RCEDIT ${CMAKE_SOURCE_DIR}/etc/rcedit/rcedit.exe)
set(ICON_PNG ${CMAKE_SOURCE_DIR}/etc/icon/icon.png)
set(ICON_ICO b2_icons.ico)
add_custom_command(
OUTPUT ${ICON_ICO} icon_16x16_32bpp.png icon_16x16_8bpp.bmp icon_32x32_32bpp.png icon_32x32_8bpp.bmp icon_48x48_32bpp.png icon_48x48_8bpp.bmp icon_64x64_32bpp.png icon_256x256_32bpp.png
COMMAND ${MAGICK} ${ICON_PNG} -resize 256x256 icon_256x256_32bpp.png
COMMAND ${MAGICK} ${ICON_PNG} -resize 16x16 icon_16x16_32bpp.png
COMMAND ${MAGICK} ${ICON_PNG} -resize 32x32 icon_32x32_32bpp.png
COMMAND ${MAGICK} ${ICON_PNG} -resize 48x48 icon_48x48_32bpp.png
COMMAND ${MAGICK} ${ICON_PNG} -resize 64x64 icon_64x64_32bpp.png
COMMAND ${MAGICK} ${ICON_PNG} -resize 16x16 -type palette icon_16x16_8bpp.bmp
COMMAND ${MAGICK} ${ICON_PNG} -resize 32x32 -type palette icon_32x32_8bpp.bmp
COMMAND ${MAGICK} ${ICON_PNG} -resize 48x48 -type palette icon_48x48_8bpp.bmp
COMMAND ${MAGICK} icon_256x256_32bpp.png icon_48x48_8bpp.bmp icon_32x32_8bpp.bmp icon_16x16_8bpp.bmp icon_256x256_32bpp.png icon_64x64_32bpp.png icon_48x48_32bpp.png icon_32x32_32bpp.png icon_16x16_32bpp.png ${ICON_ICO}
DEPENDS ${ICON_PNG}
MAIN_DEPENDENCY ${ICON_PNG})
add_custom_command(TARGET b2 POST_BUILD
COMMAND ${RCEDIT} $<TARGET_FILE:b2> --set-icon ${ICON_ICO})
target_sources(b2 PRIVATE ${ICON_ICO})
target_sources(b2 PRIVATE guids_win32.c)
target_sources(b2 PRIVATE b2.natvis)
# /INCREMENTAL:NO - http://stackoverflow.com/questions/21569478
#
# /OPT:REF /OPT:ICF - no idea why these have gone missing. Aren't
# they supposed to be the defaults?? (This would happen in VC6
# sometimes too, but I can't remember why... anyway, specifying them
# explicitly was always the solution then too.)
set(EXTRA_LINKER_FLAGS "/INCREMENTAL:NO /OPT:REF /OPT:ICF")
set_target_properties(b2 PROPERTIES LINK_FLAGS_RELWITHDEBINFO ${EXTRA_LINKER_FLAGS})
set_target_properties(b2 PROPERTIES LINK_FLAGS_FINAL ${EXTRA_LINKER_FLAGS})
# The debug and RelWithDebInfo versions want to be console apps.
#
# http://stackoverflow.com/questions/8054734/cmake-how-to-use-different-add-executable-for-debug-build
# http://public.kitware.com/Bug/view.php?id=11171
# http://public.kitware.com/Bug/view.php?id=12566
#
# TL;DR - bleargh. So this is done with a #pragma in b2.cpp.
endif()
##########################################################################
##########################################################################
# Linux-specific general stuff.
if(UNIX)
target_link_libraries(b2 PRIVATE m)
endif()
##########################################################################
##########################################################################
# VBlank monitor.
if(WIN32)
target_sources(b2 PRIVATE VBlankMonitorWindows.cpp VBlankMonitorWindows.h)
target_link_libraries(b2 PRIVATE dxgi.lib)
elseif(OSX)
target_sources(b2 PRIVATE VBlankMonitorOSX.cpp VBlankMonitorOSX.h)
target_link_libraries(b2 PRIVATE "-framework QuartzCore")
target_link_libraries(b2 PRIVATE "-framework CoreVideo")
endif()
##########################################################################
##########################################################################
# NOC. Also, on OS X, other UI-related Objective C(++) stuff.
if(OSX)
target_sources(b2 PRIVATE
native_ui.mm
native_ui_noc.m
load_save.mm)
else()
target_sources(b2 PRIVATE
native_ui_noc.c)
endif()
##########################################################################
##########################################################################
# HTTP download stuff.
if(WIN32)
target_sources(b2 PRIVATE download_windows.cpp)
target_link_libraries(b2 PRIVATE urlmon.lib)
else()
target_sources(b2 PRIVATE download_null.c)
endif()
##########################################################################
##########################################################################
# Media Foundation video writer.
if(WIN32)
target_sources(b2 PRIVATE VideoWriterMF.cpp VideoWriterMF.h VideoWriterMF_private.inl)
target_link_libraries(b2 PRIVATE mf.lib mfplat.lib mfreadwrite.lib)
endif()
##########################################################################
##########################################################################
# FFmpeg video writer.
if(HAVE_FFMPEG)
target_sources(b2 PRIVATE VideoWriterFFmpeg.cpp VideoWriterFFmpeg.h)
target_link_libraries(b2 PRIVATE ${FFMPEG_LIBRARIES})
target_include_directories(b2 PRIVATE ${FFMPEG_INCLUDE_DIRS})
target_compile_definitions(b2 PRIVATE ${FFMPEG_DEFINITIONS} -DHAVE_FFMPEG=1)
endif()
##########################################################################
##########################################################################
add_sanitizers(b2)
##########################################################################
##########################################################################
target_link_libraries(b2 PRIVATE
beeb_lib
shared_lib
6502_lib
miniz_lib
remotery_lib
imgui_lib
imgui_memory_editor_lib
noc_lib
rapidjson_lib
IconFontCppHeaders_lib
)
##########################################################################
##########################################################################
# SDL2.
target_include_directories(b2 PRIVATE ${SDL2_INCLUDE_DIR})
target_compile_definitions(b2 PRIVATE ${SDL2_DEFINITIONS})
target_link_libraries(b2 PRIVATE ${SDL2_LIBRARY})
##########################################################################
##########################################################################
if(HAVE_LIBCURL)
target_link_libraries(b2 PRIVATE libcurl)
endif()
##########################################################################
##########################################################################
if(HAVE_LIBUV)
# Only debugger builds actually use this, but that seems to be a bit
# of a pain to arrange. Need to check the dead code elimination will
# just strip all this stuff out...
target_link_libraries(b2 PRIVATE uv http-parser)
endif()
##########################################################################
##########################################################################
# Post build step - copy assets.
#
# The release process copies the asset folder from an unspecified
# configuration. The assets must be the same for every configuration.
set(ASSETS assets)
set(ROMS ${ASSETS}/roms)
set(FONTS ${ASSETS}/fonts)
set(SAMPLES ${ASSETS}/samples)
# BBC ROMs
add_custom_command(
TARGET b2 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:b2>/${ROMS}
COMMAND ${CMAKE_COMMAND} -E copy_if_different OS12.ROM B+MOS.rom BASIC2.ROM acorn/DFS-2.26.rom watford/DDFS-1.54T.rom watford/DDFS-1.53.rom opus/OPUS-DDOS-3.45.rom opus/challenger-1.01.rom $<TARGET_FILE_DIR:b2>/${ROMS}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../../etc/roms
VERBATIM)
# Master ROMs
function(do_master_ROMs VERSION)
add_custom_command(
TARGET b2 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:b2>/${ROMS}/m128/${VERSION}
COMMAND ${CMAKE_COMMAND} -E copy_if_different adfs.rom basic4.rom dfs.rom edit.rom mos.rom terminal.rom view.rom viewsht.rom $<TARGET_FILE_DIR:b2>/${ROMS}/m128/${VERSION}/
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../../etc/roms/M128/${VERSION}
VERBATIM)
endfunction()
do_master_ROMs(3.20)
do_master_ROMs(3.50)
# Fonts
add_custom_command(
TARGET b2 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:b2>/${FONTS}
COMMAND ${CMAKE_COMMAND} -E copy_if_different fontawesome-webfont.ttf $<TARGET_FILE_DIR:b2>/${FONTS}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../../submodules/Font-Awesome/fonts
VERBATIM)
# Floppy disc sounds
file(GLOB FLOPPY_SAMPLES ${CMAKE_CURRENT_LIST_DIR}/../../etc/samples_floppy/*.wav)
add_custom_command(
TARGET b2 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:b2>/${SAMPLES}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FLOPPY_SAMPLES} $<TARGET_FILE_DIR:b2>/${SAMPLES}
VERBATIM)
##########################################################################
##########################################################################
# Job queue unit tests.
add_executable(test_JobQueue
test_JobQueue.cpp
JobQueue.cpp JobQueue.h
)
target_link_libraries(test_JobQueue PRIVATE shared_lib)
add_test(
NAME b2/test_JobQueue
COMMAND $<TARGET_FILE:test_JobQueue>)
##########################################################################
##########################################################################