From 3702b3f68b2dccbdb7203f8a4caeec8578556aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 30 May 2017 14:43:08 +0200 Subject: Pick up default library paths for clang We need to actually run the linker, otherwise clang will just run the preprocessing step as we asked for. We build as a shared library to not have to provide a main() function. Change-Id: Ied34757bb5c43a862bf2d9778340c497b93d572f Reviewed-by: Oswald Buddenhagen --- mkspecs/features/toolchain.prf | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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) -- cgit v1.2.3