forked from qreal/qreal
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglobal.pri
218 lines (175 loc) · 6.22 KB
/
global.pri
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# Copyright 2016 Iakov Kirilenko, 2007-2017 QReal Research Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
win32 {
PLATFORM = windows
}
unix:!macx {
PLATFORM = linux
}
macx {
PLATFORM = mac
}
CONFIG(debug, debug | release) {
CONFIGURATION = debug
CONFIGURATION_SUFFIX = -d
unix {
QMAKE_CXXFLAGS += -coverage
QMAKE_LFLAGS += -coverage
}
} else {
CONFIGURATION = release
CONFIGURATION_SUFFIX =
}
DESTDIR = $$PWD/bin/$$CONFIGURATION
PROJECT_BASENAME = $$basename(_PRO_FILE_)
PROJECT_NAME = $$section(PROJECT_BASENAME, ".", 0, 0)
isEmpty(TARGET) {
TARGET = $$PROJECT_NAME$$CONFIGURATION_SUFFIX
} else {
TARGET = $$TARGET$$CONFIGURATION_SUFFIX
}
equals(TEMPLATE, app) {
unix:!macx {
QMAKE_LFLAGS += -Wl,-rpath-link,$$DESTDIR
!CONFIG(no_rpath) QMAKE_LFLAGS += -Wl,-O1,-rpath,.
}
macx:!CONFIG(no_rpath) {
QMAKE_LFLAGS += -rpath . -rpath @executable_path/../Lib -rpath @executable_path/../Frameworks -rpath @executable_path/../../../
}
}
macx-clang {
QMAKE_MACOSX_DEPLOYMENT_TARGET=10.9
QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
}
!clang:!win32:gcc:*-g++*:system($$QMAKE_CXX --version | grep -oe \'\\<[5-6]\\.[0-9]\\+\\.\' ){ CONFIG += gcc5 }
!clang:!win32:gcc:*-g++*:system($$QMAKE_CXX --version | grep -oe \'\\<4\\.[0-9]\\+\\.\' ){ CONFIG += gcc4 }
unix:!CONFIG(nosanitizers) {
# seems like we want USan always, but are afraid of ....
!CONFIG(sanitize_address):!CONFIG(sanitize_thread):!CONFIG(sanitize_memory):!CONFIG(sanitize_kernel_address) {
# Ubsan is turned on by default
CONFIG += sanitizer sanitize_undefined
}
CONFIG(debug, debug | release):!CONFIG(sanitize_address):!macx-clang { CONFIG += sanitize_leak }
CONFIG(sanitize_leak) {
#LSan can be used without performance degrade even in release build
QMAKE_CFLAGS += -fsanitize=leak
QMAKE_CXXFLAGS += -fsanitize=leak
QMAKE_LFLAGS += -fsanitize=leak
}
CONFIG(sanitize_undefined):macx-clang {
# sometimes runtime is missing in clang. this hack allows to avoid runtime dependency.
QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fsanitize-trap=undefined
QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fsanitize-trap=undefined
QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fsanitize-trap=undefined
}
CONFIG(gcc5){
CONFIG(sanitize_undefined){
# Ubsan has (had at least) known issues with false errors about calls of methods of the base class.
# That must be disabled. Variables for confguring ubsan are taken from here:
# https://codereview.qt-project.org/#/c/43420/17/mkspecs/common/sanitize.conf
# They can change in some version of Qt, keep track of it.
# By the way, simply setting QMAKE_CFLAGS, QMAKE_CXXFLAGS and QMAKE_LFLAGS instead of those used below
# will not work due to arguments order ("-fsanitize=undefined" must be declared before "-fno-sanitize=vptr").
QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fno-sanitize=vptr
QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fno-sanitize=vptr
QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fno-sanitize=vptr
}
}
CONFIG(release, debug | release){
CONFIG(gcc4) {
message("Too old compiler: $$QMAKE_CXX")
} else {
QMAKE_CFLAGS += -fsanitize-recover=all
QMAKE_CXXFLAGS += -fsanitize-recover=all
}
}
}
OBJECTS_DIR = .build/$$CONFIGURATION/obj
MOC_DIR = .build/$$CONFIGURATION/moc
RCC_DIR = .build/$$CONFIGURATION/rcc
UI_DIR = .build/$$CONFIGURATION/ui
INCLUDEPATH += $$_PRO_FILE_PWD_ \
$$_PRO_FILE_PWD_/include \
$$PWD \
LIBS += -L$$DESTDIR
QMAKE_CXXFLAGS += -pedantic-errors -ansi -std=c++11 -Wextra
CONFIG(gcc5)|clang{
QMAKE_CXXFLAGS +=-Werror=pedantic -Werror=delete-incomplete
}
QMAKE_CXXFLAGS += -Werror=cast-qual -Werror=write-strings -Werror=redundant-decls -Werror=unreachable-code \
-Werror=non-virtual-dtor -Wno-error=overloaded-virtual \
-Werror=uninitialized -Werror=init-self
# I want -Werror to be turned on, but Qt has problems
#QMAKE_CXXFLAGS += -Werror -Wno-error=inconsistent-missing-override -Wno-error=deprecated-declarations -Wno-error=unused-parameter
GLOBAL_PWD = $$PWD
# Simple function that checks if given argument is a file or directory.
# Returns false if argument 1 is a file or does not exist.
defineTest(isDir) {
exists($$1/*):return(true)
return(false)
}
# Useful function to copy additional files to destination,
# from http://stackoverflow.com/questions/3984104/qmake-how-to-copy-a-file-to-the-output
defineTest(copyToDestdir) {
FILES = $$1
NOW = $$2
for(FILE, FILES) {
DESTDIR_SUFFIX =
AFTER_SLASH = $$section(FILE, "/", -1, -1)
# This ugly code is needed because xcopy requires to add source directory name to target directory name when copying directories
win32 {
FILE = $$system_path($$FILE)
isDir($$FILE) {
ABSOLUTE_PATH = $$absolute_path($$FILE, $$GLOBAL_PWD)
BASE_NAME = $$section(ABSOLUTE_PATH, "/", -1, -1)
DESTDIR_SUFFIX = /$$BASE_NAME
}
}
DDIR = $$DESTDIR/$$3$$DESTDIR_SUFFIX
win32:DDIR ~= s,/,\\,g
mkpath($$DDIR)
isEmpty(NOW) {
# In case this is directory add "*" to copy contents of a directory instead of directory itself under linux.
!win32:equals(AFTER_SLASH, ""):FILE = $$FILE* #looks like inconsistent behaviour
QMAKE_POST_LINK += $(COPY_DIR) $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
} else {
win32 {
# Message here is very useful in diagnostics.
message("Executing `cmd /C xcopy $$quote($$FILE) $$quote($$DDIR) /s /e /q /y /i`")
system("cmd /C "xcopy $$quote($$FILE) $$quote($$DDIR) /s /e /q /y /i"")
}
unix:!macx {
system("cp -r -f $$FILE $$DDIR/")
}
macx {
system("rsync -avz $$FILE $$DDIR/")
}
}
}
export(QMAKE_POST_LINK)
}
defineTest(includes) {
PROJECTS = $$1
for(PROJECT, PROJECTS) {
INCLUDEPATH += $$GLOBAL_PWD/$$PROJECT $$GLOBAL_PWD/$$PROJECT/include
}
export(INCLUDEPATH)
}
defineTest(links) {
PROJECTS = $$1
for(PROJECT, PROJECTS) {
LIBS += -l$$PROJECT$$CONFIGURATION_SUFFIX
}
export(LIBS)
}