Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/src/util/CMakeLists.txt
4802 views
1
add_library(util
2
animated_image.cpp
3
animated_image.h
4
audio_stream.cpp
5
audio_stream.h
6
cd_image.cpp
7
cd_image.h
8
cd_image_cue.cpp
9
cd_image_chd.cpp
10
cd_image_device.cpp
11
cd_image_hasher.cpp
12
cd_image_hasher.h
13
cd_image_m3u.cpp
14
cd_image_memory.cpp
15
cd_image_mds.cpp
16
cd_image_pbp.cpp
17
cd_image_ppf.cpp
18
compress_helpers.cpp
19
compress_helpers.h
20
cue_parser.cpp
21
cue_parser.h
22
elf_file.cpp
23
elf_file.h
24
gpu_device.cpp
25
gpu_device.h
26
gpu_framebuffer_manager.h
27
gpu_shader_cache.cpp
28
gpu_shader_cache.h
29
gpu_texture.cpp
30
gpu_texture.h
31
host.cpp
32
host.h
33
http_downloader.cpp
34
http_downloader.h
35
image.cpp
36
image.h
37
imgui_fullscreen.cpp
38
imgui_fullscreen.h
39
imgui_manager.cpp
40
imgui_manager.h
41
ini_settings_interface.cpp
42
ini_settings_interface.h
43
input_manager.cpp
44
input_manager.h
45
input_source.cpp
46
input_source.h
47
iso_reader.cpp
48
iso_reader.h
49
media_capture.cpp
50
media_capture.h
51
page_fault_handler.cpp
52
page_fault_handler.h
53
platform_misc.h
54
postprocessing.cpp
55
postprocessing.h
56
postprocessing_shader.cpp
57
postprocessing_shader.h
58
postprocessing_shader_fx.cpp
59
postprocessing_shader_fx.h
60
postprocessing_shader_glsl.cpp
61
postprocessing_shader_glsl.h
62
shadergen.cpp
63
shadergen.h
64
shiftjis.cpp
65
shiftjis.h
66
sockets.cpp
67
sockets.h
68
state_wrapper.cpp
69
state_wrapper.h
70
texture_decompress.cpp
71
texture_decompress.h
72
wav_reader_writer.cpp
73
wav_reader_writer.h
74
window_info.cpp
75
window_info.h
76
)
77
78
target_precompile_headers(util PRIVATE "pch.h")
79
target_include_directories(util PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..")
80
target_include_directories(util PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
81
target_link_libraries(util PUBLIC common simpleini imgui)
82
target_link_libraries(util PRIVATE libchdr lzma JPEG::JPEG PNG::PNG WebP::libwebp plutosvg::plutosvg ZLIB::ZLIB SoundTouch::SoundTouchDLL xxhash zstd::libzstd_shared reshadefx)
83
84
if(ENABLE_X11)
85
target_sources(util PRIVATE
86
x11_tools.cpp
87
x11_tools.h
88
)
89
target_compile_definitions(util PRIVATE "-DENABLE_X11=1")
90
target_include_directories(util PRIVATE
91
"${X11_xcb_INCLUDE_PATH}"
92
"${X11_xcb_randr_INCLUDE_PATH}"
93
"${X11_X11_xcb_INCLUDE_PATH}"
94
)
95
endif()
96
97
if(ENABLE_WAYLAND)
98
target_compile_definitions(util PRIVATE "-DENABLE_WAYLAND=1")
99
endif()
100
101
if(ENABLE_OPENGL)
102
target_sources(util PRIVATE
103
opengl_context.cpp
104
opengl_context.h
105
opengl_device.cpp
106
opengl_device.h
107
opengl_loader.h
108
opengl_pipeline.cpp
109
opengl_pipeline.h
110
opengl_stream_buffer.cpp
111
opengl_stream_buffer.h
112
opengl_texture.cpp
113
opengl_texture.h
114
)
115
target_compile_definitions(util PUBLIC "ENABLE_OPENGL=1")
116
target_link_libraries(util PRIVATE glad)
117
118
if(WIN32)
119
target_sources(util PRIVATE
120
opengl_context_wgl.cpp
121
opengl_context_wgl.h
122
)
123
endif()
124
125
if(LINUX OR BSD OR ANDROID)
126
target_sources(util PRIVATE
127
opengl_context_egl.cpp
128
opengl_context_egl.h
129
)
130
target_compile_definitions(util PRIVATE "-DENABLE_EGL=1")
131
132
if(ENABLE_X11)
133
target_sources(util PRIVATE
134
opengl_context_egl_xcb.cpp
135
opengl_context_egl_xcb.h
136
opengl_context_egl_xlib.cpp
137
opengl_context_egl_xlib.h
138
)
139
endif()
140
if(ENABLE_WAYLAND)
141
target_sources(util PRIVATE
142
opengl_context_egl_wayland.cpp
143
opengl_context_egl_wayland.h
144
)
145
target_include_directories(util PRIVATE
146
"${Wayland_INCLUDE_DIRS}" # For wayland-egl
147
)
148
endif()
149
if(ANDROID)
150
target_include_directories(util PRIVATE "${CMAKE_SOURCE_DIR}/android")
151
endif()
152
endif()
153
154
if(APPLE)
155
target_sources(util PRIVATE
156
opengl_context_agl.mm
157
opengl_context_agl.h
158
)
159
set_source_files_properties(opengl_context_agl.mm PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE)
160
endif()
161
endif()
162
163
if(ENABLE_VULKAN)
164
target_sources(util PRIVATE
165
vulkan_builders.cpp
166
vulkan_builders.h
167
vulkan_device.cpp
168
vulkan_device.h
169
vulkan_entry_points.h
170
vulkan_entry_points.inl
171
vulkan_loader.cpp
172
vulkan_loader.h
173
vulkan_pipeline.cpp
174
vulkan_pipeline.h
175
vulkan_stream_buffer.cpp
176
vulkan_stream_buffer.h
177
vulkan_swap_chain.cpp
178
vulkan_swap_chain.h
179
vulkan_texture.cpp
180
vulkan_texture.h
181
)
182
target_compile_definitions(util PUBLIC "ENABLE_VULKAN=1")
183
target_link_libraries(util PUBLIC vulkan-headers)
184
endif()
185
186
# shaderc/spirv-cross is loaded dynamically to reduce module loads on startup.
187
get_target_property(SHADERC_INCLUDE_DIR Shaderc::shaderc_shared INTERFACE_INCLUDE_DIRECTORIES)
188
get_target_property(SPIRV_CROSS_INCLUDE_DIR spirv-cross-c-shared INTERFACE_INCLUDE_DIRECTORIES)
189
target_include_directories(util PUBLIC ${SHADERC_INCLUDE_DIR} ${SPIRV_CROSS_INCLUDE_DIR})
190
191
if(NOT ANDROID)
192
target_sources(util PRIVATE
193
cubeb_audio_stream.cpp
194
sdl_audio_stream.cpp
195
sdl_input_source.cpp
196
sdl_input_source.h
197
)
198
if(ENABLE_OPENGL)
199
target_sources(util PRIVATE
200
opengl_context_sdl.cpp
201
opengl_context_sdl.h
202
)
203
endif()
204
target_compile_definitions(util PUBLIC
205
ENABLE_SDL
206
)
207
target_link_libraries(util PUBLIC
208
cubeb
209
SDL3::SDL3
210
)
211
# FFmpeg loaded dynamically on demand.
212
target_include_directories(util PUBLIC ${FFMPEG_INCLUDE_DIRS})
213
endif()
214
215
if(WIN32)
216
target_sources(util PRIVATE
217
d3d_common.cpp
218
d3d_common.h
219
d3d11_device.cpp
220
d3d11_device.h
221
d3d11_pipeline.cpp
222
d3d11_pipeline.h
223
d3d11_stream_buffer.cpp
224
d3d11_stream_buffer.h
225
d3d11_texture.cpp
226
d3d11_texture.h
227
d3d12_builders.cpp
228
d3d12_builders.h
229
d3d12_descriptor_heap_manager.cpp
230
d3d12_descriptor_heap_manager.h
231
d3d12_device.cpp
232
d3d12_device.h
233
d3d12_pipeline.cpp
234
d3d12_pipeline.h
235
d3d12_stream_buffer.cpp
236
d3d12_stream_buffer.h
237
d3d12_texture.cpp
238
d3d12_texture.h
239
dinput_source.cpp
240
dinput_source.h
241
http_downloader_winhttp.cpp
242
platform_misc_win32.cpp
243
win32_raw_input_source.cpp
244
win32_raw_input_source.h
245
xinput_source.cpp
246
xinput_source.h
247
)
248
target_link_libraries(util PRIVATE d3d12ma)
249
target_link_libraries(util PRIVATE winmm.lib Dwmapi.lib winhttp.lib)
250
251
if(CMAKE_BUILD_TYPE MATCHES "Debug|Devel")
252
target_link_libraries(util PRIVATE WinPixEventRuntime::WinPixEventRuntime)
253
endif()
254
elseif(APPLE)
255
include(AddMetalSources)
256
257
set(MAC_SOURCES
258
metal_device.h
259
metal_device.mm
260
metal_layer.h
261
metal_stream_buffer.h
262
metal_stream_buffer.mm
263
platform_misc_mac.mm
264
)
265
set(METAL_SOURCES
266
"${CMAKE_CURRENT_SOURCE_DIR}/metal_shaders.metal"
267
)
268
set_property(GLOBAL PROPERTY UTIL_METAL_SOURCES ${METAL_SOURCES})
269
target_sources(util PRIVATE ${MAC_SOURCES})
270
find_library(IOK_LIBRARY IOKit REQUIRED)
271
find_library(METAL_LIBRARY Metal)
272
find_library(QUARTZCORE_LIBRARY QuartzCore)
273
target_link_libraries(util PRIVATE ${METAL_LIBRARY} ${QUARTZCORE_LIBRARY} ${IOK_LIBRARY})
274
set_source_files_properties(${MAC_SOURCES} PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE)
275
elseif(NOT ANDROID)
276
target_sources(util PRIVATE
277
platform_misc_unix.cpp
278
)
279
pkg_check_modules(DBUS REQUIRED dbus-1)
280
target_include_directories(util PRIVATE ${DBUS_INCLUDE_DIRS})
281
282
if(LINUX)
283
target_link_libraries(util PRIVATE UDEV::UDEV)
284
endif()
285
endif()
286
287
if(NOT WIN32 AND NOT ANDROID)
288
target_sources(util PRIVATE
289
http_downloader_curl.cpp
290
)
291
target_link_libraries(util PRIVATE
292
CURL::libcurl
293
)
294
endif()
295
296
function(add_util_resources target)
297
if(APPLE)
298
get_property(UTIL_METAL_SOURCES GLOBAL PROPERTY UTIL_METAL_SOURCES)
299
add_metal_sources(${target} ${UTIL_METAL_SOURCES})
300
301
# Copy MoltenVK into the bundle
302
unset(MOLTENVK_PATH CACHE)
303
find_file(MOLTENVK_PATH NAMES
304
libMoltenVK.dylib
305
lib/libMoltenVK.dylib
306
)
307
if (MOLTENVK_PATH)
308
target_sources(${target} PRIVATE "${MOLTENVK_PATH}")
309
set_source_files_properties("${MOLTENVK_PATH}" PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks)
310
message(STATUS "Using MoltenVK from ${MOLTENVK_PATH}")
311
else()
312
message(WARNING "MoltenVK not found in path, it will depend on the target system having it.")
313
endif()
314
315
# Copy dynamically-loaded libraries (harfbuzz/shaderc/spirv-cross) into the bundle
316
get_target_property(HARFBUZZ_LIBRARY harfbuzz::harfbuzz IMPORTED_LOCATION_RELEASE)
317
get_target_property(SPIRV_CROSS_LIBRARY spirv-cross-c-shared IMPORTED_SONAME_RELEASE)
318
get_target_property(SHADERC_LIBRARY Shaderc::shaderc_shared IMPORTED_LOCATION_RELEASE)
319
target_sources(${target} PRIVATE "${HARFBUZZ_LIBRARY}" "${SHADERC_LIBRARY}" "${SPIRV_CROSS_LIBRARY}")
320
set_source_files_properties("${HARFBUZZ_LIBRARY}" "${SHADERC_LIBRARY}" "${SPIRV_CROSS_LIBRARY}" PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks)
321
322
# Copy FFmpeg libraries into the bundle
323
foreach(component avcodec avformat avutil swresample swscale)
324
string(REGEX REPLACE "\([0-9]+\)\.[0-9]+\.[0-9]+" "\\1" major "${FFMPEG_${component}_VERSION}")
325
string(REPLACE "lib${component}.dylib" "lib${component}.${major}.dylib" version_lib "${FFMPEG_${component}_LIBRARIES}")
326
target_sources(${target} PRIVATE ${version_lib})
327
set_source_files_properties(${target} PRIVATE ${version_lib} PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks)
328
endforeach()
329
endif()
330
endfunction()
331
332