diff options
Diffstat (limited to 'mkspecs/features/qt.prf')
-rw-r--r-- | mkspecs/features/qt.prf | 165 |
1 files changed, 110 insertions, 55 deletions
diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 9d852cf23d..3b71eea6bc 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -2,6 +2,9 @@ # due to required Qt modules being missing. !isEmpty(QMAKE_FAILED_REQUIREMENTS): return() +# hardcoded defaults +QT_CONFIG *= c99 c11 c++11 c++14 c++1z c++17 + qtConfig(thread): CONFIG *= thread #handle defines @@ -13,7 +16,6 @@ win32 { } } CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG -qtConfig(force_asserts): DEFINES += QT_FORCE_ASSERTS no_keywords:DEFINES += QT_NO_KEYWORDS plugin { #Qt plugins static:DEFINES += QT_STATICPLUGIN @@ -59,6 +61,28 @@ qaxserver { !force_import_plugins:!contains(TEMPLATE, ".*app"):!if(contains(TEMPLATE, ".*lib"):dll): \ CONFIG -= import_plugins +unix { + contains(QT_CONFIG, no_direct_extern_access): CONFIG += no_direct_extern_access + else:contains(QT_CONFIG, reduce_relocations):!contains(TEMPLATE, .*lib): { + QMAKE_CFLAGS += $$QMAKE_CFLAGS_PIC + QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_PIC + } +} + +# Load the entrypoint module if requested +entrypoint { + win32 { + !console:contains(TEMPLATE, ".*app"): \ + QT_PRIVATE += entrypoint_private + } else:uikit { + qt_depends = $$resolve_depends(QT, "QT.") + !watchos:equals(TEMPLATE, app):contains(qt_depends, gui(-private)?): \ + QT_PRIVATE += entrypoint_private + } +} + +# Will automatically add plugins, so run first +contains(QT_CONFIG, permissions): load(permissions) # qmake variables cannot contain dashes, so normalize the names first CLEAN_QT = $$replace(QT, -private$, _private) @@ -69,13 +93,15 @@ all_qt_module_deps = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_d QTPLUGIN = $$unique($$list($$lower($$QTPLUGIN))) -import_plugins:qtConfig(static) { +# Sanitize requested plugins, and add any default plugins +import_plugins { manualplugs = $$QTPLUGIN # User may specify plugins. Mostly legacy. autoplugs = # Auto-added plugins. # First round: explicitly specified modules. - plugin_deps = $$all_qt_module_deps + all_plugin_deps = $$all_qt_module_deps + plugin_deps = $$all_plugin_deps for(ever) { - # Automatically link the default plugins for the linked Qt modules. + # Automatically add the default plugins for the linked Qt modules. for (qtmod, plugin_deps) { for (ptype, QT.$${qtmod}.plugin_types) { nptype = $$replace(ptype, [-/], _) @@ -83,7 +109,7 @@ import_plugins:qtConfig(static) { for (plug, QT_PLUGINS) { equals(QT_PLUGIN.$${plug}.TYPE, $$ptype) { for (dep, QT_PLUGIN.$${plug}.EXTENDS) { - !contains(all_qt_module_deps, $$dep) { + !contains(all_plugin_deps, $$dep) { plug = break() } @@ -106,57 +132,74 @@ import_plugins:qtConfig(static) { for (plug, QTPLUGIN): \ plugin_deps += $$eval(QT_PLUGIN.$${plug}.DEPENDS) plugin_deps = $$resolve_depends(plugin_deps, "QT.", ".depends" ".run_depends") - plugin_deps -= $$all_qt_module_deps + plugin_deps -= $$all_plugin_deps + isEmpty(plugin_deps): \ break() # ... and start over if any new Qt modules appeared, # as these may want to load plugins in turn. - all_qt_module_deps += $$plugin_deps + all_plugin_deps += $$plugin_deps } extraplugs = $$manualplugs manualplugs -= $$autoplugs extraplugs -= $$manualplugs !isEmpty(extraplugs): \ warning("Redundant entries in QTPLUGIN: $$extraplugs") - - !isEmpty(QTPLUGIN) { - 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>" - for (plug, QTPLUGIN) { - 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'.") - } - 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 - } } -# Only link against plugins in static builds -!isEmpty(QTPLUGIN):qtConfig(static) { +# Link static plugins +!isEmpty(QTPLUGIN) { for (plug, QTPLUGIN) { + module_config = $$eval(QT_PLUGIN.$${plug}.module_config) + isEmpty(module_config):!qtConfig(static): \ + next() # Compatibility with older modules + + !contains(module_config, staticlib): \ + next() + + 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 + # 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) { - plug_name = $$QMAKE_PREFIX_STATICLIB$${plug}$$qtPlatformTargetSuffix().$$QMAKE_EXTENSION_STATICLIB + # 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 plug_path = $$eval(QT_PLUGIN.$${plug}.PATH) isEmpty(plug_path): \ plug_path = $$[QT_INSTALL_PLUGINS/get] LIBS += $$plug_path/$$plug_type/$$plug_name } else { - LIBS += -l$${plug}$$qtPlatformTargetSuffix() + LIBS += -l$${plug}$$qtPlatformTargetSuffix(CONFIG) } } + + !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 + } } # target variable, flag source variable @@ -170,7 +213,7 @@ defineTest(qtProcessModuleFlags) { export($$1) } -unset(using_privates) +unset(using_private_headers) var_sfx = for(ever) { # Topological resolution of modules based on their QT.<module>.depends variable @@ -181,6 +224,7 @@ for(ever) { MODULE_NAME = $$eval(QT.$${QTLIB}.name) MODULE_MODULE = $$eval(QT.$${QTLIB}.module) MODULE_INCLUDES = $$eval(QT.$${QTLIB}.includes) + MODULE_LDFLAGS = $$eval(QT.$${QTLIB}.ldflags) MODULE_LIBS = $$eval(QT.$${QTLIB}.libs) MODULE_FRAMEWORKS = $$eval(QT.$${QTLIB}.frameworks) MODULE_USES = $$eval(QT.$${QTLIB}.uses) @@ -191,8 +235,8 @@ for(ever) { next() } - contains(MODULE_CONFIG, internal_module): \ - using_privates = true + contains(MODULE_CONFIG, internal_module):!isEmpty(MODULE_INCLUDES): \ + using_private_headers = true contains(MODULE_CONFIG, ltcg): \ CONFIG += link_ltcg @@ -201,6 +245,9 @@ for(ever) { MODULE_INCLUDES -= $$QMAKE_DEFAULT_INCDIRS + # Add linker flags before lib + LIBS$$var_sfx += $$MODULE_LDFLAGS + # 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 @@ -215,28 +262,36 @@ for(ever) { # Linking frameworks by absolute path does not work. LIBS$$var_sfx += -framework $$framework } else { - lib = $$MODULE_MODULE$$qtPlatformTargetSuffix() + lib_bases = $$MODULE_MODULE$$qtPlatformTargetSuffix() + darwin: lib_bases *= $$MODULE_MODULE + add_lib_to_pretargetdeps = false win32|contains(MODULE_CONFIG, staticlib) { - lib_missing = true - lib_extensions = $$QMAKE_EXTENSION_STATICLIB - lib_extensions *= $$QMAKE_LIB_EXTENSIONS - candidates = - for(ext, lib_extensions) { - candidate = $$MODULE_LIBS/$$QMAKE_PREFIX_STATICLIB$${lib}.$$ext - candidates += $$candidate - exists($$candidate) { - lib = $$candidate - lib_missing = false - break() - } + lib_prefix = $$MODULE_LIBS/$$QMAKE_PREFIX_STATICLIB + lib_suffixes = $$QMAKE_EXTENSION_STATICLIB + lib_suffixes *= $$QMAKE_LIB_EXTENSIONS + !xcodebuild: \ + add_lib_to_pretargetdeps = true + } 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} } - $$lib_missing { - lib = $$first(candidates) + } + lib = + for(candidate, candidates) { + exists("$$candidate") { + lib = "$$candidate" + break() } - PRE_TARGETDEPS += $$lib - } else { - lib = $$MODULE_LIBS/$$QMAKE_PREFIX_SHLIB$${lib}.$$QMAKE_EXTENSION_SHLIB } + isEmpty(lib): \ + lib = $$first(candidates) + $$add_lib_to_pretargetdeps: \ + PRE_TARGETDEPS += $$lib LIBS$$var_sfx += $$lib } } @@ -247,7 +302,7 @@ for(ever) { !isEmpty(var_sfx): break() var_sfx = _PRIVATE } -!isEmpty(using_privates):!no_private_qt_headers_warning:!build_pass { +!isEmpty(using_private_headers):!no_private_qt_headers_warning:!build_pass { 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!") @@ -284,7 +339,7 @@ contains(all_qt_module_deps, qml): \ QMLPATHS *= $$[QT_INSTALL_QML/get] # run qmlimportscanner - qtPrepareTool(QMLIMPORTSCANNER, qmlimportscanner, , system) + qtPrepareLibExecTool(QMLIMPORTSCANNER, qmlimportscanner, , system) for (QMLPATH, QMLPATHS): \ IMPORTPATHS += -importPath $$system_quote($$QMLPATH) |