QGCCommon.pri 9.79 KB
Newer Older
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.

19 20 21
CONFIG -= debug_and_release
CONFIG += warn_on

22
linux {
Daniel Agar's avatar
Daniel Agar committed
23
    linux-g++ | linux-g++-64 | linux-g++-32 | linux-clang {
24
        message("Linux build")
25
        CONFIG  += LinuxBuild
dogmaphobic's avatar
dogmaphobic committed
26
        DEFINES += __STDC_LIMIT_MACROS
27
        DEFINES += QGC_GST_TAISYNC_ENABLED
28 29
        DEFINES += QGC_GST_MICROHARD_ENABLED 
        DEFINES += QGC_ENABLE_MAVLINK_INSPECTOR
30 31 32
        linux-clang {
            message("Linux clang")
            QMAKE_CXXFLAGS += -Qunused-arguments -fcolor-diagnostics
33 34 35 36 37
        } else {
            #QMAKE_CXXFLAGS += -H # Handy for debugging why something is getting built when an include file is touched
            QMAKE_CXXFLAGS_WARN_ON += -Werror \
                -Wno-deprecated-copy \      # These come from mavlink headers
                -Wno-unused-parameter \     # gst_plugins-good has these errors
38 39
                -Wno-ignored-qualifiers\  # or-tools has these errors
                -Wno-sign-compare\  # or-tools has these errors
40
                -Wno-implicit-fallthrough   # gst_plugins-good has these errors
41
        }
ChukRhodes's avatar
ChukRhodes committed
42 43 44 45
    } 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
46
        DEFINES += QGC_GST_TAISYNC_ENABLED
47 48
        DEFINES += QGC_GST_MICROHARD_ENABLED 
    } else : android-clang {
dogmaphobic's avatar
dogmaphobic committed
49
        CONFIG += AndroidBuild MobileBuild
dogmaphobic's avatar
dogmaphobic committed
50
        DEFINES += __android__
dogmaphobic's avatar
dogmaphobic committed
51
        DEFINES += __STDC_LIMIT_MACROS
dogmaphobic's avatar
dogmaphobic committed
52
        DEFINES += QGC_ENABLE_BLUETOOTH
53
        DEFINES += QGC_GST_TAISYNC_ENABLED
54 55 56 57 58 59 60 61
        DEFINES += QGC_GST_MICROHARD_ENABLED 
        QMAKE_CXXFLAGS_WARN_ON += -Werror \
            -Wno-unused-parameter \             # gst_plugins-good has these errors
            -Wno-implicit-fallthrough \         # gst_plugins-good has these errors
            -Wno-unused-command-line-argument \ # from somewhere in Qt generated build files
            -Wno-parentheses-equality           # android gstreamer header files
        QMAKE_CFLAGS_WARN_ON += \
            -Wno-unused-command-line-argument   # from somewhere in Qt generated build files
dogmaphobic's avatar
dogmaphobic committed
62
        target.path = $$DESTDIR
63 64 65 66 67 68 69 70 71
        equals(ANDROID_TARGET_ARCH, armeabi-v7a)  {
            DEFINES += __androidArm32__
            DEFINES += QGC_ENABLE_MAVLINK_INSPECTOR
            message("Android Arm 32 bit build")
        } else:equals(ANDROID_TARGET_ARCH, arm64-v8a)  {
            DEFINES += __androidArm64__
            DEFINES += QGC_ENABLE_MAVLINK_INSPECTOR
            message("Android Arm 64 bit build")
        } else:equals(ANDROID_TARGET_ARCH, x86)  {
72 73 74
            CONFIG += Androidx86Build
            DEFINES += __androidx86__
            message("Android Arm build")
75 76
        } else {
            error("Unsupported Android architecture: $${ANDROID_TARGET_ARCH}")
77
        }
78 79 80 81
    } else {
        error("Unsuported Linux toolchain, only GCC 32- or 64-bit is supported")
    }
} else : win32 {
82
    contains(QMAKE_TARGET.arch, x86_64) {
83 84
        message("Windows build")
        CONFIG += WindowsBuild
dogmaphobic's avatar
dogmaphobic committed
85
        DEFINES += __STDC_LIMIT_MACROS
Gus Grubba's avatar
Gus Grubba committed
86
        DEFINES += QGC_GST_TAISYNC_ENABLED
87 88 89 90 91 92 93 94 95 96 97 98 99 100
        DEFINES += QGC_GST_MICROHARD_ENABLED 
        DEFINES += QGC_ENABLE_MAVLINK_INSPECTOR
        QMAKE_CFLAGS -= -Zc:strictStrings
        QMAKE_CFLAGS_RELEASE -= -Zc:strictStrings
        QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO -= -Zc:strictStrings
        QMAKE_CXXFLAGS -= -Zc:strictStrings
        QMAKE_CXXFLAGS_RELEASE -= -Zc:strictStrings
        QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO -= -Zc:strictStrings
        QMAKE_CXXFLAGS += /std:c++17
        QMAKE_CXXFLAGS_WARN_ON += /WX /W3 \
            /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
            /wd4100     # unreferenced formal parameter - gst-plugins-good
101
    } else {
102
        error("Unsupported Windows toolchain, only Visual Studio 2017 64 bit is supported")
103 104 105 106
    }
} else : macx {
    macx-clang | macx-llvm {
        message("Mac build")
107 108 109 110
        CONFIG  += MacBuild
        CONFIG  += x86_64
        CONFIG  -= x86
        DEFINES += QGC_GST_TAISYNC_ENABLED
111 112
        DEFINES += QGC_GST_MICROHARD_ENABLED 
        DEFINES += QGC_ENABLE_MAVLINK_INSPECTOR
113 114 115 116 117
        equals(QT_MAJOR_VERSION, 5) | greaterThan(QT_MINOR_VERSION, 5) {
                QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
        } else {
                QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
        }
118
        QMAKE_CXXFLAGS += -fvisibility=hidden
119 120
        QMAKE_CXXFLAGS_WARN_ON += -Werror \
            -Wno-unused-parameter           # gst-plugins-good
121 122 123
    } else {
        error("Unsupported Mac toolchain, only 64-bit LLVM+clang is supported")
    }
dogmaphobic's avatar
dogmaphobic committed
124
} else : ios {
dogmaphobic's avatar
dogmaphobic committed
125 126 127
    !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
128
    message("iOS build")
Gus Grubba's avatar
Gus Grubba committed
129
    CONFIG  += iOSBuild MobileBuild app_bundle NoSerialBuild
Don Gagne's avatar
Don Gagne committed
130
    CONFIG  -= bitcode
dogmaphobic's avatar
dogmaphobic committed
131
    DEFINES += __ios__
132
    DEFINES += QGC_NO_GOOGLE_MAPS
Gus Grubba's avatar
Gus Grubba committed
133
    DEFINES += NO_SERIAL_LINK
Gus Grubba's avatar
Gus Grubba committed
134
    DEFINES += QGC_DISABLE_UVC
135
    DEFINES += QGC_GST_TAISYNC_ENABLED
136
    QMAKE_IOS_DEPLOYMENT_TARGET = 11.0
DonLakeFlyer's avatar
DonLakeFlyer committed
137
    QMAKE_APPLE_TARGETED_DEVICE_FAMILY = 1,2 # Universal
dogmaphobic's avatar
dogmaphobic committed
138
    QMAKE_LFLAGS += -Wl,-no_pie
139
} else {
dogmaphobic's avatar
dogmaphobic committed
140 141 142
    error("Unsupported build platform, only Linux, Windows, Android and Mac (Mac OS and iOS) are supported")
}

