diff options
author | Ken Martin <ken.martin@kitware.com> | 2001-05-17 16:08:46 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2001-05-17 16:08:46 (GMT) |
commit | aa72e182fe88aeacb4a812c1041499973922d3cd (patch) | |
tree | 34b6e83f91a1427718f1d68f4cbc323d76c2b8db /Source/MFCDialog/CMakeSetupDialog.cpp | |
parent | e093e4a4e001cd620e36d30eb05d44210117e6f9 (diff) | |
download | CMake-aa72e182fe88aeacb4a812c1041499973922d3cd.zip CMake-aa72e182fe88aeacb4a812c1041499973922d3cd.tar.gz CMake-aa72e182fe88aeacb4a812c1041499973922d3cd.tar.bz2 |
half checked in changes for CMAKE_ROOT
Diffstat (limited to 'Source/MFCDialog/CMakeSetupDialog.cpp')
-rw-r--r-- | Source/MFCDialog/CMakeSetupDialog.cpp | 69 |
1 files changed, 25 insertions, 44 deletions
diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp index 6ee53ae..c2de964 100644 --- a/Source/MFCDialog/CMakeSetupDialog.cpp +++ b/Source/MFCDialog/CMakeSetupDialog.cpp @@ -66,36 +66,14 @@ BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) CMakeSetupDialog::CMakeSetupDialog(CWnd* pParent /*=NULL*/) : CDialog(CMakeSetupDialog::IDD, pParent) { - CString startPath = _pgmptr; - startPath.Replace('\\', '_'); - startPath.Replace(':', '_'); - startPath.Replace(".EXE", ""); - startPath.Replace(".exe", ""); - m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\"; - // _pgmptr should be the directory from which cmake was run from - // use it as the unique key for the dialog - m_RegistryKey += startPath; + m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath"; //{{AFX_DATA_INIT(CMakeSetupDialog) m_WhereSource = _T(""); m_WhereBuild = _T(""); - //}}AFX_DATA_INIT + //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); - // Guess the initial source directory based on the location - // of this program, it should be in CMake/Source/ - startPath = _pgmptr; - int removePos = startPath.Find("\\CMake\\Source"); - if(removePos == -1) - { - removePos = startPath.Find("/CMake/Source"); - } - if(removePos != -1) - { - startPath = startPath.Left(removePos); - } - m_WhereSource = startPath; - m_WhereBuild = startPath; this->LoadFromRegistry(); m_BuildPathChanged = false; } @@ -209,7 +187,7 @@ HCURSOR CMakeSetupDialog::OnQueryDragIcon() void CMakeSetupDialog::OnBrowseWhereSource() { this->UpdateData(); - Browse(m_WhereSource, "Enter Path to Insight Source"); + Browse(m_WhereSource, "Enter Path to Source"); this->UpdateData(false); } @@ -241,7 +219,7 @@ bool CMakeSetupDialog::Browse(CString &result, const char *title) void CMakeSetupDialog::OnBrowseWhereBuild() { this->UpdateData(); - Browse(m_WhereBuild, "Enter Path to Insight Build"); + Browse(m_WhereBuild, "Enter Path to Build"); this->UpdateData(false); } @@ -265,7 +243,6 @@ void CMakeSetupDialog::SaveToRegistry() RegSetValueEx(hKey, _T("WhereBuild"), 0, REG_SZ, (CONST BYTE *)(const char *)m_WhereBuild, m_WhereBuild.GetLength()); - } RegCloseKey(hKey); } @@ -307,9 +284,8 @@ void CMakeSetupDialog::LoadFromRegistry() else { // save some values - this->ReadRegistryValue(hKey, &(m_WhereSource),"WhereSource","C:\\Insight"); - this->ReadRegistryValue(hKey, &(m_WhereBuild),"WhereBuild", - "C:\\Insight"); + this->ReadRegistryValue(hKey, &(m_WhereSource),"WhereSource","C:\\"); + this->ReadRegistryValue(hKey, &(m_WhereBuild),"WhereBuild","C:\\"); } RegCloseKey(hKey); } @@ -341,10 +317,10 @@ void CMakeSetupDialog::OnBuildProjects() // current GUI values to the cache this->SaveCacheFromGUI(); } - // Create a makefile object - cmMakefile makefile; // Make sure we are working from the cache on disk this->LoadCacheFromDiskToGUI(); + // Create a makefile object + cmMakefile makefile; makefile.SetMakefileGenerator(new cmMSProjectGenerator); makefile.SetHomeDirectory(m_WhereSource); makefile.SetStartOutputDirectory(m_WhereBuild); @@ -482,21 +458,26 @@ void CMakeSetupDialog::LoadCacheFromDiskToGUI() { cmCacheManager::GetInstance()->LoadCache(m_WhereBuild); - // Make sure the internal "CMAKE" cache entry is set. - const char* cacheValue = cmCacheManager::GetInstance()->GetCacheValue("CMAKE"); - if(!cacheValue) + // Find our own exectuable. + char fname[1024]; + ::GetModuleFileName(NULL,fname,1023); + std::string root = cmSystemTools::GetProgramPath(fname); + std::string::size_type slashPos = root.rfind("/"); + if(slashPos != std::string::npos) { - // Find our own exectuable. - std::string cMakeCMD = "\""+cmSystemTools::GetProgramPath(_pgmptr); - cMakeCMD += "/CMakeSetupCMD.exe\""; - - // Save the value in the cache - cmCacheManager::GetInstance()->AddCacheEntry("CMAKE", - cMakeCMD.c_str(), - "Path to CMake executable.", - cmCacheManager::INTERNAL); + root = root.substr(0, slashPos); } + cmCacheManager::GetInstance()->AddCacheEntry + ("CMAKE_ROOT", root.c_str(), + "Path to CMake installation.", cmCacheManager::INTERNAL); + std::string cMakeCMD = "\""+cmSystemTools::GetProgramPath(fname); + cMakeCMD += "/CMakeSetupCMD.exe\""; + // Save the value in the cache + cmCacheManager::GetInstance()->AddCacheEntry("CMAKE_COMMAND", + cMakeCMD.c_str(), + "Path to CMake executable.", + cmCacheManager::INTERNAL); this->FillCacheGUIFromCacheManager(); } } |