summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2008-02-12 14:49:42 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2008-02-12 14:49:42 (GMT)
commit3fa087c8ab7bb6d1aa1c6a1edc32edd66e781bb8 (patch)
treef32e5b7a4fda680667ac13c1c9a76e2c0836dcee
parent88eca37d4ef804efc7d6cc204cf96ca07abd8482 (diff)
downloadCMake-3fa087c8ab7bb6d1aa1c6a1edc32edd66e781bb8.zip
CMake-3fa087c8ab7bb6d1aa1c6a1edc32edd66e781bb8.tar.gz
CMake-3fa087c8ab7bb6d1aa1c6a1edc32edd66e781bb8.tar.bz2
ENH: fix make edit_cache for cmake-gui
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx1
-rw-r--r--Source/MFCDialog/CMakeSetupDialog.cpp1
-rw-r--r--Source/QtDialog/CMakeSetup.cxx44
-rw-r--r--Source/QtDialog/QCMake.cxx1
-rw-r--r--Source/cmake.cxx45
-rw-r--r--Source/cmake.h5
6 files changed, 72 insertions, 25 deletions
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index 3258880..01ab275 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -48,6 +48,7 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args,
this->HelpMessage.push_back("");
this->HelpMessage.push_back(s_ConstHelpMessage);
this->CMakeInstance = new cmake;
+ this->CMakeInstance->SetCMakeEditCommand("ccmake");
// create the arguments for the cmake object
std::string whereCMake = cmSystemTools::GetProgramPath(this->Args[0].c_str());
diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp
index d9094c0..ba74c93 100644
--- a/Source/MFCDialog/CMakeSetupDialog.cpp
+++ b/Source/MFCDialog/CMakeSetupDialog.cpp
@@ -170,6 +170,7 @@ CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo,
m_CacheEntriesList.m_CMakeSetupDialog = this;
m_CMakeInstance = new cmake;
+ m_CMakeInstance->SetCMakeEditCommand("CMakeSetup");
m_CMakeInstance->SetProgressCallback(updateProgress, (void *)this);
//{{AFX_DATA_INIT(CMakeSetupDialog)
diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx
index 5d8f3c1..8be36f9 100644
--- a/Source/QtDialog/CMakeSetup.cxx
+++ b/Source/QtDialog/CMakeSetup.cxx
@@ -26,6 +26,7 @@
#include "cmSystemTools.h"
#include "cmake.h"
#include "cmVersion.h"
+#include <cmsys/CommandLineArguments.hxx>
//----------------------------------------------------------------------------
static const char * cmDocumentationName[][3] =
@@ -125,20 +126,39 @@ int main(int argc, char** argv)
dialog.setWindowTitle(title);
dialog.show();
- // for now: args support specifying build and/or source directory
- QStringList args = app.arguments();
- if(args.count() == 2)
+ cmsys::CommandLineArguments arg;
+ arg.Initialize(argc, argv);
+ std::string binaryDirectory;
+ std::string sourceDirectory;
+ typedef cmsys::CommandLineArguments argT;
+ arg.AddArgument("-B", argT::CONCAT_ARGUMENT,
+ &binaryDirectory, "Binary Directory");
+ arg.AddArgument("-H", argT::CONCAT_ARGUMENT,
+ &sourceDirectory, "Source Directory");
+ // do not complain about unknown options
+ arg.StoreUnusedArguments(true);
+ arg.Parse();
+ if(!sourceDirectory.empty() && !binaryDirectory.empty())
{
- QFileInfo buildFileInfo(args[1], "CMakeCache.txt");
- QFileInfo srcFileInfo(args[1], "CMakeLists.txt");
- if(buildFileInfo.exists())
- {
- dialog.setBinaryDirectory(buildFileInfo.absolutePath());
- }
- else if(srcFileInfo.exists())
+ dialog.setSourceDirectory(sourceDirectory.c_str());
+ dialog.setBinaryDirectory(binaryDirectory.c_str());
+ }
+ else
+ {
+ QStringList args = app.arguments();
+ if(args.count() == 2)
{
- dialog.setSourceDirectory(srcFileInfo.absolutePath());
- dialog.setBinaryDirectory(QDir::currentPath());
+ QFileInfo buildFileInfo(args[1], "CMakeCache.txt");
+ QFileInfo srcFileInfo(args[1], "CMakeLists.txt");
+ if(buildFileInfo.exists())
+ {
+ dialog.setBinaryDirectory(buildFileInfo.absolutePath());
+ }
+ else if(srcFileInfo.exists())
+ {
+ dialog.setSourceDirectory(srcFileInfo.absolutePath());
+ dialog.setBinaryDirectory(QDir::currentPath());
+ }
}
}
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index d07d5ec..0784dae 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -47,6 +47,7 @@ QCMake::QCMake(QObject* p)
cmSystemTools::SetErrorCallback(QCMake::errorCallback, this);
this->CMakeInstance = new cmake;
+ this->CMakeInstance->SetCMakeEditCommand("cmake-gui");
this->CMakeInstance->SetProgressCallback(QCMake::progressCallback, this);
std::vector<std::string> generators;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 8f36aab..cf89a4c 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -756,20 +756,39 @@ int cmake::AddCMakePaths()
this->CacheManager->AddCacheEntry
("CMAKE_COMMAND",cMakeSelf.c_str(), "Path to CMake 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()))
+ // if the edit command is not yet in the cache,
+ // or if CMakeEditCommand has been set on this object,
+ // then set the CMAKE_EDIT_COMMAND in the cache
+ // This will mean that the last gui to edit the cache
+ // will be the one that make edit_cache uses.
+ if(!this->GetCacheDefinition("CMAKE_EDIT_COMMAND")
+ || !this->CMakeEditCommand.empty())
{
- this->CacheManager->AddCacheEntry
- ("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(),
- "Path to cache edit program executable.", cmCacheManager::INTERNAL);
+ // Find and save the command to edit the cache
+ std::string editCacheCommand;
+ if(!this->CMakeEditCommand.empty())
+ {
+ editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf)
+ + std::string("/")
+ + this->CMakeEditCommand
+ + cmSystemTools::GetFilenameExtension(cMakeSelf);
+ }
+ if( !cmSystemTools::FileExists(editCacheCommand.c_str()))
+ {
+ 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()))
+ {
+ this->CacheManager->AddCacheEntry
+ ("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(),
+ "Path to cache edit program executable.", cmCacheManager::INTERNAL);
+ }
}
std::string ctestCommand = cmSystemTools::GetFilenamePath(cMakeSelf) +
"/ctest" + cmSystemTools::GetFilenameExtension(cMakeSelf);
diff --git a/Source/cmake.h b/Source/cmake.h
index 80c9de8..e1eda4a 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -329,6 +329,10 @@ class cmake
// Define the properties
static void DefineProperties(cmake *cm);
+ void SetCMakeEditCommand(const char* s)
+ {
+ this->CMakeEditCommand = s;
+ }
protected:
int HandleDeleteCacheVariables(const char* var);
cmPropertyMap Properties;
@@ -413,6 +417,7 @@ private:
bool InTryCompile;
bool ScriptMode;
bool DebugOutput;
+ std::string CMakeEditCommand;
std::string CMakeCommand;
std::string CXXEnvironment;
std::string CCEnvironment;