From be11a85286ad538654dacce63a6be0af0c3c5bec Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sun, 19 Nov 2017 13:34:43 +0100 Subject: Autogen: Use project relative paths in rcc custom command comment --- Source/cmQtAutoGeneratorInitializer.cxx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index b265f28..a2c9b42 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -147,6 +147,26 @@ static void AddCleanFile(cmMakefile* makefile, std::string const& fileName) false); } +static std::string FileProjectRelativePath(cmMakefile* makefile, + std::string const& fileName) +{ + std::string res; + { + std::string pSource = cmSystemTools::RelativePath( + makefile->GetCurrentSourceDirectory(), fileName.c_str()); + std::string pBinary = cmSystemTools::RelativePath( + makefile->GetCurrentBinaryDirectory(), fileName.c_str()); + if (pSource.size() < pBinary.size()) { + res = std::move(pSource); + } else if (pBinary.size() < fileName.size()) { + res = std::move(pBinary); + } else { + res = fileName; + } + } + return res; +} + /* @brief Tests if targetDepend is a STATIC_LIBRARY and if any of its * recursive STATIC_LIBRARY dependencies depends on targetOrigin * (STATIC_LIBRARY cycle). @@ -646,7 +666,7 @@ void cmQtAutoGeneratorInitializer::InitCustomTargets() commandLines.push_back(std::move(currentLine)); } std::string ccComment = "Automatic RCC for "; - ccComment += qrc.QrcFile; + ccComment += FileProjectRelativePath(makefile, qrc.QrcFile); if (qrc.Generated) { // Create custom rcc target -- cgit v0.12