diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index eb7b1385f2..b3726a1160 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -111,6 +111,26 @@ isEmpty($${target_prefix}.INCDIRS) { } } } + !darwin:clang { + # Clang on a non-Apple system (that is, a system without ld64 -- say, with GNU ld + # or gold under Linux) will not print any library search path. Need to use another + # invocation with different options (which in turn doesn't print include search + # paths, so it can't just be used in place of the above code). + # What's more, -print-search-dirs can't be used on clang on Apple because it + # won't print all the library paths (only the clang-internal ones). + output = $$system("$$cmd_prefix $$QMAKE_CXX -print-search-dirs", lines, ec) + !equals(ec, 0): \ + error("Cannot run compiler '$$QMAKE_CXX'. Maybe you forgot to setup the environment?") + + for (line, output) { + contains(line, "^libraries: .*") { + line ~= s,^libraries: ,, + paths = $$split(line, $$QMAKE_DIRLIST_SEP) + for (path, paths): \ + QMAKE_DEFAULT_LIBDIRS += $$clean_path($$replace(path, ^=, $$[SYSROOT])) + } + } + } isEmpty(QMAKE_DEFAULT_LIBDIRS)|isEmpty(QMAKE_DEFAULT_INCDIRS): \ !integrity: \ error("failed to parse default search paths from compiler output")