From 4a2b9e086eb3d16403620b31a4d05bef529910d3 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 28 Oct 2015 13:19:59 +0100 Subject: [PATCH] Xcode generator: only replace the suffix in the library path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Xcode generator iterates trought all libraries and replaces their suffix (e.g "_debug") with a placeholder that lets Xcode switch between different library versions depending on the target. The current way we do this fails when the name of a library happens to contain the string "_debug" (e.g "qmldbg_debugger"). Since we replace every occurrence of suffix in the path, we end up replacing that part as well. The result will be linking errors. This patch ensures that we only replace the last occurrence of the suffix in the file path. Task-number: QTBUG-48961 Change-Id: I9fafbe0ea0ad8b9cfd13448d6b28801106e645ec Reviewed-by: Oswald Buddenhagen Reviewed-by: Ulf Hermann Reviewed-by: Tor Arne Vestbø --- qmake/generators/mac/pbuilder_pbx.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index ccb3cfe810..42dd6c8aeb 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -853,8 +853,15 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) QString librarySuffix = project->first("QMAKE_XCODE_LIBRARY_SUFFIX").toQString(); suffixSetting = "$(" + suffixSetting + ")"; if (!librarySuffix.isEmpty()) { - library.replace(librarySuffix, suffixSetting); - name.remove(librarySuffix); + int pos = library.lastIndexOf(librarySuffix + '.'); + if (pos == -1) { + warn_msg(WarnLogic, "Failed to find expected suffix '%s' for library '%s'.", + qPrintable(librarySuffix), qPrintable(library)); + } else { + library.replace(pos, librarySuffix.length(), suffixSetting); + if (name.endsWith(librarySuffix)) + name.chop(librarySuffix.length()); + } } else { library.replace(name, name + suffixSetting); }