Merge topic 'use-algorithms'

bb9d71b4 Replace loops with algorithms.
4afe6c26 cmAlgorithms: Add cmReverseRange adaptor.
a3a0a8c2 cmAlgorithms: Add cmFindNot algorithm.
8c74a41f cmRST: Replace two erase with a rotate and larger erase.
61fe1919 cmAlgorithms: Update concept requirement to FowardIterator
09d6125b cmAlgorithms: Move cmRotate out of 'implementation detail' namespace.
8ed6ecac cmRST: Move two algorithms beside each other.
dfe49c20 cmRST: Use std::min where appropriate.
21b0654a cmGlobalGenerator: Convert set insert algorithm to vector algorithms.
416df93a Convert some raw loops to cmWrap.
37b88d34 cmAlgorithms: Add cmWrap.
a2818093 Use cmJoin where possible.
76207b08 cmCacheManager: Replace loop with algorithm.
60c3bb73 cmGlobalGenerator: Replace loop with algorithm.
05fec779 cmTarget: Port loop to algorithm.
9c225767 cmGlobalGenerator: Replace set::insert algorithm with cmRemoveDuplicates.
...
This commit is contained in:
Brad King 2015-02-23 10:26:38 -05:00 committed by CMake Topic Stage
commit cc3611023d
18 changed files with 127 additions and 213 deletions

View File

@ -81,6 +81,16 @@ private:
const std::string m_test; const std::string m_test;
}; };
template<typename FwdIt>
FwdIt cmRotate(FwdIt first, FwdIt middle, FwdIt last)
{
typename std::iterator_traits<FwdIt>::difference_type dist =
std::distance(middle, last);
std::rotate(first, middle, last);
std::advance(first, dist);
return first;
}
namespace ContainerAlgorithms { namespace ContainerAlgorithms {
template<typename T> template<typename T>
@ -138,20 +148,10 @@ private:
const_iterator End; const_iterator End;
}; };
template<typename BiDirIt>
BiDirIt Rotate(BiDirIt first, BiDirIt middle, BiDirIt last)
{
typename std::iterator_traits<BiDirIt>::difference_type dist =
std::distance(first, middle);
std::rotate(first, middle, last);
std::advance(last, -dist);
return last;
}
template<typename Iter> template<typename Iter>
Iter RemoveN(Iter i1, Iter i2, size_t n) Iter RemoveN(Iter i1, Iter i2, size_t n)
{ {
return ContainerAlgorithms::Rotate(i1, i1 + n, i2); return cmRotate(i1, i1 + n, i2);
} }
template<typename Range> template<typename Range>
@ -278,4 +278,36 @@ typename Range::const_iterator cmRemoveDuplicates(Range& r)
return cmRemoveIndices(r, indices); return cmRemoveIndices(r, indices);
} }
template<typename Range>
std::string cmWrap(std::string prefix, Range const& r, std::string suffix,
std::string sep)
{
if (r.empty())
{
return std::string();
}
return prefix + cmJoin(r, (suffix + sep + prefix).c_str()) + suffix;
}
template<typename Range>
std::string cmWrap(char prefix, Range const& r, char suffix, std::string sep)
{
return cmWrap(std::string(1, prefix), r, std::string(1, suffix), sep);
}
template<typename Range, typename T>
typename Range::const_iterator cmFindNot(Range const& r, T const& t)
{
return std::find_if(r.begin(), r.end(),
std::bind1st(std::not_equal_to<T>(), t));
}
template<typename Range>
ContainerAlgorithms::Range<typename Range::const_reverse_iterator>
cmReverseRange(Range const& range)
{
return ContainerAlgorithms::Range<typename Range::const_reverse_iterator>(
range.rbegin(), range.rend());
}
#endif #endif

View File

@ -2256,10 +2256,9 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
bool SRArgumentSpecified = false; bool SRArgumentSpecified = false;
// copy the command line // copy the command line
for(size_t i=0; i < args.size(); ++i) this->InitialCommandLineArguments.insert(
{ this->InitialCommandLineArguments.end(),
this->InitialCommandLineArguments.push_back(args[i]); args.begin(), args.end());
}
// process the command line arguments // process the command line arguments
for(size_t i=1; i < args.size(); ++i) for(size_t i=1; i < args.size(); ++i)

