Commit 5c83326f authored by Bill Hoffman's avatar Bill Hoffman
Browse files

ENH: clean up cmake GUI and remove the parsing of CMakeLists.txt files by configure

parent 61091234
......@@ -48,11 +48,12 @@ protected:
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnChangeEdit1();
afx_msg void OnBrowse();
virtual void OnOK();
afx_msg void OnButton3();
afx_msg void OnBuildProjects();
afx_msg void OnChangeWhereBuild();
afx_msg void OnChangeWhereSource();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
......
......@@ -81,7 +81,7 @@ BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
LTEXT "CMakeSetup Version 1.0",IDC_STATIC,40,10,119,8,
SS_NOPREFIX
LTEXT "Copyright (C) 2000",IDC_STATIC,40,25,119,8
LTEXT "Kitware Inc.",IDC_STATIC,40,25,119,8
DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP
END
......
......@@ -7,6 +7,7 @@
#include "../cmDSWMakefile.h"
#include "../cmMSProjectGenerator.h"
#include "../cmCacheManager.h"
#include "../cmMakefile.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
......@@ -95,55 +96,7 @@ CMakeSetupDialog::CMakeSetupDialog(CWnd* pParent /*=NULL*/)
}
m_WhereSource = startPath;
this->LoadFromRegistry();
m_InitMakefile = false;
m_GUIInitialized = false;
this->InitMakefile();
}
void CMakeSetupDialog::InitMakefile()
{
if(m_InitMakefile)
{
// if no change in source or build then
// do not re-init the m_Makefile
if(m_WhereSource == m_WhereSourceLast
&& m_WhereBuild == m_WhereBuildLast)
{
return;
}
}
if(m_WhereBuild == "")
{
m_WhereBuild = m_WhereSource;
}
if(m_WhereSource == "")
{
return;
}
// save the values for these so we can detect
// when the GUI has changed them
m_WhereBuildLast = m_WhereBuild;
m_WhereSourceLast = m_WhereSource;
m_InitMakefile = true;
// set up the cmMakefile member
m_Makefile.SetMakefileGenerator(new cmMSProjectGenerator);
m_Makefile.SetHomeDirectory(m_WhereSource);
// Set the output directory
m_Makefile.SetStartOutputDirectory(m_WhereBuild);
m_Makefile.SetHomeOutputDirectory(m_WhereBuild);
// set the directory which contains the CMakeLists.txt
m_Makefile.SetStartDirectory(m_WhereSource);
// Create the master DSW file and all children dsp files for ITK
// Set the CMakeLists.txt file
m_Makefile.MakeStartDirectoriesCurrent();
// Create a string for the cache file
cmCacheManager::GetInstance()->LoadCache(&m_Makefile);
// if the GUI is already up, then reset it to the loaded cache
if(m_GUIInitialized)
{
this->FillCacheEditorFromCacheManager();
}
m_BuildPathChanged = false;
}
void CMakeSetupDialog::DoDataExchange(CDataExchange* pDX)
......@@ -161,11 +114,12 @@ BEGIN_MESSAGE_MAP(CMakeSetupDialog, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_EN_CHANGE(IDC_WhereSource, OnChangeEdit1)
ON_BN_CLICKED(IDC_BUTTON2, OnBrowse)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BuildProjects, OnBuildProjects)
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_BUTTON2, OnBrowseWhereSource)
ON_BN_CLICKED(IDC_BUTTON3, OnBrowseWhereBuild)
ON_BN_CLICKED(IDC_BuildProjects, OnBuildProjects)
ON_EN_CHANGE(IDC_WhereBuild, OnChangeWhereBuild)
ON_EN_CHANGE(IDC_WhereSource, OnChangeWhereSource)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
......@@ -197,13 +151,7 @@ BEGIN_MESSAGE_MAP(CMakeSetupDialog, CDialog)
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
if(m_InitMakefile)
{
this->FillCacheEditorFromCacheManager();
}
m_GUIInitialized = true;
this->LoadCacheFromDiskToGUI();
return TRUE; // return TRUE unless you set the focus to a control
}
......@@ -256,18 +204,8 @@ HCURSOR CMakeSetupDialog::OnQueryDragIcon()
return (HCURSOR) m_hIcon;
}
void CMakeSetupDialog::OnChangeEdit1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CMakeSetupDialog::OnBrowse()
void CMakeSetupDialog::OnBrowseWhereSource()
{
this->UpdateData();
Browse(m_WhereSource, "Enter Path to Insight Source");
......@@ -298,13 +236,8 @@ bool CMakeSetupDialog::Browse(CString &result, const char *title)
return bSuccess;
}
void CMakeSetupDialog::OnOK()
{
CDialog::OnOK();
}
void CMakeSetupDialog::OnButton3()
void CMakeSetupDialog::OnBrowseWhereBuild()
{
this->UpdateData();
Browse(m_WhereBuild, "Enter Path to Insight Build");
......@@ -385,27 +318,45 @@ void CMakeSetupDialog::OnBuildProjects()
::SetCursor(LoadCursor(NULL, IDC_WAIT));
// get all the info from the screen
this->UpdateData();
// re-init the m_Makefile
this->InitMakefile();
// copy the GUI cache values into the cache manager
this->FillCacheManagerFromCacheEditor();
if(!m_BuildPathChanged)
{
// if the build path has not changed save the
// current GUI values to the cache
this->SaveCacheFromGUI();
}
// 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);
makefile.SetHomeOutputDirectory(m_WhereBuild);
makefile.SetStartDirectory(m_WhereSource);
makefile.MakeStartDirectoriesCurrent();
CString makefileIn = m_WhereSource;
makefileIn += "/CMakeLists.txt";
m_Makefile.ReadListFile(makefileIn);
// Move this to the cache editor
m_Makefile.GenerateMakefile();
cmCacheManager::GetInstance()->SaveCache(&m_Makefile);
makefile.ReadListFile(makefileIn);
// Generate the project files
makefile.GenerateMakefile();
// Save the cache
cmCacheManager::GetInstance()->SaveCache(&makefile);
// update the GUI with any new values in the caused by the
// generation process
this->FillCacheEditorFromCacheManager();
this->LoadCacheFromDiskToGUI();
// save source and build paths to registry
this->SaveToRegistry();
// path is not up-to-date
m_BuildPathChanged = false;
::SetCursor(LoadCursor(NULL, IDC_ARROW));
}
// copy from the cache manager to the cache edit list box
void CMakeSetupDialog::FillCacheEditorFromCacheManager()
void CMakeSetupDialog::FillCacheGUIFromCacheManager()
{
// Clear the current GUI
m_CacheEntriesList.RemoveAll();
const cmCacheManager::CacheEntryMap &cache =
cmCacheManager::GetInstance()->GetCacheMap();
for(cmCacheManager::CacheEntryMap::const_iterator i = cache.begin();
......@@ -420,26 +371,26 @@ void CMakeSetupDialog::FillCacheEditorFromCacheManager()
{
m_CacheEntriesList.AddProperty(key,
"ON",
PIT_CHECKBOX,"");
CPropertyList::CHECKBOX,"");
}
else
{
m_CacheEntriesList.AddProperty(key,
"OFF",
PIT_CHECKBOX,"");
CPropertyList::CHECKBOX,"");
}
break;
case cmCacheManager::PATH:
m_CacheEntriesList.AddProperty(key, value.m_Value.c_str(),
PIT_FILE,"");
CPropertyList::PATH,"");
break;
case cmCacheManager::FILEPATH:
m_CacheEntriesList.AddProperty(key, value.m_Value.c_str(),
PIT_FILE,"");
CPropertyList::FILE,"");
break;
case cmCacheManager::STRING:
m_CacheEntriesList.AddProperty(key, value.m_Value.c_str(),
PIT_EDIT,"");
CPropertyList::EDIT,"");
break;
case cmCacheManager::INTERNAL:
break;
......@@ -449,7 +400,7 @@ void CMakeSetupDialog::FillCacheEditorFromCacheManager()
}
// copy from the list box to the cache manager
void CMakeSetupDialog::FillCacheManagerFromCacheEditor()
void CMakeSetupDialog::FillCacheManagerFromCacheGUI()
{
cmCacheManager::GetInstance()->GetCacheMap();
std::set<CPropertyItem*> items = m_CacheEntriesList.GetItems();
......@@ -476,3 +427,46 @@ void CMakeSetupDialog::FillCacheManagerFromCacheEditor()
void CMakeSetupDialog::OnChangeWhereBuild()
{
this->UpdateData();
std::string cachefile = m_WhereBuild;
cachefile += "/CMakeCache.txt";
if(cmSystemTools::FileExists(cachefile.c_str()))
{
m_CacheEntriesList.ShowWindow(SW_SHOW);
this->LoadCacheFromDiskToGUI();
m_BuildPathChanged = true;
}
else
{
m_CacheEntriesList.RemoveAll();
}
}
void CMakeSetupDialog::OnChangeWhereSource()
{
this->UpdateData();
}
//! Load cache file from m_WhereBuild and display in GUI editor
void CMakeSetupDialog::LoadCacheFromDiskToGUI()
{
if(m_WhereBuild != "")
{
cmCacheManager::GetInstance()->LoadCache(m_WhereBuild);
this->FillCacheGUIFromCacheManager();
}
}
//! Save GUI values to cmCacheManager and then save to disk.
void CMakeSetupDialog::SaveCacheFromGUI()
{
this->FillCacheManagerFromCacheGUI();
if(m_WhereBuild != "")
{
cmCacheManager::GetInstance()->SaveCache(m_WhereBuild);
}
}
......@@ -7,7 +7,8 @@
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "../cmMakefile.h"
#include "PropertyList.h"
/////////////////////////////////////////////////////////////////////////////
// CMakeSetupDialog dialog
......@@ -18,10 +19,13 @@ class CMakeSetupDialog : public CDialog
public:
CMakeSetupDialog(CWnd* pParent = NULL); // standard constructor
protected:
bool Browse(CString&, const char* title);
//! Load cache file from m_WhereBuild and display in GUI editor
void LoadCacheFromDiskToGUI();
//! Save GUI values to cmCacheManager and then save to disk.
void SaveCacheFromGUI();
void SaveToRegistry();
void LoadFromRegistry();
void InitMakefile();
bool Browse(CString&, const char* title);
void ReadRegistryValue(HKEY hKey,
CString *val,
const char *key,
......@@ -29,13 +33,9 @@ protected:
// Dialog Data
//{{AFX_DATA(CMakeSetupDialog)
enum { IDD = IDD_CMakeSetupDialog_DIALOG };
cmMakefile m_Makefile;
bool m_InitMakefile;
bool m_GUIInitialized;
CString m_WhereSource;
CString m_WhereBuild;
CString m_WhereSourceLast;
CString m_WhereBuildLast;
bool m_BuildPathChanged;
CPropertyList m_CacheEntriesList;
//}}AFX_DATA
......@@ -48,6 +48,12 @@ protected:
// Implementation
protected:
// copy from the cache manager to the cache edit list box
void FillCacheGUIFromCacheManager();
// copy from the list box to the cache manager
void FillCacheManagerFromCacheGUI();
HICON m_hIcon;
CString m_RegistryKey;
// Generated message map functions
......@@ -56,17 +62,11 @@ protected:
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnChangeEdit1();
afx_msg void OnBrowse();
virtual void OnOK();
afx_msg void OnBrowseWhereSource();
virtual void OnBuildProjects();
afx_msg void OnButton3();
// copy from the cache manager to the cache edit list box
void FillCacheEditorFromCacheManager();
// copy from the list box to the cache manager
void FillCacheManagerFromCacheEditor();
afx_msg void OnBrowseWhereBuild();
afx_msg void OnChangeWhereBuild();
afx_msg void OnChangeWhereSource();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
......
......@@ -4,11 +4,10 @@
#include "stdafx.h"
#include "PropertyList.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define IDC_PROPCMBBOX 712
#define IDC_PROPEDITBOX 713
#define IDC_PROPBTNCTRL 714
#define IDC_PROPCHECKBOXCTRL 715
/////////////////////////////////////////////////////////////////////////////
// CPropertyList
......@@ -154,6 +153,8 @@ int CPropertyList::AddProperty(const char* name,
{
pItem = *p;
pItem->m_Removed = false;
pItem->m_curValue = value;
Invalidate();
}
}
// if it is not found, then create a new one
......@@ -197,7 +198,7 @@ void CPropertyList::OnSelchange()
if (m_CheckBoxControl)
m_CheckBoxControl.ShowWindow(SW_HIDE);
if (pItem->m_nItemType==PIT_COMBO)
if (pItem->m_nItemType==CPropertyList::COMBO)
{
//display the combo box. If the combo box has already been
//created then simply move it to the new location, else create it
......@@ -207,7 +208,9 @@ void CPropertyList::OnSelchange()
else
{
rect.bottom += 100;
m_cmbBox.Create(CBS_DROPDOWNLIST | CBS_NOINTEGRALHEIGHT | WS_VISIBLE | WS_CHILD | WS_BORDER,
m_cmbBox.Create(CBS_DROPDOWNLIST
| CBS_NOINTEGRALHEIGHT | WS_VISIBLE
| WS_CHILD | WS_BORDER,
rect,this,IDC_PROPCMBBOX);
m_cmbBox.SetFont(&m_SSerif8Font);
}
......@@ -237,7 +240,7 @@ void CPropertyList::OnSelchange()
else
m_cmbBox.SetCurSel(0);
}
else if (pItem->m_nItemType==PIT_EDIT)
else if (pItem->m_nItemType==CPropertyList::EDIT)
{
//display edit box
m_nLastBox = 1;
......@@ -247,7 +250,8 @@ void CPropertyList::OnSelchange()
m_editBox.MoveWindow(rect);
else
{
m_editBox.Create(ES_LEFT | ES_AUTOHSCROLL | WS_VISIBLE | WS_CHILD | WS_BORDER,
m_editBox.Create(ES_LEFT | ES_AUTOHSCROLL | WS_VISIBLE
| WS_CHILD | WS_BORDER,
rect,this,IDC_PROPEDITBOX);
m_editBox.SetFont(&m_SSerif8Font);
}
......@@ -259,14 +263,16 @@ void CPropertyList::OnSelchange()
//set the text in the edit box to the property's current value
m_editBox.SetWindowText(lBoxSelText);
}
else if (pItem->m_nItemType == PIT_CHECKBOX)
else if (pItem->m_nItemType == CPropertyList::CHECKBOX)
{
rect.bottom -= 3;
if (m_CheckBoxControl)
m_CheckBoxControl.MoveWindow(rect);
else
{
m_CheckBoxControl.Create("check",BS_CHECKBOX | BM_SETCHECK |BS_LEFTTEXT | WS_VISIBLE | WS_CHILD,
m_CheckBoxControl.Create("check",BS_CHECKBOX
| BM_SETCHECK |BS_LEFTTEXT
| WS_VISIBLE | WS_CHILD,
rect,this,IDC_PROPCHECKBOXCTRL);
m_CheckBoxControl.SetFont(&m_SSerif8Font);
}
......@@ -377,7 +383,7 @@ void CPropertyList::OnButton()
//display the appropriate common dialog depending on what type
//of chooser is associated with the property
if (pItem->m_nItemType == PIT_COLOR)
if (pItem->m_nItemType == CPropertyList::COLOR)
{
COLORREF initClr;
CString currClr = pItem->m_curValue;
......@@ -413,7 +419,7 @@ void CPropertyList::OnButton()
Invalidate();
}
}
else if (pItem->m_nItemType == PIT_FILE)
else if (pItem->m_nItemType == CPropertyList::FILE)
{
CString SelectedFile;
CString Filter("Gif Files (*.gif)|*.gif||");
......@@ -438,7 +444,32 @@ void CPropertyList::OnButton()
Invalidate();
}
}
else if (pItem->m_nItemType == PIT_FONT)
else if (pItem->m_nItemType == CPropertyList::PATH)
{
char szPathName[4096];
BROWSEINFO bi;
bi.hwndOwner = m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = (LPTSTR)szPathName;
bi.lpszTitle = "Select Directory";
bi.ulFlags = BIF_EDITBOX | BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
BOOL bSuccess = SHGetPathFromIDList(pidl, szPathName);
CString SelectedFile;
if(bSuccess)
{
SelectedFile = szPathName;
m_btnCtrl.ShowWindow(SW_HIDE);
pItem->m_curValue = SelectedFile;
m_Dirty = true;
Invalidate();
}
}
else if (pItem->m_nItemType == CPropertyList::FONT)
{
CFontDialog FontDlg(NULL,CF_EFFECTS | CF_SCREENFONTS,NULL,this);
......@@ -598,3 +629,14 @@ void CPropertyList::OnDelete()
Invalidate();
}
void CPropertyList::RemoveAll()
{
int c = this->GetCount();
for(int i =0; i < c; ++i)
{
CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(0);
pItem->m_Removed = true;
this->DeleteString(0);
}
Invalidate();
}
#if !defined(AFX_PROPERTYLIST_H__74205380_1B56_11D4_BC48_00105AA2186F__INCLUDED_)
#define AFX_PROPERTYLIST_H__74205380_1B56_11D4_BC48_00105AA2186F__INCLUDED_
#ifndef CPROPERTYLIST_H
#define CPROPERTYLIST_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PropertyList.h : header file
//
#define PIT_COMBO 0 //PIT = property item type
#define PIT_EDIT 1
#define PIT_COLOR 2
#define PIT_FONT 3
#define PIT_FILE 4
#define PIT_CHECKBOX 5
#define IDC_PROPCMBBOX 712
#define IDC_PROPEDITBOX 713
#define IDC_PROPBTNCTRL 714
#define IDC_PROPCHECKBOXCTRL 715
#include "../cmStandardIncludes.h"
......@@ -51,6 +35,16 @@ class CPropertyList : public CListBox
{
// Construction
public:
enum ItemType
{
COMBO = 0,
EDIT,
COLOR,
FONT,
FILE,
CHECKBOX,
PATH
};
CPropertyList();
// Attributes
......@@ -67,7 +61,7 @@ public:
{
return m_PropertyItems;
}
void RemoveAll();
CPropertyItem* GetItem(int index);
// Overrides
// ClassWizard generated virtual function overrides
......@@ -76,7 +70,6 @@ public:
virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
protected:
int AddPropItem(CPropertyItem* pItem);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
......@@ -85,7 +78,7 @@ protected:
public:
virtual ~CPropertyList();
// Generated message map functions
// Generated message map functions
protected:
//{{AFX_MSG(CPropertyList)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
......@@ -104,12 +97,11 @@ protected:
afx_msg void OnDelete();
afx_msg void OnCheckBox();
DECLARE_MESSAGE_MAP()
void InvertLine(CDC* pDC,CPoint ptFrom,CPoint ptTo);
void DisplayButton(CRect region);
int AddPropItem(CPropertyItem* pItem);
CComboBox m_cmbBox;
CEdit m_editBox;
......
......@@ -27,7 +27,7 @@ cmCustomCommand.o \
cmCacheManager.o \
cmSourceGroup.o
DEPENDS = $(srcdir)/*.h $(srcdir)/*.cxx ${CMAKE_CONFIG_DIR}/CMake/Source/cmConfigure.h
DEPENDS = $(srcdir)/*.h ${CMAKE_CONFIG_DIR}/CMake/Source/cmConfigure.h
cmCollectFlags.o : $(DEPENDS)
CMakeBuildTargets.o : $(DEPENDS)
......@@ -40,7 +40,7 @@ cmSourceFile.o : $(DEPENDS)
cmDirectory.o : $(DEPENDS)
cmCustomCommand.o : $(DEPENDS)
cmUnixMakefileGenerator.o : $(DEPENDS)
cmCommands.o : $(DEPENDS)
cmCommands.o : $(DEPENDS) $(srcdir)/*.cxx
cmTarget.o : $(DEPENDS)
cmCacheManager.o : $(DEPENDS)
cmSourceGroup.o : $(DEPENDS)
......
......@@ -59,7 +59,13 @@ cmCacheManager* cmCacheManager::GetInstance()
bool cmCacheManager::LoadCache(cmMakefile* mf)
{
std::string cacheFile = mf->GetHomeOutputDirectory();
return this->LoadCache(mf->GetHomeOutputDirectory());
}
bool cmCacheManager::LoadCache(const char* path)