CMakeLists.txt 4.69 KB
Newer Older
1
cmake_minimum_required(VERSION 3.10)
2

3
project(QGroundControl LANGUAGES C CXX)
4 5 6

set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel;Coverage")

7 8 9 10 11 12
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

13 14
include(FeatureSummary)

15 16 17 18
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
	add_compile_options(-Wall -Wextra -Wno-address-of-packed-member)
endif()

19 20 21 22 23 24 25 26 27 28
# 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)

29 30
# Configure Qt5 to get necessary variables
include(Qt5QGCConfiguration)
31 32 33 34 35 36 37 38 39 40 41 42 43 44
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(
	-DQGC_APPLICATION_NAME="QGroundControl"
	-DQGC_ORG_NAME="QGroundControl.org"
	-DQGC_ORG_DOMAIN="org.qgroundcontrol"
	)

45 46
include(Git)
message(STATUS "QGroundControl version: ${GIT_VERSION}")
47 48 49 50 51 52 53 54 55 56

#=============================================================================
# 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()

57 58 59 60 61 62 63 64 65 66 67 68 69
#=============================================================================
# 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
        DESCRIPTION "Pre-compile QML files using the Qt Quick compiler."
        TYPE OPTIONAL
    )
endif()
70

71 72 73 74 75 76 77 78 79 80 81 82
#=============================================================================
# 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()

83 84 85 86 87 88 89
#=============================================================================
# GStreamer
#
find_package(PkgConfig)
pkg_check_modules(GST
    gstreamer-1.0>=1.14
    gstreamer-video-1.0>=1.14
90
    gstreamer-gl-1.0>=1.14
91
    egl
92
)
93

94 95 96
if (GST_FOUND)
    include_directories(
        ${GST_INCLUDE_DIRS}
97 98
        src/Taisync
        src/Microhard
99 100 101
    )
    add_definitions(
        -DQGC_GST_STREAMING
102 103
        -DQGC_GST_TAISYNC_ENABLED
        -DQGC_GST_MICROHARD_ENABLED
104
    )
105 106

    include(qmlglsink.cmake)
107
endif()
108 109 110 111 112

add_definitions(
    -DQGC_ENABLE_MAVLINK_INSPECTOR
)

113 114 115 116 117 118
#=============================================================================
# Qt5
#
find_package(Qt5 ${QT_VERSION}
	COMPONENTS
		Bluetooth
119
		Charts
120 121 122 123 124 125 126 127
		Concurrent
		Core
		Location
		Multimedia
		Network
		Positioning
		Quick
		QuickWidgets
128
		OpenGL
129 130 131 132 133 134 135 136
		Sql
		Svg
		Test
		TextToSpeech
		Widgets
		Xml
	REQUIRED
	HINTS
Tomaz Canabrava's avatar
Tomaz Canabrava committed
137
		${QT_LIBRARY_HINTS}
138 139 140 141 142 143 144 145
)

if(NOT QT_MKSPEC MATCHES "winrt")
	find_package(Qt5 ${QT_VERSION}
		COMPONENTS
			SerialPort
		REQUIRED
		HINTS
Tomaz Canabrava's avatar
Tomaz Canabrava committed
146
			${QT_LIBRARY_HINTS}
147 148 149
	)
endif()

150 151
# Sets the default flags for compilation and linking.
include(CompileOptions)
152 153 154 155 156 157 158

include_directories(
	libs/eigen

	libs/mavlink/include/mavlink/v2.0
	libs/mavlink/include/mavlink/v2.0/ardupilotmega
	libs/mavlink/include/mavlink/v2.0/common
Daniel Agar's avatar
Daniel Agar committed
159 160

	libs/shapelib
161 162
)

163
add_subdirectory(libs)
164 165
add_subdirectory(src)

Daniel Agar's avatar
Daniel Agar committed
166 167 168 169 170
set(QGC_RESOURCES
	#HackAndroidFileDialog.qrc
	HackFileDialog.qrc
	qgcresources.qrc
	qgroundcontrol.qrc
171
	qgcimages.qrc
172 173 174 175
	src/FirmwarePlugin/APM/APMResources.qrc
	src/FirmwarePlugin/PX4/PX4Resources.qrc
	src/Airmap/airmap.qrc
	src/Airmap/dummy/airmap_dummy.qrc
Daniel Agar's avatar
Daniel Agar committed
176 177 178 179 180 181 182 183
	)

if(BUILD_TESTING)
	list(APPEND QGC_RESOURCES
		UnitTest.qrc
	)
endif()

184
if(ANDROID)
Daniel Agar's avatar
Daniel Agar committed
185
	add_library(QGroundControl SHARED ${QGC_RESOURCES})
186
else()
187
	add_executable(QGroundControl ${QGC_RESOURCES})
188 189
endif()

190
target_link_libraries(QGroundControl PRIVATE qgc)
191

Daniel Agar's avatar
Daniel Agar committed
192 193 194 195
if(BUILD_TESTING)
        target_link_libraries(QGroundControl PRIVATE Qt5::Test)
endif()

196 197
if(NOT QT_MKSPEC MATCHES "winrt")
	target_link_libraries(QGroundControl
198 199
		PUBLIC
			Qt5::SerialPort
200 201 202
		)
endif()

203
include(QGCDeploy)
204