forked from qreal/qreal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.pri
160 lines (130 loc) · 4.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
# Copyright 2007-2015 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
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) {
!macx {
QMAKE_LFLAGS += -Wl,-O1,-rpath,.
QMAKE_LFLAGS += -Wl,-rpath-link,$$DESTDIR
}
}
macx {
QMAKE_CXXFLAGS += -stdlib=libc++
QMAKE_LFLAGS_SONAME = -Wl,-install_name,@executable_path/../../../
}
unix {
CONFIG(debug):!CONFIG(sanitize_address):!CONFIG(sanitize_thread):!CONFIG(sanitize_memory):!CONFIG(sanitize_kernel_address) {
# Ubsan is turned on by default into debug build
CONFIG += sanitizer sanitize_undefined
}
linux-g++:CONFIG(sanitize_undefined):system( g++ --version | grep -e "\<5.[0-9]" ) {
# 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
}
}
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
CONFIG += c++14
QMAKE_CXXFLAGS += -Wextra -Wcast-qual -Wwrite-strings -Wredundant-decls -Wunreachable-code -Wnon-virtual-dtor
GLOBAL_PWD = $$PWD
# 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 =
isEmpty(QMAKE_SH) {
# This ugly code is needed because xcopy requires to add source directory name to target directory name when copying directories
win32 {
AFTER_SLASH = $$section(FILE, "/", -1, -1)
BASE_NAME = $$section(FILE, "/", -2, -2)
equals(AFTER_SLASH, ""):DESTDIR_SUFFIX = /$$BASE_NAME
FILE ~= s,/$,,g
FILE ~= s,/,\,g
}
DDIR = $$DESTDIR$$DESTDIR_SUFFIX/$$3
win32:DDIR ~= s,/,\,g
} else {
DDIR = $$DESTDIR$$DESTDIR_SUFFIX/$$3
}
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*
QMAKE_POST_LINK += $(COPY_DIR) $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t)
} else {
win32 {
system("cmd /C "xcopy $$quote($$FILE) $$quote($$DDIR) /s /e /q /y /i"")
}
unix:!macx {
system("cp -r -f $$FILE $$DDIR")
}
macx {
system("cp -R $$FILE $$DDIR/$$FILE")
}
}
}
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)
}