qt5base-lts/mkspecs/features/default_pre.prf
Kai Koehne efd2ea8ea7 Determine the compiler's default include and lib directories at qmake time
This fixes a long-standing issue for Qt packages, where the
paths detected at configure time do not necessarily match the
paths on the user's machine. Hence they have been stripped
manually from qconfig.pri so far, preventing moc from resolving
some includes.

The same logic in configure is left alone for the time being,
since the paths there are also used to filter paths returned
by pg_config and mysql_config. I expect that this will
eventually be removed too in a bigger refactoring going on
right now in dev.

Asking the compiler for implicit paths only works for non-msvc
builds - that is, gcc, clang and icc fortunately have a
compatible way to retrieve the paths. MSVC works
solely on environment variables, which will be taken into
account by a separate patch.

[ChangeLog][qmake] The implicit compiler directories that
moc needs for resolving include files are now determined
when qmake runs. So far QMAKE_DEFAULT_INCDIR was determined
at configure time, which might be wrong for relocated
installations.

Task-number: QTBUG-52687
Change-Id: If0706e8c56a5aca2b6e777e79e90342c498726f3
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-05-24 17:54:24 +00:00

68 lines
2.6 KiB
Plaintext

# This file is loaded by qmake right before each actual project file.
# Note that evaluating variable assignments from the command line
# still happens in between these two steps.
load(exclusive_builds)
CONFIG = \
lex yacc debug exceptions depend_includepath \
testcase_targets import_plugins import_qpa_plugin \
$$CONFIG
contains(QT_CONFIG, c++11):lessThan(QT_COMPILER_STDCXX, 201103): CONFIG += c++11
!build_pass:defined(QT_EDITION, var):!equals(QT_EDITION, "OpenSource"):!equals(QT_EDITION, "Preview") {
#
# call license checker (but cache result for one day)
#
today = $$section(_DATE_, " ", 0, 2)
!isEqual(QMAKE_LICHECK_TIMESTAMP, $$today) {
!system("$$system_quote($$system_path($$[QT_HOST_BINS/src]/$$QT_LICHECK)) check" \
"$$QT_RELEASE_DATE $$[QMAKE_SPEC] $$[QMAKE_XSPEC]"): \
error("License check failed! Giving up ...")
cache(QMAKE_LICHECK_TIMESTAMP, set stash, today)
}
unset(today)
}
isEmpty(QMAKE_DEFAULT_INCDIRS):!host_build {
#
# Get default include and library paths from compiler
#
gcc {
equals(QMAKE_DIR_SEP, /) {
cmd_prefix = "LC_ALL=C"
cmd_suffix = "</dev/null >/dev/null"
} else {
cmd_prefix = "set LC_ALL=C&"
cmd_suffix = "<NUL >NUL"
}
output = $$system("$$cmd_prefix $$QMAKE_CXX $$QMAKE_CXXFLAGS -xc++ -E -v - 2>&1 $$cmd_suffix", lines)
add_includes = false
for (line, output) {
line ~= s/^ *// # remove leading spaces
contains(line, "LIBRARY_PATH=.*") {
line ~= s/^LIBRARY_PATH=// # remove leading LIBRARY_PATH=
paths = $$split(line, $$QMAKE_DIRLIST_SEP)
for (path, paths): \
QMAKE_DEFAULT_LIBDIRS += $$clean_path($$path)
} else: contains(line, "$${LITERAL_HASH}include <.*") { # #include <...> search starts here:
add_includes = true
} else: contains(line, "End of search list.*") {
add_includes = false
} else {
$$add_includes: QMAKE_DEFAULT_INCDIRS += $$clean_path($$line)
}
}
QMAKE_DEFAULT_LIBDIRS = $$unique(QMAKE_DEFAULT_LIBDIRS)
}
unix {
isEmpty(QMAKE_DEFAULT_INCDIRS): QMAKE_DEFAULT_INCDIRS = /usr/include /usr/local/include
isEmpty(QMAKE_DEFAULT_LIBDIRS): QMAKE_DEFAULT_LIBDIRS = /lib /usr/lib
}
!isEmpty(QMAKE_DEFAULT_INCDIRS): cache(QMAKE_DEFAULT_INCDIRS, set stash)
!isEmpty(QMAKE_DEFAULT_LIBDIRS): cache(QMAKE_DEFAULT_LIBDIRS, set stash)
}