2017-12-11 13:09:04 +00:00
|
|
|
# This avoids spurious errors when a project is explicitly disabled
|
|
|
|
# due to required Qt modules being missing.
|
|
|
|
!isEmpty(QMAKE_FAILED_REQUIREMENTS): return()
|
|
|
|
|
2023-02-28 19:42:22 +00:00
|
|
|
# hardcoded defaults
|
|
|
|
QT_CONFIG *= c99 c11 c++11 c++14 c++1z c++17
|
|
|
|
|
2018-03-20 12:30:53 +00:00
|
|
|
qtConfig(thread): CONFIG *= thread
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#handle defines
|
|
|
|
win32 {
|
2016-08-05 11:35:39 +00:00
|
|
|
qtConfig(shared) {
|
2012-05-30 10:09:00 +00:00
|
|
|
# this variable is read by qmake in qmake/generators/win32/msvc_vcproj.cpp
|
2015-03-16 13:15:27 +00:00
|
|
|
# function VcprojGenerator::initDeploymentTool()
|
|
|
|
QMAKE_DLL_PATHS += $$[QT_INSTALL_BINS/get]
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG
|
|
|
|
no_keywords:DEFINES += QT_NO_KEYWORDS
|
|
|
|
plugin { #Qt plugins
|
|
|
|
static:DEFINES += QT_STATICPLUGIN
|
|
|
|
DEFINES += QT_PLUGIN
|
|
|
|
}
|
|
|
|
|
2012-12-20 08:05:29 +00:00
|
|
|
qtestlib {
|
|
|
|
warning("CONFIG+=qtestlib is deprecated. Use QT+=testlib instead.")
|
|
|
|
QT += testlib
|
|
|
|
}
|
|
|
|
qdbus {
|
|
|
|
warning("CONFIG+=qdbus is deprecated. Use QT+=dbus instead.")
|
|
|
|
QT += dbus
|
|
|
|
}
|
|
|
|
help {
|
|
|
|
warning("CONFIG+=help is deprecated. Use QT+=help instead.")
|
|
|
|
QT += help-private # sic!
|
|
|
|
}
|
|
|
|
designer {
|
|
|
|
warning("CONFIG+=designer is deprecated. Use QT+=designer instead.")
|
|
|
|
QT += designer
|
|
|
|
}
|
|
|
|
uitools {
|
|
|
|
warning("CONFIG+=uitools is deprecated. Use QT+=uitools instead.")
|
|
|
|
QT += uitools
|
|
|
|
}
|
|
|
|
qaxcontainer {
|
|
|
|
warning("CONFIG+=qaxcontainer is deprecated. Use QT+=axcontainer instead.")
|
|
|
|
QT += axcontainer
|
|
|
|
}
|
|
|
|
qaxserver {
|
|
|
|
warning("CONFIG+=qaxserver is deprecated. Use QT+=axserver instead.")
|
|
|
|
QT += axserver
|
|
|
|
}
|
2012-12-10 13:56:29 +00:00
|
|
|
|
2016-12-20 19:20:35 +00:00
|
|
|
!import_qpa_plugin {
|
|
|
|
warning("CONFIG-=import_qpa_plugin is deprecated. Use QTPLUGIN.platforms=- instead.")
|
|
|
|
QTPLUGIN.platforms = -
|
|
|
|
} else: qpa_minimal_plugin {
|
|
|
|
warning("CONFIG+=qpa_minimal_plugin is deprecated. Use QTPLUGIN.platforms=qminimal instead.")
|
|
|
|
QTPLUGIN.platforms = qminimal
|
|
|
|
}
|
|
|
|
|
2016-12-06 16:27:50 +00:00
|
|
|
!force_import_plugins:!contains(TEMPLATE, ".*app"):!if(contains(TEMPLATE, ".*lib"):dll): \
|
|
|
|
CONFIG -= import_plugins
|
2012-01-23 13:46:58 +00:00
|
|
|
unix {
|
2022-07-15 23:32:11 +00:00
|
|
|
contains(QT_CONFIG, no_direct_extern_access): CONFIG += no_direct_extern_access
|
2012-01-23 13:46:58 +00:00
|
|
|
else:contains(QT_CONFIG, reduce_relocations):!contains(TEMPLATE, .*lib): {
|
|
|
|
QMAKE_CFLAGS += $$QMAKE_CFLAGS_PIC
|
|
|
|
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_PIC
|
|
|
|
}
|
|
|
|
}
|
2016-12-06 16:27:50 +00:00
|
|
|
|
2022-05-10 13:02:43 +00:00
|
|
|
# Will automatically add plugins, so run first
|
|
|
|
contains(QT_CONFIG, permissions): load(permissions)
|
|
|
|
|
2016-12-20 19:20:35 +00:00
|
|
|
# qmake variables cannot contain dashes, so normalize the names first
|
|
|
|
CLEAN_QT = $$replace(QT, -private$, _private)
|
|
|
|
CLEAN_QT_PRIVATE = $$replace(QT_PRIVATE, -private$, _private)
|
|
|
|
|
|
|
|
qt_module_deps = $$CLEAN_QT $$CLEAN_QT_PRIVATE
|
|
|
|
all_qt_module_deps = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_depends")
|
|
|
|
|
2016-12-20 19:20:39 +00:00
|
|
|
QTPLUGIN = $$unique($$list($$lower($$QTPLUGIN)))
|
|
|
|
|
2022-07-18 13:56:29 +00:00
|
|
|
# Sanitize requested plugins, and add any default plugins
|
2022-07-18 14:22:16 +00:00
|
|
|
import_plugins {
|
2016-12-20 19:20:35 +00:00
|
|
|
manualplugs = $$QTPLUGIN # User may specify plugins. Mostly legacy.
|
|
|
|
autoplugs = # Auto-added plugins.
|
|
|
|
# First round: explicitly specified modules.
|
2022-07-18 13:56:29 +00:00
|
|
|
all_plugin_deps = $$all_qt_module_deps
|
|
|
|
plugin_deps = $$all_plugin_deps
|
2016-12-20 19:20:35 +00:00
|
|
|
for(ever) {
|
2022-07-18 13:56:29 +00:00
|
|
|
# Automatically add the default plugins for the linked Qt modules.
|
2016-12-20 19:20:35 +00:00
|
|
|
for (qtmod, plugin_deps) {
|
|
|
|
for (ptype, QT.$${qtmod}.plugin_types) {
|
|
|
|
nptype = $$replace(ptype, [-/], _)
|
|
|
|
isEmpty(QTPLUGIN.$$nptype) {
|
|
|
|
for (plug, QT_PLUGINS) {
|
|
|
|
equals(QT_PLUGIN.$${plug}.TYPE, $$ptype) {
|
|
|
|
for (dep, QT_PLUGIN.$${plug}.EXTENDS) {
|
2022-07-18 13:56:29 +00:00
|
|
|
!contains(all_plugin_deps, $$dep) {
|
2016-12-20 19:20:35 +00:00
|
|
|
plug =
|
|
|
|
break()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
autoplugs += $$plug
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
plug = $$eval(QTPLUGIN.$$nptype)
|
|
|
|
!equals(plug, -): \
|
|
|
|
autoplugs += $$plug
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QTPLUGIN = $$manualplugs $$autoplugs
|
|
|
|
QTPLUGIN = $$unique(QTPLUGIN)
|
|
|
|
|
|
|
|
# Obtain the plugins' Qt dependencies ...
|
|
|
|
plugin_deps =
|
|
|
|
for (plug, QTPLUGIN): \
|
|
|
|
plugin_deps += $$eval(QT_PLUGIN.$${plug}.DEPENDS)
|
|
|
|
plugin_deps = $$resolve_depends(plugin_deps, "QT.", ".depends" ".run_depends")
|
2022-07-18 13:56:29 +00:00
|
|
|
plugin_deps -= $$all_plugin_deps
|
|
|
|
|
2016-12-20 19:20:35 +00:00
|
|
|
isEmpty(plugin_deps): \
|
|
|
|
break()
|
|
|
|
# ... and start over if any new Qt modules appeared,
|
|
|
|
# as these may want to load plugins in turn.
|
2022-07-18 13:56:29 +00:00
|
|
|
all_plugin_deps += $$plugin_deps
|
2016-12-20 19:20:35 +00:00
|
|
|
}
|
|
|
|
extraplugs = $$manualplugs
|
|
|
|
manualplugs -= $$autoplugs
|
|
|
|
extraplugs -= $$manualplugs
|
|
|
|
!isEmpty(extraplugs): \
|
|
|
|
warning("Redundant entries in QTPLUGIN: $$extraplugs")
|
|
|
|
}
|
|
|
|
|
2022-07-18 14:22:16 +00:00
|
|
|
# Link static plugins
|
|
|
|
!isEmpty(QTPLUGIN) {
|
2016-12-20 19:20:39 +00:00
|
|
|
for (plug, QTPLUGIN) {
|
2022-07-18 14:22:16 +00:00
|
|
|
module_config = $$eval(QT_PLUGIN.$${plug}.module_config)
|
|
|
|
isEmpty(module_config):!qtConfig(static): \
|
|
|
|
next() # Compatibility with older modules
|
|
|
|
|
|
|
|
!contains(module_config, staticlib): \
|
|
|
|
next()
|
|
|
|
|
2022-07-18 13:56:29 +00:00
|
|
|
plug_class = $$eval(QT_PLUGIN.$${plug}.CLASS_NAME)
|
|
|
|
!isEmpty(plug_class): \
|
|
|
|
IMPORT_FILE_CONT += "Q_IMPORT_PLUGIN($$plug_class)"
|
|
|
|
else: \
|
|
|
|
warning("Plugin class name could not be determined for plugin '$$plug'.")
|
|
|
|
|
|
|
|
plugin_deps = $$eval(QT_PLUGIN.$${plug}.DEPENDS)
|
|
|
|
plugin_deps = $$resolve_depends(plugin_deps, "QT.", ".depends" ".run_depends")
|
|
|
|
all_qt_module_deps *= $$plugin_deps
|
|
|
|
|
2016-12-20 19:20:39 +00:00
|
|
|
# Check if the plugin is known to Qt. We can use this to determine
|
|
|
|
# the plugin path. Unknown plugins must rely on the default link path.
|
|
|
|
plug_type = $$eval(QT_PLUGIN.$${plug}.TYPE)
|
|
|
|
!isEmpty(plug_type) {
|
qmake: Resolve target suffix based on Qt build config for static plugins
The qtPlatformTargetSuffix() function is used in various places to
determine the suffix of targets based on the config, which for macOS
will result in a _debug suffix in debug mode.
This becomes tricky when one project built in debug mode tries to depend
on the libraries/plugins of another project (Qt) built in release, as
the qtPlatformTargetSuffix() function uses the current CONFIG as input,
which may be different than the QT_CONFIG (or CONFIG of whatever project
is being depended on).
For libraries this was fixed in 50e664835bc2130e8693364641f9aaa7133b6998
by iterating all known library paths, and trying the CONFIG suffix before
falling back to release version.
For plugins this was never solved, which becomes an issue when linking
to static plugins, either in a fully static build of Qt, or when some
of the plugins are static (permission plugins e.g.).
In this situation, the user project has to have the same configuration
as Qt was built with, to avoid errors like:
error: no such file or directory: '~/6.x-static/qtbase/plugins/platforms/libqcocoa_debug.a'
To work around this, we assume that a plugin installed into the Qt
tree has the same build configuration as Qt itself, then then use
QT_CONFIG as the determining factor when linking to the plugin.
This still ties the build config of the plugin to the config of Qt,
but relaxes the relationship to the application, allowing it to be
built in either debug or release, which is an improvement to the
current state.
Pick-to: 6.5 6.5.0
Task-number: QTBUG-110356
Change-Id: Icee67fc01313a6c6f34178a6345ccae1b57429d7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-02-23 14:50:23 +00:00
|
|
|
# Respect target config if Qt provides both debug and release versions
|
|
|
|
# of each plugin. Otherwise, respect what Qt was configured with.
|
|
|
|
qtConfig(debug_and_release): config_variable = CONFIG
|
|
|
|
else: config_variable = QT_CONFIG
|
|
|
|
|
|
|
|
plug_name = $$QMAKE_PREFIX_STATICLIB$${plug}$$qtPlatformTargetSuffix($$config_variable).$$QMAKE_EXTENSION_STATICLIB
|
2016-12-20 19:20:39 +00:00
|
|
|
plug_path = $$eval(QT_PLUGIN.$${plug}.PATH)
|
|
|
|
isEmpty(plug_path): \
|
|
|
|
plug_path = $$[QT_INSTALL_PLUGINS/get]
|
2018-12-19 11:46:52 +00:00
|
|
|
LIBS += $$plug_path/$$plug_type/$$plug_name
|
|
|
|
} else {
|
qmake: Resolve target suffix based on Qt build config for static plugins
The qtPlatformTargetSuffix() function is used in various places to
determine the suffix of targets based on the config, which for macOS
will result in a _debug suffix in debug mode.
This becomes tricky when one project built in debug mode tries to depend
on the libraries/plugins of another project (Qt) built in release, as
the qtPlatformTargetSuffix() function uses the current CONFIG as input,
which may be different than the QT_CONFIG (or CONFIG of whatever project
is being depended on).
For libraries this was fixed in 50e664835bc2130e8693364641f9aaa7133b6998
by iterating all known library paths, and trying the CONFIG suffix before
falling back to release version.
For plugins this was never solved, which becomes an issue when linking
to static plugins, either in a fully static build of Qt, or when some
of the plugins are static (permission plugins e.g.).
In this situation, the user project has to have the same configuration
as Qt was built with, to avoid errors like:
error: no such file or directory: '~/6.x-static/qtbase/plugins/platforms/libqcocoa_debug.a'
To work around this, we assume that a plugin installed into the Qt
tree has the same build configuration as Qt itself, then then use
QT_CONFIG as the determining factor when linking to the plugin.
This still ties the build config of the plugin to the config of Qt,
but relaxes the relationship to the application, allowing it to be
built in either debug or release, which is an improvement to the
current state.
Pick-to: 6.5 6.5.0
Task-number: QTBUG-110356
Change-Id: Icee67fc01313a6c6f34178a6345ccae1b57429d7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-02-23 14:50:23 +00:00
|
|
|
LIBS += -l$${plug}$$qtPlatformTargetSuffix(CONFIG)
|
2016-12-20 19:20:39 +00:00
|
|
|
}
|
|
|
|
}
|
2022-07-18 13:56:29 +00:00
|
|
|
|
2022-07-18 14:22:16 +00:00
|
|
|
!isEmpty(IMPORT_FILE_CONT) {
|
|
|
|
IMPORT_FILE_CONT = \
|
|
|
|
"// This file is autogenerated by qmake. It imports static plugin classes for" \
|
|
|
|
"// static plugins specified using QTPLUGIN and QT_PLUGIN_CLASS.<plugin> variables." \
|
|
|
|
"$${LITERAL_HASH}include <QtPlugin>" \
|
|
|
|
"$$IMPORT_FILE_CONT"
|
|
|
|
|
|
|
|
TARGET_BASENAME = $$lower($$basename(TARGET))
|
|
|
|
TARGET_BASENAME ~= s/\s/_/g
|
|
|
|
IMPORT_CPP = $$OUT_PWD/$${TARGET_BASENAME}_plugin_import.cpp
|
|
|
|
write_file($$IMPORT_CPP, IMPORT_FILE_CONT)|error()
|
|
|
|
GENERATED_SOURCES += $$IMPORT_CPP
|
|
|
|
QMAKE_DISTCLEAN += $$IMPORT_CPP
|
|
|
|
}
|
2016-12-20 19:20:39 +00:00
|
|
|
}
|
|
|
|
|
2015-06-05 17:01:50 +00:00
|
|
|
# target variable, flag source variable
|
|
|
|
defineTest(qtProcessModuleFlags) {
|
|
|
|
for(flag, $$2) {
|
|
|
|
contains(flag, ^-.*): \
|
|
|
|
$$1 -= $$replace(flag, ^-, )
|
|
|
|
else: \
|
|
|
|
$$1 += $$flag
|
|
|
|
}
|
|
|
|
export($$1)
|
|
|
|
}
|
|
|
|
|
2020-10-23 09:38:30 +00:00
|
|
|
unset(using_private_headers)
|
2015-06-05 17:01:50 +00:00
|
|
|
var_sfx =
|
|
|
|
for(ever) {
|
|
|
|
# Topological resolution of modules based on their QT.<module>.depends variable
|
|
|
|
FULL_QT$$var_sfx = $$resolve_depends(CLEAN_QT$$var_sfx, "QT.")
|
|
|
|
# Finally actually add the modules
|
|
|
|
unset(BAD_QT)
|
|
|
|
for(QTLIB, FULL_QT$$var_sfx) {
|
|
|
|
MODULE_NAME = $$eval(QT.$${QTLIB}.name)
|
2015-11-19 16:11:05 +00:00
|
|
|
MODULE_MODULE = $$eval(QT.$${QTLIB}.module)
|
2015-06-05 17:01:50 +00:00
|
|
|
MODULE_INCLUDES = $$eval(QT.$${QTLIB}.includes)
|
2020-11-02 16:12:32 +00:00
|
|
|
MODULE_LDFLAGS = $$eval(QT.$${QTLIB}.ldflags)
|
2015-06-05 17:01:50 +00:00
|
|
|
MODULE_LIBS = $$eval(QT.$${QTLIB}.libs)
|
2015-11-19 16:11:05 +00:00
|
|
|
MODULE_FRAMEWORKS = $$eval(QT.$${QTLIB}.frameworks)
|
2016-10-12 09:30:58 +00:00
|
|
|
MODULE_USES = $$eval(QT.$${QTLIB}.uses)
|
2015-06-05 17:01:50 +00:00
|
|
|
MODULE_CONFIG = $$eval(QT.$${QTLIB}.module_config)
|
|
|
|
|
|
|
|
isEmpty(MODULE_NAME) {
|
|
|
|
BAD_QT += $$QTLIB
|
|
|
|
next()
|
|
|
|
}
|
|
|
|
|
2020-10-23 09:38:30 +00:00
|
|
|
contains(MODULE_CONFIG, internal_module):!isEmpty(MODULE_INCLUDES): \
|
|
|
|
using_private_headers = true
|
2015-06-05 17:01:50 +00:00
|
|
|
contains(MODULE_CONFIG, ltcg): \
|
|
|
|
CONFIG += link_ltcg
|
|
|
|
|
|
|
|
qtProcessModuleFlags(CONFIG, QT.$${QTLIB}.CONFIG)
|
|
|
|
qtProcessModuleFlags(DEFINES, QT.$${QTLIB}.DEFINES)
|
|
|
|
|
|
|
|
MODULE_INCLUDES -= $$QMAKE_DEFAULT_INCDIRS
|
|
|
|
|
2020-11-02 16:12:32 +00:00
|
|
|
# Add linker flags before lib
|
|
|
|
LIBS$$var_sfx += $$MODULE_LDFLAGS
|
|
|
|
|
2015-11-19 16:11:05 +00:00
|
|
|
# Frameworks shouldn't need include paths, but much code does not use
|
|
|
|
# module-qualified #includes, so by default we add paths which point
|
|
|
|
# directly into the frameworks. Private modules have somewhat convoluted
|
|
|
|
# header paths, so adding them is necessary in every case.
|
|
|
|
!if(contains(MODULE_CONFIG, lib_bundle):qt_no_framework_direct_includes) \
|
|
|
|
|contains(MODULE_CONFIG, internal_module): \
|
|
|
|
INCLUDEPATH *= $$MODULE_INCLUDES
|
|
|
|
QMAKE_FRAMEWORKPATH *= $$MODULE_FRAMEWORKS
|
|
|
|
!isEmpty(MODULE_MODULE) {
|
|
|
|
contains(MODULE_CONFIG, lib_bundle) {
|
macOS: Explicitly link to debug version of framework when needed
When Qt is configured for both debug and release, and frameworks are
enabled, we produce two dynamic libraries inside each framework, eg:
QtCore.framework/QtCore
QtCore.framework/QtCore_debug
When building an executable against these frameworks, we pass -framework
QtCore, and the resulting executable will have its LC_LOAD_DYLIB load
commands pointing to e.g.:
@rpath/QtCore.framework/Versions/5/QtCore
When running the executable, the dynamic loader will load the dynamic
library dependencies based on these load commands.
By setting the DYLD_IMAGE_SUFFIX environment variable at runtime to
'_debug', the dynamic loader will prefer the debug versions of each
library inside the frameworks.
Unfortunately the use of an environment variable to choose debug or
release versions leaves room for mismatches between the executable
and the libraries that are loaded. An executable built in debug
mode will at runtime pick up the release versions of the Qt libraries
unless the DYLD_IMAGE_SUFFIX has also been set to match the build
configuration of the executable.
This results in confusing situations such as building your application
in debug mode, and then stepping into Qt code but not getting any
symbols. Qt Creator has an option to run the application with
DYLD_IMAGE_SUFFIX set, but this is not enabled by default due
to the startup cost of loading the Qt debug libraries.
More critically, it results in tests failing when the tests are using
QTest::ignoreMessage to ignore warnings produced by Qt, and these
calls are ifdefed (correctly) inside QT_NO_DEBUG, as the test
(built in debug mode) will then expect warnings from Qt, but those
warnings are not emittet, as the test is run against the release
version of the Qt libraries.
To mitigate this mismatch, we now link the Qt frameworks using
an explicit suffix, just like we would for no-framework builds
on macOS, for debug and release builds on Windows, and for
normal builds on other Unixes, leaving the dependency chain
for the application predictable:
@rpath/QtCore.framework/Versions/5/QtCore_debug
This also conceptually matches how Xcode builds applications and
frameworks, where it never relies on DYLD_IMAGE_SUFFIX, and instead
uses two separate build directories, one for each configuration.
The change means that Qt Creator will always load the Qt debug
libraries if the application is built in debug mode. For Qt
development this is a good thing, as you expect to be able to
step into Qt code. For our users, the added startup cost can
be mitigated by shipping our binary packages as release-only,
but with separate debug info enabled.
Change-Id: Ib9f1f2dab90ed00b9fb011200e3a69c71955e399
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2018-03-09 16:04:37 +00:00
|
|
|
framework = $$MODULE_MODULE
|
2018-12-19 11:46:52 +00:00
|
|
|
# Linking frameworks by absolute path does not work.
|
macOS: Explicitly link to debug version of framework when needed
When Qt is configured for both debug and release, and frameworks are
enabled, we produce two dynamic libraries inside each framework, eg:
QtCore.framework/QtCore
QtCore.framework/QtCore_debug
When building an executable against these frameworks, we pass -framework
QtCore, and the resulting executable will have its LC_LOAD_DYLIB load
commands pointing to e.g.:
@rpath/QtCore.framework/Versions/5/QtCore
When running the executable, the dynamic loader will load the dynamic
library dependencies based on these load commands.
By setting the DYLD_IMAGE_SUFFIX environment variable at runtime to
'_debug', the dynamic loader will prefer the debug versions of each
library inside the frameworks.
Unfortunately the use of an environment variable to choose debug or
release versions leaves room for mismatches between the executable
and the libraries that are loaded. An executable built in debug
mode will at runtime pick up the release versions of the Qt libraries
unless the DYLD_IMAGE_SUFFIX has also been set to match the build
configuration of the executable.
This results in confusing situations such as building your application
in debug mode, and then stepping into Qt code but not getting any
symbols. Qt Creator has an option to run the application with
DYLD_IMAGE_SUFFIX set, but this is not enabled by default due
to the startup cost of loading the Qt debug libraries.
More critically, it results in tests failing when the tests are using
QTest::ignoreMessage to ignore warnings produced by Qt, and these
calls are ifdefed (correctly) inside QT_NO_DEBUG, as the test
(built in debug mode) will then expect warnings from Qt, but those
warnings are not emittet, as the test is run against the release
version of the Qt libraries.
To mitigate this mismatch, we now link the Qt frameworks using
an explicit suffix, just like we would for no-framework builds
on macOS, for debug and release builds on Windows, and for
normal builds on other Unixes, leaving the dependency chain
for the application predictable:
@rpath/QtCore.framework/Versions/5/QtCore_debug
This also conceptually matches how Xcode builds applications and
frameworks, where it never relies on DYLD_IMAGE_SUFFIX, and instead
uses two separate build directories, one for each configuration.
The change means that Qt Creator will always load the Qt debug
libraries if the application is built in debug mode. For Qt
development this is a good thing, as you expect to be able to
step into Qt code. For our users, the added startup cost can
be mitigated by shipping our binary packages as release-only,
but with separate debug info enabled.
Change-Id: Ib9f1f2dab90ed00b9fb011200e3a69c71955e399
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2018-03-09 16:04:37 +00:00
|
|
|
LIBS$$var_sfx += -framework $$framework
|
2015-11-19 16:11:05 +00:00
|
|
|
} else {
|
2021-06-24 12:27:37 +00:00
|
|
|
lib_bases = $$MODULE_MODULE$$qtPlatformTargetSuffix()
|
|
|
|
darwin: lib_bases *= $$MODULE_MODULE
|
2023-05-10 11:47:33 +00:00
|
|
|
add_lib_to_pretargetdeps = false
|
2018-12-19 11:46:52 +00:00
|
|
|
win32|contains(MODULE_CONFIG, staticlib) {
|
2021-06-24 12:27:37 +00:00
|
|
|
lib_prefix = $$MODULE_LIBS/$$QMAKE_PREFIX_STATICLIB
|
|
|
|
lib_suffixes = $$QMAKE_EXTENSION_STATICLIB
|
|
|
|
lib_suffixes *= $$QMAKE_LIB_EXTENSIONS
|
2023-05-10 11:47:33 +00:00
|
|
|
!xcodebuild: \
|
|
|
|
add_lib_to_pretargetdeps = true
|
2021-06-24 12:27:37 +00:00
|
|
|
} else {
|
|
|
|
lib_prefix = $$MODULE_LIBS/$$QMAKE_PREFIX_SHLIB
|
|
|
|
lib_suffixes = $$QMAKE_EXTENSION_SHLIB
|
|
|
|
}
|
|
|
|
candidates =
|
|
|
|
for(lib_base, lib_bases) {
|
|
|
|
for(lib_suffix, lib_suffixes) {
|
|
|
|
candidates += $${lib_prefix}$${lib_base}.$${lib_suffix}
|
2020-06-11 09:49:42 +00:00
|
|
|
}
|
2021-06-24 12:27:37 +00:00
|
|
|
}
|
|
|
|
lib =
|
|
|
|
for(candidate, candidates) {
|
|
|
|
exists("$$candidate") {
|
|
|
|
lib = "$$candidate"
|
|
|
|
break()
|
2020-06-11 09:49:42 +00:00
|
|
|
}
|
2015-11-19 16:11:05 +00:00
|
|
|
}
|
2021-06-24 12:27:37 +00:00
|
|
|
isEmpty(lib): \
|
|
|
|
lib = $$first(candidates)
|
|
|
|
$$add_lib_to_pretargetdeps: \
|
|
|
|
PRE_TARGETDEPS += $$lib
|
2018-12-19 11:46:52 +00:00
|
|
|
LIBS$$var_sfx += $$lib
|
2015-06-05 17:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
2016-10-12 09:30:58 +00:00
|
|
|
QMAKE_USE$$var_sfx += $$MODULE_USES
|
2015-06-05 17:01:50 +00:00
|
|
|
}
|
|
|
|
!isEmpty(BAD_QT):error("Unknown module(s) in QT$$var_sfx: $$replace(BAD_QT, _private$, -private)")
|
|
|
|
|
|
|
|
!isEmpty(var_sfx): break()
|
|
|
|
var_sfx = _PRIVATE
|
|
|
|
}
|
2020-10-23 09:38:30 +00:00
|
|
|
!isEmpty(using_private_headers):!no_private_qt_headers_warning:!build_pass {
|
2012-12-20 08:05:29 +00:00
|
|
|
message("This project is using private headers and will therefore be tied to this specific Qt module build version.")
|
|
|
|
message("Running this project against other versions of the Qt modules may crash at any arbitrary point.")
|
|
|
|
message("This is not a bug, but a result of using Qt internals. You have been warned!")
|
|
|
|
}
|
|
|
|
|
2016-08-05 11:35:39 +00:00
|
|
|
!no_qt_rpath:!static:qtConfig(rpath):!qtConfig(static):\
|
2016-12-20 17:43:00 +00:00
|
|
|
contains(all_qt_module_deps, core) {
|
2015-11-12 08:48:03 +00:00
|
|
|
relative_qt_rpath:!isEmpty(QMAKE_REL_RPATH_BASE):contains(INSTALLS, target):\
|
2015-09-23 16:36:08 +00:00
|
|
|
isEmpty(target.files):isEmpty(target.commands):isEmpty(target.extra) {
|
2015-09-23 16:29:02 +00:00
|
|
|
# NOT the /dev property, as INSTALLS use host paths
|
2016-03-09 16:42:29 +00:00
|
|
|
QMAKE_RPATHDIR += $$relative_path($$[QT_INSTALL_LIBS], $$qtRelativeRPathBase())
|
2015-06-05 15:45:47 +00:00
|
|
|
} else {
|
|
|
|
QMAKE_RPATHDIR += $$[QT_INSTALL_LIBS/dev]
|
|
|
|
}
|
2015-06-04 19:20:25 +00:00
|
|
|
}
|
|
|
|
|
2016-08-05 11:35:39 +00:00
|
|
|
!isEmpty(QMAKE_LFLAGS_RPATHLINK):!qtConfig(static) {
|
2015-06-04 19:04:49 +00:00
|
|
|
# -rpath-link is used by the linker to find dependencies of dynamic
|
|
|
|
# libraries which were NOT specified on the command line.
|
|
|
|
# This means that paths of direct dependencies (QT & QT_PRIVATE)
|
|
|
|
# don't need to be listed, unlike their private dependencies' paths.
|
2016-12-20 17:43:00 +00:00
|
|
|
privdep = $$all_qt_module_deps
|
|
|
|
privdep -= $$resolve_depends(qt_module_deps, "QT.")
|
2015-06-04 19:04:49 +00:00
|
|
|
rpaths =
|
|
|
|
for(dep, privdep): \
|
|
|
|
rpaths += $$eval(QT.$${dep}.libs)
|
|
|
|
QMAKE_RPATHLINKDIR *= $$unique(rpaths)
|
|
|
|
}
|
|
|
|
|
2016-12-06 16:27:50 +00:00
|
|
|
# static builds: link qml import plugins into the target.
|
2016-12-20 17:43:00 +00:00
|
|
|
contains(all_qt_module_deps, qml): \
|
2016-12-06 16:27:50 +00:00
|
|
|
qtConfig(static):import_plugins:!host_build:!no_import_scan {
|
2016-11-24 16:01:24 +00:00
|
|
|
exists($$[QT_INSTALL_QML/get]): \
|
|
|
|
QMLPATHS *= $$[QT_INSTALL_QML/get]
|
2014-06-02 09:40:36 +00:00
|
|
|
|
2013-09-10 14:25:32 +00:00
|
|
|
# run qmlimportscanner
|
2021-03-31 07:28:40 +00:00
|
|
|
qtPrepareLibExecTool(QMLIMPORTSCANNER, qmlimportscanner, , system)
|
2013-10-18 11:20:41 +00:00
|
|
|
for (QMLPATH, QMLPATHS): \
|
2016-08-24 15:35:59 +00:00
|
|
|
IMPORTPATHS += -importPath $$system_quote($$QMLPATH)
|
2013-10-18 11:20:41 +00:00
|
|
|
|
2020-04-24 11:52:32 +00:00
|
|
|
# add resources to qmlimportscanner
|
|
|
|
for (RESOURCE, RESOURCES) {
|
|
|
|
defined($${RESOURCE}.files, var) {
|
|
|
|
# in case of a "struct", add the struct's files
|
|
|
|
base = $$RESOURCE.base
|
|
|
|
for (f, $$RESOURCE.files): SCANNERRESOURCES += "$$base/$$f"
|
|
|
|
} else {
|
|
|
|
# if the resource is a file, just add it
|
|
|
|
SCANNERRESOURCES += $$RESOURCE
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
!isEmpty(SCANNERRESOURCES) {
|
|
|
|
IMPORTPATHS += -qrcFiles
|
2020-05-11 08:15:08 +00:00
|
|
|
for (RESOURCE, SCANNERRESOURCES): \
|
2020-04-24 11:52:32 +00:00
|
|
|
IMPORTPATHS += $$absolute_path($$system_quote($$RESOURCE), $$_PRO_FILE_PWD_)
|
2020-03-16 14:11:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# message(run $$QMLIMPORTSCANNER $$_PRO_FILE_PWD_ $$IMPORTPATHS)
|
2016-08-24 15:35:59 +00:00
|
|
|
JSON = $$system($$QMLIMPORTSCANNER $$system_quote($$_PRO_FILE_PWD_) $$IMPORTPATHS)
|
2013-09-10 14:25:32 +00:00
|
|
|
|
|
|
|
parseJson(JSON, IMPORTS)| error("Failed to parse qmlimportscanner output.")
|
|
|
|
|
|
|
|
!isEmpty(IMPORTS._KEYS_) {
|
|
|
|
# add import plugins to LIBS line
|
2016-01-06 12:01:22 +00:00
|
|
|
for (key, IMPORTS._KEYS_) {
|
2013-09-10 14:25:32 +00:00
|
|
|
PATH = $$eval(IMPORTS.$${key}.path)
|
|
|
|
PLUGIN = $$eval(IMPORTS.$${key}.plugin)
|
2018-12-19 11:46:52 +00:00
|
|
|
!isEmpty(PATH):!isEmpty(PLUGIN): \
|
|
|
|
LIBS += $$PATH/$$QMAKE_PREFIX_STATICLIB$${PLUGIN}$$qtPlatformTargetSuffix().$$QMAKE_EXTENSION_STATICLIB
|
2013-09-10 14:25:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# create qml_plugin_import.cpp
|
|
|
|
IMPORT_FILE_CONT = \
|
|
|
|
"// This file is autogenerated by qmake. It imports static plugin classes for" \
|
|
|
|
"// static plugins used by QML imports." \
|
|
|
|
"$${LITERAL_HASH}include <QtPlugin>"
|
|
|
|
for (key, IMPORTS._KEYS_) {
|
|
|
|
PLUGIN = $$eval(IMPORTS.$${key}.plugin)
|
|
|
|
CLASSNAME = $$eval(IMPORTS.$${key}.classname)
|
|
|
|
!isEmpty(PLUGIN) {
|
|
|
|
!isEmpty(CLASSNAME) {
|
|
|
|
!contains(ADDED_IMPORTS, $$PLUGIN) {
|
|
|
|
ADDED_IMPORTS += $$PLUGIN
|
|
|
|
IMPORT_FILE_CONT += "Q_IMPORT_PLUGIN($$CLASSNAME)"
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
error("Plugin $$PLUGIN is missing a classname entry, please add one to the qmldir file.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-28 15:49:27 +00:00
|
|
|
TARGET_BASENAME = $$lower($$basename(TARGET))
|
|
|
|
TARGET_BASENAME ~= s/\s/_/g
|
|
|
|
|
|
|
|
QML_IMPORT_CPP = $$OUT_PWD/$${TARGET_BASENAME}_qml_plugin_import.cpp
|
2016-07-14 14:50:02 +00:00
|
|
|
write_file($$QML_IMPORT_CPP, IMPORT_FILE_CONT)|error()
|
2015-11-04 13:41:05 +00:00
|
|
|
GENERATED_SOURCES += $$QML_IMPORT_CPP
|
2014-06-25 08:44:54 +00:00
|
|
|
QMAKE_DISTCLEAN += $$QML_IMPORT_CPP
|
2013-09-10 14:25:32 +00:00
|
|
|
}
|
|
|
|
}
|