-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
130 lines (91 loc) · 3.16 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
cmake_minimum_required(VERSION 3.16)
project(FluentExample VERSION 0.1.1 LANGUAGES CXX)
# set(CMAKE_AUTORCC ON) # since we use the qt_add_xx() functions in cmake
# we won't need to use the auto rcc
# In fact, we don't need to add `.qrc` files anymore
set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# configure file for auto generate header
# e.g. version directly from CMakeLists.
# OpenGL, Vulkan and some features
#
configure_file(config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/config.h)
find_package(Qt6 REQUIRED COMPONENTS Quick LinguistTools)
file(GLOB TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts")
file(GLOB IMAGE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/res/images/*")
file(GLOB ICON_FILES "${CMAKE_CURRENT_SOURCE_DIR}/res/icons/*")
file(GLOB FONT_FILES "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts/*")
# !WARNING: Do not add ${CMAKE_CURRENT_SOURCE_DIR} in set function
# Use RELATIVE PATH instead
set(QML_FILES qml/App.qml
qml/window/MainWindow.qml
qml/window/About.qml
qml/components/Footer.qml
qml/components/Sidebar.qml
qml/components/MainEvent.qml
qml/views/V_Home.qml
qml/views/V_Settings.qml
qml/views/V_Demo.qml
)
set(APP_SOURCES
src/main.cpp
)
include_directories(./include)
set(APP_SOURCES
include/config.h
include/appInfo.h
include/localization.h
include/util.h
src/appInfo.cpp
src/localization.cpp
src/util.cpp
src/main.cpp
)
qt_add_executable(appFluentExample
${APP_SOURCES}
)
# Singleton type in QML must add properties
# So the generated qmldir will add "singleton"
set_source_files_properties(qml/components/Footer.qml
qml/components/Sidebar.qml
qml/components/MainEvent.qml
PROPERTIES
QT_QML_SINGLETON_TYPE TRUE
)
qt_add_qml_module(appFluentExample
URI FluentExample
VERSION 1.0
QML_FILES ${QML_FILES}
)
# compiled into the source file
# access translation files via `:/i18n`
qt_add_translations(appFluentExample
TS_FILES ${TS_FILES}
# LUPDATE_OPTIONS "-no-obsolete"
)
# images
qt_add_resources(appFluentExample "images"
PREFIX "/images"
BASE "res/images" # alias
FILES ${IMAGE_FILES})
# fonts
qt_add_resources(appFluentExample "fonts"
PREFIX "/fonts"
FILES ${FONT_FILES})
# program icons
qt_add_resources(appFluentExample "icons"
PREFIX "/icons"
BASE "res/icons"
FILES ${ICON_FILES})
target_link_libraries(appFluentExample
PRIVATE Qt6::Quick
)
# POST BUILD
# Copy Config files
set(CONFIG_FILE ${CMAKE_CURRENT_BINARY_DIR}/conf/config.json)
if(NOT EXISTS ${CONFIG_FILE})
add_custom_command(TARGET appFluentExample
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/conf ${CMAKE_CURRENT_BINARY_DIR}/conf
)
endif()