QGCExternalLibs.pri 8.11 KB
Newer Older
Gus Grubba's avatar
Gus Grubba committed
1 2 3 4 5 6 7 8 9
################################################################################
#
# (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.
#
################################################################################

Don Gagne's avatar
Don Gagne committed
10
#
11
# [REQUIRED] Add support for <inttypes.h> to Windows.
Don Gagne's avatar
Don Gagne committed
12 13
#
WindowsBuild {
Don Gagne's avatar
Don Gagne committed
14
    INCLUDEPATH += libs/msinttypes
Don Gagne's avatar
Don Gagne committed
15 16 17
}

#
18
# [REQUIRED] Add support for the MAVLink communications protocol.
19 20
#
# By default MAVLink dialect is hardwired to arudpilotmega. The reason being
21
# the current codebase supports both PX4 and APM flight stack. PX4 flight stack
22 23
# only uses common MAVLink specifications, whereas APM flight stack uses custom
# MAVLink specifications which adds to common. So by using the adupilotmega dialect
24
# QGC can support both in the same codebase.
25

26 27 28 29
# 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.

30 31 32
# In the mean time, it’s possible to define a completely different dialect by defining the
# location and name below.

33
# check for user defined settings in user_config.pri if not already set as qmake argument
34
isEmpty(MAVLINKPATH_REL) {
35 36 37 38 39 40
    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
    }
41
}
42

43
isEmpty(MAVLINKPATH) {
44 45 46 47
    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 {
48
        MAVLINKPATH     = $$SOURCE_DIR/$$MAVLINKPATH_REL
49
    }
50
}
51

52
isEmpty(MAVLINK_CONF) {
53 54 55 56 57 58
    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
    }
59 60 61 62 63 64
}

# If defined, all APM specific MAVLink messages are disabled
contains (CONFIG, QGC_DISABLE_APM_MAVLINK) {
    message("Disable APM MAVLink support")
    DEFINES += NO_ARDUPILOT_DIALECT
65
    CONFIG  += ArdupilotDisabled
66 67
} else {
    CONFIG  += ArdupilotEnabled
68
}
Don Gagne's avatar
Don Gagne committed
69

70 71 72
# 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) {
73
    message($$sprintf("Using MAVLink dialect '%1'.", $$MAVLINK_CONF))
Don Gagne's avatar
Don Gagne committed
74
}
75 76

# Then we add the proper include paths dependent on the dialect.
Don Gagne's avatar
Don Gagne committed
77
INCLUDEPATH += $$MAVLINKPATH
Lorenz Meier's avatar
Lorenz Meier committed
78 79 80 81 82 83 84 85 86 87

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))
            }
88
        } else {
Lorenz Meier's avatar
Lorenz Meier committed
89
            error(Only a single mavlink dialect can be specified in MAVLINK_CONF)
90 91
        }
    } else {
Lorenz Meier's avatar
Lorenz Meier committed
92
        INCLUDEPATH += $$MAVLINKPATH/common
93
    }
Don Gagne's avatar
Don Gagne committed
94
} else {
Lorenz Meier's avatar
Lorenz Meier committed
95
    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
96 97 98
}

#
99 100
# [REQUIRED] EIGEN matrix library
# NOMINMAX constant required to make internal min/max work.
Don Gagne's avatar
Don Gagne committed
101 102 103
INCLUDEPATH += libs/eigen
DEFINES += NOMINMAX

104 105 106 107 108 109 110
#
# [REQUIRED] shapelib library
INCLUDEPATH += libs/shapelib
SOURCES += \
    libs/shapelib/shpopen.c \
    libs/shapelib/safileio.c

111 112
#
# [REQUIRED] zlib library
Oleg's avatar
Oleg committed
113
WindowsBuild {
DonLakeFlyer's avatar
DonLakeFlyer committed
114 115
    INCLUDEPATH +=  $$SOURCE_DIR/libs/zlib/windows/include
    LIBS += -L$$SOURCE_DIR/libs/zlib/windows/lib
DonLakeFlyer's avatar
DonLakeFlyer committed
116 117 118
    LIBS += -lzlibstat
} else {
    LIBS += -lz
DonLakeFlyer's avatar
DonLakeFlyer committed
119
}
120

