Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/src/duckstation-qt/CMakeLists.txt
4802 views
1
include(CopyBaseTranslations)
2
3
set(CMAKE_AUTOUIC OFF)
4
set(CMAKE_AUTOMOC ON)
5
set(CMAKE_AUTORCC ON)
6
7
set(SRCS
8
aboutdialog.cpp
9
aboutdialog.h
10
aboutdialog.ui
11
achievementlogindialog.cpp
12
achievementlogindialog.h
13
achievementlogindialog.ui
14
achievementsettingswidget.cpp
15
achievementsettingswidget.h
16
achievementsettingswidget.ui
17
advancedsettingswidget.cpp
18
advancedsettingswidget.h
19
advancedsettingswidget.ui
20
audiosettingswidget.cpp
21
audiosettingswidget.h
22
audiosettingswidget.ui
23
audiostretchsettingsdialog.ui
24
autoupdaterwindow.cpp
25
autoupdaterwindow.h
26
autoupdaterwindow.ui
27
biossettingswidget.cpp
28
biossettingswidget.h
29
biossettingswidget.ui
30
colorpickerbutton.cpp
31
colorpickerbutton.h
32
consolesettingswidget.cpp
33
consolesettingswidget.h
34
consolesettingswidget.ui
35
controllerbindingwidget_analog_controller.ui
36
controllerbindingwidget_analog_joystick.ui
37
controllerbindingwidget_digital_controller.ui
38
controllerbindingwidget_guncon.ui
39
controllerbindingwidget_justifier.ui
40
controllerbindingwidget_mouse.ui
41
controllerbindingwidget_negcon.ui
42
controllerbindingwidget_negconrumble.ui
43
controllerbindingwidgets.cpp
44
controllerbindingwidgets.h
45
controllerbindingwidget.ui
46
controllerglobalsettingswidget.cpp
47
controllerglobalsettingswidget.h
48
controllerglobalsettingswidget.ui
49
controllermacroeditwidget.ui
50
controllermacrowidget.ui
51
controllersettingswindow.cpp
52
controllersettingswindow.h
53
controllersettingswindow.ui
54
controllersettingwidgetbinder.h
55
coverdownloadwindow.cpp
56
coverdownloadwindow.h
57
coverdownloadwindow.ui
58
debuggeraddbreakpointdialog.ui
59
debuggercodeview.cpp
60
debuggercodeview.h
61
debuggermodels.cpp
62
debuggermodels.h
63
debuggerwindow.cpp
64
debuggerwindow.h
65
debuggerwindow.ui
66
displaywidget.cpp
67
displaywidget.h
68
emptygamelistwidget.ui
69
emulationsettingswidget.cpp
70
emulationsettingswidget.h
71
emulationsettingswidget.ui
72
foldersettingswidget.cpp
73
foldersettingswidget.h
74
foldersettingswidget.ui
75
gamecheatcodechoiceeditordialog.ui
76
gamecheatcodeeditordialog.ui
77
gamecheatsettingswidget.cpp
78
gamecheatsettingswidget.h
79
gamecheatsettingswidget.ui
80
gamepatchdetailswidget.ui
81
gamepatchsettingswidget.cpp
82
gamepatchsettingswidget.h
83
gamepatchsettingswidget.ui
84
gamelistrefreshthread.cpp
85
gamelistrefreshthread.h
86
gamelistsettingswidget.cpp
87
gamelistsettingswidget.h
88
gamelistsettingswidget.ui
89
gamelistwidget.cpp
90
gamelistwidget.h
91
gamelistwidget.ui
92
gamesummarywidget.cpp
93
gamesummarywidget.h
94
gamesummarywidget.ui
95
graphicssettingswidget.cpp
96
graphicssettingswidget.h
97
graphicssettingswidget.ui
98
hotkeysettingswidget.cpp
99
hotkeysettingswidget.h
100
inputbindingdialog.cpp
101
inputbindingdialog.h
102
inputbindingdialog.ui
103
inputbindingwidgets.cpp
104
inputbindingwidgets.h
105
interfacesettingswidget.cpp
106
interfacesettingswidget.h
107
interfacesettingswidget.ui
108
isobrowserwindow.cpp
109
isobrowserwindow.h
110
isobrowserwindow.ui
111
logwindow.cpp
112
logwindow.h
113
mainwindow.cpp
114
mainwindow.h
115
mainwindow.ui
116
memorycardeditorwindow.cpp
117
memorycardeditorwindow.h
118
memorycardeditorwindow.ui
119
memorycardrenamefiledialog.ui
120
memorycardsettingswidget.cpp
121
memorycardsettingswidget.h
122
memoryeditorwindow.cpp
123
memoryeditorwindow.h
124
memoryeditorwindow.ui
125
memoryscannerwindow.cpp
126
memoryscannerwindow.h
127
memoryscannerwindow.ui
128
memoryviewwidget.cpp
129
memoryviewwidget.h
130
postprocessingsettingswidget.cpp
131
postprocessingsettingswidget.h
132
postprocessingchainconfigwidget.ui
133
postprocessingoverlayconfigwidget.ui
134
qthost.cpp
135
qthost.h
136
qtprogresscallback.cpp
137
qtprogresscallback.h
138
qtthemes.cpp
139
qttranslations.inl
140
qtutils.cpp
141
qtutils.h
142
resource.h
143
selectdiscdialog.cpp
144
selectdiscdialog.h
145
selectdiscdialog.ui
146
settingswindow.cpp
147
settingswindow.h
148
settingswindow.ui
149
settingwidgetbinder.h
150
setupwizarddialog.cpp
151
setupwizarddialog.h
152
setupwizarddialog.ui
153
texturereplacementsettingsdialog.ui
154
togglebutton.cpp
155
togglebutton.h
156
)
157
158
set(TS_FILES
159
translations/duckstation-qt_de.ts
160
translations/duckstation-qt_en.ts
161
translations/duckstation-qt_es.ts
162
translations/duckstation-qt_es-ES.ts
163
translations/duckstation-qt_fr.ts
164
translations/duckstation-qt_he.ts
165
translations/duckstation-qt_id.ts
166
translations/duckstation-qt_it.ts
167
translations/duckstation-qt_ja.ts
168
translations/duckstation-qt_ko.ts
169
translations/duckstation-qt_nl.ts
170
translations/duckstation-qt_pl.ts
171
translations/duckstation-qt_pt-BR.ts
172
translations/duckstation-qt_pt-PT.ts
173
translations/duckstation-qt_ru.ts
174
translations/duckstation-qt_sv.ts
175
translations/duckstation-qt_tr.ts
176
translations/duckstation-qt_zh-CN.ts
177
)
178
179
add_executable(duckstation-qt ${SRCS} ${QM_FILES})
180
target_precompile_headers(duckstation-qt PRIVATE "pch.h")
181
target_include_directories(duckstation-qt PRIVATE "${Qt6Gui_PRIVATE_INCLUDE_DIRS}" "${CMAKE_CURRENT_SOURCE_DIR}")
182
target_link_libraries(duckstation-qt PRIVATE core common imgui minizip scmversion Qt6::Core Qt6::Gui Qt6::Widgets)
183
184
# Our Qt builds may have exceptions on, so force them off.
185
target_compile_definitions(duckstation-qt PRIVATE QT_NO_EXCEPTIONS)
186
187
add_core_resources(duckstation-qt)
188
189
# Automatically generate a list of .ui calls and call qt_wrap_ui() to generate targets.
190
# This is needed because otherwise CMake rebuilds all source files if any unrelated files change.
191
# See https://gitlab.kitware.com/cmake/cmake/-/issues/22531 and https://gitlab.kitware.com/cmake/cmake/-/issues/16776
192
# Documentation says to use qt_add_ui(), but this generates a separate directory for every file.
193
# I'm concerned about arg length limits, so I manually invoke qt_wrap_ui().
194
# Also see https://github.com/thorntonryan/autouic_example.
195
set(UI_FILES "")
196
foreach(src ${SRCS})
197
if(src MATCHES "\\.ui$")
198
list(APPEND UI_FILES ${src})
199
endif()
200
endforeach()
201
qt_wrap_ui(UI_SRCS SOURCES ${UI_FILES})
202
target_sources(duckstation-qt PRIVATE ${UI_SRCS})
203
target_include_directories(duckstation-qt PRIVATE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
204
205
if(WIN32)
206
target_sources(duckstation-qt PRIVATE
207
duckstation-qt.rc
208
vcruntimecheck.cpp
209
)
210
211
# Needed to enable RAIntegration.
212
target_link_libraries(duckstation-qt PRIVATE rcheevos)
213
214
# We want a Windows subsystem application not console.
215
set_target_properties(duckstation-qt PROPERTIES
216
WIN32_EXECUTABLE TRUE
217
DEBUG_POSTFIX "-debug")
218
219
# Copy in Qt DLLs. Borrowed from Dolphin.
220
get_target_property(MOC_EXECUTABLE_LOCATION Qt6::moc IMPORTED_LOCATION)
221
get_filename_component(QT_BINARY_DIRECTORY "${MOC_EXECUTABLE_LOCATION}" DIRECTORY)
222
find_program(WINDEPLOYQT_EXE windeployqt HINTS "${QT_BINARY_DIRECTORY}")
223
add_custom_command(TARGET duckstation-qt POST_BUILD
224
COMMAND "${CMAKE_COMMAND}" -E env PATH="${QT_BINARY_DIRECTORY}"
225
"${WINDEPLOYQT_EXE}" --libdir="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
226
--plugindir="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/QtPlugins"
227
$<IF:$<CONFIG:Debug>,--debug,--release>
228
--no-compiler-runtime
229
--no-system-d3d-compiler
230
--no-system-dxc-compiler
231
--no-translations
232
"$<TARGET_FILE:duckstation-qt>"
233
)
234
add_custom_command(TARGET duckstation-qt POST_BUILD
235
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/qt.conf.win" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qt.conf"
236
)
237
#set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/translations")
238
239
set(DEPS_TO_COPY cpuinfo.dll discord-rpc.dll dxcompiler.dll dxil.dll freetype.dll harfbuzz.dll jpeg62.dll libpng16.dll
240
libsharpyuv.dll libwebp.dll libwebpdemux.dll libwebpmux.dll plutosvg.dll SDL3.dll shaderc_shared.dll
241
soundtouch.dll spirv-cross-c-shared.dll zip.dll zlib1.dll zstd.dll)
242
foreach(DEP ${DEPS_TO_COPY})
243
list(APPEND DEP_BINS "${CMAKE_PREFIX_PATH}/bin/${DEP}")
244
endforeach()
245
add_custom_command(TARGET duckstation-qt POST_BUILD
246
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEP_BINS} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
247
)
248
if(CMAKE_BUILD_TYPE MATCHES "Debug|Devel")
249
get_property(WINPIXEVENTRUNTIME_DLL TARGET WinPixEventRuntime::WinPixEventRuntime PROPERTY IMPORTED_LOCATION)
250
message(STATUS WP "${WINPIXEVENTRUNTIME_DLL}")
251
add_custom_command(TARGET duckstation-qt POST_BUILD
252
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${WINPIXEVENTRUNTIME_DLL}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
253
)
254
endif()
255
elseif(APPLE)
256
# Don't generate a bundle for XCode, it makes code signing fail...
257
if(NOT CMAKE_GENERATOR MATCHES "Xcode")
258
get_scm_version()
259
set(BUNDLE_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/DuckStation.app)
260
set_target_properties(duckstation-qt PROPERTIES
261
MACOSX_BUNDLE true
262
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
263
OUTPUT_NAME DuckStation
264
)
265
266
# Inject Qt Libraries into bundle.
267
if(NOT SKIP_POSTPROCESS_BUNDLE)
268
find_program(MACDEPLOYQT_EXE macdeployqt HINTS "${QT_BINARY_DIRECTORY}")
269
add_custom_target(duckstation-postprocess-bundle ALL
270
COMMAND "${MACDEPLOYQT_EXE}" "${BUNDLE_PATH}" -no-strip
271
)
272
add_dependencies(duckstation-postprocess-bundle duckstation-qt)
273
endif()
274
endif()
275
276
# Copy icon into the bundle
277
target_sources(duckstation-qt PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/DuckStation.icns")
278
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/DuckStation.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
279
endif()
280
281
# Compile qrc to a binary file.
282
if(NOT APPLE)
283
set(RCC_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/resources/duckstation-qt.rcc")
284
qt_add_binary_resources(duckstation-qt-rcc resources/duckstation-qt.qrc DESTINATION ${RCC_FILE} OPTIONS -no-compress)
285
add_dependencies(duckstation-qt duckstation-qt-rcc)
286
else()
287
set(RCC_FILE "${CMAKE_CURRENT_BINARY_DIR}/duckstation-qt.rcc")
288
qt_add_binary_resources(duckstation-qt-rcc resources/duckstation-qt.qrc DESTINATION ${RCC_FILE} OPTIONS -no-compress)
289
add_dependencies(duckstation-qt duckstation-qt-rcc)
290
target_sources(duckstation-qt PRIVATE ${RCC_FILE})
291
set_source_files_properties(${RCC_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
292
endif()
293
294
295
# Translation setup.
296
qt_add_lrelease(duckstation-qt TS_FILES ${TS_FILES} QM_FILES_OUTPUT_VARIABLE QM_FILES)
297
if(NOT APPLE)
298
set(QM_OUTPUT_DIR "$<TARGET_FILE_DIR:duckstation-qt>/translations")
299
add_custom_command(TARGET duckstation-qt POST_BUILD COMMAND "${CMAKE_COMMAND}" -E make_directory "${QM_OUTPUT_DIR}")
300
foreach (QM_FILE IN LISTS QM_FILES)
301
get_filename_component(QM_FILE_NAME ${QM_FILE} NAME)
302
add_custom_command(TARGET duckstation-qt POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${QM_FILE}" "${QM_OUTPUT_DIR}/${QM_FILE_NAME}")
303
endforeach()
304
else()
305
foreach (QM_FILE IN LISTS QM_FILES)
306
target_sources(duckstation-qt PRIVATE ${QM_FILE})
307
set_source_files_properties(${QM_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/translations)
308
endforeach()
309
endif()
310
copy_base_translations(duckstation-qt)
311
312