Browse Source

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

This is much simpler than finding a way to lookup "CMAKE_COMMAND"
everywhere.
Brad King 10 years ago
parent
commit
6fbd4cae0d

+ 4 - 6
Source/CPack/cmCPackDebGenerator.cxx

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

+ 3 - 8
Source/cmCacheManager.cxx

@@ -407,14 +407,9 @@ bool cmCacheManager::SaveCache(const std::string& path)
                       " was created", cmState::INTERNAL);
                       " was created", cmState::INTERNAL);
 
 
   fout << "# This is the CMakeCache file.\n"
   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."
   fout << "# You can edit this file to change values found and used by cmake."
        << std::endl
        << std::endl

+ 3 - 3
Source/cmExtraEclipseCDT4Generator.cxx

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

+ 1 - 1
Source/cmExtraKateGenerator.cxx

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

+ 3 - 4
Source/cmGlobalGenerator.cxx

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

+ 4 - 7
Source/cmGlobalNinjaGenerator.cxx

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

+ 1 - 3
Source/cmGlobalVisualStudio8Generator.cxx

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

+ 3 - 3
Source/cmGlobalXCodeGenerator.cxx

@@ -582,8 +582,8 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
     {
     {
     makefileStream << "\\\n" << this->ConvertToRelativeForMake(i->c_str());
     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(
                  << " -H" << this->ConvertToRelativeForMake(
                    mf->GetHomeDirectory())
                    mf->GetHomeDirectory())
                  << " -B" << this->ConvertToRelativeForMake(
                  << " -B" << this->ConvertToRelativeForMake(
@@ -1447,7 +1447,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
     {
     {
     cmCustomCommandLines cmd;
     cmCustomCommandLines cmd;
     cmd.resize(1);
     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("-E");
     cmd[0].push_back("cmake_symlink_library");
     cmd[0].push_back("cmake_symlink_library");
     std::string str_file = "$<TARGET_FILE:";
     std::string str_file = "$<TARGET_FILE:";

+ 1 - 3
Source/cmLocalGenerator.cxx

@@ -1001,9 +1001,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
     }
     }
   if(variable == "CMAKE_COMMAND")
   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;
   std::vector<std::string> enabledLanguages;
   this->GlobalGenerator->GetEnabledLanguages(enabledLanguages);
   this->GlobalGenerator->GetEnabledLanguages(enabledLanguages);

+ 2 - 4
Source/cmLocalUnixMakefileGenerator3.cxx

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

+ 2 - 4
Source/cmLocalVisualStudio6Generator.cxx

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

+ 1 - 3
Source/cmLocalVisualStudio7Generator.cxx

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

+ 1 - 1
Source/cmLocalVisualStudioGenerator.cxx

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

+ 0 - 1
Source/cmMakefile.cxx

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

+ 2 - 4
Source/cmNinjaNormalTargetGenerator.cxx

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

+ 1 - 1
Source/cmQtAutoGenerators.cxx

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