View File

@ -186,11 +186,7 @@ void cmCacheManager::CleanCMakeFiles(const std::string& path)
cmsys::Glob globIt; cmsys::Glob globIt;
globIt.FindFiles(glob); globIt.FindFiles(glob);
std::vector<std::string> files = globIt.GetFiles(); std::vector<std::string> files = globIt.GetFiles();
for(std::vector<std::string>::iterator i = files.begin(); std::for_each(files.begin(), files.end(), cmSystemTools::RemoveFile);
i != files.end(); ++i)
{
cmSystemTools::RemoveFile(*i);
}
} }
bool cmCacheManager::LoadCache(const std::string& path, bool cmCacheManager::LoadCache(const std::string& path,

View File

@ -705,10 +705,7 @@ void cmComputeLinkDepends::DisplayConstraintGraph()
{ {
EdgeList const& nl = this->EntryConstraintGraph[i]; EdgeList const& nl = this->EntryConstraintGraph[i];
e << "item " << i << " is [" << this->EntryList[i].Item << "]\n"; e << "item " << i << " is [" << this->EntryList[i].Item << "]\n";
for(EdgeList::const_iterator j = nl.begin(); j != nl.end(); ++j) e << cmWrap(" item ", nl, " must follow it", "\n") << "\n";
{
e << " item " << *j << " must follow it\n";
}
} }
fprintf(stderr, "%s\n", e.str().c_str()); fprintf(stderr, "%s\n", e.str().c_str());
} }

View File

