Use cmSystemTools::GetCMakeCommand() to get path to cmake internally

This is much simpler than finding a way to lookup "CMAKE_COMMAND"
everywhere.
This commit is contained in:
Brad King 2015-05-20 09:10:52 -04:00
parent 594dd9b36a
commit 6fbd4cae0d
16 changed files with 32 additions and 56 deletions

View File

@ -283,8 +283,6 @@ int cmCPackDebGenerator::PackageFiles()
int cmCPackDebGenerator::createDeb()
{
const char* cmakeExecutable = this->GetOption("CMAKE_COMMAND");
// debian-binary file
std::string dbfilename;
dbfilename += this->GetOption("GEN_WDIR");
@ -420,15 +418,15 @@ int cmCPackDebGenerator::createDeb()
} else if(!strcmp(debian_compression_type, "bzip2")) {
compression_suffix = ".bz2";
compression_modifier = "j";
cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E ";
cmake_tar += "\"" + cmSystemTools::GetCMakeCommand() + "\" -E ";
} else if(!strcmp(debian_compression_type, "gzip")) {
compression_suffix = ".gz";
compression_modifier = "z";
cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E ";
cmake_tar += "\"" + cmSystemTools::GetCMakeCommand() + "\" -E ";
} else if(!strcmp(debian_compression_type, "none")) {
compression_suffix = "";
compression_modifier = "";
cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E ";
cmake_tar += "\"" + cmSystemTools::GetCMakeCommand() + "\" -E ";
} else {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error unrecognized compression type: "
@ -501,7 +499,7 @@ int cmCPackDebGenerator::createDeb()
fileIt != packageFiles.end(); ++ fileIt )
{
cmd = "\"";
cmd += cmakeExecutable;
cmd += cmSystemTools::GetCMakeCommand();
cmd += "\" -E md5sum \"";
cmd += *fileIt;
cmd += "\"";

View File

@ -407,14 +407,9 @@ bool cmCacheManager::SaveCache(const std::string& path)
" was created", cmState::INTERNAL);
fout << "# This is the CMakeCache file.\n"
<< "# For build in directory: " << currentcwd << "\n";
cmCacheManager::CacheEntry* cmakeCacheEntry
= this->GetCacheEntry("CMAKE_COMMAND");
if ( cmakeCacheEntry )
{
fout << "# It was generated by CMake: " <<
cmakeCacheEntry->Value << std::endl;
}
<< "# For build in directory: " << currentcwd << "\n"
<< "# It was generated by CMake: "
<< cmSystemTools::GetCMakeCommand() << std::endl;
fout << "# You can edit this file to change values found and used by cmake."
<< std::endl

View File

@ -1008,7 +1008,6 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
const std::string makeArgs = mf->GetSafeDefinition(
"CMAKE_ECLIPSE_MAKE_ARGUMENTS");
const std::string cmake = mf->GetRequiredDefinition("CMAKE_COMMAND");
cmGlobalGenerator* generator
= const_cast<cmGlobalGenerator*>(this->GlobalGenerator);
@ -1096,11 +1095,12 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
std::string cleanArgs = "-E chdir \"";
cleanArgs += makefile->GetCurrentBinaryDirectory();
cleanArgs += "\" \"";
cleanArgs += cmake;
cleanArgs += cmSystemTools::GetCMakeCommand();
cleanArgs += "\" -P \"";
cleanArgs += (*it)->GetTargetDirectory(ti->second);
cleanArgs += "/cmake_clean.cmake\"";
this->AppendTarget(fout, "Clean", cmake, cleanArgs, virtDir, "", "");
this->AppendTarget(fout, "Clean", cmSystemTools::GetCMakeCommand(),
cleanArgs, virtDir, "", "");
}
}
break;

View File

@ -247,7 +247,7 @@ cmExtraKateGenerator::CreateDummyKateProjectFile(const cmMakefile* mf) const
return;
}
fout << "#Generated by " << mf->GetRequiredDefinition("CMAKE_COMMAND")
fout << "#Generated by " << cmSystemTools::GetCMakeCommand()
<< ", do not edit.\n";
}

View File

