b9facbf345
The qmake function prepareRecursiveTarget can now be used both by the existing logic in default_post, as well as future recursive targets that will be needed as part of the modularization of documentation builds. Change-Id: Ibc72c3e224cb57c9f1796de3b04fda9de663dbb4 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
296 lines
9.8 KiB
Plaintext
296 lines
9.8 KiB
Plaintext
defineReplace(qtPlatformTargetSuffix) {
|
|
CONFIG(debug, debug|release) {
|
|
!debug_and_release|build_pass {
|
|
mac:return(_debug)
|
|
win32:return(d)
|
|
}
|
|
}
|
|
return()
|
|
}
|
|
|
|
defineReplace(qtLibraryTarget) {
|
|
unset(LIBRARY_NAME)
|
|
LIBRARY_NAME = $$1
|
|
mac:!static:contains(QT_CONFIG, qt_framework) {
|
|
QMAKE_FRAMEWORK_BUNDLE_NAME = $$LIBRARY_NAME
|
|
export(QMAKE_FRAMEWORK_BUNDLE_NAME)
|
|
}
|
|
unset(LIBRARY_SUFFIX)
|
|
contains(TEMPLATE, .*lib):LIBRARY_SUFFIX = $$qtPlatformTargetSuffix()
|
|
isEmpty(LIBRARY_SUFFIX):return($$LIBRARY_NAME)
|
|
else:return($$member(LIBRARY_NAME, 0)$$LIBRARY_SUFFIX)
|
|
}
|
|
|
|
defineTest(qtAddLibrary) {
|
|
warning("qtAddLibrary() is deprecated. Use qtAddModule() or QT+= instead.")
|
|
|
|
# Reverse-engineer the module name from the library name.
|
|
for(var, $$list($$find($$list($$enumerate_vars()), ^QT\\.[^.]+\\.name$))) {
|
|
isEqual($$var, $$1) {
|
|
var ~= s,^QT\\.([^.]+)\\.name$,\\1,
|
|
qtAddModule($$var, , LIBS):return(true):break()
|
|
return(false):break() # Yes, the break is insanity. But necessary.
|
|
}
|
|
}
|
|
error("No module matching library '$$1' found.")
|
|
}
|
|
|
|
# qt module, UsePrivate flag, libs variable
|
|
defineTest(qtAddModule) {
|
|
MODULE_NAME = $$eval(QT.$${1}.name)
|
|
MODULE_INCLUDES = $$eval(QT.$${1}.includes)
|
|
MODULE_LIBS = $$eval(QT.$${1}.libs)
|
|
MODULE_CONFIG = $$eval(QT.$${1}.module_config)
|
|
MODULE_MAJOR_VERSION = $$eval(QT.$${1}.MAJOR_VERSION)
|
|
|
|
CONFIG += $$eval(QT.$${1}.CONFIG)
|
|
DEFINES += $$eval(QT.$${1}.DEFINES)
|
|
|
|
MODULE_INCLUDES -= $$QMAKE_DEFAULT_INCDIRS
|
|
MODULE_LIBS -= $$QMAKE_DEFAULT_LIBDIRS
|
|
|
|
INCLUDEPATH *= $$MODULE_INCLUDES
|
|
auto_use_privates|isEqual(2, UsePrivate) { # Tests function parameter 2 ($$2) being equal to 'UsePrivate'
|
|
INCLUDEPATH += $$eval(QT.$${1}.private_includes)
|
|
}
|
|
|
|
unset(LINKAGE)
|
|
mac {
|
|
contains(MODULE_CONFIG, lib_bundle) {
|
|
FRAMEWORK_INCLUDE = $${MODULE_LIBS}/$${MODULE_NAME}.framework/Headers
|
|
!qt_no_framework_direct_includes:exists($$FRAMEWORK_INCLUDE) {
|
|
INCLUDEPATH *= $$FRAMEWORK_INCLUDE
|
|
LINKAGE = -F$${MODULE_LIBS}
|
|
} else {
|
|
QMAKE_FRAMEWORKPATH *= $${MODULE_LIBS}
|
|
}
|
|
LINKAGE += -framework $${MODULE_NAME}$${QT_LIBINFIX}
|
|
}
|
|
}
|
|
|
|
win32 {
|
|
# Make sure we link against the version pulled from the module's .pri
|
|
ver_var = QMAKE_$${upper($$MODULE_NAME$$QT_LIBINFIX)}_VERSION_OVERRIDE
|
|
dver_var = QMAKE_$${upper($$MODULE_NAME$$QT_LIBINFIX)}D_VERSION_OVERRIDE
|
|
$$ver_var = $$MODULE_MAJOR_VERSION
|
|
$$dver_var = $$MODULE_MAJOR_VERSION
|
|
export($$ver_var)
|
|
export($$dver_var)
|
|
}
|
|
|
|
isEmpty(LINKAGE) {
|
|
!isEmpty(MODULE_LIBS): LINKAGE = -L$$MODULE_LIBS
|
|
lib =
|
|
if(!debug_and_release|build_pass):CONFIG(debug, debug|release) {
|
|
win32: lib = -l$${MODULE_NAME}$${QT_LIBINFIX}d
|
|
mac: lib = -l$${MODULE_NAME}$${QT_LIBINFIX}_debug
|
|
}
|
|
isEmpty(lib): lib = -l$${MODULE_NAME}$${QT_LIBINFIX}
|
|
LINKAGE += $$lib
|
|
|
|
contains(QT_CONFIG, rpath) {
|
|
rpath = $$eval(QT.$${1}.rpath)
|
|
isEmpty(rpath): rpath = $$MODULE_LIBS
|
|
QMAKE_RPATHDIR *= $$rpath
|
|
}
|
|
|
|
# Make sure we can link to uninstalled libraries
|
|
unix:!mac:!isEmpty(QT.$${1}.libs) { # Use unmodified path, so /usr/lib also works
|
|
for(rpl, QT.$${1}.rpath_link): \
|
|
QMAKE_LFLAGS *= -Wl,-rpath-link,$$rpl
|
|
!auto_use_privates:!isEqual(2, UsePrivate): \
|
|
for(rpl, QT.$${1}.rpath_link_private): \
|
|
QMAKE_LFLAGS *= -Wl,-rpath-link,$$rpl
|
|
}
|
|
}
|
|
# Only link to this module if a libs directory is set, else this is just a module
|
|
# to give access to sources or include files, and not for linking.
|
|
!isEmpty(QT.$${1}.libs) { # Use unmodified path, so /usr/lib also works
|
|
!isEmpty(QMAKE_LSB) {
|
|
!isEmpty(MODULE_LIBS): QMAKE_LFLAGS *= --lsb-libpath=$$MODULE_LIBS
|
|
QMAKE_LIBDIR *= /opt/lsb/lib
|
|
QMAKE_LFLAGS *= --lsb-shared-libs=$${MODULE_NAME}$${QT_LIBINFIX}
|
|
}
|
|
$$3 += $$LINKAGE
|
|
}
|
|
export(CONFIG)
|
|
export(DEFINES)
|
|
export($$3)
|
|
export(INCLUDEPATH)
|
|
export(QMAKE_FRAMEWORKPATH)
|
|
export(QMAKE_LFLAGS)
|
|
export(QMAKE_LIBDIR)
|
|
export(QMAKE_RPATHDIR)
|
|
return(true)
|
|
}
|
|
|
|
# qt variable, libs variable
|
|
defineTest(qtAddModules) {
|
|
# Figure out from which modules we're wanting to use the private headers
|
|
NEWQT =
|
|
for(QTLIB, $$1) {
|
|
QTLIBRAW = $$replace(QTLIB, -private$, )
|
|
!isEqual(QTLIBRAW, $$QTLIB) {
|
|
want_var = QT.$${QTLIBRAW}.want_private
|
|
$$want_var = UsePrivate
|
|
using_privates = true
|
|
NEWQT += $$eval(QT.$${QTLIBRAW}.private_depends)
|
|
}
|
|
NEWQT += $$QTLIBRAW
|
|
contains(QT.$${QTLIBRAW}.CONFIG, auto_use_privates): CONFIG += auto_use_privates
|
|
}
|
|
# Topological resolution of modules based on their QT.<module>.depends variable
|
|
$$1 = $$resolve_depends(NEWQT, "QT.")
|
|
# Finally actually add the modules
|
|
unset(BAD_QT)
|
|
for(QTLIB, $$1) {
|
|
QTLIBNAME = $$eval(QT.$${QTLIB}.name)
|
|
isEmpty(QTLIBNAME) {
|
|
BAD_QT += $$QTLIB
|
|
next()
|
|
}
|
|
|
|
target_qt:isEqual(TARGET, $$QTLIBNAME) {
|
|
warning("$$TARGET cannot have a $$1 of $$QTLIB")
|
|
next()
|
|
}
|
|
|
|
qtAddModule($$QTLIB, $$eval(QT.$${QTLIB}.want_private), $$2)
|
|
}
|
|
!isEmpty(BAD_QT):error("Unknown module(s) in $$1: $$BAD_QT")
|
|
|
|
export(using_privates)
|
|
}
|
|
|
|
# variable, default
|
|
defineTest(qtPrepareTool) {
|
|
$$1 = $$eval(QT_TOOL.$${2}.command)
|
|
isEmpty($$1) {
|
|
$$1 = $$[QT_HOST_BINS/get]/$$2
|
|
contains(QMAKE_HOST.os, Windows):!contains($$1, .*\\.(exe|bat)$) {
|
|
exists($$eval($$1).bat) {
|
|
$$1 = $$eval($$1).bat
|
|
} else {
|
|
$$1 = $$eval($$1).exe
|
|
}
|
|
} else:contains(QMAKE_HOST.os, Darwin) {
|
|
BUNDLENAME = $$eval($$1).app/Contents/MacOS/$$2
|
|
exists($$BUNDLENAME) {
|
|
$$1 = $$BUNDLENAME
|
|
}
|
|
}
|
|
$$1 = $$shell_path($$eval($$1))
|
|
}
|
|
export($$1)
|
|
}
|
|
|
|
defineTest(qtAddToolEnv) {
|
|
for(env, 2) {
|
|
value = $$eval($${env}.value)
|
|
!isEmpty(value) {
|
|
name = $$eval($${env}.name)
|
|
equals(QMAKE_DIR_SEP, /) {
|
|
contains($${env}.CONFIG, prepend): infix = \${$$name:+:\$$$name}
|
|
else: infix =
|
|
$$1 = "$$name=$$join(value, :)$$infix $$eval($$1)"
|
|
} else {
|
|
# Escape closing parens when expanding the variable, otherwise cmd confuses itself.
|
|
contains($${env}.CONFIG, prepend): infix = ;%$$name:)=^)%
|
|
else: infix =
|
|
$$1 = "(set $$name=$$join(value, ;)$$infix) & $$eval($$1)"
|
|
}
|
|
}
|
|
}
|
|
export($$1)
|
|
}
|
|
|
|
defineTest(qtAddTargetEnv) {
|
|
deps = $$resolve_depends(QT, "QT.")
|
|
!isEmpty(deps) {
|
|
plugin_paths =
|
|
for(dep, deps) {
|
|
deppath += $$shell_path($$eval(QT.$${dep}.libs))
|
|
for(rpath, QT.$${dep}.rpath_link): \
|
|
deppath += $$shell_path($$rpath)
|
|
plugin_paths += $$eval(QT.$${dep}.plugin_path) $$eval(QT.$${dep}.plugins)
|
|
}
|
|
equals(QMAKE_HOST.os, Windows): \
|
|
deppath.name = PATH
|
|
else:contains(QMAKE_HOST.os, Linux|FreeBSD): \
|
|
deppath.name = LD_LIBRARY_PATH
|
|
else:equals(QMAKE_HOST.os, Darwin): \
|
|
deppath.name = DYLD_LIBRARY_PATH
|
|
else: \
|
|
error("Operating system not supported.")
|
|
deppath.value = $$unique(deppath)
|
|
deppath.CONFIG = prepend
|
|
pluginpath.name = QT_PLUGIN_PATH
|
|
pluginpath.value =
|
|
plugin_paths = $$unique(plugin_paths)
|
|
for(ppath, plugin_paths): \
|
|
exists($$ppath): \
|
|
pluginpath.value += $$shell_path($$ppath)
|
|
QT_TOOL_ENV += deppath pluginpath
|
|
}
|
|
qtAddToolEnv($$1, $$QT_TOOL_ENV)
|
|
}
|
|
|
|
defineReplace(pkgConfigExecutable) {
|
|
isEmpty(PKG_CONFIG) {
|
|
PKG_CONFIG = pkg-config
|
|
|
|
!isEmpty(PKG_CONFIG_SYSROOT_DIR) {
|
|
win32:isEmpty(MINGW_IN_SHELL):PKG_CONFIG = set PKG_CONFIG_SYSROOT_DIR=$$PKG_CONFIG_SYSROOT_DIR& $$PKG_CONFIG
|
|
else:PKG_CONFIG = PKG_CONFIG_SYSROOT_DIR=\"$$PKG_CONFIG_SYSROOT_DIR\" $$PKG_CONFIG
|
|
}
|
|
|
|
!isEmpty(PKG_CONFIG_LIBDIR) {
|
|
win32:isEmpty(MINGW_IN_SHELL):PKG_CONFIG = set PKG_CONFIG_LIBDIR=$$PKG_CONFIG_LIBDIR& $$PKG_CONFIG
|
|
else:PKG_CONFIG = PKG_CONFIG_LIBDIR=\"$$PKG_CONFIG_LIBDIR\" $$PKG_CONFIG
|
|
}
|
|
}
|
|
|
|
return($$PKG_CONFIG)
|
|
}
|
|
|
|
defineTest(packagesExist) {
|
|
# 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)
|
|
}
|