Don Gagne's avatar
Don Gagne committed
121
#
122 123 124
# [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
125 126 127
#
MacBuild {
    INCLUDEPATH += \
128
        $$SOURCE_DIR/libs/Frameworks/SDL2.framework/Headers
Don Gagne's avatar
Don Gagne committed
129
    LIBS += \
130
        -F$$SOURCE_DIR/libs/Frameworks \
131
        -framework SDL2
132
} else:LinuxBuild {
133
    PKGCONFIG = sdl2
134
} else:WindowsBuild {
135 136 137
    INCLUDEPATH += $$SOURCE_DIR/libs/sdl2/msvc/include
    INCLUDEPATH += $$SOURCE_DIR/libs/OpenSSL/Windows/x64/include
    LIBS += -L$$SOURCE_DIR/libs/sdl2/msvc/lib/x64
DonLakeFlyer's avatar
DonLakeFlyer committed
138
    LIBS += -lSDL2
Don Gagne's avatar
Don Gagne committed
139 140
}

Don Gagne's avatar
Don Gagne committed
141
# Include Android OpenSSL libs
142
AndroidBuild {
143
    include($$SOURCE_DIR/libs/OpenSSL/android_openssl/openssl.pri)
Don Gagne's avatar
Don Gagne committed
144 145 146
    message("ANDROID_EXTRA_LIBS")
    message($$ANDROID_TARGET_ARCH)
    message($$ANDROID_EXTRA_LIBS)
147 148 149 150 151 152
}

# Pairing
contains(DEFINES, QGC_ENABLE_PAIRING) {
    MacBuild {
        #- Pairing is generally not supported on macOS. This is here solely for development.
Gus Grubba's avatar
Gus Grubba committed
153 154 155
        exists(/usr/local/Cellar/openssl/1.0.2t/include) {
            INCLUDEPATH += /usr/local/Cellar/openssl/1.0.2t/include
            LIBS += -L/usr/local/Cellar/openssl/1.0.2t/lib
DonLakeFlyer's avatar
DonLakeFlyer committed
156
            LIBS += -lcrypto
157 158 159 160 161
        } 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_PAIRING
        }
Gus Grubba's avatar
Gus Grubba committed
162 163 164
    } else:WindowsBuild {
        #- Pairing is not supported on Windows
        DEFINES -= QGC_ENABLE_PAIRING
165
    } else {
DonLakeFlyer's avatar
DonLakeFlyer committed
166
        LIBS += -lcrypto
167 168 169
        AndroidBuild {
            contains(QT_ARCH, arm) {
                LIBS += $$ANDROID_EXTRA_LIBS
170
                INCLUDEPATH += $$SOURCE_DIR/libs/OpenSSL/Android/arch-armeabi-v7a/include
171 172
            } else {
                LIBS += $$ANDROID_EXTRA_LIBS
173
                INCLUDEPATH += $$SOURCE_DIR/libs/OpenSSL/Android/arch-x86/include
174 175
            }
        }
176 177 178
    }
}

179 180 181 182 183 184 185 186 187 188 189 190 191
#
# [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
192 193
} else {
    message("Skipping support for Zeroconf (unsupported platform)")
194 195
}

196 197 198 199 200 201 202 203 204
#
# [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 {
205 206
    AIRMAPD_PATH    = $$PWD/libs/airmapd
    AIRMAP_QT_PATH  = Qt.$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}
Gus Grubba's avatar
Gus Grubba committed
207
    message('Looking for Airmap in folder "$${AIRMAPD_PATH}", variant: "$$AIRMAP_QT_PATH"')
208 209 210 211 212
    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
213
        }
214 215 216 217 218 219 220 221
    } 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)")
222 223 224 225
    }
    contains (DEFINES, QGC_AIRMAP_ENABLED) {
        INCLUDEPATH += \
            $${AIRMAPD_PATH}/include
226 227
    }
}