QGCCommon.pri 6.96 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
# -------------------------------------------------
# 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
# This file is part of the open groundstation project
# QGroundControl is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# QGroundControl is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with QGroundControl. If not, see <http://www.gnu.org/licenses/>.
# -------------------------------------------------

#
# This file contains configuration settings which are common to both the QGC Application and
# the Location Plugin. It should mainly contains intial CONFIG tag setup and compiler settings.
#

# 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 {
    linux-g++ | linux-g++-64 {
        message("Linux build")
        CONFIG += LinuxBuild
dogmaphobic's avatar
dogmaphobic committed
33 34
    } else : android-g++ {
        message("Android build")
dogmaphobic's avatar
dogmaphobic committed
35
        CONFIG += AndroidBuild MobileBuild
dogmaphobic's avatar
dogmaphobic committed
36
        DEFINES += __android__
dogmaphobic's avatar
dogmaphobic committed
37
        warning("Android build is experimental and not fully functional")
38 39 40 41 42 43 44 45 46 47 48 49 50 51
    } 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
    } 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
52
        DEFINES += __macos__
53 54 55 56
        QMAKE_CXXFLAGS += -fvisibility=hidden
    } else {
        error("Unsupported Mac toolchain, only 64-bit LLVM+clang is supported")
    }
dogmaphobic's avatar
dogmaphobic committed
57
} else : ios {
dogmaphobic's avatar
dogmaphobic committed
58 59 60
    !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
61 62 63
    message("iOS build")
    CONFIG += iOSBuild MobileBuild app_bundle
    DEFINES += __ios__
dogmaphobic's avatar
dogmaphobic committed
64
    QMAKE_IOS_DEPLOYMENT_TARGET = 8.0
dogmaphobic's avatar
dogmaphobic committed
65
    warning("iOS build is experimental and not yet fully functional")
66
} else {
dogmaphobic's avatar
dogmaphobic committed
67 68 69 70 71
    error("Unsupported build platform, only Linux, Windows, Android and Mac (Mac OS and iOS) are supported")
}

MobileBuild {
    DEFINES += __mobile__
72 73
}

dogmaphobic's avatar
dogmaphobic committed
74 75 76 77
# set the QGC version from git

exists ($$PWD/.git) {
  GIT_DESCRIBE = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags)
Daniel Agar's avatar
Daniel Agar committed
78
  message(QGroundControl version $${GIT_DESCRIBE})
dogmaphobic's avatar
dogmaphobic committed
79 80 81 82 83 84
} else {
  GIT_DESCRIBE = None
}

DEFINES += GIT_VERSION=\"\\\"$$GIT_DESCRIBE\\\"\"

85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
# 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)
}

# Need to special case Windows debug_and_release since VS Project creation in this case does strange things [QTBUG-40351]
win32:debug_and_release {
    CONFIG += WindowsDebugAndRelease
}

# Setup our build directories

dogmaphobic's avatar
dogmaphobic committed
113 114 115
BASEDIR      = $$IN_PWD
DESTDIR      = $${OUT_PWD}/debug
BUILDDIR     = $${OUT_PWD}/build-debug
116 117 118 119 120 121

ReleaseBuild {
    DESTDIR  = $${OUT_PWD}/release
    BUILDDIR = $${OUT_PWD}/build-release
}

dogmaphobic's avatar
dogmaphobic committed
122 123 124 125
iOSBuild {
    # For whatever reason, the iOS build fails with these set. Some files have the full,
    # properly concatenaded path and file name while others have only the second portion,
    # as if BUILDDIR was empty.
dogmaphobic's avatar
dogmaphobic committed
126 127 128 129
    OBJECTS_DIR = $$(HOME)/tmp/qgcfoo
    MOC_DIR     = $$(HOME)/tmp/qgcfoo
    UI_DIR      = $$(HOME)/tmp/qgcfoo
    RCC_DIR     = $$(HOME)/tmp/qgcfoo
dogmaphobic's avatar
dogmaphobic committed
130 131 132 133 134 135 136 137 138 139 140 141
} else {
    OBJECTS_DIR = $${BUILDDIR}/obj
    MOC_DIR     = $${BUILDDIR}/moc
    UI_DIR      = $${BUILDDIR}/ui
    RCC_DIR     = $${BUILDDIR}/rcc
}

