2023-12-06 13:51:14 -04:00
cmake_minimum_required ( VERSION 3.10 )
project ( QGroundControl LANGUAGES C CXX )
include ( GNUInstallDirs )
set_property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel;Coverage" )
2023-12-08 12:08:42 -04:00
set ( CMAKE_CXX_STANDARD 17 )
2023-12-06 13:51:14 -04:00
set ( CMAKE_AUTOMOC ON )
set ( CMAKE_AUTOUIC ON )
set ( CMAKE_AUTORCC ON )
set ( CMAKE_INCLUDE_CURRENT_DIR ON )
include ( FeatureSummary )
if ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
add_compile_options ( -Wall -Wextra )
endif ( )
# CMake build type
# Debug Release RelWithDebInfo MinSizeRel Coverage
if ( NOT CMAKE_BUILD_TYPE )
# default to release with debug symbols
set ( CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type" FORCE )
endif ( )
# Add folder where are supportive functions
list ( APPEND CMAKE_MODULE_PATH ${ CMAKE_SOURCE_DIR } /cmake )
# Configure Qt5 to get necessary variables
include ( Qt5QGCConfiguration )
message ( STATUS "Build Type: ${CMAKE_BUILD_TYPE}" )
message ( STATUS "Qt version: ${QT_VERSION}" )
message ( STATUS "Qt spec: ${QT_MKSPEC}" )
set ( COMPANY "Mavlink" )
set ( COPYRIGHT "Copyright (c) 2018 QGroundControl. All rights reserved." )
set ( IDENTIFIER "io.mavlink.qgroundcontrol" )
add_definitions (
- D Q G C _ A P P L I C A T I O N _ N A M E = " Q G r o u n d C o n t r o l "
- D Q G C _ O R G _ N A M E = " Q G r o u n d C o n t r o l . o r g "
- D Q G C _ O R G _ D O M A I N = " o r g . q g r o u n d c o n t r o l "
)
include ( Git )
message ( STATUS "QGroundControl version: ${APP_VERSION_STR}" )
#=============================================================================
# ccache
#
option ( CCACHE "Use ccache if available" ON )
find_program ( CCACHE_PROGRAM ccache )
if ( CCACHE AND CCACHE_PROGRAM AND NOT DEFINED ENV{CCACHE_DISABLE} )
set_property ( GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}" )
endif ( )
#=============================================================================
# Compile QML
#
option ( 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 ( COMPILE_QML )
find_package ( Qt5QuickCompiler )
set_package_properties ( Qt5QuickCompiler PROPERTIES
D E S C R I P T I O N " P r e - c o m p i l e Q M L f i l e s u s i n g t h e Q t Q u i c k c o m p i l e r . "
T Y P E O P T I O N A L
)
endif ( )
#=============================================================================
# Debug QML
#
option ( 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 ( DEBUG_QML )
message ( STATUS "To enable the QML debugger/profiler, run with: '-qmljsdebugger=port:1234'" )
add_definitions ( -DQMLJSDEBUGGER )
add_definitions ( -DQT_DECLARATIVE_DEBUG )
add_definitions ( -DQT_QML_DEBUG )
endif ( )
#=============================================================================
# GStreamer
#
find_package ( PkgConfig )
set ( GST_DEPENDENCIES
g s t r e a m e r - 1 . 0 > = 1 . 1 4
g s t r e a m e r - v i d e o - 1 . 0 > = 1 . 1 4
g s t r e a m e r - g l - 1 . 0 > = 1 . 1 4
)
if ( MSVC )
pkg_check_modules ( GST
$ { G S T _ D E P E N D E N C I E S }
)
else ( )
pkg_check_modules ( GST
$ { G S T _ D E P E N D E N C I E S }
e g l
)
endif ( )
if ( GST_FOUND )
add_definitions (
- D Q G C _ G S T _ S T R E A M I N G
)
option ( QGC_GST_MICROHARD_ENABLED "Enable microhard" OFF )
option ( QGC_GST_TAISYNC_ENABLED "Enable taisyng" OFF )
else ( )
if ( QGC_GST_MICROHARD_ENABLED OR QGC_GST_TAISYNC_ENABLED )
message ( FATAL_ERROR "You tried to enable Microhard or Taisync but gstreamer is not found. Make sure to set PKG_CONFIG_EXECUTABLE and/or PKG_CONFIG_PATH properly." )
endif ( )
endif ( )
#=============================================================================
# Qt5
#
find_package ( Qt5 ${ QT_VERSION }
C O M P O N E N T S
B l u e t o o t h
C h a r t s
C o n c u r r e n t
C o r e
L o c a t i o n
M u l t i m e d i a
N e t w o r k
P o s i t i o n i n g
Q u i c k
Q u i c k C o n t r o l s 2
Q u i c k W i d g e t s
O p e n G L
S q l
S v g
T e s t
T e x t T o S p e e c h
W i d g e t s
X m l
R E Q U I R E D
H I N T S
$ { Q T _ L I B R A R Y _ H I N T S }
)
if ( NOT QT_MKSPEC MATCHES "winrt" )
find_package ( Qt5 ${ QT_VERSION }
C O M P O N E N T S
S e r i a l P o r t
R E Q U I R E D
H I N T S
$ { Q T _ L I B R A R Y _ H I N T S }
)
endif ( )
# Sets the default flags for compilation and linking.
include ( CompileOptions )
include_directories (
l i b s / e i g e n
l i b s / l i b e v e n t s
l i b s / m a v l i n k / i n c l u d e / m a v l i n k / v 2 . 0
2023-12-08 12:08:42 -04:00
l i b s / m a v l i n k / i n c l u d e / m a v l i n k / v 2 . 0 / a l l
2023-12-06 13:51:14 -04:00
l i b s / m a v l i n k / i n c l u d e / m a v l i n k / v 2 . 0 / c o m m o n
l i b s / s h a p e l i b
)
add_subdirectory ( libs )
add_subdirectory ( src )
set ( QGC_RESOURCES
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / q g c i m a g e s . q r c
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / q g c r e s o u r c e s . q r c
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / q g r o u n d c o n t r o l . q r c
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / r e s o u r c e s / I n s t r u m e n t V a l u e I c o n s / I n s t r u m e n t V a l u e I c o n s . q r c
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / F i r m w a r e P l u g i n / A P M / A P M R e s o u r c e s . q r c
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / F i r m w a r e P l u g i n / P X 4 / P X 4 R e s o u r c e s . q r c
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / V i d e o R e c e i v e r A p p / q m l . q r c
)
if ( WIN32 )
# append application icon resource for Windows
set ( QGC_RESOURCES
$ { Q G C _ R E S O U R C E S }
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / w i n d o w s / Q G r o u n d C o n t r o l . r c )
endif ( )
if ( BUILD_TESTING )
list ( APPEND QGC_RESOURCES
U n i t T e s t . q r c
)
endif ( )
if ( ANDROID )
add_library ( QGroundControl SHARED ${ QGC_RESOURCES } )
else ( )
add_executable ( QGroundControl ${ QGC_RESOURCES } )
endif ( )
target_link_libraries ( QGroundControl PRIVATE qgc )
# Files/directories to install
install (
T A R G E T S Q G r o u n d C o n t r o l
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ B I N D I R }
)
install (
D I R E C T O R Y $ { C M A K E _ S O U R C E _ D I R } / r e s o u r c e s /
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ D A T A D I R } / q g r o u n d c o n t r o l
)
install (
F I L E S $ { C M A K E _ S O U R C E _ D I R } / d e p l o y / o r g . m a v l i n k . q g r o u n d c o n t r o l . d e s k t o p
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ D A T A D I R } / a p p l i c a t i o n s
)
install (
F I L E S $ { C M A K E _ S O U R C E _ D I R } / r e s o u r c e s / i c o n s / q g r o u n d c o n t r o l . p n g
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ D A T A D I R } / i c o n s / h i c o l o r / 1 2 8 x 1 2 8 / a p p s /
R E N A M E o r g . m a v l i n k . q g r o u n d c o n t r o l . p n g
)
configure_file (
$ { C M A K E _ S O U R C E _ D I R } / d e p l o y / o r g . m a v l i n k . q g r o u n d c o n t r o l . m e t a i n f o . x m l . i n
$ { C M A K E _ B I N A R Y _ D I R } / m e t a i n f o / o r g . m a v l i n k . q g r o u n d c o n t r o l . m e t a i n f o . x m l
@ O N L Y
)
install (
F I L E S $ { C M A K E _ B I N A R Y _ D I R } / m e t a i n f o / o r g . m a v l i n k . q g r o u n d c o n t r o l . m e t a i n f o . x m l
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ D A T A D I R } / m e t a i n f o /
)
if ( BUILD_TESTING )
target_link_libraries ( QGroundControl PRIVATE Qt5::Test )
endif ( )
if ( NOT QT_MKSPEC MATCHES "winrt" )
target_link_libraries ( QGroundControl
P U B L I C
Q t 5 : : S e r i a l P o r t
)
endif ( )
include ( QGCDeploy )