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
219
220
221
222
223
224
225
226
227
228
|
defineReplace(qtPlatformTargetSuffix) {
ios:CONFIG(iphonesimulator, iphonesimulator|iphoneos): \
suffix = _iphonesimulator
else: \
suffix =
CONFIG(debug, debug|release) {
!debug_and_release|build_pass {
mac: return($${suffix}_debug)
win32: return($${suffix}d)
}
}
return($$suffix)
}
defineReplace(qtLibraryTarget) {
LIBRARY_NAME = $$1
mac:CONFIG(shared, static|shared):contains(QT_CONFIG, qt_framework) {
QMAKE_FRAMEWORK_BUNDLE_NAME = $$LIBRARY_NAME
export(QMAKE_FRAMEWORK_BUNDLE_NAME)
}
return($$LIBRARY_NAME$$qtPlatformTargetSuffix())
}
defineReplace(qt5LibraryTarget) {
LIBRARY_NAME = $$qtLibraryTarget($$1)
isEmpty(QMAKE_FRAMEWORK_BUNDLE_NAME) {
# Insert the major version of Qt in the library name
# unless it's a framework build.
LIBRARY_NAME ~= s,^Qt,Qt$$QT_MAJOR_VERSION,
}
return($$LIBRARY_NAME)
}
defineTest(qtAddLibrary) {
warning("qtAddLibrary() is deprecated. Use QT+= instead.")
# Reverse-engineer the module name from the library name.
for(var, QT_MODULES) {
isEqual(QT.$${var}.name, $$1) {
QT += $$var
export(QT)
return(true)
}
}
error("No module matching library '$$1' found.")
}
# qt module
defineTest(qtHaveModule) {
!isEmpty(QT.$$replace(1, -, _).name): \
return(true)
return(false)
}
# variable, default, [suffix for variable for system() use], [prepare primary variable for system() use]
defineTest(qtPrepareTool) {
cmd = $$eval(QT_TOOL.$${2}.binary)
isEmpty(cmd) {
cmd = $$[QT_HOST_BINS]/$$2
exists($${cmd}.pl) {
cmd = perl -w $$system_path($${cmd}.pl)
} else: contains(QMAKE_HOST.os, Windows) {
cmd = $$system_path($${cmd}.exe)
} else:contains(QMAKE_HOST.os, Darwin) {
BUNDLENAME = $${cmd}.app/Contents/MacOS/$$2
exists($$BUNDLENAME) {
cmd = $$BUNDLENAME
}
}
}
QT_TOOL_ENV += $$eval(QT_TOOL.$${2}.envvars)
!isEmpty(3)|!isEmpty(4) {
$$1$$3 =
for (arg, cmd): \
$$1$$3 += $$system_quote($$arg)
qtAddTargetEnv($$1$$3, QT_TOOL.$${2}.depends, system)
}
isEmpty(4) {
$$1 =
for (arg, cmd): \
$$1 += $$shell_quote($$arg)
qtAddTargetEnv($$1, QT_TOOL.$${2}.depends, )
}
}
# target variable, list of env var names, [non-empty: prepare for system(), not make]
defineTest(qtAddToolEnv) {
isEmpty(3): \
ds = $$QMAKE_DIR_SEP
else: \
ds = $$DIR_SEPARATOR
for(env, 2) {
value = $$eval($${env}.value)
!isEmpty(value) {
name = $$eval($${env}.name)
equals(ds, /) {
contains($${env}.CONFIG, prepend): infix = \${$$name:+:\$$$name}
else: infix =
val = "$$name=$$shell_quote($$join(value, :))$$infix"
} else {
# Escape closing parens when expanding the variable, otherwise cmd confuses itself.
contains($${env}.CONFIG, prepend): infix = ;%$$name:)=^)%
else: infix =
value ~= s,\\),^),g
val = "(set $$name=$$join(value, ;)$$infix) &"
}
isEmpty(3): !contains(TEMPLATE, vc.*) {
contains(MAKEFILE_GENERATOR, MS.*): val ~= s,%,%%,g
val ~= s,\\\$,\$\$,g
}
$$1 = "$$val $$eval($$1)"
}
}
export($$1)
}
# target variable, dependency var name, [non-empty: prepare for system(), not make]
defineTest(qtAddTargetEnv) {
deps = $$replace($$2, -private$, _private)
deps = $$resolve_depends(deps, "QT.", ".depends" ".run_depends")
!isEmpty(deps) {
ptypes =
for(dep, deps) {
isEmpty(3): \
deppath += $$shell_path($$eval(QT.$${dep}.libs))
else: \
deppath += $$system_path($$eval(QT.$${dep}.libs))
ptypes += $$eval(QT.$${dep}.plugin_types)
}
equals(QMAKE_HOST.os, Windows) {
deppath.name = PATH
} else:contains(QMAKE_HOST.os, Linux|FreeBSD|OpenBSD|NetBSD|DragonFly|SunOS|HP-UX|QNX|GNU) {
deppath.name = LD_LIBRARY_PATH
} else:contains(QMAKE_HOST.os, Haiku) {
deppath.name = LIBRARY_PATH
} else:equals(QMAKE_HOST.os, Darwin) {
contains(QT_CONFIG, qt_framework): \
deppath.name = DYLD_FRAMEWORK_PATH
else: \
deppath.name = DYLD_LIBRARY_PATH
} else:equals(QMAKE_HOST.os, AIX) {
deppath.name = LIBPATH
} else {
error("Operating system not supported.")
}
deppath.value = $$unique(deppath)
deppath.CONFIG = prepend
pluginpath.value =
ppaths = $$[QT_INSTALL_PLUGINS/get]
for(qplug, QT_PLUGINS): \
contains(ptypes, QT_PLUGIN.$${qplug}.TYPE): \
ppaths += $$eval(QT_PLUGIN.$${qplug}.PATH)
ppaths = $$unique(ppaths)
for(qplug, ppaths) {
isEmpty(3): \
pluginpath.value += $$shell_path($$qplug)
else: \
pluginpath.value += $$system_path($$qplug)
}
pluginpath.name = QT_PLUGIN_PATH
QT_TOOL_ENV += deppath pluginpath
}
qtAddToolEnv($$1, $$QT_TOOL_ENV, $$3)
}
defineReplace(pkgConfigExecutable) {
isEmpty(PKG_CONFIG) {
PKG_CONFIG = pkg-config
sysroot.name = PKG_CONFIG_SYSROOT_DIR
sysroot.value = $$PKG_CONFIG_SYSROOT_DIR
libdir.name = PKG_CONFIG_LIBDIR
libdir.value = $$PKG_CONFIG_LIBDIR
qtAddToolEnv(PKG_CONFIG, sysroot libdir, SYS)
}
equals(QMAKE_HOST.os, Windows): \
PKG_CONFIG += 2> NUL
else: \
PKG_CONFIG += 2> /dev/null
return($$PKG_CONFIG)
}
defineTest(packagesExist) {
contains(QT_CONFIG, no-pkg-config):return(false)
# this can't be done in global scope here because qt_functions is loaded
# before the .pro is parsed, so if the .pro set PKG_CONFIG, we wouldn't know it
# yet. oops.
pkg_config = $$pkgConfigExecutable()
for(package, ARGS) {
!system($$pkg_config --exists $$package):return(false)
}
return(true)
}
# Prepares target that will iterate through all subdirs (except those
# with no_default_target or no_{name_of_target}_target. The prepared
# target must still be manually added to QMAKE_EXTRA_TARGETS.
defineTest(prepareRecursiveTarget) {
target = $$1
no_$${target}_target: return()
for(subdir, SUBDIRS) {
subdir_config = $$eval($${subdir}.CONFIG)
contains(subdir_config, no_default_target): next()
contains(subdir_config, no_$${target}_target): next()
$${target}.recurse += $$subdir
}
# Set up the recurse target only when there
# is something to recurse into.
isEmpty($${target}.recurse): return()
$${target}.CONFIG = recursive
$${target}.recurse_target = $${target}
export($${target}.recurse)
export($${target}.CONFIG)
export($${target}.recurse_target)
}
|