From 3bc9830686f25304024d3bc2849d530ac057763d Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 7 May 2002 09:02:45 -0400 Subject: ENH: add an edit_cache target that runs ccmake or CMakeSetup --- Source/cmBorlandMakefileGenerator.cxx | 16 +++++++++++----- Source/cmNMakeMakefileGenerator.cxx | 7 +++++++ Source/cmUnixMakefileGenerator.cxx | 18 ++++++++++++++++++ Source/cmake.cxx | 19 +++++++++++++++++-- 4 files changed, 53 insertions(+), 7 deletions(-) diff --git a/Source/cmBorlandMakefileGenerator.cxx b/Source/cmBorlandMakefileGenerator.cxx index 0e6fa01..32e76d9 100644 --- a/Source/cmBorlandMakefileGenerator.cxx +++ b/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& includes = m_Makefile->GetIncludeDirectories(); std::vector::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; diff --git a/Source/cmNMakeMakefileGenerator.cxx b/Source/cmNMakeMakefileGenerator.cxx index eee9685..cdb42b1 100644 --- a/Source/cmNMakeMakefileGenerator.cxx +++ b/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"; diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx index 5609bda..2bbd1e9 100644 --- a/Source/cmUnixMakefileGenerator.cxx +++ b/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", diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 47f204c..95f62ea 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -254,10 +254,10 @@ void cmake::AddCMakePaths(const std::vector& 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& 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; -- cgit v0.12