-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
353 lines (322 loc) · 10.5 KB
/
Copy pathCMakeLists.txt
File metadata and controls
353 lines (322 loc) · 10.5 KB
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
cmake_minimum_required(VERSION 3.21)
project(iris LANGUAGES C CXX)
set(WIN_ICON ${CMAKE_CURRENT_SOURCE_DIR}/res/iris.rc)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15")
set(OSX_ICON ${CMAKE_CURRENT_SOURCE_DIR}/res/iris.icns)
set_source_files_properties(${OSX_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
# Statically link SDL3 for Linux targets
set(SDL_STATIC ON)
set(ASMJIT_STATIC ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
find_package(Git QUIET)
if (GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty --match "0.*"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VERSION_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if(NOT GIT_VERSION_STRING)
# Fallback if git describe fails (e.g., no tags in the history)
set(GIT_VERSION_STRING "unknown-version")
endif()
else()
set(GIT_VERSION_STRING "git-not-found")
endif()
message(STATUS "Project Version: ${GIT_VERSION_STRING}")
# You can then use GIT_VERSION_STRING in your project, e.g., to generate a header file:
# configure_file(
# ${CMAKE_CURRENT_SOURCE_DIR}/version.h.in
# ${CMAKE_CURRENT_BINARY_DIR}/version.h
# @ONLY
# )
include(CheckIPOSupported)
check_ipo_supported(RESULT LTO_SUPPORTED OUTPUT LTO_ERROR)
set(BUILD_SHARED_LIBS OFF)
# And this part tells CMake where to find and install the file itself
add_executable(iris MACOSX_BUNDLE ${OSX_ICON} ${WIN_ICON})
target_compile_definitions(iris PUBLIC IMGUI_IMPL_VULKAN_NO_PROTOTYPES)
target_compile_definitions(iris PUBLIC IMGUI_IMPL_VULKAN_USE_VOLK)
target_compile_options(iris PUBLIC "-Wno-deprecated-declarations")
# target_compile_definitions(iris PUBLIC _DEBUG)
set(PARALLEL_GS_STANDALONE ON CACHE BOOL "" FORCE)
add_subdirectory(deps/asmjit EXCLUDE_FROM_ALL)
add_subdirectory(deps/tomlplusplus EXCLUDE_FROM_ALL)
add_subdirectory(deps/libdeflate EXCLUDE_FROM_ALL)
add_subdirectory(deps/parallel-gs EXCLUDE_FROM_ALL)
add_subdirectory(deps/libchdr EXCLUDE_FROM_ALL)
add_subdirectory(deps/SDL EXCLUDE_FROM_ALL)
if (CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64")
target_compile_options(iris PRIVATE -D_EE_USE_INTRINSICS -mssse3 -msse4.1)
endif()
if (X11_API)
target_compile_definitions(granite-volk PUBLIC VK_USE_PLATFORM_XLIB_KHR)
endif()
if (WAYLAND_API)
target_compile_definitions(granite-volk PUBLIC VK_USE_PLATFORM_WAYLAND_KHR)
endif()
if (WIN32)
target_compile_definitions(granite-volk PUBLIC VK_USE_PLATFORM_WIN32_KHR)
endif()
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
if (LTO_SUPPORTED)
message(STATUS "IPO/LTO enabled")
set_property(TARGET iris PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(STATUS "IPO/LTO not supported: ${LTO_ERROR}")
endif()
endif()
set_property(TARGET iris PROPERTY CXX_STANDARD 20)
add_definitions("-D_IRIS_VERSION=${GIT_VERSION_STRING}")
target_sources(iris PRIVATE
main.cpp
frontend/audio.cpp
frontend/handlers.cpp
frontend/vulkan.cpp
frontend/imgui.cpp
frontend/emu.cpp
frontend/render.cpp
frontend/shaders.cpp
frontend/input.cpp
frontend/iris.cpp
frontend/elf.cpp
frontend/notifications.cpp
frontend/settings.cpp
frontend/ui/about.cpp
frontend/ui/bios_setting.cpp
frontend/ui/breakpoints.cpp
frontend/ui/control.cpp
frontend/ui/dma.cpp
frontend/ui/gs.cpp
frontend/ui/intc.cpp
frontend/ui/logs.cpp
frontend/ui/memory.cpp
frontend/ui/memory_card_tool.cpp
frontend/ui/memory_search.cpp
frontend/ui/menubar.cpp
frontend/ui/modules.cpp
frontend/ui/overlay.cpp
frontend/ui/pad.cpp
frontend/ui/settings.cpp
frontend/ui/spu2.cpp
frontend/ui/state.cpp
frontend/ui/statusbar.cpp
frontend/ui/symbols.cpp
frontend/ui/threads.cpp
frontend/ui/vu_disassembly.cpp
src/ps2.c
src/ps2_elf.c
src/ps2_iso9660.c
src/queue.c
src/rom.c
src/md5.c
src/list.c
src/scheduler.c
src/dev/ds.c
src/dev/guncon.c
src/dev/mcd.c
src/dev/mtap.c
src/dev/ps1_mcd.c
src/dev/ps1_mcd.c
src/ee/ee_cached.cpp
src/ee/bus.c
src/ee/dmac.c
src/ee/ee_dis.c
src/ee/gif.c
src/ee/intc.c
src/ee/timers.c
src/ee/vif.c
src/ee/vu_cached.cpp
src/ee/vu_dis.c
src/gs/gs.c
src/gs/renderer/null.cpp
src/gs/renderer/renderer.cpp
src/gs/renderer/hardware.cpp
src/iop/bus.c
src/iop/cdvd.c
src/iop/disc.c
src/iop/dma.c
src/iop/fw.c
src/iop/intc.c
src/iop/iop.c
src/iop/iop_dis.c
src/iop/iop_export.c
src/iop/rpc.c
src/iop/sio2.c
src/iop/spu2.c
src/iop/timers.c
src/iop/usb.c
src/iop/disc/bin.c
src/iop/disc/cue.c
src/iop/disc/chd.c
src/iop/disc/ciso.c
src/iop/disc/iso.c
src/iop/hle/ioman.cpp
src/iop/hle/loadcore.c
src/iop/hle/sysmem.c
src/ipu/chromtable.cpp
src/ipu/codedblockpattern.cpp
src/ipu/dct_coeff.cpp
src/ipu/dct_coeff_table0.cpp
src/ipu/dct_coeff_table1.cpp
src/ipu/ipu.cpp
src/ipu/ipu_fifo.cpp
src/ipu/lumtable.cpp
src/ipu/mac_addr_inc.cpp
src/ipu/mac_b_pic.cpp
src/ipu/mac_i_pic.cpp
src/ipu/mac_p_pic.cpp
src/ipu/motioncode.cpp
src/ipu/vlc_table.cpp
src/shared/bios.c
src/shared/dev9.c
src/shared/ram.c
src/shared/sbus.c
src/shared/sif.c
src/shared/speed.c
src/shared/speed/ata.c
src/shared/speed/eeprom.c
src/shared/speed/flash.c
src/s14x/nand.c
src/s14x/syscon.c
src/s14x/sram.c
src/s14x/link.c
src/s14x/ioboard.c
src/s14x/aiboard.c
deps/imgui/imgui.cpp
deps/imgui/imgui_demo.cpp
deps/imgui/imgui_draw.cpp
deps/imgui/imgui_tables.cpp
deps/imgui/imgui_widgets.cpp
deps/imgui/backends/imgui_impl_sdl3.cpp
deps/imgui/backends/imgui_impl_vulkan.cpp
deps/implot/implot_demo.cpp
deps/implot/implot_items.cpp
deps/implot/implot.cpp
deps/lz4/lib/lz4.c
)
target_include_directories(iris PRIVATE
deps/asmjit
deps/imgui
deps/imgui/backends
deps/implot
deps/SDL/include
deps/incbin
deps/parallel-gs
deps/libchdr/include
deps/lz4/lib
deps/stb
deps/portable-file-dialogs
frontend
src
res
)
target_link_libraries(iris PUBLIC
asmjit::asmjit
libdeflate::libdeflate_static
tomlplusplus::tomlplusplus
SDL3::SDL3-static
parallel-gs
chdr-static
)
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
find_package(Vulkan COMPONENTS MoltenVK)
message(STATUS "VulkanSDK path: $ENV{VULKAN_SDK}")
find_library(MOLTENVK_LIBRARY
NAMES libMoltenVK.dylib
PATHS ENV VULKAN_SDK
PATH_SUFFIXES /lib
)
target_link_libraries(iris PUBLIC
Vulkan::Vulkan
${MOLTENVK_LIBRARY}
)
endif()
if (WIN32)
target_link_libraries(iris PRIVATE dwmapi)
target_sources(iris PRIVATE frontend/platform/windows.cpp)
else()
target_sources(iris PRIVATE frontend/platform/stub.cpp)
endif()
set_target_properties(iris PROPERTIES
# On macOS, make a proper .app bundle instead of a bare executable
MACOSX_BUNDLE TRUE
# Set the Info.plist file for Apple Mobile platforms. Without this file, your app
# will not launch.
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist"
MACOSX_BUNDLE_ICON_FILE iris.icns
# in Xcode, create a Scheme in the schemes dropdown for the app.
XCODE_GENERATE_SCHEME TRUE
# Identification for Xcode
XCODE_ATTRIBUTE_BUNDLE_IDENTIFIER "com.allkern.iris"
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.allkern.iris"
XCODE_ATTRIBUTE_CURRENTYEAR "${CURRENTYEAR}"
RESOURCE "${RESOURCE_FILES}"
)
# on Visual Studio, set our app as the default project
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT "${EXECUTABLE_NAME}")
# On macOS Platforms, ensure that the bundle is valid for distribution by calling fixup_bundle.
# note that fixup_bundle does not work on iOS, so you will want to use static libraries
# or manually copy dylibs and set rpaths
message(STATUS "CMake System Name: ${CMAKE_SYSTEM_NAME}")
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
# tell Install about the target, otherwise fixup won't know about the transitive dependencies
install(TARGETS iris
BUNDLE DESTINATION ./install COMPONENT Runtime
RUNTIME DESTINATION ./install/bin COMPONENT Runtime
)
set(BUNDLE_PATH "${CMAKE_BINARY_DIR}/iris.app") # where to look for dependencies when fixing up
file(GLOB VULKAN_DYLIBS $ENV{VULKAN_SDK}/lib/libvulkan.*.dylib)
set(VULKAN_DYLIBS ${VULKAN_DYLIBS} $ENV{VULKAN_SDK}/lib/libMoltenVK.dylib)
install(CODE "
execute_process(COMMAND echo \"Preparing to bundle iris...\")
execute_process(COMMAND echo \"Bundle path: ${BUNDLE_PATH}\")
execute_process(COMMAND echo \"Vulkan dylibs: ${VULKAN_DYLIBS}\")
execute_process(COMMAND echo \"Adding local RPATH...\")
execute_process(
COMMAND install_name_tool -add_rpath
\"@executable_path/../Frameworks\"
\"${BUNDLE_PATH}/Contents/MacOS/iris\"
)
execute_process(COMMAND echo \"Creating ICD JSON directory...\")
make_directory(${BUNDLE_PATH}/Contents/Resources/vulkan/icd.d)
execute_process(COMMAND echo \"Creating Frameworks directory...\")
make_directory(${BUNDLE_PATH}/Contents/Frameworks)
execute_process(COMMAND echo \"Copying files...\")
file(COPY
${CMAKE_CURRENT_SOURCE_DIR}/MoltenVK_icd.json
DESTINATION ${BUNDLE_PATH}/Contents/Resources/vulkan/icd.d/
)
file(COPY
${VULKAN_DYLIBS}
DESTINATION ${BUNDLE_PATH}/Contents/Frameworks/
)
execute_process(COMMAND echo \"Signing app bundle...\")
execute_process(COMMAND
codesign --force --deep --sign - ${BUNDLE_PATH}
RESULT_VARIABLE codesign_result
OUTPUT_VARIABLE codesign_output
)
if (codesign_result)
execute_process(COMMAND echo \"${codesign_output}\")
endif()
")
set(CPACK_GENERATOR "DragNDrop")
include(CPack)
endif()
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
install(CODE
"include(${CMAKE_CURRENT_SOURCE_DIR}/AppImage.cmake)
make_appimage(
EXE \"${CMAKE_CURRENT_SOURCE_DIR}/build/iris\"
NAME \"Iris\"
ICON \"${CMAKE_CURRENT_SOURCE_DIR}/res/iris.png\"
DIR_ICON \"${CMAKE_CURRENT_SOURCE_DIR}/res/iris.png\"
OUTPUT_NAME \"${CMAKE_CURRENT_SOURCE_DIR}/build/Iris-${GIT_VERSION_STRING}.AppImage\"
)
"
COMPONENT Runtime
)
endif()