Skip to content

Commit 8ddc8ec

Browse files
committed
[squashme]Use customized cmake for Fluid
Now the submodule ref can be used as-is Clean up some Fluid hackiness.
1 parent f5094a0 commit 8ddc8ec

File tree

3 files changed

+143
-19
lines changed

3 files changed

+143
-19
lines changed

CMakeLists.txt

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ set(CMAKE_AUTORCC ON)
1616
set(ARIA2_LIBS "${CMAKE_CURRENT_SOURCE_DIR}/aria2/src/.libs/libaria2.a" CACHE STRING "aria2 libraries")
1717
set(ARIA2_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/aria2/include" CACHE STRING "aria2 include directory")
1818

19-
find_package(Qt6 REQUIRED COMPONENTS Core Qml Quick QuickControls2 QuickDialogs2 Network Svg Gui Widgets )
20-
21-
# Actually only used by Fluid and Quazip, not us. HACK: prevent warning spam
22-
find_package(Qt6 COMPONENTS Core5Compat)
19+
find_package(Qt6 REQUIRED COMPONENTS Core Qml Quick QuickControls2 QuickDialogs2 Network Gui Widgets)
2320

2421
if (WIN32)
2522
set(CMAKE_C_FLAGS "-static -static-libgcc ${CMAKE_C_FLAGS}")
@@ -28,10 +25,27 @@ endif()
2825

2926
qt_standard_project_setup(REQUIRES 6.8)
3027

31-
option(FLUID_WITH_GALLERY "" OFF)
32-
option(FLUID_WITH_DOCUMENTATION "" OFF)
3328
option(FLUID_INSTALL_ICONS "" OFF)
34-
add_subdirectory(fluid)
29+
option(FLUID_WITH_DOCUMENTATION "" OFF)
30+
option(FLUID_WITH_GALLERY "" OFF)
31+
option(FLUID_WITH_QML_MODULES "" ON)
32+
function(add_fluid) # Use function to emulate the new scope created by add_subdirectory
33+
find_package(Qt6 6.8
34+
REQUIRED
35+
COMPONENTS
36+
Core
37+
Core5Compat
38+
Gui
39+
#GuiPrivate
40+
Svg
41+
Qml
42+
Quick
43+
QuickControls2
44+
)
45+
set(QT_QML_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/qml_modules")
46+
include(fluid.cmake)
47+
endfunction()
48+
add_fluid()
3549

3650
set(QUAZIP_BZIP2 OFF)
3751
set(QUAZIP_ENABLE_TESTS OFF)

fluid.cmake

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# This file was created the same as fluid/src/controls/CMakeLists.txt in the
2+
# fluid submodule commit, with a few changes:
3+
# - rejigger QML module structure (rebased to upstream at https://github.com/lirios/fluid/pull/362)
4+
# - make the library static
5+
# - remove an install command
6+
# - make it work regardless of CMAKE_CURRENT_SOURCE_DIR (i.e. without add_subdirectory)
7+
# - remove the custom plugin class (controlsplugin.cpp) and use the auto-generated one. Thes
8+
# custom plugin class registers the image provider, which
9+
# we no longer use. Using a custom plugin class disables a ton of helpful Qt infrastructure for
10+
# automatic registration, and with the aggressive linker flags we are using, which don't follow
11+
# the C++ standard and remove things even from referenced translation units, it's very difficult
12+
# to get it to stop removing the plugin registration code.
13+
14+
set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/fluid/src/controls")
15+
16+
set(LIBNAME Fluid)
17+
18+
# Source files
19+
set(_sources
20+
# cpp/controlsplugin.cpp cpp/controlsplugin.h
21+
cpp/core/clipboard.cpp cpp/core/clipboard.h
22+
cpp/core/controlsutils.cpp cpp/core/controlsutils.h
23+
cpp/core/device.cpp cpp/core/device.h
24+
cpp/core/inputregion.cpp cpp/core/inputregion.h
25+
cpp/core/standardpaths.cpp cpp/core/standardpaths.h
26+
cpp/datetime/datepicker.cpp cpp/datetime/datepicker.h
27+
cpp/datetime/dateselector.cpp cpp/datetime/dateselector.h
28+
cpp/datetime/datetimepicker.cpp cpp/datetime/datetimepicker.h
29+
cpp/datetime/dateutils.cpp cpp/datetime/dateutils.h
30+
cpp/datetime/picker.cpp cpp/datetime/picker.h
31+
cpp/datetime/timepicker.cpp cpp/datetime/timepicker.h
32+
cpp/datetime/timeselector.cpp cpp/datetime/timeselector.h
33+
cpp/datetime/yearmodel.cpp cpp/datetime/yearmodel.h
34+
cpp/datetime/yearselector.cpp cpp/datetime/yearselector.h
35+
cpp/iconthemeimageprovider.cpp cpp/iconthemeimageprovider.h
36+
cpp/style/color.cpp cpp/style/color.h
37+
cpp/style/style.cpp cpp/style/style.h
38+
)
39+
40+
# QML files
41+
file(GLOB_RECURSE _qml CONFIGURE_DEPENDS
42+
RELATIVE "${SOURCE_DIR}"
43+
"${SOURCE_DIR}/qml/*.qml" "${SOURCE_DIR}/qml/**/*.qml"
44+
)
45+
foreach(_qmlfile ${_qml})
46+
set_source_files_properties("${SOURCE_DIR}/${_qmlfile}" PROPERTIES QT_RESOURCE_ALIAS "${_qmlfile}")
47+
endforeach()
48+
49+
string(REGEX REPLACE cpp/ "${SOURCE_DIR}/cpp/" _sources "${_sources}")
50+
string(REGEX REPLACE qml/ "${SOURCE_DIR}/qml/" _qml "${_qml}")
51+
52+
# ------------------------------------------------------------
53+
# Define the QML module
54+
# ------------------------------------------------------------
55+
set_source_files_properties("${SOURCE_DIR}/qml/core/Units.qml" PROPERTIES
56+
QT_QML_SINGLETON_TYPE TRUE
57+
)
58+
59+
qt_add_qml_module(${LIBNAME} STATIC
60+
URI Fluid
61+
VERSION 2.0
62+
SOURCES ${_sources}
63+
QML_FILES ${_qml}
64+
IMPORTS
65+
QtQuick.Layouts
66+
DEPENDENCIES
67+
QtQuick
68+
QtQuick.Templates
69+
#Fluid.Private
70+
PLUGIN_TARGET ${LIBNAME}
71+
CLASS_NAME FluidPlugin
72+
NO_PLUGIN_OPTIONAL
73+
)
74+
75+
set_target_properties(${LIBNAME} PROPERTIES
76+
AUTOMOC ON
77+
AUTORCC ON
78+
AUTOUIC ON
79+
)
80+
target_include_directories(${LIBNAME}
81+
PUBLIC
82+
${SOURCE_DIR}/cpp/core
83+
${SOURCE_DIR}/cpp/datetime
84+
${SOURCE_DIR}/cpp/style
85+
)
86+
target_link_libraries(${LIBNAME}
87+
PRIVATE
88+
Qt6::Core
89+
Qt6::Gui
90+
Qt6::GuiPrivate
91+
Qt6::Qml
92+
Qt6::Quick
93+
Qt6::QuickControls2
94+
Qt6::Svg
95+
)
96+
target_compile_definitions(${LIBNAME}
97+
PRIVATE
98+
FLUID_INSTALL_ICONS=$<IF:$<BOOL:${FLUID_INSTALL_ICONS}>,1,0>
99+
)
100+
101+
install(TARGETS ${LIBNAME}
102+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
103+
104+
# qt_install_qml_module(${LIBNAME})
105+
106+
if(FLUID_INSTALL_ICONS)
107+
file(GLOB icons "${SOURCE_DIR}/icons/*/*.svg")
108+
foreach(source_path IN LISTS icons)
109+
string(REPLACE "${SOURCE_DIR}/icons/" "" icon_basename "${source_path}")
110+
get_filename_component(_category "${icon_basename}" DIRECTORY)
111+
install(FILES "${source_path}" DESTINATION "${QML_INSTALL_DIR}/Fluid/icons/${_category}")
112+
endforeach()
113+
else()
114+
file(GLOB_RECURSE _icons CONFIGURE_DEPENDS
115+
"${SOURCE_DIR}/icons/*/*.svg"
116+
)
117+
qt_add_resources(${LIBNAME} FluidIcons
118+
PREFIX "/liri.io/fluid"
119+
BASE "${SOURCE_DIR}"
120+
FILES ${_icons}
121+
)
122+
endif()

main.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@
3434
#include "splashcontroller.h"
3535
#include "system.h"
3636

37-
#if 0
38-
#include <QtQml/QQmlExtensionPlugin>
39-
Q_IMPORT_QML_PLUGIN(Fluid)
40-
#endif
41-
4237
namespace {
4338

4439
QFile logFile;
@@ -218,10 +213,6 @@ int main(int argc, char *argv[])
218213
QmlDownloader downloader(options.ariaLogFilename, options.connectUrl, settings);
219214
QQmlApplicationEngine engine;
220215

221-
// HACK: Q_IMPORT_QML_PLUGIN(Fluid) gives a linker error
222-
void qml_register_types_Fluid();
223-
qml_register_types_Fluid();
224-
225216
// Top-level windows can be attached to this so that they aren't QObject-children of the
226217
// splash screen. Must destruct before engine.
227218
QObject motherOfWindows;
@@ -238,9 +229,6 @@ int main(int argc, char *argv[])
238229
qmlRegisterUncreatableType<QmlDownloader>(
239230
"QmlDownloader", 1, 0, "QmlDownloader", "QmlDownloader not constructible");
240231

241-
// LOAD-BEARING POSTER - DO NOT TOUCH
242-
engine.singletonInstance<QObject*>("Fluid", "foo");
243-
244232
engine.load(QUrl(QLatin1String("qrc:/UnvUpdater/splash.qml")));
245233
return app.exec();
246234
}

0 commit comments

Comments
 (0)