QGCCommon.pri 9.9 KB
Newer Older
Gus Grubba's avatar
Gus Grubba committed
1 2 3 4 5 6 7 8
################################################################################
#
# (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
#
# QGroundControl is licensed according to the terms in the file
# COPYING.md in the root of the source code directory.
#
################################################################################
9 10 11

#
# This file contains configuration settings which are common to both the QGC Application and
nopeppermint's avatar
nopeppermint committed
12
# the Location Plugin. It should mainly contains initial CONFIG tag setup and compiler settings.
13 14 15 16 17 18
#

# Setup our supported build types. We do this once here and then use the defined config scopes
# to allow us to easily modify suported build types in one place instead of duplicated throughout
# the project file.

DonLakeFlyer's avatar
DonLakeFlyer committed
19
CONFIG -= debug_and_release
20
linux {
Daniel Agar's avatar
Daniel Agar committed
21
    linux-g++ | linux-g++-64 | linux-g++-32 | linux-clang {
22
        message("Linux build")
23
        CONFIG  += LinuxBuild
dogmaphobic's avatar
dogmaphobic committed
24
        DEFINES += __STDC_LIMIT_MACROS
25
        DEFINES += QGC_GST_TAISYNC_ENABLED
26
        DEFINES += QGC_GST_MICROHARD_ENABLED 
27
        DEFINES += QGC_ENABLE_MAVLINK_INSPECTOR
28
        QMAKE_CXXFLAGS += -Wno-address-of-packed-member
29 30 31
        linux-clang {
            message("Linux clang")
            QMAKE_CXXFLAGS += -Qunused-arguments -fcolor-diagnostics
32 33
        } else {
            QMAKE_CXXFLAGS += -Wno-deprecated-copy
34
        }
ChukRhodes's avatar
ChukRhodes committed
35 36 37 38
    } else : linux-rasp-pi2-g++ {
        message("Linux R-Pi2 build")
        CONFIG += LinuxBuild
        DEFINES += __STDC_LIMIT_MACROS __rasp_pi2__
Gus Grubba's avatar
Gus Grubba committed
39
        DEFINES += QGC_GST_TAISYNC_ENABLED
40
        DEFINES += QGC_GST_MICROHARD_ENABLED 
41
    } else : android-clang {
dogmaphobic's avatar
dogmaphobic committed
42
        CONFIG += AndroidBuild MobileBuild
dogmaphobic's avatar
dogmaphobic committed
43
        DEFINES += __android__
dogmaphobic's avatar
dogmaphobic committed
44
        DEFINES += __STDC_LIMIT_MACROS
dogmaphobic's avatar
dogmaphobic committed
45
        DEFINES += QGC_ENABLE_BLUETOOTH
46
        DEFINES += QGC_GST_TAISYNC_ENABLED
47
        DEFINES += QGC_GST_MICROHARD_ENABLED 
Don Gagne's avatar
Don Gagne committed
48 49
        QMAKE_CXXFLAGS += -Wno-address-of-packed-member
        QMAKE_CXXFLAGS += -Wno-unused-command-line-argument
Don Gagne's avatar
Don Gagne committed
50
        QMAKE_CFLAGS += -Wno-unused-command-line-argument
51
        QMAKE_LINK += -nostdlib++ # Hack fix?: https://forum.qt.io/topic/103713/error-cannot-find-lc-qt-5-12-android
dogmaphobic's avatar
dogmaphobic committed
52
        target.path = $$DESTDIR
53 54
        equals(ANDROID_TARGET_ARCH, armeabi-v7a)  {
            DEFINES += __androidArm32__
55
            DEFINES += QGC_ENABLE_MAVLINK_INSPECTOR
56 57 58
            message("Android Arm 32 bit build")
        } else:equals(ANDROID_TARGET_ARCH, arm64-v8a)  {
            DEFINES += __androidArm64__
59
            DEFINES += QGC_ENABLE_MAVLINK_INSPECTOR
60 61
            message("Android Arm 64 bit build")
        } else:equals(ANDROID_TARGET_ARCH, x86)  {
62 63 64
            CONFIG += Androidx86Build
            DEFINES += __androidx86__
            message("Android Arm build")
65 66
        } else {
            error("Unsupported Android architecture: $${ANDROID_TARGET_ARCH}")
67
        }
68 69 70 71
    } else {
        error("Unsuported Linux toolchain, only GCC 32- or 64-bit is supported")
    }
} else : win32 {
DonLakeFlyer's avatar
DonLakeFlyer committed
72
    contains(QMAKE_TARGET.arch, x86_64) {
73 74
        message("Windows build")
        CONFIG += WindowsBuild
DonLakeFlyer's avatar
DonLakeFlyer committed
75
        CONFIG += WarningsAsErrorsOn
dogmaphobic's avatar
dogmaphobic committed
76
        DEFINES += __STDC_LIMIT_MACROS
Gus Grubba's avatar
Gus Grubba committed
77
        DEFINES += QGC_GST_TAISYNC_ENABLED
78
        DEFINES += QGC_GST_MICROHARD_ENABLED 
79
        DEFINES += QGC_ENABLE_MAVLINK_INSPECTOR
80
    } else {
DonLakeFlyer's avatar
DonLakeFlyer committed
81
        error("Unsupported Windows toolchain, only Visual Studio 2017 64 bit is supported")
82 83 84 85
    }
} else : macx {
    macx-clang | macx-llvm {
        message("Mac build")
86 87 88 89
        CONFIG  += MacBuild
        CONFIG  += x86_64
        CONFIG  -= x86
        DEFINES += QGC_GST_TAISYNC_ENABLED
90
        DEFINES += QGC_GST_MICROHARD_ENABLED 
91
        DEFINES += QGC_ENABLE_MAVLINK_INSPECTOR
92 93 94 95 96
        equals(QT_MAJOR_VERSION, 5) | greaterThan(QT_MINOR_VERSION, 5) {
                QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
        } else {
                QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
        }
97 98
        #-- Not forcing anything. Let qmake find the latest, installed SDK.
        #QMAKE_MAC_SDK = macosx10.12
99
        QMAKE_CXXFLAGS += -fvisibility=hidden
100 101
        #-- Disable annoying warnings comming from mavlink.h
        QMAKE_CXXFLAGS += -Wno-address-of-packed-member
102 103 104
    } else {
        error("Unsupported Mac toolchain, only 64-bit LLVM+clang is supported")
    }
dogmaphobic's avatar
dogmaphobic committed
105
} else : ios {
dogmaphobic's avatar
dogmaphobic committed
106 107 108
    !equals(QT_MAJOR_VERSION, 5) | !greaterThan(QT_MINOR_VERSION, 4) {
        error("Unsupported Qt version, 5.5.x or greater is required for iOS")
    }
dogmaphobic's avatar
dogmaphobic committed
109
    message("iOS build")
Gus Grubba's avatar
Gus Grubba committed
110
    CONFIG  += iOSBuild MobileBuild app_bundle NoSerialBuild
Don Gagne's avatar
Don Gagne committed
111
    CONFIG  -= bitcode
dogmaphobic's avatar
dogmaphobic committed
112
    DEFINES += __ios__
113
    DEFINES += QGC_NO_GOOGLE_MAPS
Gus Grubba's avatar
Gus Grubba committed
114
    DEFINES += NO_SERIAL_LINK
Gus Grubba's avatar
Gus Grubba committed
115
    DEFINES += QGC_DISABLE_UVC
116
    DEFINES += QGC_GST_TAISYNC_ENABLED
Gus Grubba's avatar
Gus Grubba committed
117
    QMAKE_IOS_DEPLOYMENT_TARGET = 11.0
DonLakeFlyer's avatar
DonLakeFlyer committed
118
    QMAKE_APPLE_TARGETED_DEVICE_FAMILY = 1,2 # Universal
dogmaphobic's avatar
dogmaphobic committed
119
    QMAKE_LFLAGS += -Wl,-no_pie
120
} else {
dogmaphobic's avatar
dogmaphobic committed
121 122 123
    error("Unsupported build platform, only Linux, Windows, Android and Mac (Mac OS and iOS) are supported")
}

