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

This commit is contained in:
Bill Hoffman 2001-04-25 16:09:17 -04:00
parent 61091234c3
commit 5c83326fb4
11 changed files with 234 additions and 206 deletions

View File

@ -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()
};

View File

@ -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

View File

@ -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);
}
}

View File

@ -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()
};

View File

@ -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();
}

View File

@ -1,23 +1,7 @@
#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;

View File

@ -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)

View File

@ -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)
{
std::string cacheFile = path;
cacheFile += "/CMakeCache.txt";
// clear the old cache
m_Cache.clear();
@ -98,7 +104,13 @@ bool cmCacheManager::LoadCache(cmMakefile* mf)
bool cmCacheManager::SaveCache(cmMakefile* mf) const
{
std::string cacheFile = mf->GetHomeOutputDirectory();
return this->SaveCache(mf->GetHomeOutputDirectory());
}
bool cmCacheManager::SaveCache(const char* path) const
{
std::string cacheFile = path;
cacheFile += "/CMakeCache.txt";
std::string tempFile = cacheFile;
tempFile += ".tmp";
@ -110,6 +122,7 @@ bool cmCacheManager::SaveCache(cmMakefile* mf) const
return false;
}
fout << "# This is the CMakeCache file.\n"
<< "# For build in directory: " << path << "\n"
<< "# You can edit this file to change values found and used by cmake.\n"
<< "# If you do not want to change any of the values, simply exit the editor.\n"
<< "# If you do want to change a value, simply edit, save, and exit the editor.\n"

View File

@ -50,10 +50,14 @@ public:
//! Load a cache for given makefile. Loads from ouput home.
bool LoadCache(cmMakefile*);
bool LoadCache(cmMakefile*);
//! Load a cache for given makefile. Loads from path/CMakeCache.txt.
bool LoadCache(const char* path);
//! Save cache for given makefile. Saves to ouput home CMakeCache.txt
//! Save cache for given makefile. Saves to ouput home CMakeCache.txt.
bool SaveCache(cmMakefile*) const;
//! Save cache for given makefile. Saves to ouput path/CMakeCache.txt
bool SaveCache(const char* path) const;
//! Add an entry into the cache
void AddCacheEntry(const char* key, const char* value, CacheEntryType type);

View File

@ -609,6 +609,37 @@ void cmMakefile::GenerateCacheOnly()
{
std::vector<cmMakefile*> makefiles;
this->FindSubDirectoryCMakeListsFiles(makefiles);
for(std::vector<cmMakefile*>::iterator i = makefiles.begin();
i != makefiles.end(); ++i)
{
cmMakefile* mf = *i;
std::string source = mf->GetHomeDirectory();
source += "/CMake/CMakeMakefileTemplate.in";
cmSystemTools::MakeDirectory(mf->GetStartOutputDirectory());
std::string dest = mf->GetStartOutputDirectory();
dest += "/Makefile";
std::ofstream fout(dest.c_str());
if(!fout)
{
cmSystemTools::Error("Failed to open file for write " , dest.c_str());
}
else
{
if(strcmp(mf->GetHomeDirectory(),
mf->GetHomeOutputDirectory()) == 0)
{
fout << "srcdir = .\n\n";
}
else
{
fout << "srcdir = " << mf->GetStartDirectory() << "\n";
fout << "VPATH = " << mf->GetStartDirectory() << "\n";
}
}
fout << "include "
<< mf->GetHomeOutputDirectory() << "/CMake/CMakeMaster.make\n";
}
for(unsigned int i =0; i < makefiles.size(); ++i)
{
delete makefiles[i];

View File

@ -573,53 +573,6 @@ AC_CONFIG_SUBDIRS(Code/Numerics/vxl/vcl)
# and any sub directories recursivley
#
echo "Searching CMakeLists.txt files for all sub directories"
# the result of a the directories found is stored in allDirs
allDirs=
# start looking in the current directory .
searchDirs=$srcdir
# loop until the flag dirHasListsFile is set to falls
dirHasListsFile=:
while $dirHasListsFile; do
# reset the varible used to store the full paths to the directory
# outside the for loop
fullPathDirs=
# loop over all directorirs in the current searchDirs varible
for currentDir in $searchDirs;do
# look for a CMakeLists.txt file in the current directory
if test -e$currentDir/CMakeLists.txt; then
# extract the SUBDIRS varible from the CMakeLists.txt file
dirsInListsFile=`cat $currentDir/CMakeLists.txt | sed -e :a -e '/SUBDIRS.*\\\\$/N; s/\\\\\\n//; ta' | grep SUBDIRS | sed -e "s/SUBDIRS//g; s/(//g;s/)//g" `
# add the current directory to any sub dirs found
# in the above search of CMakeLists.txt
for subdir in $dirsInListsFile;do
fullPathDirs="$fullPathDirs $currentDir/$subdir"
allDirs="$allDirs $currentDir/$subdir"
done
fi
done
# now get ready to search any directories found in the above for loop
searchDirs=$fullPathDirs
# check to see if searchDirs is emtpy
if test "x$searchDirs" = x; then
dirHasListsFile=false
fi
done # continue while loop until dirHasListsFile=false
if test "x$srcdir" = x.; then
allDirs=`echo $allDirs | sed -e "s|\./||g"`
else
allDirs=`echo $allDirs | sed -e "s|$srcdir/||g"`
fi
SUBDIR_MAKEFILES=`echo $allDirs | sed -e 's|\\([[A-Za-z0-9_/]][[A-Za-z0-9_/]]*\\)|\1/Makefile:CMake/CMakeMakefileTemplate.in|g'`
SUBDIR_CMAKE_TARGETS=`echo $allDirs | sed -e 's|\\([[A-Za-z0-9_/]][[A-Za-z0-9_/]]*\\)|\1/CMakeTargets.make:CMake/CMakeTargets.make.in|g'`
#
# *****************************************
# end of extract SUBDIRS out of CMakeLists.txt files
#
#
# Build two variables (SITE, INSTANCE) used for setting up testing
#
@ -673,8 +626,6 @@ CMake/CMakeVariables.make
CMake/CMakeRules.make
CMake/Source/CMakeTargets.make:CMake/dummy.in
CMake/Source/Makefile
$SUBDIR_MAKEFILES
$SUBDIR_CMAKE_TARGETS
)