143 144 145 146 147 148 149 150 151 152 153 154 155 156
# 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
        }
    }
}

157 158 159 160 161
!MacBuild {
    # See QGCPostLinkCommon.pri for details on why MacBuild doesn't use DESTDIR
    DESTDIR = staging
}

dogmaphobic's avatar
dogmaphobic committed
162 163
MobileBuild {
    DEFINES += __mobile__
164 165
}

166 167 168 169 170 171 172
StableBuild {
    message("Stable Build")
} else {
    message("Daily Build")
    DEFINES += DAILY_BUILD
}

dogmaphobic's avatar
dogmaphobic committed
173 174 175
# set the QGC version from git

exists ($$PWD/.git) {
176
    GIT_DESCRIBE = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags)
Daniel Agar's avatar
Daniel Agar committed
177 178 179 180 181
    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)
182
    contains(GIT_DESCRIBE, v[0-9]+.[0-9]+.[0-9]+) {
Daniel Agar's avatar
Daniel Agar committed
183 184
        # release version "vX.Y.Z"
        GIT_VERSION = $${GIT_DESCRIBE}
185 186 187
        VERSION      = $$replace(GIT_DESCRIBE, "v", "")
        VERSION      = $$replace(VERSION, "-", ".")
        VERSION      = $$section(VERSION, ".", 0, 3)
Daniel Agar's avatar
Daniel Agar committed
188 189 190
    } else {
        # development version "Development branch:sha date"
        GIT_VERSION = "Development $${GIT_BRANCH}:$${GIT_HASH} $${GIT_TIME}"
191
        VERSION         = 0.0.0
Daniel Agar's avatar
Daniel Agar committed
192 193
    }