124 125 126 127 128 129 130 131 132 133 134 135 136 137
# Enable ccache where we can
linux|macx|ios {
    system(which ccache) {
        message("Found ccache, enabling")
        !ios {
            QMAKE_CXX = ccache $$QMAKE_CXX
            QMAKE_CC  = ccache $$QMAKE_CC
        } else {
            QMAKE_CXX = $$PWD/tools/iosccachecc.sh
            QMAKE_CC  = $$PWD/tools/iosccachecxx.sh
        }
    }
}

dogmaphobic's avatar
dogmaphobic committed
138 139
MobileBuild {
    DEFINES += __mobile__
140 141
}

142 143 144 145 146 147 148
StableBuild {
    message("Stable Build")
} else {
    message("Daily Build")
    DEFINES += DAILY_BUILD
}

dogmaphobic's avatar
dogmaphobic committed
149 150 151
# set the QGC version from git

exists ($$PWD/.git) {
152
    GIT_DESCRIBE = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags)
Daniel Agar's avatar
Daniel Agar committed
153 154 155 156 157
    GIT_BRANCH   = $$system(git --git-dir $$PWD/.git --work-tree $$PWD rev-parse --abbrev-ref HEAD)
    GIT_HASH     = $$system(git --git-dir $$PWD/.git --work-tree $$PWD rev-parse --short HEAD)
    GIT_TIME     = $$system(git --git-dir $$PWD/.git --work-tree $$PWD show --oneline --format=\"%ci\" -s HEAD)

    # determine if we're on a tag matching vX.Y.Z (stable release)
158
    contains(GIT_DESCRIBE, v[0-9]+.[0-9]+.[0-9]+) {
Daniel Agar's avatar
Daniel Agar committed
159 160
        # release version "vX.Y.Z"
        GIT_VERSION = $${GIT_DESCRIBE}
161 162 163
        VERSION      = $$replace(GIT_DESCRIBE, "v", "")
        VERSION      = $$replace(VERSION, "-", ".")
        VERSION      = $$section(VERSION, ".", 0, 3)
Daniel Agar's avatar
Daniel Agar committed
164 165 166
    } else {
        # development version "Development branch:sha date"
        GIT_VERSION = "Development $${GIT_BRANCH}:$${GIT_HASH} $${GIT_TIME}"
167
        VERSION         = 0.0.0
Daniel Agar's avatar
Daniel Agar committed
168 169
    }

170 171 172
    MacBuild {
        MAC_VERSION  = $$section(VERSION, ".", 0, 2)
        MAC_BUILD    = $$section(VERSION, ".", 3, 3)
Daniel Agar's avatar
Daniel Agar committed
173
        message(QGroundControl version $${MAC_VERSION} build $${MAC_BUILD} describe $${GIT_VERSION})
174
    } else {
Daniel Agar's avatar
Daniel Agar committed
175
        message(QGroundControl $${GIT_VERSION})
176
    }
dogmaphobic's avatar
dogmaphobic committed
177
} else {
Daniel Agar's avatar
Daniel Agar committed
178
    GIT_VERSION     = None
179 180 181
    VERSION         = 0.0.0   # Marker to indicate out-of-tree build
    MAC_VERSION     = 0.0.0
    MAC_BUILD       = 0
dogmaphobic's avatar
dogmaphobic committed
182 183
}

