Skip to content

Commit 00a5b1e

Browse files
committed
[cmake] FEXConfig: automatically generate qrc
Rather than manually creating a Qt 5 and Qt 6 QRC, instead automatically generate it. This makes it more flexible in the future in case any major refactors are done (wink wink). Needs some quick tests on Qt 5 Signed-off-by: crueter <[email protected]>
1 parent 974ba78 commit 00a5b1e

File tree

8 files changed

+37
-38
lines changed

8 files changed

+37
-38
lines changed

CMakeSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,4 @@
129129
"variables": []
130130
}
131131
]
132-
}
132+
}

External/jemalloc

Source/Tools/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ add_subdirectory(CommonTools)
33
if (NOT MINGW_BUILD)
44
if (BUILD_FEXCONFIG)
55
find_package(Qt6 COMPONENTS Qml Quick Widgets QUIET)
6-
if (NOT Qt6_FOUND)
6+
if (Qt6_FOUND)
7+
set(QT_VERSION_MAJOR 6)
8+
else()
9+
set(QT_VERSION_MAJOR 5)
710
find_package(Qt5 COMPONENTS Qml Quick Widgets REQUIRED)
811
endif()
912

Source/Tools/FEXConfig/CMakeLists.txt

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
11
set(CMAKE_AUTOMOC ON)
22

3-
add_executable(FEXConfig)
4-
target_sources(FEXConfig PRIVATE Main.cpp Main.h)
3+
add_executable(FEXConfig Main.cpp Main.h)
54
target_include_directories(FEXConfig PRIVATE ${CMAKE_SOURCE_DIR}/Source/)
6-
target_link_libraries(FEXConfig PRIVATE Common JemallocDummy)
7-
if (Qt6_FOUND)
8-
qt_add_resources(QT_RESOURCES qml6.qrc)
9-
target_link_libraries(FEXConfig PRIVATE Qt6::Qml Qt6::Quick Qt6::Widgets)
10-
else()
11-
qt_add_resources(QT_RESOURCES qml5.qrc)
12-
target_link_libraries(FEXConfig PRIVATE Qt5::Qml Qt5::Quick Qt5::Widgets)
13-
endif()
14-
target_sources(FEXConfig PRIVATE ${QT_RESOURCES})
5+
6+
set(common_qml
7+
main.qml
8+
icon.png)
9+
10+
set(dialog_qml
11+
qt${QT_VERSION_MAJOR}/FileDialog.qml
12+
qt${QT_VERSION_MAJOR}/FolderDialog.qml
13+
qt${QT_VERSION_MAJOR}/MessageDialog.qml)
14+
15+
set(all_qml ${common_qml} ${dialog_qml})
16+
17+
qt_add_resources(FEXConfig qml_common
18+
PREFIX /qml/FEX/Config
19+
BASE ${CMAKE_CURRENT_SOURCE_DIR}
20+
FILES ${common_qml} icon.png)
21+
22+
qt_add_resources(FEXConfig qml_dialog
23+
PREFIX /qml/FEX/Config
24+
BASE qt${QT_VERSION_MAJOR}
25+
FILES ${dialog_qml})
26+
27+
target_link_libraries(FEXConfig PRIVATE
28+
Common JemallocDummy
29+
Qt${QT_VERSION_MAJOR}::Qml
30+
Qt${QT_VERSION_MAJOR}::Quick
31+
Qt${QT_VERSION_MAJOR}::Widgets)
1532

1633
if (CMAKE_BUILD_TYPE MATCHES "RELEASE")
1734
target_link_options(FEXConfig

Source/Tools/FEXConfig/Main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ ConfigRuntime::ConfigRuntime(const QString& ConfigFilename) {
401401
qmlRegisterSingletonInstance<ConfigModel>("FEX.ConfigModel", 1, 0, "ConfigModel", &ConfigModelInst);
402402
qmlRegisterSingletonInstance<HostLibsModel>("FEX.HostLibsModel", 1, 0, "HostLibsModel", &HostLibs);
403403
qmlRegisterSingletonInstance<RootFSModel>("FEX.RootFSModel", 1, 0, "RootFSModel", &RootFSList);
404-
Engine.load(QUrl("qrc:/main.qml"));
404+
405+
Engine.load(QUrl(QStringLiteral("qrc:/qml/FEX/Config/main.qml")));
405406

406407
Window = qobject_cast<QQuickWindow*>(Engine.rootObjects().first());
407408
if (!ConfigFilename.isEmpty()) {

Source/Tools/FEXConfig/main.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import FEX.RootFSModel 1.0
99

1010
// Qt 6 changed the API of the Dialogs module slightly.
1111
// The differences are abstracted away in this import:
12-
import "qrc:/dialogs"
12+
import "qrc:/qml"
1313

1414
ApplicationWindow {
1515
id: root

Source/Tools/FEXConfig/qml5.qrc

Lines changed: 0 additions & 11 deletions
This file was deleted.

Source/Tools/FEXConfig/qml6.qrc

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)