@ -2151,7 +2151,6 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
{
cmMakefile* mf = this->LocalGenerators[0]->GetMakefile();
const char* cmakeCfgIntDir = this->GetCMakeCFGIntDir();
const char* cmakeCommand = mf->GetRequiredDefinition("CMAKE_COMMAND");
// CPack
std::string workingDir = mf->GetCurrentBinaryDirectory();
@ -2266,7 +2265,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
}
else
{
singleLine.push_back(cmakeCommand);
singleLine.push_back(cmSystemTools::GetCMakeCommand());
singleLine.push_back("-E");
singleLine.push_back("echo");
singleLine.push_back("No interactive CMake dialog available.");
@ -2287,7 +2286,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
cpackCommandLines.end());
singleLine.erase(singleLine.begin(), singleLine.end());
depends.erase(depends.begin(), depends.end());
singleLine.push_back(cmakeCommand);
singleLine.push_back(cmSystemTools::GetCMakeCommand());
singleLine.push_back("-H$(CMAKE_SOURCE_DIR)");
singleLine.push_back("-B$(CMAKE_BINARY_DIR)");
cpackCommandLines.push_back(singleLine);
@ -2329,7 +2328,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
ostr.str().c_str(),
&cpackCommandLines, depends, 0, /*uses_terminal*/false);
}
std::string cmd = cmakeCommand;
std::string cmd = cmSystemTools::GetCMakeCommand();
cpackCommandLines.erase(cpackCommandLines.begin(),
cpackCommandLines.end());
singleLine.erase(singleLine.begin(), singleLine.end());

View File

