QGCCommon.pri 7.51 KB
Newer Older
1 2 3 4 5 6
# -------------------------------------------------
# QGroundControl - Micro Air Vehicle Groundstation
# Please see our website at <http://qgroundcontrol.org>
# Maintainer:
# Lorenz Meier <lm@inf.ethz.ch>
# (c) 2009-2014 QGroundControl Developers
Lorenz Meier's avatar
Lorenz Meier committed
7
# License terms set in COPYING.md
8 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 19
#

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

linux {
Daniel Agar's avatar
Daniel Agar committed
20
    linux-g++ | linux-g++-64 | linux-g++-32 | linux-clang {
21 22
        message("Linux build")
        CONFIG += LinuxBuild
dogmaphobic's avatar
dogmaphobic committed
23
        DEFINES += __STDC_LIMIT_MACROS
24 25 26 27
        linux-clang {
            message("Linux clang")
            QMAKE_CXXFLAGS += -Qunused-arguments -fcolor-diagnostics
        }
ChukRhodes's avatar
ChukRhodes committed
28 29 30 31
    } else : linux-rasp-pi2-g++ {
        message("Linux R-Pi2 build")
        CONFIG += LinuxBuild
        DEFINES += __STDC_LIMIT_MACROS __rasp_pi2__
dogmaphobic's avatar
dogmaphobic committed
32 33
    } else : android-g++ {
        message("Android build")
dogmaphobic's avatar
dogmaphobic committed
34
        CONFIG += AndroidBuild MobileBuild
dogmaphobic's avatar
dogmaphobic committed
35
        DEFINES += __android__
dogmaphobic's avatar
dogmaphobic committed
36
        DEFINES += __STDC_LIMIT_MACROS
dogmaphobic's avatar
dogmaphobic committed
37
        DEFINES += QGC_ENABLE_BLUETOOTH
dogmaphobic's avatar
dogmaphobic committed
38
        target.path = $$DESTDIR
39 40 41 42 43 44 45
    } else {
        error("Unsuported Linux toolchain, only GCC 32- or 64-bit is supported")
    }
} else : win32 {
    win32-msvc2010 | win32-msvc2012 | win32-msvc2013 {
        message("Windows build")
        CONFIG += WindowsBuild
dogmaphobic's avatar
dogmaphobic committed
46
        DEFINES += __STDC_LIMIT_MACROS
47 48 49 50 51 52 53
    } else {
        error("Unsupported Windows toolchain, only Visual Studio 2010, 2012, and 2013 are supported")
    }
} else : macx {
    macx-clang | macx-llvm {
        message("Mac build")
        CONFIG += MacBuild
dogmaphobic's avatar
dogmaphobic committed
54
        DEFINES += __macos__
dogmaphobic's avatar
dogmaphobic committed
55 56
        CONFIG += x86_64
        CONFIG -= x86
57 58 59
equals(QT_MAJOR_VERSION, 5) | greaterThan(QT_MINOR_VERSION, 5) {
        QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
} else {
dogmaphobic's avatar
dogmaphobic committed
60
        QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
61
}
dogmaphobic's avatar
dogmaphobic committed
62
        QMAKE_MAC_SDK = macosx10.11
63 64 65 66
        QMAKE_CXXFLAGS += -fvisibility=hidden
    } else {
        error("Unsupported Mac toolchain, only 64-bit LLVM+clang is supported")
    }
dogmaphobic's avatar
dogmaphobic committed
67
} else : ios {
dogmaphobic's avatar
dogmaphobic committed
68 69 70
    !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
71 72 73
    message("iOS build")
    CONFIG += iOSBuild MobileBuild app_bundle
    DEFINES += __ios__
dogmaphobic's avatar
dogmaphobic committed
74
    QMAKE_IOS_DEPLOYMENT_TARGET = 8.0
75
    QMAKE_IOS_TARGETED_DEVICE_FAMILY = 1,2 # Universal
dogmaphobic's avatar
dogmaphobic committed
76
    QMAKE_LFLAGS += -Wl,-no_pie
77
} else {
dogmaphobic's avatar
dogmaphobic committed
78 79 80
    error("Unsupported build platform, only Linux, Windows, Android and Mac (Mac OS and iOS) are supported")
}

81 82 83 84 85 86 87 88 89 90 91 92 93 94
# 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
95 96
MobileBuild {
    DEFINES += __mobile__
97 98
}

dogmaphobic's avatar
dogmaphobic committed
99 100 101
# set the QGC version from git

exists ($$PWD/.git) {
102
    GIT_DESCRIBE = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags)
