diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index 46a9c5707a..d3487ef1ab 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -40,19 +40,36 @@ isEmpty($${target_prefix}.INCDIRS) { # QMAKE_DEFAULT_*DIRS, because they're handled in a single build pass. darwin: cxx_flags += -isysroot $$QMAKE_MAC_SDK_PATH - output = $$system("$$cmd_prefix $$QMAKE_CXX $$qtMakeExpand($$cxx_flags) -xc++ -E -v - 2>&1 $$cmd_suffix", lines) + clang: \ + # Need to link to pick up library paths + cxx_flags += $$QMAKE_LFLAGS_SHLIB -o /dev/null -v -Wl,-v + else: \ + # gcc is fine with just preprocessing + cxx_flags += -E -v + + output = $$system("$$cmd_prefix $$QMAKE_CXX $$qtMakeExpand($$cxx_flags) -xc++ - 2>&1 $$cmd_suffix", lines) add_includes = false + add_libraries = false for (line, output) { - line ~= s/^ *// # remove leading spaces + line ~= s/^[ \\t]*// # 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, "Library search paths:") { + add_libraries = true } else: contains(line, "$${LITERAL_HASH}include <.*") { # #include <...> search starts here: add_includes = true } else: contains(line, "End of search.*") { add_includes = false + } else: $$add_libraries { + # We assume all library search paths are absolute + !contains(line, "^/.*") { + add_libraries = false + next() + } + QMAKE_DEFAULT_LIBDIRS += $$clean_path($$line) } else: $$add_includes { !contains(line, ".* \\(framework directory\\)"): \ QMAKE_DEFAULT_INCDIRS += $$clean_path($$line)