LANGUAGE = C++

AndroidBuild {
    target.path = $$DESTDIR
}
142

143
# We place the created plugin lib into the objects dir so that make clean will clean it as well
dogmaphobic's avatar
dogmaphobic committed
144
iOSBuild {
dogmaphobic's avatar
dogmaphobic committed
145
    LOCATION_PLUGIN_DESTDIR = $$(HOME)/tmp/qgcfoo
dogmaphobic's avatar
dogmaphobic committed
146 147 148 149 150
} else {
    LOCATION_PLUGIN_DESTDIR = $$OBJECTS_DIR
}

LOCATION_PLUGIN_NAME = QGeoServiceProviderFactoryQGC
151

dogmaphobic's avatar
dogmaphobic committed
152
message(BASEDIR $$BASEDIR DESTDIR $$DESTDIR TARGET $$TARGET OUTPUT $$OUT_PWD)
153 154 155 156 157 158 159 160

# Turn off serial port warnings
DEFINES += _TTY_NOWARN_

#
# OS Specific settings
#

161 162 163 164
AndroidBuild {
    DEFINES += __STDC_LIMIT_MACROS
}

dogmaphobic's avatar
dogmaphobic committed
165 166 167 168
iOSBuild {
    QMAKE_IOS_DEPLOYMENT_TARGET = 7.0
}

169 170 171
MacBuild {
    CONFIG += x86_64
    CONFIG -= x86
172
    QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
173
    QMAKE_MAC_SDK = macosx10.11
174 175 176
}

LinuxBuild {
dogmaphobic's avatar
dogmaphobic committed
177
    DEFINES += __STDC_LIMIT_MACROS
178 179 180
}

WindowsBuild {
dogmaphobic's avatar
dogmaphobic committed
181
    DEFINES += __STDC_LIMIT_MACROS
182 183 184 185 186 187 188 189 190 191 192
}

#
# 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
193
    QMAKE_CXXFLAGS_WARN_ON += -Wall
194 195 196 197 198 199
    WarningsAsErrorsOn {
        QMAKE_CXXFLAGS_WARN_ON += -Werror
    }
}

WindowsBuild {
dogmaphobic's avatar
dogmaphobic committed
200
    QMAKE_CXXFLAGS_WARN_ON += /W3 \
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
        /wd4996 \   # silence warnings about deprecated strcpy and whatnot
        /wd4005 \   # silence warnings about macro redefinition
        /wd4290 \   # ignore exception specifications
        /Zc:strictStrings-  # work around win 8.1 sdk sapi.h problem
    WarningsAsErrorsOn {
        QMAKE_CXXFLAGS_WARN_ON += /WX
    }
}

#
# Build-specific settings
#

ReleaseBuild {
    DEFINES += QT_NO_DEBUG
dogmaphobic's avatar
dogmaphobic committed
216 217 218 219 220 221 222 223
    WindowsBuild {
        # Use link time code generation for better optimization (I believe this is supported in MSVC Express, but not 100% sure)
        QMAKE_LFLAGS_LTCG = /LTCG
        QMAKE_CFLAGS_LTCG = -GL

        # Turn on debugging information so we can collect good crash dumps from release builds
        QMAKE_CXXFLAGS_RELEASE += /Zi
        QMAKE_LFLAGS_RELEASE += /DEBUG
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
    }
}

#
# Unit Test specific configuration goes here
#
# We have to special case Windows debug_and_release builds because you can't have files
# which are only in the debug variant [QTBUG-40351]. So in this case we include unit tests
# even in the release variant. If you want a Windows release build with no unit tests run
# qmake with CONFIG-=debug_and_release CONFIG+=release.
#

DebugBuild|WindowsDebugAndRelease {
    DEFINES += UNITTEST_BUILD
}