-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
CMakeLists.txt
230 lines (191 loc) · 8.03 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
cmake_minimum_required(VERSION 3.20)
project(QmlAppTemplate VERSION 0.8 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
string(TIMESTAMP CURRENT_TIMESTAMP "%s" UTC)
set(APP_NAME ${CMAKE_PROJECT_NAME})
set(APP_VERSION ${CMAKE_PROJECT_VERSION})
set(APP_VERSION_CODE ${TIMESTAMP})
################################################################################
message(STATUS "[CMAKE] CMAKE_VERSION = ${CMAKE_VERSION}")
message(STATUS "[CMAKE] CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}")
message(STATUS "[SYSTEM] (HOST) SYSTEM NAME = ${CMAKE_HOST_SYSTEM_NAME}")
message(STATUS "[SYSTEM] (HOST) SYSTEM VERSION = ${CMAKE_HOST_SYSTEM_VERSION}")
message(STATUS "[SYSTEM] (TARGET) SYSTEM NAME = ${CMAKE_SYSTEM_NAME}")
message(STATUS "[SYSTEM] (TARGET) SYSTEM VERSION = ${CMAKE_SYSTEM_VERSION}")
message(STATUS "[PROJECT] SOURCE_DIR = ${CMAKE_SOURCE_DIR}")
message(STATUS "[PROJECT] BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
message(STATUS "[PROJECT] TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}")
message(STATUS "[PROJECT] QT_HOST_PATH = ${QT_HOST_PATH}")
################################################################################
find_package(Qt6 REQUIRED COMPONENTS Core Gui Svg Qml Quick QuickControls2)
find_package(Qt6 REQUIRED COMPONENTS LinguistTools)
qt_standard_project_setup(REQUIRES 6.7)
qt_policy(SET QTP0001 NEW)
qt_policy(SET QTP0002 NEW)
qt_policy(SET QTP0003 NEW) # Qt 6.7
#qt_policy(SET QTP0004 NEW) # Qt 6.8
qt_add_executable(${CMAKE_PROJECT_NAME}
src/main.cpp
src/SettingsManager.cpp src/SettingsManager.h
assets/assets.qrc
thirdparty/IconLibrary/IconLibrary.qrc
)
qt_add_qml_module(${CMAKE_PROJECT_NAME}
URI ${CMAKE_PROJECT_NAME}
QML_FILES
qml/MobileApplication.qml
qml/MobileHeader.qml
qml/MobileDrawer.qml
qml/MobilePermissions.qml
qml/MobileMenu.qml
qml/MobileExit.qml
qml/DesktopApplication.qml
qml/DesktopHeader.qml
qml/DesktopSidebar.qml
qml/ScreenMainView.qml
qml/ScreenMobileComponents.qml
qml/ScreenDesktopComponents.qml
qml/ScreenPlayground.qml
qml/ScreenFontInfos.qml
qml/ScreenHostInfos.qml
qml/ScreenSettings.qml
qml/ScreenAbout.qml
qml/PageButtons.qml
qml/PageColors.qml
qml/PageDateTime.qml
qml/PageDialogs.qml
qml/PageIndicators.qml
qml/PageSelectors.qml
qml/PageSliders.qml
qml/PageTextFields.qml
qml/PageTickers.qml
qml/popups/PopupMessage.qml
qml/popups/PopupChoice.qml
qml/popups/PopupDate.qml
qml/popups/PopupTime.qml
)
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE src/)
################################################################################
qt_standard_project_setup(
I18N_SOURCE_LANGUAGE en
I18N_TRANSLATED_LANGUAGES fr
)
qt_add_translations(${CMAKE_PROJECT_NAME}
TS_FILE_BASE ${CMAKE_PROJECT_NAME}
TS_FILE_DIR ${CMAKE_SOURCE_DIR}/i18n/
RESOURCE_PREFIX "/i18n"
)
################################################################################
# Qt libraries
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE
Qt6::Core
Qt6::Gui
Qt6::Svg
Qt6::Qml
Qt6::Quick
Qt6::QuickControls2
)
################################################################################
# SingleApplication
set(QAPPLICATION_CLASS QGuiApplication)
add_subdirectory(thirdparty/SingleApplication)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE SingleApplication)
# AppUtils
set(UTILS_DOCK_ENABLED true)
add_subdirectory(thirdparty/AppUtils)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE AppUtils)
# MobileUI
add_subdirectory(thirdparty/MobileUI)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE MobileUI)
# ComponentLibrary
add_subdirectory(thirdparty/ComponentLibrary)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ComponentLibraryplugin)
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE thirdparty/)
################################################################################
## Android
if (CMAKE_SYSTEM_NAME STREQUAL "Android")
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
#QT_ANDROID_ABIS "armeabi-v7a;arm64-v8a;x86;x86_64"
#QT_ANDROID_BUILD_ALL_ABIS ON
QT_ANDROID_MIN_SDK_VERSION 23
QT_ANDROID_TARGET_SDK_VERSION 35
QT_ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/assets/android/"
)
endif()
#if (APPLE)
# set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
# set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
# set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "")
# set(CMAKE_XCODE_ATTRIBUTE_PROVISIONING_PROFILE "")
#endif()
## macOS
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
#set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0")
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE ON
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/assets/macos/Info.plist"
# Old way (???)
MACOSX_BUNDLE_GUI_IDENTIFIER "io.emeric.qmlapptemplate"
MACOSX_BUNDLE_BUNDLE_NAME ${CMAKE_PROJECT_NAME}
MACOSX_BUNDLE_BUNDLE_VERSION ${CMAKE_PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
# New Xcode attributes (???)
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "io.emeric.qmlapptemplate"
XCODE_ATTRIBUTE_PRODUCT_NAME ${CMAKE_PROJECT_NAME}
XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION ${CMAKE_PROJECT_VERSION}
XCODE_ATTRIBUTE_MARKETING_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${CMAKE_SOURCE_DIR}/assets/macos/${CMAKE_PROJECT_NAME}.entitlements"
)
endif()
## iOS
if (CMAKE_SYSTEM_NAME STREQUAL "iOS")
#set(assets_catalog_path "${CMAKE_SOURCE_DIR}/assets/ios/Assets.xcassets")
#target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${assets_catalog_path})
#set_source_files_properties(${assets_catalog_path} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE ON
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/assets/ios/Info.plist"
# Qt
#QT_IOS_LAUNCH_SCREEN "${CMAKE_SOURCE_DIR}/assets/ios/LaunchScreen.storyboard"
# New Xcode attributes (???)
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "io.emeric.qmlapptemplate"
XCODE_ATTRIBUTE_PRODUCT_NAME ${CMAKE_PROJECT_NAME}
XCODE_ATTRIBUTE_CURRENT_PROJECT_VERSION ${CMAKE_PROJECT_VERSION}
XCODE_ATTRIBUTE_MARKETING_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "14.0"
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2" # iPhone,iPad
XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon"
XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS "YES"
)
endif()
## Windows
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
WIN32_EXECUTABLE ON
)
endif()
## Release build? Set "no debug" macros
if (CMAKE_BUILD_TYPE STREQUAL Release)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
NDEBUG
QT_NO_DEBUG
QT_NO_DEBUG_OUTPUT
)
endif()
################################################################################
# Output?
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
#ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib"
#LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin"
)
# Output?
#install(TARGETS ${CMAKE_PROJECT_NAME}
# BUNDLE DESTINATION bin/
# LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
#)
################################################################################