@@ -14,7 +14,7 @@ set(CMAKE_AUTOUIC_SEARCH_PATHS
1414 "${CMAKE_CURRENT_LIST_DIR} /Source/Dialogs"
1515)
1616
17- find_package (Qt5 REQUIRED COMPONENTS Widgets )
17+ find_package (Qt6 REQUIRED COMPONENTS Widgets )
1818
1919if (WIN32 )
2020 include (FetchContent )
@@ -266,6 +266,15 @@ set_target_properties(editor PROPERTIES
266266 VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR} /Run"
267267)
268268
269+ if (WIN32 )
270+ set_property (DIRECTORY PROPERTY VS_STARTUP_PROJECT editor )
271+
272+ # Rely on windeployqt instead of vcpkg applocal for Qt deployment.
273+ set (VCPKG_APPLOCAL_DEPS OFF CACHE BOOL "" FORCE )
274+ set_target_properties (editor PROPERTIES VCPKG_APPLOCAL_DEPS OFF )
275+ set_property (TARGET editor PROPERTY VS_GLOBAL_VcpkgApplocalDeps "false" )
276+ endif ()
277+
269278target_include_directories (editor PRIVATE
270279 .
271280 Source
@@ -281,7 +290,7 @@ target_compile_definitions(editor PRIVATE
281290)
282291
283292target_link_libraries (editor PRIVATE
284- Qt5 ::Widgets
293+ Qt6 ::Widgets
285294 SDL3::SDL3
286295 SDL3_mixer::SDL3_mixer
287296)
@@ -300,21 +309,56 @@ if(WIN32)
300309 list (APPEND _runtime_dlls $<TARGET_FILE :SDL3_mixer -shared >)
301310 endif ()
302311
303- if (TARGET Qt5::Widgets)
304- list (APPEND _runtime_dlls $<TARGET_FILE :Qt5 ::Widgets >)
305- endif ()
306- if (TARGET Qt5::Gui)
307- list (APPEND _runtime_dlls $<TARGET_FILE :Qt5 ::Gui >)
308- endif ()
309- if (TARGET Qt5::Core)
310- list (APPEND _runtime_dlls $<TARGET_FILE :Qt5 ::Core >)
311- endif ()
312-
313312 if (_runtime_dlls)
314313 add_custom_command (TARGET editor POST_BUILD
315314 COMMAND ${CMAKE_COMMAND} -E copy_if_different
316315 ${_runtime_dlls}
317316 "${CMAKE_CURRENT_LIST_DIR} /Run"
318317 COMMENT "Copy runtime DLLs to Run" )
319318 endif ()
319+
320+ if (TARGET Qt6::qmake)
321+ get_target_property (_qt6_qmake Qt6::qmake IMPORTED_LOCATION )
322+ get_filename_component (_qt6_bin_dir "${_qt6_qmake} " DIRECTORY )
323+ set (_qt6_windeployqt "${_qt6_bin_dir} /windeployqt.exe" )
324+ if (EXISTS "${_qt6_windeployqt} " )
325+ if (DEFINED VCPKG_INSTALLED_DIR AND DEFINED VCPKG_TARGET_TRIPLET)
326+ set (_qt6_debug_bin "${VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /debug/bin" )
327+ set (_qt6_release_bin "${VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /bin" )
328+ set (_qt6_debug_plugins "${VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /debug/Qt6/plugins" )
329+ set (_qt6_release_plugins "${VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /Qt6/plugins" )
330+ endif ()
331+ add_custom_command (TARGET editor POST_BUILD
332+ COMMAND ${CMAKE_COMMAND}
333+ -DDEPLOY_CONFIG=$<CONFIG>
334+ -DWINDEPLOYQT= "${_qt6_windeployqt} "
335+ -DRUN_DIR= "${CMAKE_CURRENT_LIST_DIR} /Run"
336+ -DTARGET_EXE= "$<TARGET_FILE :editor >"
337+ -DQT_DEBUG_BIN= "${_qt6_debug_bin} "
338+ -DQT_RELEASE_BIN= "${_qt6_release_bin} "
339+ -DQT_BIN_DIR= "${_qt6_bin_dir} "
340+ -P "${CMAKE_CURRENT_LIST_DIR} /cmake/windeployqt.cmake"
341+ COMMENT "Run windeployqt for editor" )
342+ endif ()
343+ endif ()
344+
345+ if (DEFINED _qt6_debug_bin AND DEFINED _qt6_debug_plugins)
346+ add_custom_command (TARGET editor POST_BUILD
347+ COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_LIST_DIR} /Run/platforms"
348+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
349+ "${_qt6_debug_bin} /Qt6Cored.dll"
350+ "${_qt6_debug_bin} /Qt6Guid.dll"
351+ "${_qt6_debug_bin} /Qt6Widgetsd.dll"
352+ "${CMAKE_CURRENT_LIST_DIR} /Run"
353+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
354+ "${_qt6_debug_plugins} /platforms/qwindowsd.dll"
355+ "${CMAKE_CURRENT_LIST_DIR} /Run/platforms"
356+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
357+ "${_qt6_debug_bin} /Qt6Cored.dll"
358+ "${_qt6_debug_bin} /Qt6Guid.dll"
359+ "${_qt6_debug_bin} /Qt6Widgetsd.dll"
360+ "${VCPKG_INSTALLED_DIR} /${VCPKG_TARGET_TRIPLET} /bin"
361+ COMMENT "Copy Qt debug DLLs and platform plugin"
362+ CONFIGURATIONS Debug )
363+ endif ()
320364endif ()
0 commit comments