diff --git a/src/libs/utils/environment.cpp b/src/libs/utils/environment.cpp index 12958108e41..0705c300818 100644 --- a/src/libs/utils/environment.cpp +++ b/src/libs/utils/environment.cpp @@ -332,6 +332,13 @@ void Environment::prependOrSetLibrarySearchPath(const QString &value) } } +void Environment::prependOrSetLibrarySearchPaths(const QStringList &values) +{ + Utils::reverseForeach(values, [this](const QString &value) { + prependOrSetLibrarySearchPath(value); + }); +} + Environment Environment::systemEnvironment() { return *staticSystemEnvironment(); diff --git a/src/libs/utils/environment.h b/src/libs/utils/environment.h index c9ebb99b8dc..e3a382daf04 100644 --- a/src/libs/utils/environment.h +++ b/src/libs/utils/environment.h @@ -101,6 +101,7 @@ public: void prependOrSetPath(const QString &value); void prependOrSetLibrarySearchPath(const QString &value); + void prependOrSetLibrarySearchPaths(const QStringList &values); void clear(); int size() const; diff --git a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp index 8facdac271d..b3918b6a206 100644 --- a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp +++ b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp @@ -314,6 +314,8 @@ void DesktopQmakeRunConfiguration::addToBaseEnvironment(Environment &env) const if (m_isUsingDyldImageSuffix) env.set(QLatin1String("DYLD_IMAGE_SUFFIX"), QLatin1String("_debug")); + QStringList libraryPaths; + // The user could be linking to a library found via a -L/some/dir switch // to find those libraries while actually running we explicitly prepend those // dirs to the library search path @@ -327,7 +329,7 @@ void DesktopQmakeRunConfiguration::addToBaseEnvironment(Environment &env) const const QFileInfo fi(dir); if (!fi.isAbsolute()) dir = QDir::cleanPath(proDirectory + QLatin1Char('/') + dir); - env.prependOrSetLibrarySearchPath(dir); + libraryPaths << dir; } // foreach } // libDirectories } // pro @@ -335,10 +337,11 @@ void DesktopQmakeRunConfiguration::addToBaseEnvironment(Environment &env) const QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(target()->kit()); if (qtVersion && m_isUsingLibrarySearchPath) { if (HostOsInfo::isWindowsHost()) - env.prependOrSetLibrarySearchPath(qtVersion->qmakeProperty("QT_INSTALL_BINS")); + libraryPaths << qtVersion->qmakeProperty("QT_INSTALL_BINS"); else - env.prependOrSetLibrarySearchPath(qtVersion->qmakeProperty("QT_INSTALL_LIBS")); + libraryPaths << qtVersion->qmakeProperty("QT_INSTALL_LIBS"); } + env.prependOrSetLibrarySearchPaths(libraryPaths); } QString DesktopQmakeRunConfiguration::buildSystemTarget() const