-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
289 lines (244 loc) · 8.64 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
cmake_minimum_required(VERSION 3.21.1 FATAL_ERROR)
#######################################################
# Project Info
#######################################################
project(QGroundControl LANGUAGES C CXX)
#######################################################
# CMake Configuration Options
#######################################################
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/staging)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR OFF)
include(FeatureSummary)
include(CMakePrintHelpers)
include(FetchContent)
include(ExternalProject)
include(GNUInstallDirs)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel;Coverage")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type" FORCE)
endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
option(QGC_STABLE_BUILD "Stable build option" OFF)
if(QGC_STABLE_BUILD)
message(STATUS "Stable Build")
else()
message(STATUS "Daily Build")
add_compile_definitions(DAILY_BUILD)
endif()
include(CMakeDependentOption)
cmake_dependent_option(QGC_BUILD_TESTING "Enable testing" ON "CMAKE_BUILD_TYPE STREQUAL Debug" OFF)
include(CompileOptions)
#######################################################
# Qt6 Configuration
#######################################################
include(Qt6QGCConfiguration)
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Qt version: ${QT_VERSION}")
message(STATUS "Qt spec: ${QT_MKSPEC}")
if(LINUX)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/AppDir/usr)
endif()
# Find Qt6 libraries
find_package(Qt6
REQUIRED
COMPONENTS
Bluetooth
Charts
Concurrent
Core
Core5Compat
Location
Multimedia
Network
Positioning
Quick
QuickControls2
QuickWidgets
OpenGL
Sql
Svg
Test
TextToSpeech
Widgets
Xml
OPTIONAL_COMPONENTS
LinguistTools
SerialPort
HINTS
${QT_LIBRARY_HINTS}
)
qt_standard_project_setup(REQUIRES 6.6.0)
qt_policy(
SET QTP0001 NEW
SET QTP0002 NEW
)
set(QT_QML_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/qml" CACHE PATH "Install path for QML" FORCE)
set(QML_IMPORT_PATH ${CMAKE_SOURCE_DIR}/qml ${CMAKE_BINARY_DIR}/imports CACHE STRING "Extra QML Import Paths" FORCE)
#######################################################
# QML Configuration
#######################################################
option(QGC_COMPILE_QML "Pre-compile QML files using the Qt Quick compiler." FALSE)
add_feature_info(COMPILE_QML COMPILE_QML "Pre-compile QML files using the Qt Quick compiler.")
if(QGC_COMPILE_QML)
find_package(Qt6QuickCompiler)
set_package_properties(Qt6QuickCompiler
PROPERTIES
DESCRIPTION "Pre-compile QML files using the Qt Quick compiler."
TYPE OPTIONAL
)
endif()
option(QGC_DEBUG_QML "Build QGroundControl with QML debugging/profiling support." FALSE)
add_feature_info(DEBUG_QML DEBUG_QML "Build QGroundControl with QML debugging/profiling support.")
if(QGC_DEBUG_QML)
message(STATUS "To enable the QML debugger/profiler, run with: '-qmljsdebugger=port:1234'")
add_compile_definitions(
QMLJSDEBUGGER
QT_QML_DEBUG
)
endif()
#######################################################
# QGroundControl Info
#######################################################
set(COMPANY "Mavlink")
set(COPYRIGHT "Copyright (c) 2018 QGroundControl. All rights reserved.")
set(IDENTIFIER "io.mavlink.qgroundcontrol")
add_compile_definitions(
QGC_APPLICATION_NAME="QGroundControl"
QGC_ORG_NAME="QGroundControl.org"
QGC_ORG_DOMAIN="org.qgroundcontrol"
)
#######################################################
# QGroundControl Git Information
#######################################################
include(Git)
message(STATUS "QGroundControl version: ${APP_VERSION_STR}")
#######################################################
# QGroundControl Resources
#######################################################
add_subdirectory(libs)
add_subdirectory(src)
set(QGC_RESOURCES
${CMAKE_SOURCE_DIR}/qgcimages.qrc
${CMAKE_SOURCE_DIR}/qgcresources.qrc
${CMAKE_SOURCE_DIR}/qgroundcontrol.qrc
${CMAKE_SOURCE_DIR}/resources/InstrumentValueIcons/InstrumentValueIcons.qrc
${CMAKE_SOURCE_DIR}/src/FirmwarePlugin/APM/APMResources.qrc
${CMAKE_SOURCE_DIR}/src/FirmwarePlugin/PX4/PX4Resources.qrc
)
if(CONFIG_UTM_ADAPTER)
list(APPEND QGC_RESOURCES ${CMAKE_SOURCE_DIR}/src/UTMSP/utmsp.qrc)
else()
list(APPEND QGC_RESOURCES ${CMAKE_SOURCE_DIR}/src/UTMSP/dummy/utmsp_dummy.qrc)
endif()
if(QGC_BUILD_TESTING)
list(APPEND QGC_RESOURCES ${CMAKE_SOURCE_DIR}/test/UnitTest.qrc)
endif()
if(WIN32)
list(APPEND QGC_RESOURCES ${CMAKE_SOURCE_DIR}/deploy/windows/QGroundControl.rc)
elseif(MACOS)
set(MACOSX_BUNDLE_ICON_FILE macx.icns)
set(app_icon_macos "${CMAKE_SOURCE_DIR}/resources/icons/macx.icns")
set_source_files_properties(${app_icon_macos} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
list(APPEND QGC_RESOURCES ${app_icon_macos})
endif()
#######################################################
# QGroundControl Target
#######################################################
qt_add_executable(${PROJECT_NAME} src/main.cc ${QGC_RESOURCES})
set_target_properties(${PROJECT_NAME}
PROPERTIES
QT_RESOURCE_PREFIX "/qgc"
)
if(Qt6LinguistTools_FOUND)
file(GLOB TS_SOURCES RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/translations/qgc_*.ts)
# TODO: Update to new qt_add_translations form in Qt6.7
qt_add_translations(${PROJECT_NAME}
TS_FILES
${TS_SOURCES}
)
endif()
if(MACOS)
set_target_properties(${PROJECT_NAME}
PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/deploy/mac/MacOSXBundleInfo.plist.in
)
elseif(IOS)
set_target_properties(${PROJECT_NAME}
PROPERTIES
QT_IOS_LAUNCH_SCREEN ${CMAKE_SOURCE_DIR}/deploy/ios/QGCLaunchScreen.xib
)
elseif(WIN32)
set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE TRUE)
elseif(ANDROID)
add_android_openssl_libraries(${PROJECT_NAME})
set_target_properties(${PROJECT_NAME}
PROPERTIES
QT_ANDROID_ABIS ${ANDROID_ABI}
QT_ANDROID_MIN_SDK_VERSION 26
QT_ANDROID_TARGET_SDK_VERSION 33
QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/android
QT_ANDROID_VERSION_NAME ${APP_VERSION_STR}
# QT_ANDROID_VERSION_CODE 5.0
QT_QML_ROOT_PATH ${CMAKE_SOURCE_DIR}
)
if(CMAKE_BUILD_TYPE STREQUAL "Release" AND ANDROID_KEYSTORE_PASSWORD)
set(QT_ANDROID_SIGN_APK TRUE)
endif()
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE qgc)
#######################################################
# Testing Configuration
#######################################################
if(QGC_BUILD_TESTING)
add_subdirectory(test)
target_link_libraries(${PROJECT_NAME} PRIVATE qgctest)
endif()
#######################################################
# Install Configuration
#######################################################
install(
TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
BUNDLE DESTINATION .
)
if(NOT ANDROID)
qt_generate_deploy_qml_app_script(
TARGET ${PROJECT_NAME}
OUTPUT_SCRIPT deploy_script
MACOS_BUNDLE_POST_BUILD
)
install(SCRIPT ${deploy_script})
endif()
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/resources/
DESTINATION ${CMAKE_INSTALL_DATADIR}/qgroundcontrol
)
if(LINUX)
install(
FILES ${CMAKE_SOURCE_DIR}/deploy/linux/org.mavlink.qgroundcontrol.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
)
install(
FILES ${CMAKE_SOURCE_DIR}/resources/icons/qgroundcontrol.png
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/128x128/apps/
RENAME org.mavlink.qgroundcontrol.png
)
configure_file(
${CMAKE_SOURCE_DIR}/deploy/linux/org.mavlink.qgroundcontrol.metainfo.xml.in
${CMAKE_BINARY_DIR}/metainfo/org.mavlink.qgroundcontrol.metainfo.xml
@ONLY
)
install(
FILES ${CMAKE_BINARY_DIR}/metainfo/org.mavlink.qgroundcontrol.metainfo.xml
DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo/
)
install(SCRIPT "${CMAKE_SOURCE_DIR}/cmake/CreateAppImage.cmake")
endif()