QGCExternalLibs.pri 8.53 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1
#
2
# [REQUIRED] Add support for <inttypes.h> to Windows.
Don Gagne's avatar
Don Gagne committed
3 4 5 6 7 8
#
WindowsBuild {
    INCLUDEPATH += libs/lib/msinttypes
}

#
9
# [REQUIRED] Add support for the MAVLink communications protocol.
10 11
#
# By default MAVLink dialect is hardwired to arudpilotmega. The reason being
12
# the current codebase supports both PX4 and APM flight stack. PX4 flight stack
13 14
# only uses common MAVLink specifications, whereas APM flight stack uses custom
# MAVLink specifications which adds to common. So by using the adupilotmega dialect
15
# QGC can support both in the same codebase.
16

17 18 19 20
# Once the mavlink helper routines include support for multiple dialects within
# a single compiled codebase this hardwiring of dialect can go away. But until then
# this "workaround" is needed.

21 22 23
# In the mean time, it’s possible to define a completely different dialect by defining the
# location and name below.

24
# check for user defined settings in user_config.pri if not already set as qmake argument
25
isEmpty(MAVLINKPATH_REL) {
26 27 28 29 30 31
    exists(user_config.pri):infile(user_config.pri, MAVLINKPATH_REL) {
        MAVLINKPATH_REL = $$fromfile(user_config.pri, MAVLINKPATH_REL)
        message($$sprintf("Using user-supplied relativ mavlink path '%1' specified in user_config.pri", $$MAVLINKPATH_REL))
    } else {
        MAVLINKPATH_REL = libs/mavlink/include/mavlink/v2.0
    }
32
}
33

34
isEmpty(MAVLINKPATH) {
35 36 37 38 39 40
    exists(user_config.pri):infile(user_config.pri, MAVLINKPATH) {
        MAVLINKPATH     = $$fromfile(user_config.pri, MAVLINKPATH)
        message($$sprintf("Using user-supplied mavlink path '%1' specified in user_config.pri", $$MAVLINKPATH))
    } else {
        MAVLINKPATH     = $$BASEDIR/$$MAVLINKPATH_REL
    }
41
}
42

43
isEmpty(MAVLINK_CONF) {
44 45 46 47 48 49
    exists(user_config.pri):infile(user_config.pri, MAVLINK_CONF) {
        MAVLINK_CONF = $$fromfile(user_config.pri, MAVLINK_CONF)
        message($$sprintf("Using user-supplied mavlink dialect '%1' specified in user_config.pri", $$MAVLINK_CONF))
    } else {
        MAVLINK_CONF = ardupilotmega
    }
50 51 52 53 54 55
}

# If defined, all APM specific MAVLink messages are disabled
contains (CONFIG, QGC_DISABLE_APM_MAVLINK) {
    message("Disable APM MAVLink support")
    DEFINES += NO_ARDUPILOT_DIALECT
56
    CONFIG  += ArdupilotDisabled
57 58
} else {
    CONFIG  += ArdupilotEnabled
59
}
Don Gagne's avatar
Don Gagne committed
60

61 62 63
# First we select the dialect, checking for valid user selection
# Users can override all other settings by specifying MAVLINK_CONF as an argument to qmake
!isEmpty(MAVLINK_CONF) {
64
    message($$sprintf("Using MAVLink dialect '%1'.", $$MAVLINK_CONF))
Don Gagne's avatar
Don Gagne committed
65
}
66 67

# Then we add the proper include paths dependent on the dialect.
Don Gagne's avatar
Don Gagne committed
68
INCLUDEPATH += $$MAVLINKPATH
Lorenz Meier's avatar
Lorenz Meier committed
69 70 71 72 73 74 75 76 77 78

exists($$MAVLINKPATH/common) {
    !isEmpty(MAVLINK_CONF) {
        count(MAVLINK_CONF, 1) {
            exists($$MAVLINKPATH/$$MAVLINK_CONF) {
                INCLUDEPATH += $$MAVLINKPATH/$$MAVLINK_CONF
                DEFINES += $$sprintf('QGC_USE_%1_MESSAGES', $$upper($$MAVLINK_CONF))
            } else {
                error($$sprintf("MAVLink dialect '%1' does not exist at '%2'!", $$MAVLINK_CONF, $$MAVLINKPATH_REL))
            }
79
        } else {
Lorenz Meier's avatar
Lorenz Meier committed
80
            error(Only a single mavlink dialect can be specified in MAVLINK_CONF)
81 82
        }
    } else {
Lorenz Meier's avatar
Lorenz Meier committed
83
        INCLUDEPATH += $$MAVLINKPATH/common
84
    }
Don Gagne's avatar
Don Gagne committed
85
} else {
Lorenz Meier's avatar
Lorenz Meier committed
86
    error($$sprintf("MAVLink folder does not exist at '%1'! Run 'git submodule init && git submodule update' on the command line.",$$MAVLINKPATH_REL))
Don Gagne's avatar
Don Gagne committed
87 88 89
}

