Browse Source

ENH: add an edit_cache target that runs ccmake or CMakeSetup

Bill Hoffman 23 years ago
parent
commit
3bc9830686

+ 11 - 5
Source/cmBorlandMakefileGenerator.cxx

@@ -106,17 +106,23 @@ void cmBorlandMakefileGenerator::OutputMakeVariables(std::ostream& fout)
   fout << "RM = " << this->ConvertToOutputPath(ccommand.c_str()) << " remove -f\n";
   std::string ccompiler = m_Makefile->GetDefinition("CMAKE_C_COMPILER");
   fout << "CMAKE_C_COMPILER  = " 
-       << this->ConvertToOutputPath(ccompiler.c_str())
+       << this->ShortPath(ccompiler.c_str())
        << "\n";
   std::string cxxcompiler = m_Makefile->GetDefinition("CMAKE_CXX_COMPILER");
   fout << "CMAKE_CXX_COMPILER  = "
-       << this->ConvertToOutputPath(cxxcompiler.c_str())
+       << this->ShortPath(cxxcompiler.c_str())
        << "\n";
-
+  
+  if(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))
+    {
+    fout << "CMAKE_EDIT_COMMAND = "
+         << this->ShortPath(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))
+         << "\n";
+    }
   
   std::string cmakecommand = m_Makefile->GetDefinition("CMAKE_COMMAND");
   fout << "CMAKE_COMMAND = " 
-       << this->ConvertToOutputPath(cmakecommand.c_str()) << "\n";
+       << this->ShortPath(cmakecommand.c_str()) << "\n";
 
   fout << replaceVars.c_str();
   fout << "CMAKE_CURRENT_SOURCE = " 
@@ -135,7 +141,7 @@ void cmBorlandMakefileGenerator::OutputMakeVariables(std::ostream& fout)
   std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
   std::vector<std::string>::iterator i;
   fout << "-I" << 
-    this->ConvertToOutputPath(m_Makefile->GetStartDirectory()) << " ";
+    this->ShortPath(m_Makefile->GetStartDirectory()) << " ";
   for(i = includes.begin(); i != includes.end(); ++i)
     {
     std::string include = *i;

+ 7 - 0
Source/cmNMakeMakefileGenerator.cxx

@@ -192,6 +192,13 @@ void cmNMakeMakefileGenerator::OutputMakeVariables(std::ostream& fout)
   fout << "CMAKE_COMMAND                          = "
        << this->ShortPath(cmakecommand.c_str()) << "\n";
 
+  if(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))
+    {
+    fout << "CMAKE_EDIT_COMMAND = "
+         << this->ShortPath(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))
+         << "\n";
+    }
+
   fout << "CMAKE_CURRENT_SOURCE                   = " 
        << this->ShortPath(m_Makefile->GetStartDirectory() )
        << "\n";

+ 18 - 0
Source/cmUnixMakefileGenerator.cxx

@@ -1610,6 +1610,12 @@ void cmUnixMakefileGenerator::OutputMakeVariables(std::ostream& fout)
   fout << "CMAKE_COMMAND = "
        << this->ConvertToOutputPath(m_Makefile->GetDefinition("CMAKE_COMMAND"))
        << "\n";
+  if(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))
+    {
+    fout << "CMAKE_EDIT_COMMAND = "
+         << this->ConvertToOutputPath(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))
+         << "\n";
+    }
 
   fout << "CMAKE_CURRENT_SOURCE = " << 
     this->ConvertToOutputPath(m_Makefile->GetStartDirectory()) << "\n";
@@ -1864,6 +1870,18 @@ void cmUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
                        "$(CMAKE_BINARY_DIR)/CMakeCache.txt",
                        "$(CMAKE_COMMAND) "
                        "-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)");
+  // if CMAKE_EDIT_COMMAND is defined then add a rule to run it
+  // called edit_cache
+  if(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))
+    {
+    this->OutputMakeRule(fout, 
+                         "Edit the CMakeCache.txt file with ccmake or CMakeSetup",
+                         "edit_cache",
+                         0,
+                         "$(CMAKE_EDIT_COMMAND) "
+                         "-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)");
+    }
+  
   this->OutputMakeRule(fout, 
                        "Create CMakeCache.txt file",
                        "$(CMAKE_BINARY_DIR)/CMakeCache.txt",

+ 17 - 2
Source/cmake.cxx

@@ -254,10 +254,10 @@ void cmake::AddCMakePaths(const std::vector<std::string>& args)
   // Find ccommand
   std::string cCommand = cmSystemTools::GetFilenamePath(cMakeSelf) +
     "/ccommand" + cmSystemTools::GetFilenameExtension(cMakeSelf);
-  if( !cmSystemTools::FileExists(cMakeSelf.c_str()))
+  if( !cmSystemTools::FileExists(cCommand.c_str()))
     {
     cmSystemTools::Error("CMAKE can not find the command line program "
-			 "ccommand. Attempted path: ", cMakeSelf.c_str());
+			 "ccommand. Attempted path: ", cCommand.c_str());
     return;
     }
 
@@ -265,6 +265,21 @@ void cmake::AddCMakePaths(const std::vector<std::string>& args)
   cmCacheManager::GetInstance()->AddCacheEntry
     ("CCOMMAND_COMMAND",cCommand.c_str(),
      "Path to CMakeCommand executable.", cmCacheManager::INTERNAL);
+
+  // Find and save the command to edit the cache
+  std::string editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) +
+    "/ccmake" + cmSystemTools::GetFilenameExtension(cMakeSelf);
+  if( !cmSystemTools::FileExists(editCacheCommand.c_str()))
+    {
+    editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) +
+      "/CMakeSetup" + cmSystemTools::GetFilenameExtension(cMakeSelf);
+    }
+  if(cmSystemTools::FileExists(editCacheCommand.c_str()))
+    {
+    cmCacheManager::GetInstance()->AddCacheEntry
+      ("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(),
+       "Path to cache edit program executable.", cmCacheManager::INTERNAL);
+    }
   
   // do CMAKE_ROOT, look for the environment variable first
   std::string cMakeRoot;