@ -260,14 +260,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
err << "Unknown extension \"" << ext << "\" for file\n" err << "Unknown extension \"" << ext << "\" for file\n"
<< " " << *si << "\n" << " " << *si << "\n"
<< "try_compile() works only for enabled languages. " << "try_compile() works only for enabled languages. "
<< "Currently these are:\n "; << "Currently these are:\n ";
std::vector<std::string> langs; std::vector<std::string> langs;
gg->GetEnabledLanguages(langs); gg->GetEnabledLanguages(langs);
for(std::vector<std::string>::iterator l = langs.begin(); err << cmJoin(langs, " ");
l != langs.end(); ++l)
{
err << " " << *l;
}
err << "\nSee project() command to enable other languages."; err << "\nSee project() command to enable other languages.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, err.str()); this->Makefile->IssueMessage(cmake::FATAL_ERROR, err.str());
return -1; return -1;
@ -373,12 +369,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
// handle any compile flags we need to pass on // handle any compile flags we need to pass on
if (!compileDefs.empty()) if (!compileDefs.empty())
{ {
fprintf(fout, "add_definitions( "); fprintf(fout, "add_definitions(%s)\n", cmJoin(compileDefs, " ").c_str());
for (size_t i = 0; i < compileDefs.size(); ++i)
{
fprintf(fout,"%s ",compileDefs[i].c_str());
}
fprintf(fout, ")\n");
} }
/* Use a random file name to avoid rapid creation and deletion /* Use a random file name to avoid rapid creation and deletion
@ -692,11 +683,9 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName)
std::ostringstream emsg; std::ostringstream emsg;
emsg << "Unable to find the executable at any of:\n"; emsg << "Unable to find the executable at any of:\n";
for (unsigned int i = 0; i < searchDirs.size(); ++i) emsg << cmWrap(" " + this->BinaryDirectory,
{ searchDirs,
emsg << " " << this->BinaryDirectory << searchDirs[i] tmpOutputFile, "\n") << "\n";
<< tmpOutputFile << "\n";
}
this->FindErrorMessage = emsg.str(); this->FindErrorMessage = emsg.str();
return; return;
} }

View File

@ -351,25 +351,12 @@ void cmFindBase::PrintFindStuff()
std::cerr << "NoCMakeSystemPath " << this->NoCMakeSystemPath << "\n"; std::cerr << "NoCMakeSystemPath " << this->NoCMakeSystemPath << "\n";
std::cerr << "EnvironmentPath " << this->EnvironmentPath << "\n"; std::cerr << "EnvironmentPath " << this->EnvironmentPath << "\n";
std::cerr << "CMakePathName " << this->CMakePathName << "\n"; std::cerr << "CMakePathName " << this->CMakePathName << "\n";
std::cerr << "Names "; std::cerr << "Names " << cmJoin(this->Names, " ") << "\n";
for(unsigned int i =0; i < this->Names.size(); ++i)
{
std::cerr << this->Names[i] << " ";
}
std::cerr << "\n";
std::cerr << "\n"; std::cerr << "\n";
std::cerr << "SearchPathSuffixes "; std::cerr << "SearchPathSuffixes ";
for(unsigned int i =0; i < this->SearchPathSuffixes.size(); ++i) std::cerr << cmJoin(this->SearchPathSuffixes, "\n") << "\n";
{
std::cerr << this->SearchPathSuffixes[i] << "\n";
}
std::cerr << "\n";
std::cerr << "SearchPaths\n"; std::cerr << "SearchPaths\n";
for(std::vector<std::string>::const_iterator i = this->SearchPaths.begin(); std::cerr << cmWrap("[", this->SearchPaths, "]", "\n") << "\n";
i != this->SearchPaths.end(); ++i)
{
std::cerr << "[" << *i << "]\n";
}
} }
bool cmFindBase::CheckForVariableInCache() bool cmFindBase::CheckForVariableInCache()

View File

@ -329,10 +329,7 @@ bool cmFindPackageCommand
{ {
std::ostringstream e; std::ostringstream e;
e << "called with components that are both required and optional:\n"; e << "called with components that are both required and optional:\n";
for(unsigned int i=0; i<doubledComponents.size(); ++i) e << cmWrap(" ", doubledComponents, "", "\n") << "\n";
{
e << " " << doubledComponents[i] << "\n";
}
this->SetError(e.str()); this->SetError(e.str());
return false; return false;
} }
@ -808,13 +805,8 @@ bool cmFindPackageCommand::HandlePackageMode()
{ {
e << "Could not find a package configuration file provided by \"" e << "Could not find a package configuration file provided by \""
<< this->Name << "\"" << requestedVersionString << this->Name << "\"" << requestedVersionString
<< " with any of the following names:\n"; << " with any of the following names:\n"
for(std::vector<std::string>::const_iterator ci = << cmWrap(" ", this->Configs, "", "\n") << "\n";
this->Configs.begin();
ci != this->Configs.end(); ++ci)
{
e << " " << *ci << "\n";
}
} }
e << "Add the installation prefix of \"" << this->Name << "\" to " e << "Add the installation prefix of \"" << this->Name << "\" to "

View File

@ -528,23 +528,22 @@ cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs,
std::vector<cmSourceFile const*> objectFiles; std::vector<cmSourceFile const*> objectFiles;
this->GetExternalObjects(objectFiles, config); this->GetExternalObjects(objectFiles, config);
std::vector<cmTarget*> objectLibraries; std::vector<cmTarget*> objectLibraries;
std::set<cmTarget*> emitted;
for(std::vector<cmSourceFile const*>::const_iterator for(std::vector<cmSourceFile const*>::const_iterator
it = objectFiles.begin(); it != objectFiles.end(); ++it) it = objectFiles.begin(); it != objectFiles.end(); ++it)
{ {
std::string objLib = (*it)->GetObjectLibrary(); std::string objLib = (*it)->GetObjectLibrary();
if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib)) if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib))
{ {
if (emitted.insert(tgt).second) objectLibraries.push_back(tgt);
{
objectLibraries.push_back(tgt);
}
} }
} }
std::vector<cmTarget*>::const_iterator end
= cmRemoveDuplicates(objectLibraries);
for(std::vector<cmTarget*>::const_iterator for(std::vector<cmTarget*>::const_iterator
ti = objectLibraries.begin(); ti = objectLibraries.begin();
ti != objectLibraries.end(); ++ti) ti != end; ++ti)
{ {
cmTarget* objLib = *ti; cmTarget* objLib = *ti;
cmGeneratorTarget* ogt = cmGeneratorTarget* ogt =

View File

@ -2295,15 +2295,8 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
std::ostringstream ostr; std::ostringstream ostr;
if (!componentsSet->empty()) if (!componentsSet->empty())
{ {
ostr << "Available install components are:"; ostr << "Available install components are: ";
std::set<std::string>::iterator it; ostr << cmWrap('"', *componentsSet, '"', " ");
for (
it = componentsSet->begin();
it != componentsSet->end();
++ it )
{
ostr << " \"" << *it << "\"";
}
} }
else else
{ {
@ -2571,17 +2564,12 @@ bool cmGlobalGenerator::IsReservedTarget(std::string const& name)
"test", "RUN_TESTS", "test", "RUN_TESTS",
"package", "PACKAGE", "package", "PACKAGE",
"package_source", "package_source",
"ZERO_CHECK", "ZERO_CHECK"
0
}; };
for(const char** reservedTarget = reservedTargets; return std::find(cmArrayBegin(reservedTargets),
*reservedTarget; ++reservedTarget) cmArrayEnd(reservedTargets), name)
{ != cmArrayEnd(reservedTargets);
if(name == *reservedTarget) return true;
}
return false;
} }
void cmGlobalGenerator::SetExternalMakefileProjectGenerator( void cmGlobalGenerator::SetExternalMakefileProjectGenerator(
@ -2937,14 +2925,11 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target)
{ {
target->GetSourceFiles(sources, *ci); target->GetSourceFiles(sources, *ci);
} }
std::set<cmSourceFile*> emitted; std::vector<cmSourceFile*>::const_iterator sourcesEnd
= cmRemoveDuplicates(sources);
for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
si != sources.end(); ++si) si != sourcesEnd; ++si)
{ {
if (!emitted.insert(*si).second)
{
continue;
}
Json::Value& lj_source = lj_sources.append(Json::objectValue); Json::Value& lj_source = lj_sources.append(Json::objectValue);
cmSourceFile* sf = *si; cmSourceFile* sf = *si;
std::string const& sfp = sf->GetFullPath(); std::string const& sfp = sf->GetFullPath();
@ -3030,7 +3015,7 @@ void cmGlobalGenerator::AddEvaluationFile(const std::string &inputFile,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalGenerator::ProcessEvaluationFiles() void cmGlobalGenerator::ProcessEvaluationFiles()
{ {
std::set<std::string> generatedFiles; std::vector<std::string> generatedFiles;
for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator
li = this->EvaluationFiles.begin(); li = this->EvaluationFiles.begin();
li != this->EvaluationFiles.end(); li != this->EvaluationFiles.end();
@ -3042,16 +3027,24 @@ void cmGlobalGenerator::ProcessEvaluationFiles()
return; return;
} }
std::vector<std::string> files = (*li)->GetFiles(); std::vector<std::string> files = (*li)->GetFiles();
for(std::vector<std::string>::const_iterator fi = files.begin(); std::sort(files.begin(), files.end());
fi != files.end(); ++fi)
std::vector<std::string> intersection;
std::set_intersection(files.begin(), files.end(),
generatedFiles.begin(), generatedFiles.end(),
std::back_inserter(intersection));
if (!intersection.empty())
{ {
if (!generatedFiles.insert(*fi).second) cmSystemTools::Error("Files to be generated by multiple different "
{ "commands: ", cmWrap('"', intersection, '"', " ").c_str());
cmSystemTools::Error("File to be generated by multiple different " return;
"commands: ", fi->c_str());
return;
}
} }
generatedFiles.insert(generatedFiles.end(),
files.begin(), files.end());
std::vector<std::string>::iterator newIt =
generatedFiles.end() - files.size();
std::inplace_merge(generatedFiles.begin(), newIt, generatedFiles.end());
} }
} }

View File

@ -390,8 +390,7 @@ bool cmListCommand
return false; return false;
} }
std::reverse(varArgsExpanded.begin(), varArgsExpanded.end()); std::string value = cmJoin(cmReverseRange(varArgsExpanded), ";");
std::string value = cmJoin(varArgsExpanded, ";");
this->Makefile->AddDefinition(listName, value.c_str()); this->Makefile->AddDefinition(listName, value.c_str());
return true; return true;

View File

@ -2800,12 +2800,7 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source,
} }
if(this->WindowsShell) if(this->WindowsShell)
{ {
std::string::size_type pos = 0; std::replace(result.begin(), result.end(), '/', '\\');
while((pos = result.find('/', pos)) != std::string::npos)
{
result[pos] = '\\';
pos++;
}
} }
result = this->EscapeForShell(result, true, false, output == WATCOMQUOTE); result = this->EscapeForShell(result, true, false, output == WATCOMQUOTE);
} }

View File

@ -724,12 +724,7 @@ cmLocalUnixMakefileGenerator3
} }
// Write the list of commands. // Write the list of commands.
for(std::vector<std::string>::const_iterator i = commands.begin(); os << cmWrap("\t", commands, "", "\n") << "\n";
i != commands.end(); ++i)
{
replace = *i;
os << "\t" << replace << "\n";
}
if(symbolic && !this->WatcomWMake) if(symbolic && !this->WatcomWMake)
{ {
os << ".PHONY : " << cmMakeSafe(tgt) << "\n"; os << ".PHONY : " << cmMakeSafe(tgt) << "\n";
@ -1330,13 +1325,7 @@ cmLocalUnixMakefileGenerator3
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
fout << "\n" fout << "\n"
<< "# Per-language clean rules from dependency scanning.\n" << "# Per-language clean rules from dependency scanning.\n"
<< "foreach(lang"; << "foreach(lang " << cmJoin(languages, " ") << ")\n"
for(std::set<std::string>::const_iterator l = languages.begin();
l != languages.end(); ++l)
{
fout << " " << *l;
}
fout << ")\n"
<< " include(" << this->GetTargetDirectory(target) << " include(" << this->GetTargetDirectory(target)
<< "/cmake_clean_${lang}.cmake OPTIONAL)\n" << "/cmake_clean_${lang}.cmake OPTIONAL)\n"
<< "endforeach()\n"; << "endforeach()\n";

View File

@ -213,13 +213,7 @@ cmMakefile::~cmMakefile()
void cmMakefile::PrintStringVector(const char* s, void cmMakefile::PrintStringVector(const char* s,
const std::vector<std::string>& v) const const std::vector<std::string>& v) const
{ {
std::cout << s << ": ( \n"; std::cout << s << ": ( \n" << cmWrap('"', v, '"', " ") << ")\n";
for(std::vector<std::string>::const_iterator i = v.begin();
i != v.end(); ++i)
{
std::cout << *i << " ";
}
std::cout << " )\n";
} }
void cmMakefile void cmMakefile
@ -1340,22 +1334,11 @@ void cmMakefile::AddDefineFlag(const char* flag)
void cmMakefile::AddDefineFlag(const char* flag, std::string& dflags) void cmMakefile::AddDefineFlag(const char* flag, std::string& dflags)
{ {
// remove any \n\r // remove any \n\r
std::string ret = flag; std::string::size_type initSize = dflags.size();
std::string::size_type pos = 0; dflags += std::string(" ") + flag;
while((pos = ret.find('\n', pos)) != std::string::npos) std::string::iterator flagStart = dflags.begin() + initSize + 1;
{ std::replace(flagStart, dflags.end(), '\n', ' ');
ret[pos] = ' '; std::replace(flagStart, dflags.end(), '\r', ' ');
pos++;
}
pos = 0;
while((pos = ret.find('\r', pos)) != std::string::npos)
{
ret[pos] = ' ';
pos++;
}
dflags += " ";
dflags += ret;
} }
@ -1472,18 +1455,11 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
cmSystemTools::ExpandListArgument(cdefs, defs); cmSystemTools::ExpandListArgument(cdefs, defs);
// Recompose the list without the definition. // Recompose the list without the definition.
std::string ndefs; std::vector<std::string>::const_iterator defEnd =
const char* sep = ""; std::remove(defs.begin(), defs.end(), define);
for(std::vector<std::string>::const_iterator di = defs.begin(); std::vector<std::string>::const_iterator defBegin =
di != defs.end(); ++di) defs.begin();
{ std::string ndefs = cmJoin(cmRange(defBegin, defEnd), ";");
if(*di != define)
{
ndefs += sep;
sep = ";";
ndefs += *di;
}
}
// Store the new list. // Store the new list.
this->SetProperty("COMPILE_DEFINITIONS", ndefs.c_str()); this->SetProperty("COMPILE_DEFINITIONS", ndefs.c_str());

View File

@ -463,10 +463,7 @@ void cmRST::UnindentLines(std::vector<std::string>& lines)
} }
// Truncate indentation to match that on this line. // Truncate indentation to match that on this line.
if(line.size() < indentEnd) indentEnd = std::min(indentEnd, line.size());
{
indentEnd = line.size();
}
for(std::string::size_type j = 0; j != indentEnd; ++j) for(std::string::size_type j = 0; j != indentEnd; ++j)
{ {
if(line[j] != indentText[j]) if(line[j] != indentText[j])
@ -487,19 +484,16 @@ void cmRST::UnindentLines(std::vector<std::string>& lines)
} }
} }
// Drop leading blank lines. std::vector<std::string>::const_iterator it = lines.begin();
size_t leadingEmpty = 0; size_t leadingEmpty = std::distance(it, cmFindNot(lines, std::string()));
for(size_t i = 0; i < lines.size() && lines[i].empty(); ++i)
{
++leadingEmpty;
}
lines.erase(lines.begin(), lines.begin()+leadingEmpty);
// Drop trailing blank lines. std::vector<std::string>::const_reverse_iterator rit = lines.rbegin();
size_t trailingEmpty = 0; size_t trailingEmpty = std::distance(rit,
for(size_t i = lines.size(); i > 0 && lines[i-1].empty(); --i) cmFindNot(cmReverseRange(lines), std::string()));
{
++trailingEmpty; std::vector<std::string>::iterator contentEnd
} = cmRotate(lines.begin(),
lines.erase(lines.end()-trailingEmpty, lines.end()); lines.begin() + leadingEmpty,
lines.end() - trailingEmpty);
lines.erase(contentEnd, lines.end());
} }

View File

@ -835,7 +835,7 @@ cmSystemTools::PrintSingleCommand(std::vector<std::string> const& command)
return std::string(); return std::string();
} }
return "\"" + cmJoin(command, "\" \"") + "\""; return cmWrap('"', command, '"', " ");
} }
bool cmSystemTools::DoesFileExistWithExtensions( bool cmSystemTools::DoesFileExistWithExtensions(

View File

@ -1542,12 +1542,9 @@ void cmTarget::DeleteDependencyForVS6( DependencyMap& depMap,
if( map_itr != depMap.end() ) if( map_itr != depMap.end() )
{ {
DependencyList& depList = map_itr->second; DependencyList& depList = map_itr->second;
DependencyList::iterator itr; DependencyList::iterator begin =
while( (itr = std::find(depList.begin(), depList.end(), dep)) != std::remove(depList.begin(), depList.end(), dep);
depList.end() ) depList.erase(begin, depList.end());
{
depList.erase( itr );
}
} }
} }

View File

@ -213,27 +213,14 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// Echo string // Echo string
else if (args[1] == "echo" ) else if (args[1] == "echo" )
{ {
unsigned int cc; std::cout << cmJoin(cmRange(args).advance(2), " ") << std::endl;
const char* space = "";
for ( cc = 2; cc < args.size(); cc ++ )
{
std::cout << space << args[cc];
space = " ";
}
std::cout << std::endl;
return 0; return 0;
} }
// Echo string no new line // Echo string no new line
else if (args[1] == "echo_append" ) else if (args[1] == "echo_append" )
{ {
unsigned int cc; std::cout << cmJoin(cmRange(args).advance(2), " ");
const char* space = "";
for ( cc = 2; cc < args.size(); cc ++ )
{
std::cout << space << args[cc];
space = " ";
}
return 0; return 0;
} }
@ -463,9 +450,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
return 1; return 1;
} }
std::string command = "\""; std::string command = cmWrap('"', cmRange(args).advance(3), '"', " ");
command += cmJoin(cmRange(args).advance(3), "\" \"");
command += "\"";
int retval = 0; int retval = 0;
int timeout = 0; int timeout = 0;
if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, &retval, if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, &retval,
@ -1329,12 +1314,7 @@ bool cmcmd::RunCommand(const char* comment,
if(verbose) if(verbose)
{ {
std::cout << comment << ":\n"; std::cout << comment << ":\n";
for(std::vector<std::string>::iterator i = command.begin(); std::cout << cmJoin(command, " ") << "\n";
i != command.end(); ++i)
{
std::cout << *i << " ";
}
std::cout << "\n";
} }
std::string output; std::string output;
int retCode =0; int retCode =0;

View File

@ -1 +1 @@
CMake Error: File to be generated by multiple different commands: .*CommandConflict-build/output_.*.txt CMake Error: Files to be generated by multiple different commands: ".*CommandConflict-build/output_.*.txt"