Skip to content

Commit f55e5ce

Browse files
committed
migrate to QT6
1 parent ace66a7 commit f55e5ce

23 files changed

Lines changed: 177 additions & 211 deletions

.github/workflows/build.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: build
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
windows:
9+
runs-on: windows-2022
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Cache vcpkg
14+
uses: actions/cache@v4
15+
with:
16+
path: |
17+
vcpkg_installed
18+
Project/third_party/vcpkg
19+
Project/third_party/vcpkg/downloads
20+
Project/third_party/vcpkg/archives
21+
key: vcpkg-${{ runner.os }}-${{ hashFiles('vcpkg.json') }}
22+
23+
- name: Build (Release x64)
24+
shell: pwsh
25+
run: |
26+
.\Project\build_vs.cmd x64 Release
27+
28+
- name: Upload Run artifacts
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: editor-run
32+
path: Run/*

CMakeLists.txt

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1919
if(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+
269278
target_include_directories(editor PRIVATE
270279
.
271280
Source
@@ -281,7 +290,7 @@ target_compile_definitions(editor PRIVATE
281290
)
282291

283292
target_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()
320364
endif()

Project/build_vs.cmd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ setlocal
44
set "ROOT_DIR=%~dp0.."
55
set "BUILD_DIR=%~dp0VS"
66
set "GENERATOR=Visual Studio 17 2022"
7+
set "VCPKG_BUILD_TYPE="
78

89
if "%~1"=="" (
910
set "PLATFORM=x64"
@@ -82,6 +83,7 @@ if not exist "%VCPKG_ROOT%\vcpkg.exe" (
8283
)
8384

8485
set "VCPKG_TOOLCHAIN=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake"
86+
set "VCPKG_INSTALLED_DIR=%ROOT_DIR%\vcpkg_installed"
8587

8688
if exist "%VCPKG_ROOT%\vcpkg.exe" (
8789
"%VCPKG_ROOT%\vcpkg.exe" install --triplet %VCPKG_TRIPLET%
@@ -97,7 +99,7 @@ if exist "%BUILD_DIR%\CMakeCache.txt" (
9799
)
98100

99101
if exist "%VCPKG_TOOLCHAIN%" (
100-
cmake -S "%ROOT_DIR%" -B "%BUILD_DIR%" -G "%GENERATOR%" -A "%PLATFORM%" -DCMAKE_TOOLCHAIN_FILE="%VCPKG_TOOLCHAIN%" -DVCPKG_TARGET_TRIPLET=%VCPKG_TRIPLET%
102+
cmake -S "%ROOT_DIR%" -B "%BUILD_DIR%" -G "%GENERATOR%" -A "%PLATFORM%" -DCMAKE_TOOLCHAIN_FILE="%VCPKG_TOOLCHAIN%" -DVCPKG_TARGET_TRIPLET=%VCPKG_TRIPLET% -DVCPKG_INSTALLED_DIR="%VCPKG_INSTALLED_DIR%"
101103
) else (
102104
cmake -S "%ROOT_DIR%" -B "%BUILD_DIR%" -G "%GENERATOR%" -A "%PLATFORM%"
103105
)

Source/Dialogs/CampaignDialog.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include "stdafx_ofed.hpp"
22
#include "ofed.hpp"
3-
#include<qlineedit.h>
3+
#include <QLineEdit>
44

55
#include "ui_CampaignDialog.h"
6-
#include <qevent.h>
7-
#include <qshortcut.h>
6+
#include <QEvent>
7+
#include <QShortcut>
88

99
cCampaignDialog::cCampaignDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) {
1010

Source/Dialogs/CampaignDialog.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class cCampaignDialog : public QDialog {
1212

1313

1414
public:
15-
cCampaignDialog(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
15+
cCampaignDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
1616
~cCampaignDialog();
1717

1818
void accept() override;

Source/Dialogs/MapView.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#include "ofed.hpp"
33
#include "ui_MapView.h"
44

5-
#include <qpixmap.h>
6-
#include <qpainter.h>
7-
#include <qevent.h>
5+
#include <QPixmap>
6+
#include <QPainter>
7+
#include <QEvent>
88

99
cMapView::cMapView( QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) {
1010

Source/Dialogs/MapView.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class cMapView : public QDialog {
1212
void paintEvent(QPaintEvent* e) override;
1313

1414
public:
15-
cMapView( QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
15+
cMapView( QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
1616
~cMapView();
1717

1818
void RenderTiles();

Source/Dialogs/NewMapDialog.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class cNewMapDialog : public QDialog {
44
Ui_NewMapDialog *mUi;
55

66
public:
7-
cNewMapDialog(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
7+
cNewMapDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
88

99
void accept() override;
1010
void reject() override;

Source/Dialogs/ToolboxSprites.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#include "ofed.hpp"
33
#include "ui_ToolboxSprites.h"
44

5-
#include <qpixmap.h>
6-
#include <qpainter.h>
7-
#include <qevent.h>
5+
#include <QPixmap>
6+
#include <QPainter>
7+
#include <QEvent>
88

99
cToolboxSprites::cToolboxSprites(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) {
1010

Source/Dialogs/ToolboxSprites.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class cToolboxSprites : public QDialog {
3131
void mouseMoveEvent(QMouseEvent *eventMove) override;
3232

3333
public:
34-
cToolboxSprites(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
34+
cToolboxSprites(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
3535
~cToolboxSprites();
3636

3737
void RenderSprites();

0 commit comments

Comments
 (0)