From 0b58d7435e6bfb07cb30fd240eaefe2a1121878e Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 8 Aug 2016 17:42:32 +0200 Subject: [PATCH] Fix AddLibraryDialog when selecting the lib from different drive Omit PWD when trying to generate it for absolute path. Task-number: QTCREATORBUG-16688 Task-number: QTCREATORBUG-8413 Task-number: QTCREATORBUG-15732 Change-Id: Ief318db1249662f4c9e69a8f8c401543a8f3120a Reviewed-by: Tobias Hunger Reviewed-by: Robert Loehning --- .../librarydetailscontroller.cpp | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp b/src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp index 3fe5583f8b6..2860a6496a1 100644 --- a/src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp +++ b/src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp @@ -428,8 +428,12 @@ static QString generateLibsSnippet(AddLibraryWizard::Platforms platforms, const QString &targetRelativePath, const QString &pwd, bool useSubfolders, bool addSuffix, bool generateLibPath) { - // it contains: $$[pwd]/ - const QString libraryPathSnippet = QLatin1String("$$") + pwd + QLatin1Char('/'); + const QDir targetRelativeDir(targetRelativePath); + QString libraryPathSnippet; + if (targetRelativeDir.isRelative()) { + // it contains: $$[pwd]/ + libraryPathSnippet = QLatin1String("$$") + pwd + QLatin1Char('/'); + } AddLibraryWizard::Platforms commonPlatforms = platforms; if (macLibraryType == AddLibraryWizard::FrameworkType) // we will generate a separate -F -framework line @@ -494,10 +498,15 @@ static QString generateLibsSnippet(AddLibraryWizard::Platforms platforms, static QString generateIncludePathSnippet(const QString &includeRelativePath) { - return QLatin1String("\nINCLUDEPATH += $$PWD/") - + smartQuote(includeRelativePath) + QLatin1Char('\n') - + QLatin1String("DEPENDPATH += $$PWD/") - + smartQuote(includeRelativePath) + QLatin1Char('\n'); + const QDir includeRelativeDir(includeRelativePath); + QString includePathSnippet; + if (includeRelativeDir.isRelative()) { + includePathSnippet = QLatin1String("$$PWD/"); + } + includePathSnippet += smartQuote(includeRelativePath) + QLatin1Char('\n'); + + return QLatin1String("\nINCLUDEPATH += ") + includePathSnippet + + QLatin1String("DEPENDPATH += ") + includePathSnippet; } static QString generatePreTargetDepsSnippet(AddLibraryWizard::Platforms platforms, @@ -509,9 +518,13 @@ static QString generatePreTargetDepsSnippet(AddLibraryWizard::Platforms platform if (linkageType != AddLibraryWizard::StaticLinkage) return QString(); - // it contains: PRE_TARGETDEPS += $$[pwd]/ - const QString preTargetDepsSnippet = QLatin1String("PRE_TARGETDEPS += $$") + - pwd + QLatin1Char('/'); + const QDir targetRelativeDir(targetRelativePath); + + QString preTargetDepsSnippet = QLatin1String("PRE_TARGETDEPS += "); + if (targetRelativeDir.isRelative()) { + // it contains: PRE_TARGETDEPS += $$[pwd]/ + preTargetDepsSnippet += QLatin1String("$$") + pwd + QLatin1Char('/'); + } QString snippetMessage; QTextStream str(&snippetMessage);