summaryrefslogtreecommitdiffstats
path: root/Source/MFCDialog
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2001-05-30 19:28:55 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2001-05-30 19:28:55 (GMT)
commit4179c991f4bf3aefc1d96617e5f4e03646dcf56e (patch)
tree17edf2e2e3c400d6c01ca76d53c8f42c75be9f08 /Source/MFCDialog
parentdbf65f216fd08ce12df51bae17d0382473ce1d7b (diff)
downloadCMake-4179c991f4bf3aefc1d96617e5f4e03646dcf56e.zip
CMake-4179c991f4bf3aefc1d96617e5f4e03646dcf56e.tar.gz
CMake-4179c991f4bf3aefc1d96617e5f4e03646dcf56e.tar.bz2
ENH: change MFC gui to use cmake class
Diffstat (limited to 'Source/MFCDialog')
-rw-r--r--Source/MFCDialog/CMakeSetup.dsp4
-rw-r--r--Source/MFCDialog/CMakeSetupDialog.cpp83
-rw-r--r--Source/MFCDialog/CMakeSetupDialog.h1
3 files changed, 39 insertions, 49 deletions
diff --git a/Source/MFCDialog/CMakeSetup.dsp b/Source/MFCDialog/CMakeSetup.dsp
index 13bb7ba..0d97adf 100644
--- a/Source/MFCDialog/CMakeSetup.dsp
+++ b/Source/MFCDialog/CMakeSetup.dsp
@@ -70,8 +70,8 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FD /GZ /c
-# SUBTRACT CPP /YX /Yc /Yu
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FD /GZ /c
+# SUBTRACT CPP /O<none> /YX /Yc /Yu
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp
index 804496e..8a1f64b 100644
--- a/Source/MFCDialog/CMakeSetupDialog.cpp
+++ b/Source/MFCDialog/CMakeSetupDialog.cpp
@@ -8,6 +8,7 @@
#include "../cmMSProjectGenerator.h"
#include "../cmCacheManager.h"
#include "../cmMakefile.h"
+#include "../cmake.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
@@ -75,6 +76,13 @@ CMakeSetupDialog::CMakeSetupDialog(CWnd* pParent /*=NULL*/)
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_BuildPathChanged = false;
+ // Find the path to the cmake.exe executable
+ char fname[1024];
+ ::GetModuleFileName(NULL,fname,1023);
+ // extract just the path part
+ m_PathToExecutable = cmSystemTools::GetProgramPath(fname).c_str();
+ // add the cmake.exe to the path
+ m_PathToExecutable += "/cmake.exe";
}
void CMakeSetupDialog::DoDataExchange(CDataExchange* pDX)
@@ -412,8 +420,9 @@ void CMakeSetupDialog::OnBuildProjects()
return;
}
}
+ // set the wait cursor
::SetCursor(LoadCursor(NULL, IDC_WAIT));
- // get all the info from the screen
+ // get all the info from the dialog
this->UpdateData();
if(!m_BuildPathChanged)
{
@@ -423,34 +432,32 @@ void CMakeSetupDialog::OnBuildProjects()
}
// Make sure we are working from the cache on disk
this->LoadCacheFromDiskToGUI();
-
-// duh
- // Create a makefile object
- cmMakefile makefile;
- makefile.SetMakefileGenerator(new cmMSProjectGenerator);
- makefile.GetMakefileGenerator()->ComputeSystemInfo();
- makefile.SetHomeDirectory(m_WhereSource);
- makefile.SetStartOutputDirectory(m_WhereBuild);
- makefile.SetHomeOutputDirectory(m_WhereBuild);
- makefile.SetStartDirectory(m_WhereSource);
- makefile.MakeStartDirectoriesCurrent();
- CString makefileIn = m_WhereSource;
- makefileIn += "/CMakeLists.txt";
- makefile.ReadListFile(makefileIn);
- // Generate the project files
- makefile.GenerateMakefile();
- // Save the cache
- cmCacheManager::GetInstance()->SaveCache(&makefile);
-// end duh
-
+ // create a cmake object
+ cmake make;
+ // create the arguments for the cmake object
+ std::vector<std::string> args;
+ args.push_back((const char*)m_PathToExecutable);
+ std::string arg;
+ arg = "-H";
+ arg += m_WhereSource;
+ args.push_back(arg);
+ arg = "-B";
+ arg += m_WhereBuild;
+ args.push_back(arg);
+ // run the generate process
+ if(make.Generate(args) != 0)
+ {
+ cmSystemTools::Error(
+ "Error in generation process, project files may be invalid");
+ }
// update the GUI with any new values in the caused by the
// generation process
this->LoadCacheFromDiskToGUI();
- cmCacheManager::GetInstance()->DefineCache(&makefile);
// save source and build paths to registry
this->SaveToRegistry();
- // path is not up-to-date
+ // path is up-to-date now
m_BuildPathChanged = false;
+ // put the cursor back
::SetCursor(LoadCursor(NULL, IDC_ARROW));
}
@@ -460,7 +467,8 @@ void CMakeSetupDialog::OnBuildProjects()
// callback for combo box menu where build selection
void CMakeSetupDialog::OnSelendokWhereBuild()
{
- m_WhereBuildControl.GetLBText(m_WhereBuildControl.GetCurSel(), m_WhereBuild);
+ m_WhereBuildControl.GetLBText(m_WhereBuildControl.GetCurSel(),
+ m_WhereBuild);
this->UpdateData(FALSE);
this->OnChangeWhereBuild();
}
@@ -468,7 +476,8 @@ void CMakeSetupDialog::OnSelendokWhereBuild()
// callback for combo box menu where source selection
void CMakeSetupDialog::OnSelendokWhereSource()
{
- m_WhereSourceControl.GetLBText(m_WhereSourceControl.GetCurSel(), m_WhereSource);
+ m_WhereSourceControl.GetLBText(m_WhereSourceControl.GetCurSel(),
+ m_WhereSource);
this->UpdateData(FALSE);
this->OnChangeWhereSource();
}
@@ -557,7 +566,8 @@ void CMakeSetupDialog::FillCacheManagerFromCacheGUI()
{
CPropertyItem* item = *i;
cmCacheManager::CacheEntry *entry =
- cmCacheManager::GetInstance()->GetCacheEntry((const char*)item->m_propName);
+ cmCacheManager::GetInstance()->GetCacheEntry(
+ (const char*)item->m_propName);
if (entry)
{
entry->m_Value = item->m_curValue;
@@ -573,27 +583,6 @@ void CMakeSetupDialog::LoadCacheFromDiskToGUI()
if(m_WhereBuild != "")
{
cmCacheManager::GetInstance()->LoadCache(m_WhereBuild);
-
- // 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)
- {
- 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 += "/cmake.exe\"";
-
- // Save the value in the cache
- cmCacheManager::GetInstance()->AddCacheEntry("CMAKE_COMMAND",
- cMakeCMD.c_str(),
- "Path to CMake executable.",
- cmCacheManager::INTERNAL);
this->FillCacheGUIFromCacheManager();
}
}
diff --git a/Source/MFCDialog/CMakeSetupDialog.h b/Source/MFCDialog/CMakeSetupDialog.h
index b1140a6..aea794d 100644
--- a/Source/MFCDialog/CMakeSetupDialog.h
+++ b/Source/MFCDialog/CMakeSetupDialog.h
@@ -58,6 +58,7 @@ protected:
HICON m_hIcon;
CString m_RegistryKey;
+ CString m_PathToExecutable;
// Generated message map functions
//{{AFX_MSG(CMakeSetupDialog)
virtual BOOL OnInitDialog();