From efd2ea8ea720833f9602154221d9654aea1f2e6f Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 2 May 2016 17:09:11 +0200 Subject: 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 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/default_pre.prf | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'mkspecs/features') diff --git a/mkspecs/features/default_pre.prf b/mkspecs/features/default_pre.prf index a247b46a72..cffffdcf25 100644 --- a/mkspecs/features/default_pre.prf +++ b/mkspecs/features/default_pre.prf @@ -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" + } else { + cmd_prefix = "set LC_ALL=C&" + cmd_suffix = "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) +} -- cgit v1.2.3