Daniel Agar's avatar
Daniel Agar committed
184
DEFINES += GIT_VERSION=\"\\\"$$GIT_VERSION\\\"\"
185
DEFINES += EIGEN_MPL2_ONLY
dogmaphobic's avatar
dogmaphobic committed
186

187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
# Installer configuration

installer {
    CONFIG -= debug
    CONFIG -= debug_and_release
    CONFIG += release
    message(Build Installer)
}

# Setup our supported build flavors

CONFIG(debug, debug|release) {
    message(Debug flavor)
    CONFIG += DebugBuild
} else:CONFIG(release, debug|release) {
    message(Release flavor)
    CONFIG += ReleaseBuild
} else {
    error(Unsupported build flavor)
}

# Setup our build directories

dogmaphobic's avatar
dogmaphobic committed
210
BASEDIR      = $$IN_PWD
211

dogmaphobic's avatar
dogmaphobic committed
212
!iOSBuild {
dogmaphobic's avatar
dogmaphobic committed
213 214 215 216
    OBJECTS_DIR  = $${OUT_PWD}/obj
    MOC_DIR      = $${OUT_PWD}/moc
    UI_DIR       = $${OUT_PWD}/ui
    RCC_DIR      = $${OUT_PWD}/rcc
dogmaphobic's avatar
dogmaphobic committed
217 218 219 220
}

