summaryrefslogtreecommitdiffstats
path: root/Source/cmSourceGroupCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-05-18 12:53:47 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-05-18 12:53:51 (GMT)
commit10371cd6dcfc1bf601fa3e715734dbe66199e2e4 (patch)
tree40bab8ae75055ba2e94209f432eb1f79fe4afc41 /Source/cmSourceGroupCommand.cxx
parent21916a4784f06f14d1acb800d72758921120699b (diff)
parent4716f2be83f140deec28fd7c6b945c6fd401a433 (diff)
downloadCMake-10371cd6dcfc1bf601fa3e715734dbe66199e2e4.zip
CMake-10371cd6dcfc1bf601fa3e715734dbe66199e2e4.tar.gz
CMake-10371cd6dcfc1bf601fa3e715734dbe66199e2e4.tar.bz2
Merge topic 'source_group-TREE-relative-path'
4716f2be source_group: Restore TREE support for relative paths Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !852
Diffstat (limited to 'Source/cmSourceGroupCommand.cxx')
-rw-r--r--Source/cmSourceGroupCommand.cxx32
1 files changed, 20 insertions, 12 deletions
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index f54d777..a966300 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSourceGroupCommand.h"
-#include <algorithm>
-#include <iterator>
#include <set>
#include <sstream>
#include <stddef.h>
@@ -16,7 +14,7 @@ namespace {
const size_t RootIndex = 1;
const size_t FilesWithoutPrefixKeywordIndex = 2;
const size_t FilesWithPrefixKeywordIndex = 4;
-const size_t PrefixKeywordIdex = 2;
+const size_t PrefixKeywordIndex = 2;
std::vector<std::string> tokenizePath(const std::string& path)
{
@@ -80,17 +78,26 @@ cmSourceGroup* addSourceGroup(const std::vector<std::string>& tokenizedPath,
return sg;
}
-std::string prepareFilePathForTree(const std::string& path)
+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<std::string> prepareFilesPathsForTree(
std::vector<std::string>::const_iterator begin,
- std::vector<std::string>::const_iterator end)
+ std::vector<std::string>::const_iterator end,
+ const std::string& currentSourceDir)
{
- std::vector<std::string> prepared(std::distance(begin, end));
- std::transform(begin, end, prepared.begin(), prepareFilePathForTree);
+ std::vector<std::string> prepared;
+
+ for (; begin != end; ++begin) {
+ prepared.push_back(prepareFilePathForTree(*begin, currentSourceDir));
+ }
+
return prepared;
}
@@ -229,13 +236,13 @@ bool cmSourceGroupCommand::checkTreeArgumentsPreconditions(
}
if (args[FilesWithoutPrefixKeywordIndex] != "FILES" &&
- args[PrefixKeywordIdex] != "PREFIX") {
+ args[PrefixKeywordIndex] != "PREFIX") {
errorMsg = "Unknown argument \"" + args[2] +
"\". Perhaps the FILES keyword is missing.\n";
return false;
}
- if (args[PrefixKeywordIdex] == "PREFIX" &&
+ if (args[PrefixKeywordIndex] == "PREFIX" &&
(args.size() < 5 || args[FilesWithPrefixKeywordIndex] != "FILES")) {
errorMsg = "Missing FILES arguments.";
return false;
@@ -254,13 +261,14 @@ bool cmSourceGroupCommand::processTree(const std::vector<std::string>& args,
const std::string root = cmSystemTools::CollapseFullPath(args[RootIndex]);
std::string prefix;
size_t filesBegin = FilesWithoutPrefixKeywordIndex + 1;
- if (args[PrefixKeywordIdex] == "PREFIX") {
- prefix = args[PrefixKeywordIdex + 1];
+ if (args[PrefixKeywordIndex] == "PREFIX") {
+ prefix = args[PrefixKeywordIndex + 1];
filesBegin = FilesWithPrefixKeywordIndex + 1;
}
const std::vector<std::string> filesVector =
- prepareFilesPathsForTree(args.begin() + filesBegin, args.end());
+ prepareFilesPathsForTree(args.begin() + filesBegin, args.end(),
+ this->Makefile->GetCurrentSourceDirectory());
if (!rootIsPrefix(root, filesVector, errorMsg)) {
return false;