#
90 91
# [REQUIRED] EIGEN matrix library
# NOMINMAX constant required to make internal min/max work.
Don Gagne's avatar
Don Gagne committed
92 93 94
INCLUDEPATH += libs/eigen
DEFINES += NOMINMAX

95 96 97 98 99 100 101
#
# [REQUIRED] shapelib library
INCLUDEPATH += libs/shapelib
SOURCES += \
    libs/shapelib/shpopen.c \
    libs/shapelib/safileio.c

Don Gagne's avatar
Don Gagne committed
102
#
103 104 105
# [REQUIRED] SDL dependency. Provides joystick/gamepad support.
# The SDL is packaged with QGC for the Mac and Windows. Linux support requires installing the SDL
# library (development libraries and static binaries).
Don Gagne's avatar
Don Gagne committed
106 107 108
#
MacBuild {
    INCLUDEPATH += \
109
        $$BASEDIR/libs/lib/Frameworks/SDL2.framework/Headers
Don Gagne's avatar
Don Gagne committed
110 111
    LIBS += \
        -F$$BASEDIR/libs/lib/Frameworks \
112
        -framework SDL2
113
} else:LinuxBuild {
114
    PKGCONFIG = sdl2
115
} else:WindowsBuild {
116 117
    INCLUDEPATH += $$BASEDIR/libs/lib/sdl2/msvc/include
    contains(QT_ARCH, i386) {
Gus Grubba's avatar
Gus Grubba committed
118
        INCLUDEPATH += $$BASEDIR/libs/OpenSSL/Windows/x86/include
119
        LIBS += -L$$BASEDIR/libs/lib/sdl2/msvc/lib/x86
Gus Grubba's avatar
Gus Grubba committed
120
        LIBS += -L$$BASEDIR/libs/OpenSSL/Windows/x86/lib
121
    } else {
Gus Grubba's avatar
Gus Grubba committed
122
        INCLUDEPATH += $$BASEDIR/libs/OpenSSL/Windows/x64/include
123
        LIBS += -L$$BASEDIR/libs/lib/sdl2/msvc/lib/x64
Gus Grubba's avatar
Gus Grubba committed
124
        LIBS += -L$$BASEDIR/libs/OpenSSL/Windows/x64/lib
125
    }
dogmaphobic's avatar
dogmaphobic committed
126
    LIBS += \
127
        -lSDL2main \
Gus Grubba's avatar
Gus Grubba committed
128
        -lSDL2
Don Gagne's avatar
Don Gagne committed
129 130
}

131
# Include Android OpenSSL libs in order to make Qt OpenSSL support work
132
AndroidBuild {
133
    equals(ANDROID_TARGET_ARCH, armeabi-v7a)  {
Gus Grubba's avatar
Gus Grubba committed
134 135
        ANDROID_EXTRA_LIBS += $$BASEDIR/libs/OpenSSL/Android/arch-armeabi-v7a/lib/libcrypto.so
        ANDROID_EXTRA_LIBS += $$BASEDIR/libs/OpenSSL/Android/arch-armeabi-v7a/lib/libssl.so
136
    } else:equals(ANDROID_TARGET_ARCH, arm64-v8a)  {
137
        # Haven't figured out how to get 64 bit arm OpenSLL yet. This means things like terrain queries will not qork.
138
    } else:equals(ANDROID_TARGET_ARCH, x86)  {
Gus Grubba's avatar
Gus Grubba committed
139 140
        ANDROID_EXTRA_LIBS += $$BASEDIR/libs/OpenSSL/Android/arch-x86/lib/libcrypto.so
        ANDROID_EXTRA_LIBS += $$BASEDIR/libs/OpenSSL/Android/arch-x86/lib/libssl.so
141 142
    } else {
        error("Unsupported Android architecture: $${ANDROID_TARGET_ARCH}")
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
    }
}