LANGUAGE = C++

dogmaphobic's avatar
dogmaphobic committed
221 222
LOCATION_PLUGIN_DESTDIR = $${OUT_PWD}/src/QtLocationPlugin
LOCATION_PLUGIN_NAME    = QGeoServiceProviderFactoryQGC
223 224 225 226 227

# Turn off serial port warnings
DEFINES += _TTY_NOWARN_

MacBuild | LinuxBuild {
dogmaphobic's avatar
dogmaphobic committed
228
    QMAKE_CXXFLAGS_WARN_ON += -Wall
229 230 231
    WarningsAsErrorsOn {
        QMAKE_CXXFLAGS_WARN_ON += -Werror
    }
Don Gagne's avatar
Don Gagne committed
232 233 234
    MacBuild {
        # Latest clang version has a buggy check for this which cause Qt headers to throw warnings on qmap.h
        QMAKE_CXXFLAGS_WARN_ON += -Wno-return-stack-address
235
        # Xcode 8.3 has issues on how MAVLink accesses (packed) message structure members.
236 237 238
        # Note that this will fail when Xcode version reaches 10.x.x
        XCODE_VERSION = $$system($$PWD/tools/get_xcode_version.sh)
        greaterThan(XCODE_VERSION, 8.2.0): QMAKE_CXXFLAGS_WARN_ON += -Wno-address-of-packed-member
Don Gagne's avatar
Don Gagne committed
239
    }
240 241 242
}

WindowsBuild {
DonLakeFlyer's avatar
DonLakeFlyer committed
243
    QMAKE_CFLAGS -= -Zc:strictStrings
244 245
    QMAKE_CFLAGS_RELEASE -= -Zc:strictStrings
    QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO -= -Zc:strictStrings
DonLakeFlyer's avatar
DonLakeFlyer committed
246
    QMAKE_CXXFLAGS -= -Zc:strictStrings
247 248
    QMAKE_CXXFLAGS_RELEASE -= -Zc:strictStrings
    QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO -= -Zc:strictStrings
dogmaphobic's avatar
dogmaphobic committed
249
    QMAKE_CXXFLAGS_WARN_ON += /W3 \
DonLakeFlyer's avatar
DonLakeFlyer committed
250 251 252 253
        /wd4996 \   # silence warnings about deprecated strcpy and whatnot, these come from the shapefile code with is external
        /wd4005 \   # silence warnings about macro redefinition, these come from the shapefile code with is external
        /wd4290 \   # ignore exception specifications
        /wd4267     # silence conversion from 'size_t' to 'int', possible loss of data, these come from gps drivers shared with px4
254 255 256 257 258 259 260 261 262 263
    WarningsAsErrorsOn {
        QMAKE_CXXFLAGS_WARN_ON += /WX
    }
}

#
# Build-specific settings
#

ReleaseBuild {
264
    DEFINES += QT_NO_DEBUG QT_MESSAGELOGCONTEXT
265 266
    CONFIG += force_debug_info  # Enable debugging symbols on release builds
    !iOSBuild {
DonLakeFlyer's avatar
DonLakeFlyer committed
267 268 269
        !AndroidBuild {
            CONFIG += ltcg              # Turn on link time code generation
        }
270
    }
dogmaphobic's avatar
dogmaphobic committed
271

272
    WindowsBuild {
DonLakeFlyer's avatar
DonLakeFlyer committed
273 274 275
        # Run compilation using VS compiler using multiple threads
        QMAKE_CXXFLAGS += -MP

276 277 278 279 280 281 282 283 284
        # Enable function level linking and enhanced optimized debugging
        QMAKE_CFLAGS_RELEASE   += /Gy /Zo
        QMAKE_CXXFLAGS_RELEASE += /Gy /Zo
        QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO   += /Gy /Zo
        QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += /Gy /Zo

        # Eliminate duplicate COMDATs
        QMAKE_LFLAGS_RELEASE += /OPT:ICF
        QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO += /OPT:ICF
285 286
    }
}