-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
359 lines (321 loc) · 8.27 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
cmake_minimum_required(VERSION 3.14)
project(
QmlMaterial
VERSION 0.1.1
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD
20)
set(CMAKE_CXX_STANDARD_REQUIRED
ON)
set(CMAKE_POSITION_INDEPENDENT_CODE
ON)
set(CMAKE_AUTOMOC
ON)
set(CMAKE_AUTOMOC_PATH_PREFIX ON)
option(QM_BUILD_EXAMPLE ON)
# check lto
include(CheckIPOSupported)
check_ipo_supported(
RESULT is_ipo_supported
OUTPUT lto_error)
if(is_ipo_supported
AND NOT EMSCRIPTEN)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION
ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG
OFF)
endif()
if(UNIX
AND NOT APPLE)
set(LINUX
CACHE INTERNAL TRUE "")
endif()
include(GNUInstallDirs)
find_package(
Qt6 REQUIRED
COMPONENTS Core Quick QuickControls2 Gui ShaderTools)
find_package(PkgConfig REQUIRED)
if(QT_KNOWN_POLICY_QTP0004)
qt_policy(SET QTP0004 NEW)
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
Release)
endif()
if("${QT_INSTALL_QML}" STREQUAL "")
set(QT_INSTALL_QML "${CMAKE_INSTALL_LIBDIR}/qt6/qml")
endif()
set(QML_INSTALL_DIR "${QT_INSTALL_QML}" CACHE STRING "")
message("QML_INSTALL_DIR: ${QML_INSTALL_DIR}")
set(LIBNAME
qml_material)
set(SOURCES
include/qml_material/qml_util.h
include/qml_material/theme.h
include/qml_material/color.h
include/qml_material/corner.h
include/qml_material/icon.h
include/qml_material/input_block.h
include/qml_material/item_holder.h
include/qml_material/enum.h
include/qml_material/round_item.h
include/qml_material/state.h
include/qml_material/helper.h
include/qml_material/type_scale.h
include/qml_material/token.h
include/qml_material/page_context.h
include/qml_material/snake_model.h
include/qml_material/loggingcategory.h
include/qml_material/rectangle.h
include/qml_material/elevation.h
include/qml_material/kirigami/displayhint.h
include/qml_material/kirigami/toolbarlayout.h
include/qml_material/kirigami/toolbarlayoutdelegate.h
include/qml_material/kirigami/wheelhandler.h
include/qml_material/scenegraph/geometry.h
include/qml_material/scenegraph/rectangle_material.h
include/qml_material/scenegraph/elevation_material.h
include/qml_material/upstream/qquickmaterialtextcontainer_p.h
src/scenegraph/geometry.cpp
src/scenegraph/rectangle_material.cpp
src/scenegraph/elevation_material.cpp
src/kirigami/displayhint.cpp
src/kirigami/toolbarlayout.cpp
src/kirigami/toolbarlayoutdelegate.cpp
src/kirigami/wheelhandler.cpp
src/upstream/qquickmaterialtextcontainer.cpp
src/color.cpp
src/corner.cpp
src/icon.cpp
src/input_block.cpp
src/item_holder.cpp
src/image.cpp
src/qml_util.cpp
src/state.cpp
src/theme.cpp
src/helper.cpp
src/page_context.cpp
src/snake_model.cpp
src/token.cpp
src/type_scale.cpp
src/round_item.cpp
src/rectangle.cpp
src/elevation.cpp
)
set(QML_FILES
qml/js/jsUtils.mjs
qml/Action.qml
qml/ActionGroup.qml
qml/ActionMenu.qml
qml/ActionToolBar.qml
qml/AppBar.qml
qml/Button.qml
qml/ButtonGroup.qml
qml/BarItem.qml
qml/Control.qml
qml/ComboBox.qml
qml/Card.qml
qml/AssistChip.qml
qml/FilterChip.qml
qml/InputChip.qml
qml/SuggestionChip.qml
qml/CircleProgressBar.qml
qml/CircularIndicator.qml
qml/Dialog.qml
qml/DialogButtonBox.qml
qml/Divider.qml
qml/Drawer.qml
qml/StandardDrawer.qml
qml/DrawerItem.qml
qml/DragHandle.qml
qml/Token.qml
qml/IconLabel.qml
qml/IconButton.qml
qml/StandardIconButton.qml
qml/FAB.qml
qml/Menu.qml
qml/MenuItem.qml
qml/Image.qml
qml/ListItem.qml
qml/ListView.qml
qml/Label.qml
qml/FontMetrics.qml
qml/Flickable.qml
qml/FlickablePane.qml
qml/GridView.qml
qml/Icon.qml
qml/IconSvg.qml
qml/Text.qml
qml/TextEdit.qml
qml/Pane.qml
qml/Page.qml
qml/PageIndicator.qml
qml/Popup.qml
qml/Space.qml
qml/SnakeBar.qml
qml/StackView.qml
qml/SplitView.qml
qml/Slider.qml
qml/SearchBar.qml
qml/ScrollBar.qml
qml/ScrollPage.qml
qml/Switch.qml
qml/RailItem.qml
qml/TextInput.qml
qml/TextMetrics.qml
qml/TextField.qml
qml/TabBar.qml
qml/TabButton.qml
qml/SdfRectangle.qml
qml/state/StateAppBar.qml
qml/state/StateSnakeBar.qml
qml/state/StateButton.qml
qml/state/StateCard.qml
qml/state/StateDragHandle.qml
qml/state/StateDrawerItem.qml
qml/state/StateTabButton.qml
qml/state/StateListItem.qml
qml/state/StateSlider.qml
qml/state/StateSwitch.qml
qml/state/StateIconButton.qml
qml/state/StateStandardIconButton.qml
qml/state/StateFAB.qml
qml/state/StateAssistChip.qml
qml/state/StateFilterChip.qml
qml/state/StateInputChip.qml
qml/state/StateSuggestionChip.qml
qml/state/StateBarItem.qml
qml/state/StateSearchBar.qml
qml/impl/BoxShadow.qml
qml/impl/CircleProgressShape.qml
qml/impl/CircleIndicatorShape.qml
qml/impl/ListBusyFooter.qml
qml/impl/Ripple2.qml
qml/impl/RectangularGlow.qml
qml/impl/CursorDelegate.qml
qml/impl/SliderHandle.qml
qml/impl/FloatingPlaceholderText.qml
qml/impl/TextFieldEmbed.qml
qml/impl/RoundClip.qml
qml/impl/Elevation.qml
qml/impl/ElevationRectangle.qml
qml/impl/ElevationRectangleBorder.qml
qml/impl/Shape.qml
)
set(RESOURCES
assets/MaterialIconsRound-Regular.otf
assets/MaterialIconsOutlined-Regular.otf)
set(SHADER_DEFINES)
set(QML_MATERIAL_BUILD_TYPE
SHARED)
if(UNIX AND NOT EMSCRIPTEN)
if(ANDROID)
list(APPEND SOURCES src/android/android.cpp)
list(APPEND SHADER_DEFINES "GLES=1")
else()
list(APPEND SOURCES src/linux/xdp.h src/linux/xdp.cpp)
endif()
endif()
if(EMSCRIPTEN)
list(APPEND SOURCES src/wasm/wasm.cpp)
list(APPEND SHADER_DEFINES "GLES=1")
set(QML_MATERIAL_BUILD_TYPE
STATIC)
add_compile_options(-flto)
add_link_options("-sEXPORT_NAME=qml_material" -s FULL_ES3=1 -flto)
endif()
set_source_files_properties(
qml/Token.qml
PROPERTIES QT_QML_SINGLETON_TYPE TRUE)
include_directories(include)
qt_add_qml_module(
${LIBNAME}
URI
Qcm.Material
${QML_MATERIAL_BUILD_TYPE}
RESOURCE_PREFIX
/
QML_FILES
${QML_FILES}
SOURCES
${SOURCES}
RESOURCES
${RESOURCES}
NO_PLUGIN_OPTIONAL)
set(SHADER_GLSLS
"assets/shader/common.glsl"
"assets/shader/sdf.glsl"
)
set(SHADER_SOURCES
"assets/shader/default.vert"
"assets/shader/round_clip.frag"
"assets/shader/sdf_rectangle.frag"
"assets/shader/shadow_.frag"
"assets/shader/rectangle.vert"
"assets/shader/rectangle.frag"
"assets/shader/shadow.vert"
"assets/shader/shadow.frag"
"assets/shader/rect_glow.frag"
)
set(SHADER_OPT
BATCHABLE
OPTIMIZED
)
if(CMAKE_BUILD_TYPE MATCHES Debug)
list(APPEND SHADER_OPT DEBUGINFO)
endif()
if(NOT WIN32)
list(APPEND SHADER_OPT NOHLSL)
endif()
qt_add_shaders(
${LIBNAME}
"shader"
PREFIX
"/Qcm/Material"
GLSL
"300es,330"
${SHADER_OPT}
DEFINES
${SHADER_DEFINES}
FILES
${SHADER_SOURCES})
foreach(
file
${SHADER_SOURCES})
set(output_file
".qsb/${file}.qsb")
add_custom_command(
OUTPUT ${output_file}
DEPENDS ${SHADER_GLSLS}
APPEND)
endforeach()
target_include_directories(
${LIBNAME}
PUBLIC include
PRIVATE "include/${LIBNAME}" "include/${LIBNAME}/kirigami" "include/${LIBNAME}/upstream" src)
set_target_properties(
${LIBNAME}
PROPERTIES CXX_VISIBILITY_PRESET hidden)
add_subdirectory(third_party)
if(QM_BUILD_EXAMPLE)
add_subdirectory(example)
endif()
target_link_libraries(
${LIBNAME}
PUBLIC Qt6::Core Qt6::Quick Qt6::QuickControls2
PRIVATE material_color)
function(qt_install_qml_module target_)
get_target_property(QML_TARGET_PATH ${target_} QT_QML_MODULE_TARGET_PATH)
get_target_property(QML_TYEPINFO ${target_} QT_QML_MODULE_TYPEINFO)
get_target_property(QML_PLUGIN_TARGET ${target_} QT_QML_MODULE_PLUGIN_TARGET)
set(QML_TARGET_INSTALL_DIR "${QML_INSTALL_DIR}/${QML_TARGET_PATH}")
install(TARGETS ${target_})
install(
TARGETS ${QML_PLUGIN_TARGET}
LIBRARY DESTINATION ${QML_TARGET_INSTALL_DIR})
install(
FILES "${QT_QML_OUTPUT_DIRECTORY}/${QML_TARGET_PATH}/qmldir"
"${QT_QML_OUTPUT_DIRECTORY}/${QML_TARGET_PATH}/${QML_TYEPINFO}"
DESTINATION ${QML_TARGET_INSTALL_DIR})
endfunction()
qt_install_qml_module(${LIBNAME})