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>
This commit is contained in:
parent
65ae3de2e1
commit
efd2ea8ea7
9
configure
vendored
9
configure
vendored
@ -115,13 +115,6 @@ shellEscape()
|
||||
echo "$@" | sed 's/ /\ /g'
|
||||
}
|
||||
|
||||
shellQuoteLines()
|
||||
{
|
||||
# The call of the outer echo makes the shell word-split the output of
|
||||
# the nested pipe, thus effectively converting newlines to spaces.
|
||||
echo `echo "$1" | sed 's,^[^ ]* .*$,"&",'`
|
||||
}
|
||||
|
||||
makeabs()
|
||||
{
|
||||
local FILE="$1"
|
||||
@ -7163,8 +7156,6 @@ host_build {
|
||||
QT_TARGET_ARCH = $CFG_ARCH
|
||||
} else {
|
||||
QT_ARCH = $CFG_ARCH
|
||||
QMAKE_DEFAULT_LIBDIRS = `shellQuoteLines "$DEFAULT_LIBDIRS"`
|
||||
QMAKE_DEFAULT_INCDIRS = `shellQuoteLines "$DEFAULT_INCDIRS"`
|
||||
}
|
||||
QT_CONFIG += $QT_CONFIG
|
||||
|
||||
|
@ -24,3 +24,44 @@ contains(QT_CONFIG, c++11):lessThan(QT_COMPILER_STDCXX, 201103): CONFIG += c++11
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
@ -3496,11 +3496,6 @@ void Configure::generateQConfigPri()
|
||||
configStream << " QT_TARGET_ARCH = " << dictionary["QT_ARCH"] << endl;
|
||||
configStream << "} else {" << endl;
|
||||
configStream << " QT_ARCH = " << dictionary["QT_ARCH"] << endl;
|
||||
if (dictionary.contains("XQMAKESPEC")) {
|
||||
// FIXME: add detection
|
||||
configStream << " QMAKE_DEFAULT_LIBDIRS = /lib /usr/lib" << endl;
|
||||
configStream << " QMAKE_DEFAULT_INCDIRS = /usr/include /usr/local/include" << endl;
|
||||
}
|
||||
configStream << "}" << endl;
|
||||
configStream << "QT_CONFIG += " << qtConfig.join(' ') << endl;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user