@ -330,12 +330,10 @@ void
cmGlobalNinjaGenerator::AddMacOSXContentRule()
{
cmLocalGenerator *lg = this->LocalGenerators[0];
cmMakefile* mfRoot = lg->GetMakefile();
std::ostringstream cmd;
cmd << lg->ConvertToOutputFormat(
mfRoot->GetRequiredDefinition("CMAKE_COMMAND"),
cmLocalGenerator::SHELL)
cmd << lg->ConvertToOutputFormat(cmSystemTools::GetCMakeCommand(),
cmLocalGenerator::SHELL)
<< " -E copy $in $out";
this->AddRule("COPY_OSX_CONTENT",
@ -1185,9 +1183,8 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
cmMakefile* mfRoot = lg->GetMakefile();
std::ostringstream cmd;
cmd << lg->ConvertToOutputFormat(
mfRoot->GetRequiredDefinition("CMAKE_COMMAND"),
cmLocalGenerator::SHELL)
cmd << lg->ConvertToOutputFormat(cmSystemTools::GetCMakeCommand(),
cmLocalGenerator::SHELL)
<< " -H"
<< lg->ConvertToOutputFormat(mfRoot->GetHomeDirectory(),
cmLocalGenerator::SHELL)

View File

@ -252,7 +252,6 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
return false;
}
std::string cmake_command = mf->GetRequiredDefinition("CMAKE_COMMAND");
cmCustomCommandLines noCommandLines;
cmTarget* tgt =
mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false,
@ -310,9 +309,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
// Create a rule to re-run CMake.
std::string stampName = cmake::GetCMakeFilesDirectoryPostSlash();
stampName += "generate.stamp";
const char* dsprule = mf->GetRequiredDefinition("CMAKE_COMMAND");
cmCustomCommandLine commandLine;
commandLine.push_back(dsprule);
commandLine.push_back(cmSystemTools::GetCMakeCommand());
std::string argH = "-H";
argH += lg->Convert(mf->GetHomeDirectory(),
cmLocalGenerator::START_OUTPUT,

View File

@ -582,8 +582,8 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
{
makefileStream << "\\\n" << this->ConvertToRelativeForMake(i->c_str());
}
std::string cmake = mf->GetRequiredDefinition("CMAKE_COMMAND");
makefileStream << "\n\t" << this->ConvertToRelativeForMake(cmake.c_str())
makefileStream << "\n\t" <<
this->ConvertToRelativeForMake(cmSystemTools::GetCMakeCommand().c_str())
<< " -H" << this->ConvertToRelativeForMake(
mf->GetHomeDirectory())
<< " -B" << this->ConvertToRelativeForMake(
@ -1447,7 +1447,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
{
cmCustomCommandLines cmd;
cmd.resize(1);
cmd[0].push_back(this->CurrentMakefile->GetDefinition("CMAKE_COMMAND"));
cmd[0].push_back(cmSystemTools::GetCMakeCommand());
cmd[0].push_back("-E");
cmd[0].push_back("cmake_symlink_library");
std::string str_file = "$<TARGET_FILE:";

View File

@ -1001,9 +1001,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
}
if(variable == "CMAKE_COMMAND")
{
const char* cmcommand =
this->GetMakefile()->GetDefinition("CMAKE_COMMAND");
return this->Convert(cmcommand, FULL, SHELL);
return this->Convert(cmSystemTools::GetCMakeCommand(), FULL, SHELL);
}
std::vector<std::string> enabledLanguages;
this->GlobalGenerator->GetEnabledLanguages(enabledLanguages);

View File

@ -744,18 +744,16 @@ cmLocalUnixMakefileGenerator3
#endif
}
std::string cmakecommand =
this->Makefile->GetRequiredDefinition("CMAKE_COMMAND");
makefileStream
<< "# The CMake executable.\n"
<< "CMAKE_COMMAND = "
<< this->ConvertShellCommand(cmakecommand, FULL)
<< this->ConvertShellCommand(cmSystemTools::GetCMakeCommand(), FULL)
<< "\n"
<< "\n";
makefileStream
<< "# The command to remove a file.\n"
<< "RM = "
<< this->ConvertShellCommand(cmakecommand, FULL)
<< this->ConvertShellCommand(cmSystemTools::GetCMakeCommand(), FULL)
<< " -E remove -f\n"
<< "\n";
makefileStream

View File

@ -221,10 +221,8 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt)
{
std::string dspname = GetVS6TargetName(tgt.GetName());
dspname += ".dsp.cmake";
const char* dsprule =
this->Makefile->GetRequiredDefinition("CMAKE_COMMAND");
cmCustomCommandLine commandLine;
commandLine.push_back(dsprule);
commandLine.push_back(cmSystemTools::GetCMakeCommand());
std::string makefileIn = this->Makefile->GetCurrentSourceDirectory();
makefileIn += "/";
makefileIn += "CMakeLists.txt";
@ -817,7 +815,7 @@ cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target,
// Add a pre-link event to create the directory.
cmCustomCommandLine command;
command.push_back(this->Makefile->GetRequiredDefinition("CMAKE_COMMAND"));
command.push_back(cmSystemTools::GetCMakeCommand());
command.push_back("-E");
command.push_back("make_directory");
command.push_back(outDir);

View File

@ -290,10 +290,8 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
stampName += "/";
stampName += cmake::GetCMakeFilesDirectoryPostSlash();
stampName += "generate.stamp";
const char* dsprule =
this->Makefile->GetRequiredDefinition("CMAKE_COMMAND");
cmCustomCommandLine commandLine;
commandLine.push_back(dsprule);
commandLine.push_back(cmSystemTools::GetCMakeCommand());
std::string makefileIn = this->Makefile->GetCurrentSourceDirectory();
makefileIn += "/";
makefileIn += "CMakeLists.txt";

View File

@ -99,7 +99,7 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target,
// Add a pre-build event to create the directory.
cmCustomCommandLine command;
command.push_back(this->Makefile->GetRequiredDefinition("CMAKE_COMMAND"));
command.push_back(cmSystemTools::GetCMakeCommand());
command.push_back("-E");
command.push_back("make_directory");
command.push_back(impDir);

View File

@ -3575,7 +3575,6 @@ int cmMakefile::TryCompile(const std::string& srcdir,
// make sure the same generator is used
// use this program as the cmake to be run, it should not
// be run that way but the cmake object requires a vailid path
std::string cmakeCommand = this->GetDefinition("CMAKE_COMMAND");
cmake cm;
cm.SetIsInTryCompile(true);
cmGlobalGenerator *gg = cm.CreateGlobalGenerator

View File

@ -282,8 +282,7 @@ cmNinjaNormalTargetGenerator
!this->GetTarget()->IsFrameworkOnApple()) {
std::string cmakeCommand =
this->GetLocalGenerator()->ConvertToOutputFormat(
this->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"),
cmLocalGenerator::SHELL);
cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
if (targetType == cmTarget::EXECUTABLE)
this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_EXECUTABLE",
cmakeCommand +
@ -337,8 +336,7 @@ cmNinjaNormalTargetGenerator
{
std::string cmakeCommand =
this->GetLocalGenerator()->ConvertToOutputFormat(
mf->GetRequiredDefinition("CMAKE_COMMAND"),
cmLocalGenerator::SHELL);
cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
linkCmds.push_back(cmakeCommand + " -E remove $TARGET_FILE");
}
// TODO: Use ARCHIVE_APPEND for archives over a certain size.

View File

@ -320,7 +320,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
std::string targetDir = getAutogenTargetDir(target);
cmCustomCommandLine currentLine;
currentLine.push_back(makefile->GetSafeDefinition("CMAKE_COMMAND"));
currentLine.push_back(cmSystemTools::GetCMakeCommand());
currentLine.push_back("-E");
currentLine.push_back("cmake_autogen");
currentLine.push_back(targetDir);