Moved usagetracker defines to usagetracker.pri
[librepilot.git] / ground / gcs / gcs.pri
blob752fac93669d1afa8385571d1846a2506daad23f
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     $${file}.target    = $$dest
37     $${file}.depends   = $$src
39     # create directory. Better would be an order only dependency
40     $${file}.commands  = -@$(MKDIR) \"$$dirname(dest)\" $$addNewline()
41     $${file}.commands += $(COPY_FILE) \"$$src\" \"$$dest\"
43     QMAKE_EXTRA_TARGETS += $$file
44     POST_TARGETDEPS += $$eval($${file}.target)
46     export($${file}.target)
47     export($${file}.depends)
48     export($${file}.commands)
49     export(QMAKE_EXTRA_TARGETS)
50     export(POST_TARGETDEPS)
52     return(true)
55 defineTest(addCopyDirTarget) {
56     dir  = $$1
57     src  = $$2/$$1
58     dest = $$3/$$1
60     $${dir}.target    = $$dest
61     $${dir}.depends   = $$src
62     # Windows does not update directory timestamp if files are modified
63     win32: $${dir}.depends += FORCE
65     $${dir}.commands  = @rm -rf \"$$dest\" $$addNewline()
66     # create directory. Better would be an order only dependency
67     $${dir}.commands += -@$(MKDIR) \"$$dirname(dest)\" $$addNewline()
68     $${dir}.commands += $(COPY_DIR) \"$$src\" \"$$dest\"
70     QMAKE_EXTRA_TARGETS += $$dir
71     POST_TARGETDEPS += $$eval($${dir}.target)
73     export($${dir}.target)
74     export($${dir}.depends)
75     export($${dir}.commands)
76     export(QMAKE_EXTRA_TARGETS)
77     export(POST_TARGETDEPS)
79     return(true)
82 # For use in custom compilers which just copy files
83 win32:i_flag = i
84 defineReplace(stripSrcDir) {
85     win32 {
86         !contains(1, ^.:.*):1 = $$OUT_PWD/$$1
87     } else {
88         !contains(1, ^/.*):1 = $$OUT_PWD/$$1
89     }
90     out = $$cleanPath($$1)
91     out ~= s|^$$re_escape($$_PRO_FILE_PWD_/)||$$i_flag
92     return($$out)
95 isEmpty(TEST):CONFIG(debug, debug|release) {
96     !debug_and_release|build_pass {
97         TEST = 1
98     }
101 equals(TEST, 1) {
102     QT +=testlib
103     DEFINES += WITH_TESTS
106 #ideally, we would want a qmake.conf patch, but this does the trick...
107 win32:!isEmpty(QMAKE_SH):QMAKE_COPY_DIR = cp -r -f
109 GCS_SOURCE_TREE = $$PWD
110 ROOT_DIR = $$GCS_SOURCE_TREE/../..
112 isEmpty(GCS_BUILD_TREE) {
113     sub_dir = $$_PRO_FILE_PWD_
114     sub_dir ~= s,^$$re_escape($$PWD),,
115     GCS_BUILD_TREE = $$cleanPath($$OUT_PWD)
116     GCS_BUILD_TREE ~= s,$$re_escape($$sub_dir)$,,
119 # Find the tools directory,
120 # try from Makefile (not run by Qt Creator),
121 isEmpty(TOOLS_DIR):TOOLS_DIR = $$(TOOLS_DIR)
122 isEmpty(TOOLS_DIR):TOOLS_DIR = $$clean_path($$ROOT_DIR/tools)
124 # Set the default name of the application
125 isEmpty(GCS_SMALL_NAME):GCS_SMALL_NAME = gcs
127 isEmpty(GCS_BIG_NAME) {
128     GCS_BIG_NAME = GCS
129 } else {
130     # Requote for safety and because of QTBUG-46224
131     GCS_BIG_NAME = "$$GCS_BIG_NAME"
134 isEmpty(ORG_SMALL_NAME):ORG_SMALL_NAME = unknown
136 isEmpty(ORG_BIG_NAME) {
137     ORG_BIG_NAME = Unknown
138 } else {
139     # Requote for safety and because of QTBUG-46224
140     ORG_BIG_NAME = "$$ORG_BIG_NAME"
143 isEmpty(WIKI_URL_ROOT) {
144     WIKI_URL_ROOT = Unknown
145 } else {
146     WIKI_URL_ROOT = "$$WIKI_URL_ROOT"
150 isEmpty(GCS_LIBRARY_BASENAME):GCS_LIBRARY_BASENAME = lib
152 macx {
153     GCS_APP_TARGET   = $$GCS_BIG_NAME
154     GCS_PATH = $$GCS_BUILD_TREE/$${GCS_APP_TARGET}.app/Contents
155     GCS_APP_PATH = $$GCS_PATH/MacOS
156     GCS_LIBRARY_PATH = $$GCS_PATH/Plugins
157     GCS_PLUGIN_PATH  = $$GCS_LIBRARY_PATH
158     GCS_QT_QML_PATH = $$GCS_PATH/Imports
159     GCS_DATA_PATH    = $$GCS_PATH/Resources
160     GCS_DOC_PATH     = $$GCS_DATA_PATH/doc
161     copydata = 1
162     copyqt = 1
163     copyosg = 1
164 } else {
165     GCS_APP_TARGET = $$GCS_SMALL_NAME
166     GCS_PATH         = $$GCS_BUILD_TREE
167     GCS_APP_PATH     = $$GCS_PATH/bin
168     GCS_LIBRARY_PATH = $$GCS_PATH/$$GCS_LIBRARY_BASENAME/$$GCS_SMALL_NAME
169     GCS_PLUGIN_PATH  = $$GCS_LIBRARY_PATH/plugins
170     GCS_DATA_PATH    = $$GCS_PATH/share/$$GCS_SMALL_NAME
171     GCS_DOC_PATH     = $$GCS_PATH/share/doc
173     !isEqual(GCS_SOURCE_TREE, $$GCS_BUILD_TREE):copydata = 1
175     win32 {
176         SDL_DIR = $$(SDL_DIR)
177         isEmpty(SDL_DIR):SDL_DIR = $${TOOLS_DIR}/SDL-1.2.15
179         OPENSSL_DIR = $$(OPENSSL_DIR)
180         isEmpty(OPENSSL_DIR):OPENSSL_DIR = $${TOOLS_DIR}/openssl-1.0.1e-win32
182         MESAWIN_DIR = $$(MESAWIN_DIR)
183         isEmpty(MESAWIN_DIR):MESAWIN_DIR = $${TOOLS_DIR}/mesawin
185         GCS_QT_PLUGINS_PATH = $$GCS_APP_PATH
186         GCS_QT_QML_PATH = $$GCS_APP_PATH
188         copyqt = $$copydata
189         copyosg = $$copydata
190     } else {
191         GCS_QT_BASEPATH = $$GCS_LIBRARY_PATH/qt5
192         GCS_QT_LIBRARY_PATH = $$GCS_QT_BASEPATH/lib
193         GCS_QT_PLUGINS_PATH = $$GCS_QT_BASEPATH/plugins
194         GCS_QT_QML_PATH = $$GCS_QT_BASEPATH/qml
196         QT_INSTALL_DIR = $$clean_path($$[QT_INSTALL_LIBS]/../../../..)
197         equals(QT_INSTALL_DIR, $$TOOLS_DIR) {
198             copyqt = 1
199         } else {
200             copyqt = 0
201         }
202         copyosg = 1
203     }
207 INCLUDEPATH += \
208     $$GCS_SOURCE_TREE/src/libs
210 DEPENDPATH += \
211     $$GCS_SOURCE_TREE/src/libs
213 LIBS += -L$$GCS_LIBRARY_PATH
215 DEFINES += ORG_BIG_NAME=$$shell_quote(\"$$ORG_BIG_NAME\")
216 DEFINES += GCS_BIG_NAME=$$shell_quote(\"$$GCS_BIG_NAME\")
217 DEFINES += ORG_SMALL_NAME=$$shell_quote(\"$$ORG_SMALL_NAME\")
218 DEFINES += GCS_SMALL_NAME=$$shell_quote(\"$$GCS_SMALL_NAME\")
219 DEFINES += WIKI_URL_ROOT=$$shell_quote(\"$$WIKI_URL_ROOT\")
221 # DEFINES += QT_NO_CAST_FROM_ASCII
222 DEFINES += QT_NO_CAST_TO_ASCII
223 #DEFINES += QT_USE_FAST_OPERATOR_PLUS
224 #DEFINES += QT_USE_FAST_CONCATENATION
226 unix {
227     CONFIG(debug, debug|release):OBJECTS_DIR = $${OUT_PWD}/.obj/debug-shared
228     CONFIG(release, debug|release):OBJECTS_DIR = $${OUT_PWD}/.obj/release-shared
230     CONFIG(debug, debug|release):MOC_DIR = $${OUT_PWD}/.moc/debug-shared
231     CONFIG(release, debug|release):MOC_DIR = $${OUT_PWD}/.moc/release-shared
233     RCC_DIR = $${OUT_PWD}/.rcc
234     UI_DIR = $${OUT_PWD}/.uic
237 linux-g++-* {
238     # Bail out on non-selfcontained libraries. Just a security measure
239     # to prevent checking in code that does not compile on other platforms.
240     QMAKE_LFLAGS += -Wl,--allow-shlib-undefined -Wl,--no-undefined
243 win32 {
244     # Fix ((packed)) pragma handling issue introduced when upgrading MinGW from 4.4 to 4.8
245     # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991
246     # The ((packet)) pragma is used in uav metadata struct and other places
247     QMAKE_CXXFLAGS += -mno-ms-bitfields
250 # Stricter warnigs turned on for OS X.
251 macx {
252     CONFIG += warn_on
253     !warn_off {
254         QMAKE_CXXFLAGS_WARN_ON += -Werror
255         QMAKE_CFLAGS_WARN_ON   += -Werror
256         QMAKE_CXXFLAGS_WARN_ON += -Wno-gnu-static-float-init
257     }
261 # use ccache when available
262 QMAKE_CC = $$(CCACHE) $$QMAKE_CC
263 QMAKE_CXX = $$(CCACHE) $$QMAKE_CXX