194 195 196
    MacBuild {
        MAC_VERSION  = $$section(VERSION, ".", 0, 2)
        MAC_BUILD    = $$section(VERSION, ".", 3, 3)
Daniel Agar's avatar
Daniel Agar committed
197
        message(QGroundControl version $${MAC_VERSION} build $${MAC_BUILD} describe $${GIT_VERSION})
198
    } else {
Daniel Agar's avatar
Daniel Agar committed
199
        message(QGroundControl $${GIT_VERSION})
200
    }
dogmaphobic's avatar
dogmaphobic committed
201
} else {
Daniel Agar's avatar
Daniel Agar committed
202
    GIT_VERSION     = None
203 204 205
    VERSION         = 0.0.0   # Marker to indicate out-of-tree build
    MAC_VERSION     = 0.0.0
    MAC_BUILD       = 0
dogmaphobic's avatar
dogmaphobic committed
206 207
}

Daniel Agar's avatar
Daniel Agar committed
208
DEFINES += GIT_VERSION=\"\\\"$$GIT_VERSION\\\"\"
209
DEFINES += EIGEN_MPL2_ONLY
dogmaphobic's avatar
dogmaphobic committed
210

211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
# 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

234
SOURCE_DIR = $$IN_PWD
dogmaphobic's avatar
dogmaphobic committed
235 236 237

LANGUAGE = C++

dogmaphobic's avatar
dogmaphobic committed
238 239
LOCATION_PLUGIN_DESTDIR = $${OUT_PWD}/src/QtLocationPlugin
LOCATION_PLUGIN_NAME    = QGeoServiceProviderFactoryQGC
240 241 242 243

# Turn off serial port warnings
DEFINES += _TTY_NOWARN_

244 245 246
MacBuild {
    QMAKE_TARGET_BUNDLE_PREFIX =    org.qgroundcontrol
    QMAKE_BUNDLE =                  qgroundcontrol
247 248 249 250 251 252 253
}

#
# Build-specific settings
#

ReleaseBuild {
254
    DEFINES += QT_NO_DEBUG QT_MESSAGELOGCONTEXT
255 256
    CONFIG += force_debug_info  # Enable debugging symbols on release builds
    !iOSBuild {
DonLakeFlyer's avatar
DonLakeFlyer committed
257 258 259
        !AndroidBuild {
            CONFIG += ltcg              # Turn on link time code generation
        }
260
    }
dogmaphobic's avatar
dogmaphobic committed
261

262
    WindowsBuild {
263 264 265
        # Run compilation using VS compiler using multiple threads
        QMAKE_CXXFLAGS += -MP

266 267 268 269 270 271 272 273 274
        # 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
275 276
    }
}