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