Daniel Agar's avatar
Daniel Agar committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116
    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)
    GIT_TAG      = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --exact-match --tags HEAD)
    contains(GIT_TAG, v[0-9].[0-9].[0-9]) {
        # release version "vX.Y.Z"
        GIT_VERSION = $${GIT_DESCRIBE}
    } else {
        # development version "Development branch:sha date"
        GIT_VERSION = "Development $${GIT_BRANCH}:$${GIT_HASH} $${GIT_TIME}"
    }

117 118 119 120 121 122
    VERSION      = $$replace(GIT_DESCRIBE, "v", "")
    VERSION      = $$replace(VERSION, "-", ".")
    VERSION      = $$section(VERSION, ".", 0, 3)
    MacBuild {
        MAC_VERSION  = $$section(VERSION, ".", 0, 2)
        MAC_BUILD    = $$section(VERSION, ".", 3, 3)
Daniel Agar's avatar
Daniel Agar committed
123
        message(QGroundControl version $${MAC_VERSION} build $${MAC_BUILD} describe $${GIT_VERSION})
124
    } else {
Daniel Agar's avatar
Daniel Agar committed
125
        message(QGroundControl version $${VERSION} describe $${GIT_VERSION})
126
    }
dogmaphobic's avatar
dogmaphobic committed
127
} else {
Daniel Agar's avatar
Daniel Agar committed
128
    GIT_VERSION     = None
129 130 131
    VERSION         = 0.0.0   # Marker to indicate out-of-tree build
    MAC_VERSION     = 0.0.0
    MAC_BUILD       = 0
dogmaphobic's avatar
dogmaphobic committed
132 133
}

Daniel Agar's avatar
Daniel Agar committed
134
DEFINES += GIT_VERSION=\"\\\"$$GIT_VERSION\\\"\"
135
DEFINES += EIGEN_MPL2_ONLY
dogmaphobic's avatar
dogmaphobic committed
136

137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
# 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
160
BASEDIR      = $$IN_PWD
161

dogmaphobic's avatar
dogmaphobic committed
162
!iOSBuild {
dogmaphobic's avatar
dogmaphobic committed
163 164 165 166
    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
167 168 169 170
}

LANGUAGE = C++

dogmaphobic's avatar
dogmaphobic committed
171 172
LOCATION_PLUGIN_DESTDIR = $${OUT_PWD}/src/QtLocationPlugin
LOCATION_PLUGIN_NAME    = QGeoServiceProviderFactoryQGC
173 174 175 176 177 178 179 180 181 182 183 184 185

# Turn off serial port warnings
DEFINES += _TTY_NOWARN_

#
# By default warnings as errors are turned off. Even so, in order for a pull request
# to be accepted you must compile cleanly with warnings as errors turned on the default
# set of OS builds. See http://www.qgroundcontrol.org/dev/contribute for more details.
# You can use the WarningsAsErrorsOn CONFIG switch to turn warnings as errors on for your
# own builds.
#

MacBuild | LinuxBuild {
dogmaphobic's avatar
dogmaphobic committed
186
    QMAKE_CXXFLAGS_WARN_ON += -Wall
187 188 189
    WarningsAsErrorsOn {
        QMAKE_CXXFLAGS_WARN_ON += -Werror
    }
Don Gagne's avatar
Don Gagne committed
190 191 192 193
    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
    }
194 195 196
}

WindowsBuild {
197 198 199 200
    QMAKE_CFLAGS_RELEASE -= -Zc:strictStrings
    QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO -= -Zc:strictStrings
    QMAKE_CXXFLAGS_RELEASE -= -Zc:strictStrings
    QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO -= -Zc:strictStrings
dogmaphobic's avatar
dogmaphobic committed
201
    QMAKE_CXXFLAGS_WARN_ON += /W3 \
202 203
        /wd4996 \   # silence warnings about deprecated strcpy and whatnot
        /wd4005 \   # silence warnings about macro redefinition
204 205
        /wd4290     # ignore exception specifications

206 207 208 209 210 211 212 213 214 215 216
    WarningsAsErrorsOn {
        QMAKE_CXXFLAGS_WARN_ON += /WX
    }
}

#
# Build-specific settings
#

ReleaseBuild {
    DEFINES += QT_NO_DEBUG
217 218 219 220
    CONFIG += force_debug_info  # Enable debugging symbols on release builds
    !iOSBuild {
        CONFIG += ltcg              # Turn on link time code generation
    }
dogmaphobic's avatar
dogmaphobic committed
221

222 223 224 225 226 227 228 229 230 231
    WindowsBuild {
        # 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
232 233 234 235 236 237 238
    }
}

#
# Unit Test specific configuration goes here
#

239
DebugBuild {
240 241
    DEFINES += UNITTEST_BUILD
}