Merged in f5soh/librepilot/LP-575_fedora_package (pull request #491)
[librepilot.git] / ground / gcs / gcs.pri
blobf36f6290ea9e8912143683faf3f943c07ec0d15a
1 defineReplace(cleanPath) {
2     win32:1 ~= s|\\\\|/|g
3     contains(1, ^/.*):pfx = /
4     else:pfx =
5     segs = $$split(1, /)
6     out =
7     for(seg, segs) {
8         equals(seg, ..):out = $$member(out, 0, -2)
9         else:!equals(seg, .):out += $$seg
10     }
11     return($$join(out, /, $$pfx))
14 defineReplace(addNewline) { 
15     return($$escape_expand(\\n\\t))
18 defineReplace(qtLibraryName) {
19    unset(LIBRARY_NAME)
20    LIBRARY_NAME = $$1
21    CONFIG(debug, debug|release) {
22       !debug_and_release|build_pass {
23           mac:RET = $$member(LIBRARY_NAME, 0)_debug
24               else:win32:RET = $$member(LIBRARY_NAME, 0)d
25       }
26    }
27    isEmpty(RET):RET = $$LIBRARY_NAME
28    return($$RET)
31 defineTest(addCopyFileTarget) {
32     file = $$1
33     src  = $$2/$$1
34     dest = $$3/$$1
36     target = $${file}
37     $${target}.target    = $$dest
38     $${target}.depends   = $$src
40     # create directory. Better would be an order only dependency
41     $${target}.commands  = -@$(MKDIR) \"$$dirname(dest)\" $$addNewline()
42     $${target}.commands += $(COPY_FILE) \"$$src\" \"$$dest\"
44     QMAKE_EXTRA_TARGETS += $$target
45     POST_TARGETDEPS += $$eval($${target}.target)
47     export($${target}.target)
48     export($${target}.depends)
49     export($${target}.commands)
50     export(QMAKE_EXTRA_TARGETS)
51     export(POST_TARGETDEPS)
53     return(true)
56 defineTest(addCopyDependenciesTarget) {
57     file = $$1
58     src  = $$2/$$1
59     dest = $$3
61     target_file = $${OUT_PWD}/deps/$${file}.deps
63     target = $${file}_deps
64     $${target}.target    = $$target_file
65     $${target}.depends   = $$src
67     $${target}.commands  = -@$(MKDIR) \"$$dirname(target_file)\" $$addNewline()
68     $${target}.commands  += $$(PYTHON) $$(ROOT_DIR)/make/copy_dependencies.py --dest \"$$dest\" --files \"$$src\" --excludes OPENGL32.DLL > \"$$target_file\"
70     QMAKE_EXTRA_TARGETS += $$target
71     POST_TARGETDEPS += $$eval($${target}.target)
73     export($${target}.target)
74     export($${target}.depends)
75     export($${target}.commands)
76     export(QMAKE_EXTRA_TARGETS)
77     export(POST_TARGETDEPS)
79     return(true)
82 defineTest(addCopyDirTarget) {
83     dir  = $$1
84     src  = $$2/$$1
85     dest = $$3/$$1
87     target = $${dir}
88     $${target}.target    = $$dest
89     $${target}.depends   = $$src
90     # Windows does not update directory timestamp if files are modified
91     win32:$${target}depends += FORCE
93     $${target}.commands  = @rm -rf \"$$dest\" $$addNewline()
94     # create directory. Better would be an order only dependency
95     $${target}.commands += -@$(MKDIR) \"$$dirname(dest)\" $$addNewline()
96     $${target}.commands += $(COPY_DIR) \"$$src\" \"$$dest\"
98     QMAKE_EXTRA_TARGETS += $$target
99     POST_TARGETDEPS += $$eval($${target}.target)
101     export($${target}.target)
102     export($${target}.depends)
103     export($${target}.commands)
104     export(QMAKE_EXTRA_TARGETS)
105     export(POST_TARGETDEPS)
107     return(true)
110 # For use in custom compilers which just copy files
111 win32:i_flag = i
112 defineReplace(stripSrcDir) {
113     win32 {
114         !contains(1, ^.:.*):1 = $$OUT_PWD/$$1
115     } else {
116         !contains(1, ^/.*):1 = $$OUT_PWD/$$1
117     }
118     out = $$cleanPath($$1)
119     out ~= s|^$$re_escape($$_PRO_FILE_PWD_/)||$$i_flag
120     return($$out)
123 isEmpty(TEST):CONFIG(debug, debug|release) {
124     !debug_and_release|build_pass {
125         TEST = 1
126     }
129 equals(TEST, 1) {
130     QT +=testlib
131     DEFINES += WITH_TESTS
134 # don't build both debug and release
135 CONFIG -= debug_and_release
137 #ideally, we would want a qmake.conf patch, but this does the trick...
138 win32:!isEmpty(QMAKE_SH):QMAKE_COPY_DIR = cp -r -f
140 GCS_SOURCE_TREE = $$PWD
141 ROOT_DIR = $$GCS_SOURCE_TREE/../..
143 isEmpty(GCS_BUILD_TREE) {
144     sub_dir = $$_PRO_FILE_PWD_
145     sub_dir ~= s,^$$re_escape($$PWD),,
146     GCS_BUILD_TREE = $$cleanPath($$OUT_PWD)
147     GCS_BUILD_TREE ~= s,$$re_escape($$sub_dir)$,,
150 # Find the tools directory,
151 # try from Makefile (not run by Qt Creator),
152 isEmpty(TOOLS_DIR):TOOLS_DIR = $$(TOOLS_DIR)
153 isEmpty(TOOLS_DIR):TOOLS_DIR = $$clean_path($$ROOT_DIR/tools)
155 # Set the default name of the application
156 isEmpty(GCS_SMALL_NAME):GCS_SMALL_NAME = gcs
158 isEmpty(GCS_BIG_NAME) {
159     GCS_BIG_NAME = GCS
160 } else {
161     # Requote for safety and because of QTBUG-46224
162     GCS_BIG_NAME = "$$GCS_BIG_NAME"
165 isEmpty(ORG_SMALL_NAME):ORG_SMALL_NAME = unknown
167 isEmpty(ORG_BIG_NAME) {
168     ORG_BIG_NAME = Unknown
169 } else {
170     # Requote for safety and because of QTBUG-46224
171     ORG_BIG_NAME = "$$ORG_BIG_NAME"
174 isEmpty(WIKI_URL_ROOT) {
175     WIKI_URL_ROOT = Unknown
176 } else {
177     WIKI_URL_ROOT = "$$WIKI_URL_ROOT"
180 isEmpty(GCS_LIBRARY_BASENAME):GCS_LIBRARY_BASENAME = lib
182 macx {
183     GCS_APP_TARGET   = $$GCS_BIG_NAME
184     GCS_PATH = $$GCS_BUILD_TREE/$${GCS_APP_TARGET}.app/Contents
185     GCS_APP_PATH = $$GCS_PATH/MacOS
186     GCS_LIBRARY_PATH = $$GCS_PATH/Plugins
187     GCS_PLUGIN_PATH  = $$GCS_LIBRARY_PATH
188     GCS_QT_QML_PATH = $$GCS_PATH/Imports
189     GCS_DATA_PATH    = $$GCS_PATH/Resources
190     GCS_DOC_PATH     = $$GCS_DATA_PATH/doc
191     copydata = 1
192     copyqt = 1
193 } else {
194     GCS_APP_TARGET = $$GCS_SMALL_NAME
195     GCS_PATH         = $$GCS_BUILD_TREE
196     GCS_APP_PATH     = $$GCS_PATH/bin
197     GCS_LIBRARY_PATH = $$GCS_PATH/$$GCS_LIBRARY_BASENAME/$$GCS_SMALL_NAME
198     GCS_PLUGIN_PATH  = $$GCS_LIBRARY_PATH/plugins
199     GCS_DATA_PATH    = $$GCS_PATH/share/$$GCS_SMALL_NAME
200     GCS_DOC_PATH     = $$GCS_PATH/share/doc
202     !isEqual(GCS_SOURCE_TREE, $$GCS_BUILD_TREE):copydata = 1
204     win32 {
205         GCS_QT_PLUGINS_PATH = $$GCS_APP_PATH
206         GCS_QT_QML_PATH = $$GCS_APP_PATH
208         copyqt = $$copydata
209     } else {
210         GCS_QT_BASEPATH = $$GCS_LIBRARY_PATH/qt5
211         GCS_QT_LIBRARY_PATH = $$GCS_QT_BASEPATH/lib
212         GCS_QT_PLUGINS_PATH = $$GCS_QT_BASEPATH/plugins
213         GCS_QT_QML_PATH = $$GCS_QT_BASEPATH/qml
215         QT_INSTALL_DIR = $$clean_path($$[QT_INSTALL_LIBS]/../../../..)
216         equals(QT_INSTALL_DIR, $$TOOLS_DIR) {
217             copyqt = 1
218         } else {
219             copyqt = 0
220         }
221     }
224 INCLUDEPATH += \
225     $$GCS_SOURCE_TREE/src/libs
227 DEPENDPATH += \
228     $$GCS_SOURCE_TREE/src/libs
230 LIBS += -L$$GCS_LIBRARY_PATH
232 DEFINES += ORG_BIG_NAME=$$shell_quote(\"$$ORG_BIG_NAME\")
233 DEFINES += GCS_BIG_NAME=$$shell_quote(\"$$GCS_BIG_NAME\")
234 DEFINES += ORG_SMALL_NAME=$$shell_quote(\"$$ORG_SMALL_NAME\")
235 DEFINES += GCS_SMALL_NAME=$$shell_quote(\"$$GCS_SMALL_NAME\")
236 DEFINES += WIKI_URL_ROOT=$$shell_quote(\"$$WIKI_URL_ROOT\")
238 # DEFINES += QT_NO_CAST_FROM_ASCII
239 DEFINES += QT_NO_CAST_TO_ASCII
240 #DEFINES += QT_USE_FAST_OPERATOR_PLUS
241 #DEFINES += QT_USE_FAST_CONCATENATION
243 unix {
244     CONFIG(debug, debug|release):OBJECTS_DIR = $${OUT_PWD}/.obj/debug-shared
245     CONFIG(release, debug|release):OBJECTS_DIR = $${OUT_PWD}/.obj/release-shared
247     CONFIG(debug, debug|release):MOC_DIR = $${OUT_PWD}/.moc/debug-shared
248     CONFIG(release, debug|release):MOC_DIR = $${OUT_PWD}/.moc/release-shared
250     RCC_DIR = $${OUT_PWD}/.rcc
251     UI_DIR = $${OUT_PWD}/.uic
254 linux-g++-* {
255     # Bail out on non-selfcontained libraries. Just a security measure
256     # to prevent checking in code that does not compile on other platforms.
257     QMAKE_LFLAGS += -Wl,--allow-shlib-undefined -Wl,--no-undefined
260 win32 {
261     # Fix ((packed)) pragma handling issue introduced when upgrading MinGW from 4.4 to 4.8
262     # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991
263     # The ((packet)) pragma is used in uav metadata struct and other places
264     QMAKE_CXXFLAGS += -mno-ms-bitfields
267 # Explicit setting of C++11
268 CONFIG += c++11
270 address_sanitizer {
271     # enable asan by adding "address_sanitizer" to your root config file
272     # see https://github.com/google/sanitizers
273     # see https://blog.qt.io/blog/2013/04/17/using-gccs-4-8-0-address-sanitizer-with-qt/
274     #
275     # to use, simply compile and run, asan will crash with a report if an error is found.
276     # if you don't see symbols, try this: ./build/librepilot-gcs_debug/bin/librepilot-gcs 2>&1 | ./make/scripts/asan_symbolize.py
277     #
278     # Note: asan will apply only to GCS and not to third party libraries (Qt, osg, ...).
280     QMAKE_CXXFLAGS += -fsanitize=address -g -fno-omit-frame-pointer
281     QMAKE_CFLAGS += -fsanitize=address -g -fno-omit-frame-pointer
282     QMAKE_LFLAGS += -fsanitize=address -g
285 # Stricter warnings turned on for OS X.
286 macx {
287     CONFIG += warn_on
288     !warn_off {
289         QMAKE_CXXFLAGS_WARN_ON += -Werror
290         QMAKE_CFLAGS_WARN_ON   += -Werror
291         QMAKE_CXXFLAGS_WARN_ON += -Wno-gnu-static-float-init
292     }
293     # building with libc++ is needed when linking with osg/gdal
294     QMAKE_CXXFLAGS += -stdlib=libc++
295     QMAKE_LFLAGS += -stdlib=libc++
298 # use ccache when available
299 QMAKE_CC = $$(CCACHE) $$QMAKE_CC
300 QMAKE_CXX = $$(CCACHE) $$QMAKE_CXX