qt5base-lts/mkspecs/features/qt_module_headers.prf
Oswald Buddenhagen 133fb029a6 make it possible to override the basename of module config files
using qt$$MODULE isn't enough if the module is composed of submodules
which need the final module's headers, because that would require two
modules having the same module .pri file.

the first thought to fix this was to just use $$lower($$TARGET), but
that breaks for testlib (QtTest). while the config file name isn't
public api, it's included by a public header, so changing it is risky.

so instead stay with the original pattern, but make it explicitly
overrideable.

the cherry-pick is needed to support QtWebEngine 5.12 with Qt 5.11,
a requirement that was raised too late.

Change-Id: I758c46ed403620620d577ae16866ce751271b63e
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 95b0e4c956)
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2018-08-03 14:15:41 +00:00

306 lines
13 KiB
Plaintext

#
# W A R N I N G
# -------------
#
# This file is not part of the Qt API. It exists purely as an
# implementation detail. It may change from version to version
# without notice, or even be removed.
#
# We mean it.
#
load(qt_build_paths)
!build_pass:git_build {
qtPrepareTool(QMAKE_SYNCQT, syncqt, , system)
minimal_syncqt {
QMAKE_SYNCQT += -minimal $$QMAKE_SYNCQT_OPTIONS
} else {
qtConfig(private_tests): \ # -developer-build
QMAKE_SYNCQT += -check-includes
}
for(mod, MODULE_INCNAME): \
QMAKE_SYNCQT += -module $$mod
QMAKE_SYNCQT += \
-version $$VERSION -outdir $$system_quote($$MODULE_BASE_OUTDIR) \
-builddir $$system_quote($$shadowed($$MODULE_BASE_INDIR)) $$MODULE_SYNCQT_DIR
!silent: message($$QMAKE_SYNCQT)
system($$QMAKE_SYNCQT)|error("Failed to run: $$QMAKE_SYNCQT")
!minimal_syncqt {
include-distclean.commands = \
$$QMAKE_DEL_TREE $$shell_quote($$shell_path($$MODULE_BASE_OUTDIR/include/$$MODULE_INCNAME))
QMAKE_EXTRA_TARGETS += include-distclean
DISTCLEAN_DEPS += include-distclean
}
}
# Pre-generated headers in the source tree (tar-ball) and
# - shadow build or
# - non-shadow non-prefix build of a module which is not qtbase
# (because the build-time generated headers all end up in qtbase).
!git_build: \
if(!equals(_PRO_FILE_PWD_, $$OUT_PWD) \
|if(!prefix_build:!equals(MODULE_BASE_INDIR, $$[QT_HOST_PREFIX]))): \
CONFIG += split_incpath
# To avoid stuffing the code with repetetive conditionals,
# we parametrize the names of the variables we assign to.
# Internal modules have no private part - they *are* private.
!internal_module: \
prv = _PRIVATE
# When doing a framework build with a prefix, the module needs to point
# into the frameworks' Headers dirs directly, as no shared include/ dir
# is installed.
# However, during the build, it needs to point into the shared include/
# dir, as the framework doesn't even exist yet. For bootstrapped modules
# which borrow headers from "proper" modules, this situation persists
# even beyond the module's own build. The implication of this is that
# qmake might never use a framework's headers in a non-prefix build,
# as there is no separate set of .pri files for users outside Qt.
# Borrowing is assumed to happen from modules which, in a framework build,
# actually are frameworks.
prefix_build:module_frameworks: \
fwd = _FWD
# When using a split include path during the build, the installed module's
# include path is also structurally different from that in the build dir.
prefix_build:split_incpath: \
sfwd = _FWD
ibase = \$\$QT_MODULE_INCLUDE_BASE
MODULE$${fwd}_INCLUDES = $$ibase
split_incpath {
bibase = $$val_escape(MODULE_BASE_OUTDIR)/include
MODULE$${sfwd}_INCLUDES += $$bibase
}
for(mod, MODULE_INCNAME) {
mibase = $$ibase/$$mod
MODULE$${fwd}_INCLUDES += $$mibase
MODULE$${fwd}$${prv}_INCLUDES += $$mibase/$$VERSION $$mibase/$$VERSION/$$mod
split_incpath {
mbibase = $$bibase/$$mod
MODULE$${sfwd}_INCLUDES += $$mbibase
generated_privates: \
MODULE$${sfwd}$${prv}_INCLUDES += $$mbibase/$$VERSION $$mbibase/$$VERSION/$$mod
}
prefix_build:module_frameworks {
mfbase = \$\$QT_MODULE_LIB_BASE/$${mod}.framework/Headers
MODULE_INCLUDES += $$mfbase
MODULE$${prv}_INCLUDES += $$mfbase/$$VERSION $$mfbase/$$VERSION/$$mod
}
}
MODULE_INCLUDES += $$MODULE_AUX_INCLUDES
MODULE_PRIVATE_INCLUDES += $$MODULE_PRIVATE_AUX_INCLUDES
minimal_syncqt: return()
defineTest(syncQtResolve) {
out =
for (f, SYNCQT.$$1): \
out += $$absolute_path($$f, $$2)
SYNCQT.$$1 = $$out
export(SYNCQT.$$1)
}
#load up the headers info
git_build: \
INC_PATH = $$MODULE_BASE_OUTDIR
else: \
INC_PATH = $$MODULE_BASE_INDIR
include($$INC_PATH/include/$$MODULE_INCNAME/headers.pri, "", true)
syncQtResolve(HEADER_FILES, $$_PRO_FILE_PWD_)
syncQtResolve(PRIVATE_HEADER_FILES, $$_PRO_FILE_PWD_)
syncQtResolve(QPA_HEADER_FILES, $$_PRO_FILE_PWD_)
syncQtResolve(GENERATED_HEADER_FILES, $$INC_PATH/include/$$MODULE_INCNAME)
!lib_bundle: \ # Headers are embedded into the bundle, so don't install them separately.
CONFIG += qt_install_headers
alien_syncqt: return()
MODULE_INC_OUTDIR = $$MODULE_BASE_OUTDIR/include/$$MODULE_INCNAME
isEmpty(MODULE_CFG_FILE): MODULE_CFG_FILE = qt$${MODULE}-config
exists($$OUT_PWD/$${MODULE_CFG_FILE}.h) {
fwd_rel = $$relative_path($$OUT_PWD, $$MODULE_INC_OUTDIR)
SYNCQT.INJECTIONS += \
$$fwd_rel/$${MODULE_CFG_FILE}.h:$${MODULE_CFG_FILE}.h \
$$fwd_rel/$${MODULE_CFG_FILE}_p.h:$$MODULE_VERSION/$$MODULE_INCNAME/private/$${MODULE_CFG_FILE}_p.h
}
for (injection, SYNCQT.INJECTIONS) {
injects = $$split(injection, :)
dst_hdr = $$absolute_path($$member(injects, 0), $$MODULE_INC_OUTDIR)
ofwd_hdr = $$member(injects, 1)
fwd_hdr = $$replace(ofwd_hdr, ^\\^, )
MAIN_FWD = $$MODULE_INC_OUTDIR/$$fwd_hdr
MAIN_FWD_CONT = '$${LITERAL_HASH}include "$$relative_path($$dst_hdr, $$dirname(MAIN_FWD))"'
write_file($$MAIN_FWD, MAIN_FWD_CONT)|error()
equals(fwd_hdr, ofwd_hdr): touch($$MAIN_FWD, $$dst_hdr)
!git_build: QMAKE_DISTCLEAN += $$MAIN_FWD
!contains(ofwd_hdr, .*/private/.*): \
SYNCQT.INJECTED_HEADER_FILES += $$dst_hdr
else: \
SYNCQT.INJECTED_PRIVATE_HEADER_FILES += $$dst_hdr
injects = $$member(injects, 2, -1)
for (inject, injects) {
CLASS_FWD = $$MODULE_INC_OUTDIR/$$inject
CLASS_FWD_CONT = '$${LITERAL_HASH}include "$$fwd_hdr"'
write_file($$CLASS_FWD, CLASS_FWD_CONT)|error()
touch($$CLASS_FWD, $$MAIN_FWD)
!git_build: QMAKE_DISTCLEAN += $$CLASS_FWD
SYNCQT.INJECTED_HEADER_FILES += $$CLASS_FWD
}
}
autogen_warning = \
"/* This file was generated by qmake with the info from <root>/$$relative_path($$_PRO_FILE_, $$MODULE_BASE_INDIR). */"
# Create a module master depends header
MODULE_MASTER_DEPS_HEADER = $$MODULE_BASE_OUTDIR/include/$$MODULE_INCNAME/$${MODULE_INCNAME}Depends
!build_pass {
MODULE_MASTER_DEPS_HEADER_CONT = $$autogen_warning
MODULE_MASTER_DEPS_HEADER_CONT += "$${LITERAL_HASH}ifdef __cplusplus /* create empty PCH in C mode */"
for(dep, MODULE_DEPENDS) {
depname = $$eval(QT.$${dep}.master_header)
isEmpty(depname): \
depname = $$eval(QT.$${dep}.name)
MODULE_MASTER_DEPS_HEADER_CONT += "$${LITERAL_HASH}include <$$depname/$$depname>"
}
MODULE_MASTER_DEPS_HEADER_CONT += "$${LITERAL_HASH}endif"
write_file($$MODULE_MASTER_DEPS_HEADER, MODULE_MASTER_DEPS_HEADER_CONT)|error()
!git_build: QMAKE_DISTCLEAN += $$MODULE_MASTER_DEPS_HEADER
}
SYNCQT.HEADER_FILES += $$MODULE_MASTER_DEPS_HEADER
# Automatically enable precompiled headers for Qt modules with more than 2 sources
combined_SOURCES = $$SOURCES $$OBJECTIVE_SOURCES
count(combined_SOURCES, 2, >) {
# except for Gcc/Windows: Larger precompiled headers crash cc1plus.exe
# (e.g. with i686-4.8.2-release-posix-dwarf-rt_v3-rev3)
!if(gcc:equals(QMAKE_HOST.os, Windows)):!equals(TEMPLATE, aux) {
!defined(PRECOMPILED_HEADER, "var"): PRECOMPILED_HEADER = $$MODULE_MASTER_DEPS_HEADER
}
} else {
CONFIG -= precompile_header
}
unset(combined_SOURCES)
headersclean:!internal_module {
# Make sure that the header compiles with our strict options
hcleanDEFS = -DQT_NO_CAST_TO_ASCII=1 \
-DQT_NO_CAST_FROM_ASCII=1 \
-UQT_RESTRICTED_CAST_FROM_ASCII \
-DQT_STRICT_ITERATORS \
-DQT_NO_URL_CAST_FROM_STRING=1 \
-DQT_NO_CAST_FROM_BYTEARRAY=1 \
-DQT_NO_KEYWORDS=1 \
-DQT_USE_QSTRINGBUILDER \
-DQT_USE_FAST_OPERATOR_PLUS \
-Dsignals=int \
-Dslots=int \
-Demit=public: \
-Dforeach=public: \
-Dforever=public:
gcc:!rim_qcc {
# Turn on some extra warnings not found in -Wall -Wextra.
# Common to GCC, Clang and ICC (and other compilers that masquerade as GCC):
hcleanFLAGS = -Wall -Wextra -Werror \
-Woverloaded-virtual -Wshadow -Wundef -Wfloat-equal \
-Wnon-virtual-dtor -Wpointer-arith -Wformat-security \
-Wno-long-long -Wno-variadic-macros -pedantic-errors
intel_icc {
# these warnings are disabled because explicit constructors with zero or
# multiple arguments are permitted in C++11:
# 2304: non-explicit constructor with single argument may cause implicit type conversion
# 2305: declaration of 'explicit' constructor without a single argument is redundant
hcleanFLAGS += -wd2304,2305
greaterThan(QT_ICC_MAJOR_VERSION, 13) {
# ICC 14+ has a bug with -Wshadow, emitting it for cases where there's no shadowing
# (issue ID 0000698329, task DPD200245740)
hcleanFLAGS -= -Wshadow
}
} else {
# options accepted by GCC and Clang
hcleanFLAGS += -Wchar-subscripts -Wold-style-cast
!contains(QT_ARCH, arm):!contains(QT_ARCH, mips): \
hcleanFLAGS += -Wcast-align
clang_ver = $${QT_CLANG_MAJOR_VERSION}.$${QT_CLANG_MINOR_VERSION}
versionAtLeast(clang_ver, 3.8): hcleanFLAGS += -Wdouble-promotion
!clang {
# options accepted only by GCC
gcc_ver = $${QT_GCC_MAJOR_VERSION}.$${QT_GCC_MINOR_VERSION}
versionAtLeast(gcc_ver, 4.5): hcleanFLAGS += -Wdouble-promotion
versionAtLeast(gcc_ver, 4.9): hcleanFLAGS += -Wfloat-conversion
c++11 {
# only enabled for actual c++11 builds due to
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52806
hcleanFLAGS += -Wzero-as-null-pointer-constant
}
}
}
# Use strict mode C++11 or C++98, with no GNU extensions (see -pedantic-errors above).
# The module might set CONFIG += c++11, but it might also change QMAKE_CXXFLAGS_CXX11
# or the module (or the mkspec) can set the C++11 flag on QMAKE_CXXFLAGS
# (or QMAKE_CXXFLAGS_{RELEASE,DEBUG} but that's unlikely).
c++11:contains(QMAKE_CXXFLAGS_CXX11, -std=gnu++11) {
hcleanFLAGS += -std=c++11
} else: contains(QMAKE_CXXFLAGS, -std=gnu++11) {
hcleanFLAGS += -std=c++11
} else: c++11:contains(QMAKE_CXXFLAGS_CXX11, -std=gnu++0x) {
hcleanFLAGS += -std=c++0x
} else: contains(QMAKE_CXXFLAGS, -std=gnu++0x) {
hcleanFLAGS += -std=c++0x
} else: !c++11:!contains(QMAKE_CXXFLAGS, -std=c++0x):!contains(QMAKE_CXXFLAGS, -std=c++11) {
hcleanFLAGS += -std=c++98
}
hcleanCOMMAND = $$QMAKE_CXX -c $(CXXFLAGS) $$hcleanFLAGS $(INCPATH) $$hcleanDEFS -xc++ ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
} else: msvc:!intel_icl {
# 4180: qualifier applied to function type has no meaning; ignored
# 4458: declaration of 'identifier' hides class member
# -Za enables strict standards behavior, but we can't add it because
# <windows.h> and <GL.h> violate the standards.
hcleanFLAGS = -WX -W3 -wd4180 -wd4458
# MSVC 2015 (compiler version 19.0):
# 4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc
greaterThan(QMAKE_MSC_VER, 18): hcleanFLAGS += -wd4577
hcleanCOMMAND = $$QMAKE_CXX -c $(CXXFLAGS) $$hcleanFLAGS $(INCPATH) $$hcleanDEFS -FI${QMAKE_FILE_IN} -Fo${QMAKE_FILE_OUT} \
$$[QT_INSTALL_DATA/src]/mkspecs/features/data/dummy.cpp
}
!isEmpty(hcleanCOMMAND):if(!qtConfig(debug_and_release)|CONFIG(release, debug|release)) {
CLEAN_HEADERS =
for (h, SYNCQT.CLEAN_HEADER_FILES) {
hh = $$split(h, :)
hr = $$member(hh, 1)
isEmpty(hr)|qtConfig($$hr): \
CLEAN_HEADERS += $$member(hh, 0)
}
CLEAN_HEADERS -= $$HEADERSCLEAN_EXCLUDE
header_check.dependency_type = TYPE_C
header_check.CONFIG += no_link
header_check.output = ${QMAKE_VAR_OBJECTS_DIR}header_${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
header_check.input = CLEAN_HEADERS
header_check.variable_out = PRE_TARGETDEPS
header_check.name = headercheck ${QMAKE_FILE_IN}
header_check.commands = $$hcleanCOMMAND
silent:header_check.commands = @echo compiling[header] ${QMAKE_FILE_IN} && $$hcleanCOMMAND
QMAKE_EXTRA_COMPILERS += header_check
}
unset(hcleanCOMMAND)
unset(hcleanFLAGS)
unset(hcleanDEFS)
}