From 93af8a2583e2ec8d067a2e8eda544dfc5d3d3b4f Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 30 Jul 2019 11:26:02 -0400 Subject: source_group: Fix regression in relative FILES Fix the check added in commit 8d93815d20 (source_group command ensures that FILES arguments are actually files, 2019-04-25, v3.15.0-rc1~195^2) to convert to an absolute path before checking for existence. Also simplify the conversion to an absolute path. Fixes: #19454 --- Source/cmSourceGroupCommand.cxx | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index 5cdacaa..04b4d72 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -63,15 +63,6 @@ bool rootIsPrefix(const std::string& root, return true; } -std::string prepareFilePathForTree(const std::string& path, - const std::string& currentSourceDir) -{ - if (!cmSystemTools::FileIsFullPath(path)) { - return cmSystemTools::CollapseFullPath(currentSourceDir + "/" + path); - } - return cmSystemTools::CollapseFullPath(path); -} - std::vector prepareFilesPathsForTree( const std::vector& filesPaths, const std::string& currentSourceDir) @@ -80,9 +71,11 @@ std::vector prepareFilesPathsForTree( prepared.reserve(filesPaths.size()); for (auto const& filePath : filesPaths) { + std::string fullPath = + cmSystemTools::CollapseFullPath(filePath, currentSourceDir); // If provided file path is actually not a file, silently ignore it. - if (cmSystemTools::FileExists(filePath, /*isFile=*/true)) { - prepared.push_back(prepareFilePathForTree(filePath, currentSourceDir)); + if (cmSystemTools::FileExists(fullPath, /*isFile=*/true)) { + prepared.emplace_back(std::move(fullPath)); } } -- cgit v0.12