# Pairing
contains(DEFINES, QGC_ENABLE_PAIRING) {
    MacBuild {
        #- Pairing is generally not supported on macOS. This is here solely for development.
        exists(/usr/local/Cellar/openssl/1.0.2s/include) {
            INCLUDEPATH += /usr/local/Cellar/openssl/1.0.2s/include
            LIBS += -L/usr/local/Cellar/openssl/1.0.2s/lib
            LIBS += -lcrypto -lz
        } else {
            # There is some circular reference settings going on between QGCExternalLibs.pri and gqgroundcontrol.pro.
            # So this duplicates some of the enable/disable logic which would normally be in qgroundcontrol.pro.
            DEFINES -= QGC_ENABLE_NFC
            DEFINES -= QGC_ENABLE_PAIRING
        }
Gus Grubba's avatar
Gus Grubba committed
160 161 162 163
    } else:WindowsBuild {
        #- Pairing is not supported on Windows
        DEFINES -= QGC_ENABLE_NFC
        DEFINES -= QGC_ENABLE_PAIRING
164 165 166 167 168 169 170 171 172 173 174
    } else {
        LIBS += -lcrypto -lz
        AndroidBuild {
            contains(QT_ARCH, arm) {
                LIBS += $$ANDROID_EXTRA_LIBS
                INCLUDEPATH += $$BASEDIR/libs/OpenSSL/Android/arch-armeabi-v7a/include
            } else {
                LIBS += $$ANDROID_EXTRA_LIBS
                INCLUDEPATH += $$BASEDIR/libs/OpenSSL/Android/arch-x86/include
            }
        }
175 176 177
    }
}

178 179 180 181 182 183 184 185 186 187 188 189 190
#
# [OPTIONAL] Zeroconf for UDP links
#
contains (DEFINES, DISABLE_ZEROCONF) {
    message("Skipping support for Zeroconf (manual override from command line)")
    DEFINES -= DISABLE_ZEROCONF
# Otherwise the user can still disable this feature in the user_config.pri file.
} else:exists(user_config.pri):infile(user_config.pri, DEFINES, DISABLE_ZEROCONF) {
    message("Skipping support for Zeroconf (manual override from user_config.pri)")
# Mac support is built into OS
} else:MacBuild|iOSBuild {
    message("Including support for Zeroconf (Bonjour)")
    DEFINES += QGC_ZEROCONF_ENABLED
Gus Grubba's avatar
Gus Grubba committed
191 192
} else {
    message("Skipping support for Zeroconf (unsupported platform)")
193 194
}

195 196 197 198 199 200 201 202 203
#
# [OPTIONAL] AirMap Support
#
contains (DEFINES, DISABLE_AIRMAP) {
    message("Skipping support for AirMap (manual override from command line)")
# Otherwise the user can still disable this feature in the user_config.pri file.
} else:exists(user_config.pri):infile(user_config.pri, DEFINES, DISABLE_AIRMAP) {
    message("Skipping support for AirMap (manual override from user_config.pri)")
} else {
204 205
    AIRMAPD_PATH    = $$PWD/libs/airmapd
    AIRMAP_QT_PATH  = Qt.$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}
Gus Grubba's avatar
Gus Grubba committed
206
    message('Looking for Airmap in folder "$${AIRMAPD_PATH}", variant: "$$AIRMAP_QT_PATH"')
207 208 209 210 211
    MacBuild {
        exists($${AIRMAPD_PATH}/macOS/$$AIRMAP_QT_PATH) {
            message("Including support for AirMap for macOS")
            LIBS += -L$${AIRMAPD_PATH}/macOS/$$AIRMAP_QT_PATH -lairmap-qt
            DEFINES += QGC_AIRMAP_ENABLED
212
        }
213 214 215 216 217 218 219 220
    } else:LinuxBuild {
        exists($${AIRMAPD_PATH}/linux/$$AIRMAP_QT_PATH) {
            message("Including support for AirMap for Linux")
            LIBS += -L$${AIRMAPD_PATH}/linux/$$AIRMAP_QT_PATH -lairmap-qt
            DEFINES += QGC_AIRMAP_ENABLED
        }
    } else {
        message("Skipping support for Airmap (unsupported platform)")
221 222 223 224
    }
    contains (DEFINES, QGC_AIRMAP_ENABLED) {
        INCLUDEPATH += \
            $${AIRMAPD_PATH}/include
225 226
    }
}