diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 8e20c14e8..bcd2d812c 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -260,14 +260,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) err << "Unknown extension \"" << ext << "\" for file\n" << " " << *si << "\n" << "try_compile() works only for enabled languages. " - << "Currently these are:\n "; + << "Currently these are:\n "; std::vector langs; gg->GetEnabledLanguages(langs); - for(std::vector::iterator l = langs.begin(); - l != langs.end(); ++l) - { - err << " " << *l; - } + err << cmJoin(langs, " "); err << "\nSee project() command to enable other languages."; this->Makefile->IssueMessage(cmake::FATAL_ERROR, err.str()); return -1; @@ -373,12 +369,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) // handle any compile flags we need to pass on if (!compileDefs.empty()) { - fprintf(fout, "add_definitions( "); - for (size_t i = 0; i < compileDefs.size(); ++i) - { - fprintf(fout,"%s ",compileDefs[i].c_str()); - } - fprintf(fout, ")\n"); + fprintf(fout, "add_definitions(%s)\n", cmJoin(compileDefs, " ").c_str()); } /* Use a random file name to avoid rapid creation and deletion diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index 6e555333d..fd3aa0b1d 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -350,19 +350,10 @@ void cmFindBase::PrintFindStuff() std::cerr << "NoCMakeSystemPath " << this->NoCMakeSystemPath << "\n"; std::cerr << "EnvironmentPath " << this->EnvironmentPath << "\n"; std::cerr << "CMakePathName " << this->CMakePathName << "\n"; - std::cerr << "Names "; - for(unsigned int i =0; i < this->Names.size(); ++i) - { - std::cerr << this->Names[i] << " "; - } - std::cerr << "\n"; + std::cerr << "Names " << cmJoin(this->Names, " ") << "\n"; std::cerr << "\n"; std::cerr << "SearchPathSuffixes "; - for(unsigned int i =0; i < this->SearchPathSuffixes.size(); ++i) - { - std::cerr << this->SearchPathSuffixes[i] << "\n"; - } - std::cerr << "\n"; + std::cerr << cmJoin(this->SearchPathSuffixes, "\n") << "\n"; std::cerr << "SearchPaths\n"; for(std::vector::const_iterator i = this->SearchPaths.begin(); i != this->SearchPaths.end(); ++i) diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index c275e6b94..68657ad82 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1330,13 +1330,7 @@ cmLocalUnixMakefileGenerator3 this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); fout << "\n" << "# Per-language clean rules from dependency scanning.\n" - << "foreach(lang"; - for(std::set::const_iterator l = languages.begin(); - l != languages.end(); ++l) - { - fout << " " << *l; - } - fout << ")\n" + << "foreach(lang " << cmJoin(languages, " ") << ")\n" << " include(" << this->GetTargetDirectory(target) << "/cmake_clean_${lang}.cmake OPTIONAL)\n" << "endforeach()\n"; diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 6a7dc6ea5..eb637eff3 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -213,27 +213,14 @@ int cmcmd::ExecuteCMakeCommand(std::vector& args) // Echo string else if (args[1] == "echo" ) { - unsigned int cc; - const char* space = ""; - for ( cc = 2; cc < args.size(); cc ++ ) - { - std::cout << space << args[cc]; - space = " "; - } - std::cout << std::endl; + std::cout << cmJoin(cmRange(args).advance(2), " ") << std::endl; return 0; } // Echo string no new line else if (args[1] == "echo_append" ) { - unsigned int cc; - const char* space = ""; - for ( cc = 2; cc < args.size(); cc ++ ) - { - std::cout << space << args[cc]; - space = " "; - } + std::cout << cmJoin(cmRange(args).advance(2), " "); return 0; } @@ -1329,12 +1316,7 @@ bool cmcmd::RunCommand(const char* comment, if(verbose) { std::cout << comment << ":\n"; - for(std::vector::iterator i = command.begin(); - i != command.end(); ++i) - { - std::cout << *i << " "; - } - std::cout << "\n"; + std::cout << cmJoin(command, " ") << "\n"; } std::string output; int retCode =0;