CMakeLists.txt 3.88 KB
Newer Older
1 2
cmake_minimum_required(VERSION 3.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 15 16
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()

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

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")

execute_process(
	COMMAND git submodule update --init
	WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
	)

execute_process(
	COMMAND git describe --always --tags
	OUTPUT_VARIABLE git_tag
	OUTPUT_STRIP_TRAILING_WHITESPACE
	WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
	)

add_definitions(
	-DQGC_APPLICATION_NAME="QGroundControl"
	-DQGC_ORG_NAME="QGroundControl.org"
	-DQGC_ORG_DOMAIN="org.qgroundcontrol"
	)

message(STATUS "QGroundControl version: ${git_tag}")

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

64 65 66 67 68 69 70 71 72

#=============================================================================
# GStreamer
#
find_package(PkgConfig)
pkg_check_modules(GST
    gstreamer-1.0>=1.14
    gstreamer-video-1.0>=1.14
)
73

74 75 76
if (GST_FOUND)
    include_directories(
        ${GST_INCLUDE_DIRS}
77 78
        src/Taisync
        src/Microhard
79 80 81
    )
    add_definitions(
        -DQGC_GST_STREAMING
82 83
        -DQGC_GST_TAISYNC_ENABLED
        -DQGC_GST_MICROHARD_ENABLED
84 85
    )
endif()
86 87 88
#=============================================================================
# Qt5
#
89
include(Qt5QGCConfiguration)
90 91 92 93 94 95 96 97 98 99 100
find_package(Qt5 ${QT_VERSION}
	COMPONENTS
		Bluetooth
		Concurrent
		Core
		Location
		Multimedia
		Network
		Positioning
		Quick
		QuickWidgets
101
		OpenGL
102 103 104 105 106 107 108 109
		Sql
		Svg
		Test
		TextToSpeech
		Widgets
		Xml
	REQUIRED
	HINTS
Tomaz Canabrava's avatar
Tomaz Canabrava committed
110
		${QT_LIBRARY_HINTS}
111 112 113 114 115 116 117 118
)

if(NOT QT_MKSPEC MATCHES "winrt")
	find_package(Qt5 ${QT_VERSION}
		COMPONENTS
			SerialPort
		REQUIRED
		HINTS
Tomaz Canabrava's avatar
Tomaz Canabrava committed
119
			${QT_LIBRARY_HINTS}
120 121 122
	)
endif()

123 124
# Sets the default flags for compilation and linking.
include(CompileOptions)
125 126 127 128 129 130 131 132 133 134 135

# TODO: get qtquick compiler working
#qtquick_compiler_add_resources(QGC_RESOURCES ${QGC_RESOURCES}
#find_package(Qt5QuickCompiler)

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
136 137

	libs/shapelib
138 139
)

140
add_subdirectory(libs)
141 142
add_subdirectory(src)

Daniel Agar's avatar
Daniel Agar committed
143 144 145 146 147
set(QGC_RESOURCES
	#HackAndroidFileDialog.qrc
	HackFileDialog.qrc
	qgcresources.qrc
	qgroundcontrol.qrc
148
	qgcimages.qrc
149 150 151 152
	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
153 154 155 156 157 158 159 160
	)

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

161
if(ANDROID)
Daniel Agar's avatar
Daniel Agar committed
162
	add_library(QGroundControl SHARED ${QGC_RESOURCES})
163
else()
164
	add_executable(QGroundControl ${QGC_RESOURCES})
165 166
endif()

167
target_link_libraries(QGroundControl PRIVATE qgc)
168

Daniel Agar's avatar
Daniel Agar committed
169 170 171 172
if(BUILD_TESTING)
        target_link_libraries(QGroundControl PRIVATE Qt5::Test)
endif()

173 174
if(NOT QT_MKSPEC MATCHES "winrt")
	target_link_libraries(QGroundControl
175 176
		PUBLIC
			Qt5::SerialPort
177 178 179
		)
endif()

180
include(QGCDeploy)
181