summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/CMakeLib.dsp6
-rw-r--r--Source/MFCDialog/CMakeSetup.rc24
-rw-r--r--Source/MFCDialog/CMakeSetupDialog.cpp48
-rw-r--r--Source/MFCDialog/CMakeSetupDialog.h3
-rw-r--r--Source/MFCDialog/resource.h4
-rw-r--r--Source/cmBorlandMakefileGenerator.cpp622
-rw-r--r--Source/cmBorlandMakefileGenerator.h128
-rw-r--r--Source/cmMSProjectGenerator.h35
-rw-r--r--Source/cmMakefileGenerator.cxx45
-rw-r--r--Source/cmMakefileGenerator.h18
-rw-r--r--Source/cmUnixMakefileGenerator.h7
-rw-r--r--Source/cmake.cxx127
-rw-r--r--Source/cmake.h4
-rw-r--r--Templates/CMakeWindowsBorlandConfig.cmake14
14 files changed, 708 insertions, 377 deletions
diff --git a/Source/CMakeLib.dsp b/Source/CMakeLib.dsp
index 30996b2..215ccf9 100644
--- a/Source/CMakeLib.dsp
+++ b/Source/CMakeLib.dsp
@@ -65,7 +65,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /Gi- /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
@@ -91,6 +91,10 @@ SOURCE=.\cmake.cxx
# End Source File
# Begin Source File
+SOURCE=.\cmBorlandMakefileGenerator.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\cmCableClassSet.cxx
# End Source File
# Begin Source File
diff --git a/Source/MFCDialog/CMakeSetup.rc b/Source/MFCDialog/CMakeSetup.rc
index 20ca197..6cbe57e 100644
--- a/Source/MFCDialog/CMakeSetup.rc
+++ b/Source/MFCDialog/CMakeSetup.rc
@@ -85,32 +85,34 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP
END
-IDD_CMakeSetupDialog_DIALOG DIALOGEX 0, 0, 376, 225
+IDD_CMakeSetupDialog_DIALOG DIALOGEX 0, 0, 389, 225
STYLE WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU | WS_THICKFRAME
EXSTYLE WS_EX_APPWINDOW
CAPTION "CMakeSetupDialog"
FONT 8, "MS Sans Serif"
BEGIN
- COMBOBOX IDC_WhereSource,147,6,135,66,CBS_DROPDOWN |
+ COMBOBOX IDC_WhereSource,96,6,133,66,CBS_DROPDOWN |
CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
- PUSHBUTTON "Browse...",IDC_BUTTON2,286,5,43,13
- COMBOBOX IDC_WhereBuild,148,26,133,68,CBS_DROPDOWN |
+ PUSHBUTTON "Browse...",IDC_BUTTON2,230,6,34,13
+ COMBOBOX IDC_WhereBuild,96,26,133,68,CBS_DROPDOWN |
CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
- PUSHBUTTON "Browse...",IDC_BUTTON3,286,25,43,13
+ PUSHBUTTON "Browse...",IDC_BUTTON3,230,25,34,13
DEFPUSHBUTTON "Configure",IDC_BuildProjects,88,202,67,15
PUSHBUTTON "Cancel",IDCANCEL,220,201,67,15
- LISTBOX IDC_LIST2,15,55,344,122,LBS_OWNERDRAWVARIABLE |
+ LISTBOX IDC_LIST2,15,55,356,122,LBS_OWNERDRAWVARIABLE |
LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
WS_HSCROLL
- RTEXT "Where is the source code:",IDC_STATIC,52,6,86,9
- RTEXT "Where do you want to build the binaries:",IDC_STATIC,10,
- 27,128,9
- GROUPBOX "Cache Values",IDC_FRAME,9,43,356,141
+ RTEXT "Where is the source code:",IDC_STATIC,6,7,86,9
+ RTEXT "Where to build the binaries:",IDC_STATIC,5,27,90,9
+ GROUPBOX "Cache Values",IDC_FRAME,9,43,369,141
CTEXT "Right click on cache entries for additional options",
IDC_MouseHelpCaption,106,189,156,8
LTEXT "Static",IDC_CMAKE_VERSION,3,211,58,13,SS_CENTERIMAGE
PUSHBUTTON "OK",IDC_OK,160,202,56,14
+ COMBOBOX IDC_Generator,275,25,103,50,CBS_DROPDOWN | CBS_SORT |
+ WS_VSCROLL | WS_TABSTOP
+ LTEXT "Build For:",IDC_GeneratorLabel,279,10,103,12
END
@@ -175,7 +177,7 @@ BEGIN
IDD_CMakeSetupDialog_DIALOG, DIALOG
BEGIN
- RIGHTMARGIN, 375
+ RIGHTMARGIN, 388
END
END
#endif // APSTUDIO_INVOKED
diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp
index d66f8aa..ebb2c02 100644
--- a/Source/MFCDialog/CMakeSetupDialog.cpp
+++ b/Source/MFCDialog/CMakeSetupDialog.cpp
@@ -8,6 +8,7 @@
#include "CMakeCommandLineInfo.h"
#include "../cmCacheManager.h"
#include "../cmake.h"
+#include "../cmMakefileGenerator.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
@@ -72,6 +73,7 @@ CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo,
//{{AFX_DATA_INIT(CMakeSetupDialog)
m_WhereSource = cmdInfo.m_WhereSource;
m_WhereBuild = cmdInfo.m_WhereBuild;
+ m_GeneratorChoiceString = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
@@ -92,6 +94,7 @@ void CMakeSetupDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMakeSetupDialog)
+ DDX_Control(pDX, IDC_Generator, m_GeneratorChoice);
DDX_Control(pDX, IDC_OK, m_OKButton);
DDX_Control(pDX, IDCANCEL, m_CancelButton);
DDX_CBStringExact(pDX, IDC_WhereSource, m_WhereSource);
@@ -103,6 +106,7 @@ void CMakeSetupDialog::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_MouseHelpCaption, m_MouseHelp);
DDX_Control(pDX, IDC_CMAKE_VERSION, m_VersionDisplay);
DDX_Control(pDX, IDC_BuildProjects, m_Configure);
+ DDX_CBStringExact(pDX, IDC_Generator, m_GeneratorChoiceString);
//}}AFX_DATA_MAP
}
@@ -120,8 +124,9 @@ BEGIN_MESSAGE_MAP(CMakeSetupDialog, CDialog)
ON_CBN_SELENDOK(IDC_WhereSource, OnSelendokWhereSource)
ON_WM_SIZE()
ON_WM_GETMINMAXINFO()
- ON_BN_CLICKED(IDCANCEL, OnCancel)
ON_BN_CLICKED(IDC_OK, OnOk)
+ ON_BN_CLICKED(IDCANCEL, OnCancel)
+ ON_CBN_EDITCHANGE(IDC_Generator, OnEditchangeGenerator)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -156,10 +161,22 @@ BOOL CMakeSetupDialog::OnInitDialog()
SetIcon(m_hIcon, FALSE); // Set small icon
// Load source and build dirs from registry
this->LoadFromRegistry();
+ cmake m; // force a register of generators
+ std::vector<std::string> names;
+ cmMakefileGenerator::GetRegisteredGenerators(names);
+ for(std::vector<std::string>::iterator i = names.begin();
+ i != names.end(); ++i)
+ {
+ m_GeneratorChoice.AddString(i->c_str());
+ }
+ m_GeneratorChoiceString = "Visual Studio 6";
+
// try to load the cmake cache from disk
this->LoadCacheFromDiskToGUI();
m_WhereBuildControl.LimitText(2048);
m_WhereSourceControl.LimitText(2048);
+ m_GeneratorChoice.LimitText(2048);
+
// Set the version number
char tmp[1024];
sprintf(tmp,"Version %d.%d", cmMakefile::GetMajorVersion(),
@@ -435,6 +452,9 @@ void CMakeSetupDialog::RunCMake(bool generateProjectFiles)
arg = "-B";
arg += m_WhereBuild;
args.push_back(arg);
+ arg = "-G";
+ arg += m_GeneratorChoiceString;
+ args.push_back(arg);
// run the generate process
if(make.Generate(args, generateProjectFiles) != 0)
{
@@ -617,6 +637,26 @@ void CMakeSetupDialog::LoadCacheFromDiskToGUI()
{
cmCacheManager::GetInstance()->LoadCache(m_WhereBuild);
this->FillCacheGUIFromCacheManager();
+ if(cmCacheManager::GetInstance()->GetCacheEntry("CMAKE_GENERATOR"))
+ {
+ std::string curGen =
+ cmCacheManager::GetInstance()->GetCacheEntry("CMAKE_GENERATOR")->m_Value;
+ if(m_GeneratorChoiceString != curGen.c_str())
+ {
+ m_GeneratorChoiceString = curGen.c_str();
+ this->UpdateData(FALSE);
+ // m_GeneratorChoice.SetWindowText(m_GeneratorChoiceString);
+// int c = m_GeneratorChoice.GetCount();
+// int j = m_GeneratorChoice.FindStringExact(0, curGen.c_str());
+// if (j != CB_ERR)
+// {
+// m_GeneratorChoice.SetCurSel(j);
+// }
+
+// m_GeneratorChoice.SelectString(0, curGen.c_str());
+// this->UpdateData(FALSE);
+ }
+ }
}
}
@@ -735,3 +775,9 @@ void CMakeSetupDialog::OnOk()
this->RunCMake(true);
CDialog::OnOK();
}
+
+void CMakeSetupDialog::OnEditchangeGenerator()
+{
+ // TODO: Add your control notification handler code here
+
+}
diff --git a/Source/MFCDialog/CMakeSetupDialog.h b/Source/MFCDialog/CMakeSetupDialog.h
index f2fdd9d..7cac124 100644
--- a/Source/MFCDialog/CMakeSetupDialog.h
+++ b/Source/MFCDialog/CMakeSetupDialog.h
@@ -36,6 +36,7 @@ protected:
// Dialog Data
//{{AFX_DATA(CMakeSetupDialog)
enum { IDD = IDD_CMakeSetupDialog_DIALOG };
+ CComboBox m_GeneratorChoice;
CButton m_OKButton;
CButton m_CancelButton;
CString m_WhereSource;
@@ -48,6 +49,7 @@ protected:
CStatic m_MouseHelp;
CStatic m_VersionDisplay;
CButton m_Configure;
+ CString m_GeneratorChoiceString;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
@@ -85,6 +87,7 @@ protected:
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI );
afx_msg void OnOk();
+ afx_msg void OnEditchangeGenerator();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
diff --git a/Source/MFCDialog/resource.h b/Source/MFCDialog/resource.h
index b899c8b..69dfa66 100644
--- a/Source/MFCDialog/resource.h
+++ b/Source/MFCDialog/resource.h
@@ -18,6 +18,8 @@
#define IDC_FRAME 1015
#define IDC_MouseHelpCaption 1016
#define IDC_OK 1018
+#define IDC_Generator 1019
+#define IDC_GeneratorLabel 1020
// Next default values for new objects
//
@@ -25,7 +27,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 133
#define _APS_NEXT_COMMAND_VALUE 32771
-#define _APS_NEXT_CONTROL_VALUE 1019
+#define _APS_NEXT_CONTROL_VALUE 1021
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/Source/cmBorlandMakefileGenerator.cpp b/Source/cmBorlandMakefileGenerator.cpp
index b6ac1af..0448f24 100644
--- a/Source/cmBorlandMakefileGenerator.cpp
+++ b/Source/cmBorlandMakefileGenerator.cpp
@@ -5,62 +5,113 @@
#include "cmSourceFile.h"
#include "cmMakeDepend.h"
#include "cmCacheManager.h"
-#include <Sysutils.hpp>
-using namespace std;
//---------------------------------------------------------------------------
-cmBorlandMakefileGenerator::cmBorlandMakefileGenerator() {
+cmBorlandMakefileGenerator::cmBorlandMakefileGenerator()
+{
m_CacheOnly = false;
m_Recurse = false;
}
//---------------------------------------------------------------------------
-void cmBorlandMakefileGenerator::GenerateMakefile() {
- if (m_CacheOnly) {
+void cmBorlandMakefileGenerator::GenerateMakefile()
+{
+ // suppoirt override in output directories
+ if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"))
+ {
+ m_LibraryOutputPath = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH");
+ if(m_LibraryOutputPath.size())
+ {
+ if(m_LibraryOutputPath[m_LibraryOutputPath.size() -1] != '/')
+ {
+ m_LibraryOutputPath += "/";
+ }
+ if(!cmSystemTools::MakeDirectory(m_LibraryOutputPath.c_str()))
+ {
+ cmSystemTools::Error("Error failed create "
+ "LIBRARY_OUTPUT_PATH directory:",
+ m_LibraryOutputPath.c_str());
+ }
+ m_Makefile->AddLinkDirectory(m_LibraryOutputPath.c_str());
+ }
+ }
+ if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
+ {
+ m_ExecutableOutputPath =
+ m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
+ if(m_ExecutableOutputPath.size())
+ {
+ if(m_ExecutableOutputPath[m_ExecutableOutputPath.size() -1] != '/')
+ {
+ m_ExecutableOutputPath += "/";
+ }
+ if(!cmSystemTools::MakeDirectory(m_ExecutableOutputPath.c_str()))
+ {
+ cmSystemTools::Error("Error failed to create "
+ "EXECUTABLE_OUTPUT_PATH directory:",
+ m_ExecutableOutputPath.c_str());
+ }
+ m_Makefile->AddLinkDirectory(m_ExecutableOutputPath.c_str());
+ }
+ }
+
+ if (m_CacheOnly)
+ {
// Generate the cache only stuff
this->GenerateCacheOnly();
// if recurse then generate for all sub- makefiles
- if (m_Recurse) {
+ if (m_Recurse)
+ {
this->RecursiveGenerateCacheOnly();
+ }
}
- }
}
//---------------------------------------------------------------------------
-void cmBorlandMakefileGenerator::GenerateCacheOnly() {
+void cmBorlandMakefileGenerator::GenerateCacheOnly()
+{
cmSystemTools::MakeDirectory(m_Makefile->GetStartOutputDirectory());
- string dest = m_Makefile->GetStartOutputDirectory();
+ std::string dest = m_Makefile->GetStartOutputDirectory();
dest += "/makefile.mak";
this->OutputMakefile(dest.c_str());
}
//---------------------------------------------------------------------------
-void cmBorlandMakefileGenerator::RecursiveGenerateCacheOnly() {
- vector<cmMakefile*> makefiles;
+void cmBorlandMakefileGenerator::RecursiveGenerateCacheOnly()
+{
+ std::vector<cmMakefile*> makefiles;
m_Makefile->FindSubDirectoryCMakeListsFiles(makefiles);
- for (vector<cmMakefile*>::iterator i=makefiles.begin(); i!=makefiles.end(); ++i) {
+ for (std::vector<cmMakefile*>::iterator i=makefiles.begin();
+ i!=makefiles.end(); ++i)
+ {
cmMakefile* mf = *i;
cmBorlandMakefileGenerator* gen = new cmBorlandMakefileGenerator;
gen->SetCacheOnlyOn();
gen->SetRecurseOff();
mf->SetMakefileGenerator(gen);
mf->GenerateMakefile();
- }
+ }
// CLEAN up the makefiles created
- for (unsigned int i=0; i<makefiles.size(); ++i) {
+ for (unsigned int i=0; i<makefiles.size(); ++i)
+ {
delete makefiles[i];
- }
+ }
}
//---------------------------------------------------------------------------
-void cmBorlandMakefileGenerator::OutputMakefile(const char* file) {
+void cmBorlandMakefileGenerator::OutputMakefile(const char* file)
+{
//
// Create sub directories for aux source directories
//
- vector<string>& auxSourceDirs = m_Makefile->GetAuxSourceDirectories();
- if ( auxSourceDirs.size() ) {
+ std::vector<std::string>& auxSourceDirs =
+ m_Makefile->GetAuxSourceDirectories();
+ if ( auxSourceDirs.size() )
+ {
// For the case when this is running as a remote build
// on unix, make the directory
- for (vector<string>::iterator i=auxSourceDirs.begin(); i!=auxSourceDirs.end(); ++i) {
+ for (std::vector<std::string>::iterator i=auxSourceDirs.begin();
+ i!=auxSourceDirs.end(); ++i)
+ {
cmSystemTools::MakeDirectory(i->c_str());
+ }
}
- }
- ostrstream fout;
+ std::ostrstream fout;
//
// Begin writing to makefile.mak
//
@@ -72,16 +123,18 @@ void cmBorlandMakefileGenerator::OutputMakefile(const char* file) {
//
// Define all our compile and make flags/variables
//
- string replace;
+ std::string replace;
// Careful with these directory paths....\ vs /
replace = "BCBBINPATH = @BCB_BIN_PATH@ \n";
fout << m_Makefile->ExpandVariablesInString(replace);
replace = "BCB = $(BCBBINPATH)/.. \n";
fout << m_Makefile->ExpandVariablesInString(replace);
replace = "OUTDIRLIB = @LIBRARY_OUTPUT_PATH@ \n";
- fout << cmSystemTools::ConvertToWindowsSlashes(m_Makefile->ExpandVariablesInString(replace));
+ m_Makefile->ExpandVariablesInString(replace);
+ fout << cmSystemTools::ConvertToWindowsSlashes(replace);
replace = "OUTDIREXE = @EXECUTABLE_OUTPUT_PATH@ \n";
- fout << m_Makefile->ExpandVariablesInString(replace);
+ m_Makefile->ExpandVariablesInString(replace);
+ fout << cmSystemTools::ConvertToWindowsSlashes(replace);
replace = "USERDEFINES = @DEFS_USER@ \n";
fout << m_Makefile->ExpandVariablesInString(replace);
replace = "SYSDEFINES = @DEFS_SYS@ \n";
@@ -111,19 +164,22 @@ void cmBorlandMakefileGenerator::OutputMakefile(const char* file) {
//
// create a make variable with all of the sources for this makefile for depend purposes.
//
- vector<string> lfiles = m_Makefile->GetListFiles();
+ std::vector<std::string> lfiles = m_Makefile->GetListFiles();
// sort the array
- sort(lfiles.begin(), lfiles.end(), less<string>());
+ std::sort(lfiles.begin(), lfiles.end(), std::less<std::string>());
// remove duplicates
- vector<string>::iterator new_end = unique(lfiles.begin(), lfiles.end());
+ std::vector<std::string>::iterator new_end =
+ std::unique(lfiles.begin(), lfiles.end());
lfiles.erase(new_end, lfiles.end());
fout << "CMAKE_MAKEFILE_SOURCES = \\ \n";
- string dir;
- for (vector<string>::const_iterator i=lfiles.begin(); i!=lfiles.end(); ++i) {
+ std::string dir;
+ for (std::vector<std::string>::const_iterator i=lfiles.begin();
+ i!=lfiles.end(); ++i)
+ {
dir = *i;
cmSystemTools::ConvertToWindowsSlashes(dir);
fout << " " << dir << " \\\n";
- }
+ }
dir = m_Makefile->GetHomeOutputDirectory();
dir += "/CMakeCache.txt";
cmSystemTools::ConvertToWindowsSlashes(dir);
@@ -131,125 +187,156 @@ void cmBorlandMakefileGenerator::OutputMakefile(const char* file) {
//
// Output Include paths
//
- vector<string>& includes = m_Makefile->GetIncludeDirectories();
+ std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
fout << "INCLUDEPATH =";
- for (vector<string>::iterator i=includes.begin(); i!=includes.end(); ++i) {
- string include = *i;
+ for (std::vector<std::string>::iterator i=includes.begin();
+ i!=includes.end(); ++i)
+ {
+ std::string include = *i;
fout << "-I" << cmSystemTools::EscapeSpaces(i->c_str()) << "; \\\n ";
- }
- fout << "-I" << cmSystemTools::EscapeSpaces(m_Makefile->GetStartDirectory()) << "\n\n";
+ }
+ fout << "-I" <<
+ cmSystemTools::EscapeSpaces(m_Makefile->GetStartDirectory()) << "\n\n";
//
// for each target add to the list of targets
//
fout << "TARGETS = ";
const cmTargets &tgts = m_Makefile->GetTargets();
// list libraries first
- for (cmTargets::const_iterator l=tgts.begin(); l!=tgts.end(); l++) {
- if ((l->second.GetType() == cmTarget::STATIC_LIBRARY) && l->second.IsInAll()) {
+ for (cmTargets::const_iterator l=tgts.begin();
+ l!=tgts.end(); ++l)
+ {
+ if ((l->second.GetType() == cmTarget::STATIC_LIBRARY)
+ && l->second.IsInAll())
+ {
fout << " \\\n $(OUTDIRLIB)\\" << l->first.c_str() << ".lib";
- }
- if ((l->second.GetType() == cmTarget::SHARED_LIBRARY) && l->second.IsInAll()) {
+ }
+ if ((l->second.GetType() == cmTarget::SHARED_LIBRARY) && l->second.IsInAll())
+ {
fout << " \\\n $(OUTDIRLIB)\\" << l->first.c_str() << ".dll";
- }
- if ((l->second.GetType() == cmTarget::MODULE_LIBRARY) && l->second.IsInAll()) {
+ }
+ if ((l->second.GetType() == cmTarget::MODULE_LIBRARY) && l->second.IsInAll())
+ {
fout << " \\\n $(OUTDIRLIB)\\" << l->first.c_str() << ".bpl";
+ }
}
- }
// executables
- for (cmTargets::const_iterator l=tgts.begin(); l!=tgts.end(); l++) {
- if ((l->second.GetType() == cmTarget::EXECUTABLE || l->second.GetType() == cmTarget::WIN32_EXECUTABLE) && l->second.IsInAll()) {
+ for (cmTargets::const_iterator l=tgts.begin(); l!=tgts.end(); l++)
+ {
+ if ((l->second.GetType() == cmTarget::EXECUTABLE
+ || l->second.GetType() == cmTarget::WIN32_EXECUTABLE) && l->second.IsInAll())
+ {
fout << " \\\n " << l->first.c_str() << ".exe";
+ }
}
- }
// list utilities last
- for (cmTargets::const_iterator l=tgts.begin(); l!=tgts.end(); l++) {
- if (l->second.GetType() == cmTarget::UTILITY && l->second.IsInAll()) {
+ for (cmTargets::const_iterator l=tgts.begin(); l!=tgts.end(); l++)
+ {
+ if (l->second.GetType() == cmTarget::UTILITY && l->second.IsInAll())
+ {
fout << " \\\n " << l->first.c_str();
+ }
}
- }
fout << "\n\n";
//
// Now create the source file groups for each target
//
- for (cmTargets::const_iterator l=tgts.begin(); l!=tgts.end(); l++) {
- vector<cmSourceFile> classes = l->second.GetSourceFiles();
- if (classes.begin() != classes.end()) {
- fout << l->first << "_SRC_OBJS = ";
- for (vector<cmSourceFile>::iterator i=classes.begin(); i!=classes.end(); i++) {
- string ext = i->GetSourceExtension();
- if (!i->IsAHeaderFileOnly() && (ext!="def" && ext!="rc")) {
- fout << " \\\n " << cmSystemTools::ConvertToWindowsSlashes(i->GetSourceName()) << ".obj ";
+ for (cmTargets::const_iterator l=tgts.begin(); l!=tgts.end(); l++)
+ {
+ std::vector<cmSourceFile> classes = l->second.GetSourceFiles();
+ if (classes.begin() != classes.end())
+ {
+ fout << l->first << "_SRC_OBJS = ";
+ for (std::vector<cmSourceFile>::iterator i=classes.begin(); i!=classes.end(); i++)
+ {
+ std::string ext = i->GetSourceExtension();
+ if (!i->IsAHeaderFileOnly() && (ext!="def" && ext!="rc"))
+ {
+ fout << " \\\n " <<
+ cmSystemTools::ConvertToWindowsSlashes(i->GetSourceName())
+ << ".obj ";
+ }
}
+ fout << "\n\n";
}
- fout << "\n\n";
}
- }
//
// Create the link lib list for each target
//
// do .lib files
- string libname;
- for (cmTargets::const_iterator t=tgts.begin(); t!=tgts.end(); t++) {
- cmTarget::LinkLibraries& libs = t->second.GetLinkLibraries();
-
+ std::string libname;
+ for (cmTargets::const_iterator t=tgts.begin(); t!=tgts.end(); t++)
+ {
+ cmTarget::LinkLibraries const& libs = t->second.GetLinkLibraries();
+
if ((t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
(t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
(t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
(t->second.GetType() == cmTarget::EXECUTABLE) ||
(t->second.GetType() == cmTarget::WIN32_EXECUTABLE))
- {
- fout << t->first << "_LINK_LIB = ";
- for (cmTarget::LinkLibraries::const_iterator l=libs.begin(); l!=libs.end(); l++) {
- if ((t->first!=l->first) &&
- (t->second.GetType()!=cmTarget::INSTALL_FILES || t->second.GetType()!=cmTarget::INSTALL_PROGRAMS)) {
- // if this lib is not a target then don't add OUTDIRLIB to it
- if (tgts.find(l->first)==tgts.end())
- libname = l->first;
- else
- libname = "$(OUTDIRLIB)\\" + l->first;
- if (libname.find(".bpi")!=string::npos) continue;
- cmSystemTools::ReplaceString(libname, ".lib", "");
- libname += ".lib";
- fout << " \\\n " << cmSystemTools::EscapeSpaces(libname.c_str());
+ {
+ fout << t->first << "_LINK_LIB = ";
+ for (cmTarget::LinkLibraries::const_iterator l=libs.begin();
+ l!=libs.end(); l++)
+ {
+ if ((t->first!=l->first) &&
+ (t->second.GetType()!=cmTarget::INSTALL_FILES
+ || t->second.GetType()!=cmTarget::INSTALL_PROGRAMS))
+ {
+ // if this lib is not a target then don't add OUTDIRLIB to it
+ if (tgts.find(l->first)==tgts.end())
+ libname = l->first;
+ else
+ libname = "$(OUTDIRLIB)\\" + l->first;
+ if (libname.find(".bpi")!=std::string::npos) continue;
+ cmSystemTools::ReplaceString(libname, ".lib", "");
+ libname += ".lib";
+ fout << " \\\n " << cmSystemTools::EscapeSpaces(libname.c_str());
}
}
- fout << "\n\n";
+ fout << "\n\n";
+ }
}
- }
// do .bpi package files
- for (cmTargets::const_iterator t=tgts.begin(); t!=tgts.end(); t++) {
- cmTarget::LinkLibraries& libs = t->second.GetLinkLibraries();
+ for (cmTargets::const_iterator t=tgts.begin(); t!=tgts.end(); t++)
+ {
+ cmTarget::LinkLibraries const& libs = t->second.GetLinkLibraries();
if ((t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
(t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
(t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
(t->second.GetType() == cmTarget::EXECUTABLE) ||
(t->second.GetType() == cmTarget::WIN32_EXECUTABLE))
- {
- fout << t->first << "_LINK_BPI = ";
- for (cmTarget::LinkLibraries::const_iterator l=libs.begin(); l!=libs.end(); l++) {
- if ((t->first!=l->first) &&
- (t->second.GetType()!=cmTarget::INSTALL_FILES || t->second.GetType()!=cmTarget::INSTALL_PROGRAMS)) {
- // if this lib is not a target then don't add OUTDIRLIB to it
- if (tgts.find(l->first)==tgts.end())
- libname = l->first;
- else
- libname = "$(OUTDIRLIB)\\" + l->first;
- if (libname.find(".bpi")==string::npos) continue;
- fout << " \\\n " << cmSystemTools::EscapeSpaces(libname.c_str());
+ {
+ fout << t->first << "_LINK_BPI = ";
+ for (cmTarget::LinkLibraries::const_iterator l=libs.begin();
+ l!=libs.end(); l++)
+ {
+ if ((t->first!=l->first) &&
+ (t->second.GetType()!=cmTarget::INSTALL_FILES
+ || t->second.GetType()!=cmTarget::INSTALL_PROGRAMS))
+ {
+ // if this lib is not a target then don't add OUTDIRLIB to it
+ if (tgts.find(l->first)==tgts.end())
+ libname = l->first;
+ else
+ libname = "$(OUTDIRLIB)\\" + l->first;
+ if (libname.find(".bpi")==std::string::npos) continue;
+ fout << " \\\n " << cmSystemTools::EscapeSpaces(libname.c_str());
}
}
- fout << "\n\n";
+ fout << "\n\n";
+ }
}
- }
//
// Create the link dir list - use same for all targets
//
- vector<string> dirs = m_Makefile->GetLinkDirectories();
+ std::vector<std::string> dirs = m_Makefile->GetLinkDirectories();
fout << "LINK_DIR =";
- for (vector<string>::const_iterator d=dirs.begin(); d!=dirs.end(); d++) {
- string temp = cmSystemTools::EscapeSpaces(d->c_str());
+ for (std::vector<std::string>::const_iterator d=dirs.begin(); d!=dirs.end(); d++)
+ {
+ std::string temp = cmSystemTools::EscapeSpaces(d->c_str());
fout << temp << ";";
- }
+ }
fout << "$(OUTDIRLIB)\n\n";
//
@@ -278,67 +365,81 @@ void cmBorlandMakefileGenerator::OutputMakefile(const char* file) {
this->OutputMakeRules(fout);
//
// We'll omit current dir in path where possible
- string fullname, outpath = m_Makefile->GetStartOutputDirectory();
+ std::string fullname, outpath = m_Makefile->GetStartOutputDirectory();
outpath += "/";
//
- for (cmTargets::const_iterator l=tgts.begin(); l!=tgts.end(); l++) {
- vector<cmSourceFile> classes = l->second.GetSourceFiles();
- if (classes.begin() != classes.end()) {
- for (vector<cmSourceFile>::iterator i=classes.begin(); i!=classes.end(); i++) {
- if (!i->IsAHeaderFileOnly()) {
+ for (cmTargets::const_iterator l=tgts.begin(); l!=tgts.end(); l++)
+ {
+ std::vector<cmSourceFile> classes = l->second.GetSourceFiles();
+ if (classes.begin() != classes.end())
+ {
+ for (std::vector<cmSourceFile>::iterator i=classes.begin(); i!=classes.end(); i++)
+ {
+ if (!i->IsAHeaderFileOnly())
+ {
fullname = i->GetFullPath();
cmSystemTools::ReplaceString(fullname, outpath.c_str(), "");
- fout << "" << cmSystemTools::ConvertToWindowsSlashes(i->GetSourceName()) << ".obj : " << fullname << "\n";
+ fout << ""
+ << cmSystemTools::ConvertToWindowsSlashes(i->GetSourceName())
+ << ".obj : " << fullname << "\n";
+ }
}
}
}
- }
//
//
//
- ofstream ffout(file);
- if (!ffout) {
+ std::ofstream ffout(file);
+ if (!ffout)
+ {
cmSystemTools::Error("Error can not open for write: ", file);
return;
- }
- string makefileastext = fout.str();
+ }
+ fout << std::ends;
+ std::string makefileastext = fout.str();
// cmSystemTools::CleanUpWindowsSlashes(makefileastext);
// makefileastext = StringReplace(makefileastext.c_str(), "¬", "/", TReplaceFlags()<<rfReplaceAll).c_str();
ffout << makefileastext << "\n# End of File\n";
}
//---------------------------------------------------------------------------
// output the list of libraries that the executables in this makefile will depend on.
-void cmBorlandMakefileGenerator::OutputDependencies(ostream& fout) {
- // Each dependency should only be emitted once.
- set<string> emitted;
- //
- // Output/Search the list of libraries that will be linked into the executable
- //
- fout << "DEPEND_LIBS = ";
- cmTarget::LinkLibraries& libs = m_Makefile->GetLinkLibraries();
- emitted.clear();
- for (cmTarget::LinkLibraries::const_iterator lib2=libs.begin(); lib2!=libs.end(); ++lib2) {
+void cmBorlandMakefileGenerator::OutputDependencies(std::ostream& fout)
+{
+ // Each dependency should only be emitted once.
+ std::set<std::string> emitted;
+ //
+ // Output/Search the list of libraries that will be linked into the executable
+ //
+ fout << "DEPEND_LIBS = ";
+ cmTarget::LinkLibraries& libs = m_Makefile->GetLinkLibraries();
+ emitted.clear();
+ for (cmTarget::LinkLibraries::const_iterator lib2=libs.begin();
+ lib2!=libs.end(); ++lib2)
+ {
- // loop over the list of directories that the libraries might
- // be in, looking for an ADD_LIBRARY(lib...) line. This would
- // be stored in the cache
- if( ! emitted.insert(lib2->first).second ) continue;
+ // loop over the list of directories that the libraries might
+ // be in, looking for an ADD_LIBRARY(lib...) line. This would
+ // be stored in the cache
+ if( ! emitted.insert(lib2->first).second ) continue;
- const char* cacheValue = m_Makefile->GetDefinition(lib2->first.c_str());
- if (cacheValue) {
- fout << "\\\n $(OUTDIRLIB)\\" << lib2->first << ".lib ";
+ const char* cacheValue = m_Makefile->GetDefinition(lib2->first.c_str());
+ if (cacheValue)
+ {
+ fout << "\\\n $(OUTDIRLIB)\\" << lib2->first << ".lib ";
}
}
- fout << "\n\n";
- //
- // Same list, but this time output a rule to rebuild if they are out of date
- //
- emitted.clear();
- for (cmTarget::LinkLibraries::const_iterator lib2=libs.begin(); lib2!=libs.end(); ++lib2) {
- // loop over the list of directories that the libraries might
- // be in, looking for an ADD_LIBRARY(lib...) line. This would
- // be stored in the cache
- if ( ! emitted.insert(lib2->first).second ) continue;
+ fout << "\n\n";
+ //
+ // Same list, but this time output a rule to rebuild if they are out of date
+ //
+ emitted.clear();
+ for (cmTarget::LinkLibraries::const_iterator lib2=libs.begin();
+ lib2!=libs.end(); ++lib2)
+ {
+ // loop over the list of directories that the libraries might
+ // be in, looking for an ADD_LIBRARY(lib...) line. This would
+ // be stored in the cache
+ if ( ! emitted.insert(lib2->first).second ) continue;
// const char* cacheValue = cmCacheManager::GetInstance()->GetCacheValue(lib2->first.c_str());
// if (cacheValue) {
@@ -349,74 +450,84 @@ void cmBorlandMakefileGenerator::OutputDependencies(ostream& fout) {
}
// fout << "\n";
}
-void cmBorlandMakefileGenerator::OutputTargets(ostream& fout) {
- // Do Libraries first as executables may depend on them
- const cmTargets &tgts = m_Makefile->GetTargets();
- for (cmTargets::const_iterator l=tgts.begin(); l!=tgts.end(); l++) {
- if (l->second.GetType() == cmTarget::STATIC_LIBRARY) {
- //
- // at the moment, static and shared are treated the same
- // WARNING. TLIB fails with Unix style Forward slashes - use $(OUTDIRLIB)\\
- // WARNING. IMPLIB works better with Forward slashes - use $(OUTDIRLIB)\\
- //
- fout << "# this should be a static library \n";
- fout << "$(OUTDIRLIB)\\" << l->first << ".lib : ${" << l->first << "_SRC_OBJS} \n";
- string Libname = "$(OUTDIRLIB)\\" + l->first + ".lib";
- fout << " TLib.exe $(LINKFLAGS_STATIC) /u " << Libname.c_str() << " @&&| \n";
- fout << " $? \n";
- fout << "| \n\n";
+void cmBorlandMakefileGenerator::OutputTargets(std::ostream& fout)
+{
+ // Do Libraries first as executables may depend on them
+ const cmTargets &tgts = m_Makefile->GetTargets();
+ for (cmTargets::const_iterator l=tgts.begin(); l!=tgts.end(); l++)
+ {
+ if (l->second.GetType() == cmTarget::STATIC_LIBRARY)
+ {
+ //
+ // at the moment, static and shared are treated the same
+ // WARNING. TLIB fails with Unix style Forward slashes - use $(OUTDIRLIB)\\
+ // WARNING. IMPLIB works better with Forward slashes - use $(OUTDIRLIB)\\
+ //
+ fout << "# this should be a static library \n";
+ fout << "$(OUTDIRLIB)\\" << l->first << ".lib : ${" << l->first << "_SRC_OBJS} \n";
+ std::string Libname = "$(OUTDIRLIB)\\" + l->first + ".lib";
+ fout << " TLib.exe $(LINKFLAGS_STATIC) /u " << Libname.c_str() << " @&&| \n";
+ fout << " $? \n";
+ fout << "| \n\n";
}
- if (l->second.GetType() == cmTarget::SHARED_LIBRARY) {
- fout << "# this should be a shared (DLL) library \n";
- fout << "$(OUTDIRLIB)\\" << l->first << ".dll : ${" << l->first << "_SRC_OBJS} \n";
- fout << " @ilink32.exe @&&| \n";
- fout << " -L\"$(BCB)/lib\" -L$(LINK_DIR) $(LINKFLAGS_DLL) $(LINKFLAGS_DEBUG) \"$(BCB)/lib/c0d32.obj\" ";
- fout << "$(" << l->first << "_SRC_OBJS) ";
- fout << "$(" << l->first << "_LINK_BPI) , $<, $*, ";
- fout << "$(" << l->first << "_LINK_LIB) $(LINK_LIB) \n";
- fout << "| \n";
- fout << " @implib -w " << "$(OUTDIRLIB)\\" << l->first << ".lib " << "$(OUTDIRLIB)\\" << l->first << ".dll \n\n";
+ if (l->second.GetType() == cmTarget::SHARED_LIBRARY)
+ {
+ fout << "# this should be a shared (DLL) library \n";
+ fout << "$(OUTDIRLIB)\\" << l->first << ".dll : ${" << l->first << "_SRC_OBJS} \n";
+ fout << " @ilink32.exe @&&| \n";
+ fout << " -L\"$(BCB)/lib\" -L$(LINK_DIR) $(LINKFLAGS_DLL) $(LINKFLAGS_DEBUG) \"$(BCB)/lib/c0d32.obj\" ";
+ fout << "$(" << l->first << "_SRC_OBJS) ";
+ fout << "$(" << l->first << "_LINK_BPI) , $<, $*, ";
+ fout << "$(" << l->first << "_LINK_LIB) $(LINK_LIB) \n";
+ fout << "| \n";
+ fout << " @implib -w " << "$(OUTDIRLIB)\\" << l->first << ".lib " << "$(OUTDIRLIB)\\" << l->first << ".dll \n\n";
}
- if (l->second.GetType() == cmTarget::MODULE_LIBRARY) {
- fout << "# this should be a Borland Package library \n";
- fout << "$(OUTDIRLIB)\\" << l->first << ".bpl : ${" << l->first << "_SRC_OBJS} \n";
- fout << " @ilink32.exe @&&| \n";
- fout << " -L\"$(BCB)/lib\" -L$(LINK_DIR) $(LINKFLAGS_BPL) $(LINKFLAGS_DEBUG) \"$(BCB)/lib/c0pkg32.obj\" ";
- fout << "$(" << l->first << "_SRC_OBJS) ";
- fout << "$(" << l->first << "_LINK_BPI) , $<, $*, ";
- fout << "$(" << l->first << "_LINK_LIB) $(LINK_LIB) \n";
- fout << "| \n";
+ if (l->second.GetType() == cmTarget::MODULE_LIBRARY)
+ {
+ fout << "# this should be a Borland Package library \n";
+ fout << "$(OUTDIRLIB)\\" << l->first << ".bpl : ${" << l->first << "_SRC_OBJS} \n";
+ fout << " @ilink32.exe @&&| \n";
+ fout << " -L\"$(BCB)/lib\" -L$(LINK_DIR) $(LINKFLAGS_BPL) $(LINKFLAGS_DEBUG) \"$(BCB)/lib/c0pkg32.obj\" ";
+ fout << "$(" << l->first << "_SRC_OBJS) ";
+ fout << "$(" << l->first << "_LINK_BPI) , $<, $*, ";
+ fout << "$(" << l->first << "_LINK_LIB) $(LINK_LIB) \n";
+ fout << "| \n";
}
}
- // Do Executables
- for (cmTargets::const_iterator l=tgts.begin(); l!=tgts.end(); l++) {
- if (l->second.GetType()==cmTarget::WIN32_EXECUTABLE) {
- fout << l->first << ".exe : ${" << l->first << "_SRC_OBJS} \n";
- fout << " @ilink32.exe @&&| \n";
- fout << " -L\"$(BCB)/lib\" -L$(LINK_DIR) $(LINKFLAGS_EXE) $(LINKFLAGS_DEBUG) \"$(BCB)/lib/c0w32.obj\" ";
- fout << "$(" << l->first << "_SRC_OBJS) ";
- fout << "$(" << l->first << "_LINK_BPI) , $<, $*, ";
- fout << "$(" << l->first << "_LINK_LIB) $(LINK_LIB) \n";
- fout << "| \n\n";
+ // Do Executables
+ for (cmTargets::const_iterator l=tgts.begin(); l!=tgts.end(); l++)
+ {
+ if (l->second.GetType()==cmTarget::WIN32_EXECUTABLE)
+ {
+ fout << l->first << ".exe : ${" << l->first << "_SRC_OBJS} \n";
+ fout << " @ilink32.exe @&&| \n";
+ fout << " -L\"$(BCB)/lib\" -L$(LINK_DIR) $(LINKFLAGS_EXE) $(LINKFLAGS_DEBUG) \"$(BCB)/lib/c0w32.obj\" ";
+ fout << "$(" << l->first << "_SRC_OBJS) ";
+ fout << "$(" << l->first << "_LINK_BPI) , $<, $*, ";
+ fout << "$(" << l->first << "_LINK_LIB) $(LINK_LIB) \n";
+ fout << "| \n\n";
}
- else if (l->second.GetType()==cmTarget::EXECUTABLE) {
- fout << l->first << ".exe : ${" << l->first << "_SRC_OBJS} \n";
- fout << " @ilink32.exe @&&| \n";
- fout << " -L\"$(BCB)/lib\" -L$(LINK_DIR) $(LINKFLAGS_EXE) $(LINKFLAGS_DEBUG) \"$(BCB)/lib/c0x32.obj\" ";
- fout << "$(" << l->first << "_SRC_OBJS) , $<, $*, ";
- fout << "$(" << l->first << "_LINK_LIB) $(LINK_LIB) \n";
- fout << "| \n\n";
+ else if (l->second.GetType()==cmTarget::EXECUTABLE)
+ {
+ fout << l->first << ".exe : ${" << l->first << "_SRC_OBJS} \n";
+ fout << " @ilink32.exe @&&| \n";
+ fout << " -L\"$(BCB)/lib\" -L$(LINK_DIR) $(LINKFLAGS_EXE) $(LINKFLAGS_DEBUG) \"$(BCB)/lib/c0x32.obj\" ";
+ fout << "$(" << l->first << "_SRC_OBJS) , $<, $*, ";
+ fout << "$(" << l->first << "_LINK_LIB) $(LINK_LIB) \n";
+ fout << "| \n\n";
}
}
}
//---------------------------------------------------------------------------
-void cmBorlandMakefileGenerator::OutputSubDirectoryRules(ostream& fout) {
+void cmBorlandMakefileGenerator::OutputSubDirectoryRules(std::ostream& fout)
+{
// output rules for decending into sub directories
- const vector<string>& SubDirectories = m_Makefile->GetSubDirectories();
+ const std::vector<std::string>& SubDirectories = m_Makefile->GetSubDirectories();
//
- if ( SubDirectories.size() == 0) {
+ if ( SubDirectories.size() == 0)
+ {
return;
- }
+ }
//
this->OutputSubDirectoryVars(fout, "SUBDIR_BUILD", "build",
0,
@@ -426,18 +537,18 @@ void cmBorlandMakefileGenerator::OutputSubDirectoryRules(ostream& fout) {
//---------------------------------------------------------------------------
// fix up names of directories so they can be used
// as targets in makefiles.
-inline string FixDirectoryName(const char* dir)
+inline std::string FixDirectoryName(const char* dir)
{
- string s = dir;
+ std::string s = dir;
// replace ../ with 3 under bars
size_t pos = s.find("../");
- if (pos != string::npos)
+ if (pos != std::string::npos)
{
s.replace(pos, 3, "___");
}
// replace / directory separators with a single under bar
pos = s.find("/");
- while(pos != string::npos)
+ while(pos != std::string::npos)
{
s.replace(pos, 1, "_");
pos = s.find("/");
@@ -445,36 +556,41 @@ inline string FixDirectoryName(const char* dir)
return s;
}
-void cmBorlandMakefileGenerator::OutputSubDirectoryVars(ostream& fout,
- const char* var,
- const char* target,
- const char* target1,
- const char* target2,
- const vector<string>& SubDirectories)
+void cmBorlandMakefileGenerator::OutputSubDirectoryVars(std::ostream& fout,
+ const char* var,
+ const char* target,
+ const char* target1,
+ const char* target2,
+ const std::vector<std::string>& SubDirectories)
{
if (!SubDirectories.size()) return;
//
fout << "# Variable for making " << target << " in subdirectories.\n";
fout << var << " = \\\n";
unsigned int i;
- for (i =0; i < SubDirectories.size(); i++) {
- string subdir = FixDirectoryName(SubDirectories[i].c_str());
+ for (i =0; i < SubDirectories.size(); i++)
+ {
+ std::string subdir = FixDirectoryName(SubDirectories[i].c_str());
fout << " " << target << "_" << subdir.c_str();
- if (i == SubDirectories.size()-1) {
+ if (i == SubDirectories.size()-1)
+ {
fout << " \n\n";
- }
- else {
+ }
+ else
+ {
fout << " \\\n";
+ }
}
- }
//
fout << "# Targets for making " << target << " in subdirectories.\n";
- for (unsigned int i=0; i<SubDirectories.size(); i++) {
- string subdir = FixDirectoryName(SubDirectories[i].c_str());
+ for (unsigned int i=0; i<SubDirectories.size(); i++)
+ {
+ std::string subdir = FixDirectoryName(SubDirectories[i].c_str());
fout << target << "_" << subdir.c_str() << ":\n";
fout << " cd " << m_Makefile->GetStartOutputDirectory() << "/" << SubDirectories[i] << " \n";
- fout << " make -fmakefile.mak \n\n";
- }
+ fout << " make makefile.mak\n";
+ fout << " make \n\n";
+ }
}
@@ -484,7 +600,8 @@ void cmBorlandMakefileGenerator::OutputSubDirectoryVars(ostream& fout,
// (tab) command...
// This routine is copied direct from unix makefile generator
-void cmBorlandMakefileGenerator::OutputCustomRules(ostream& fout) {
+void cmBorlandMakefileGenerator::OutputCustomRules(std::ostream& fout)
+{
// We may be modifying the source groups temporarily, so make a copy.
std::vector<cmSourceGroup> sourceGroups = m_Makefile->GetSourceGroups();
@@ -512,7 +629,9 @@ void cmBorlandMakefileGenerator::OutputCustomRules(ostream& fout) {
{
const cmSourceGroup::BuildRules& buildRules = sg->GetBuildRules();
if(buildRules.empty())
- { continue; }
+ {
+ continue;
+ }
std::string name = sg->GetName();
if(name != "")
@@ -536,16 +655,16 @@ void cmBorlandMakefileGenerator::OutputCustomRules(ostream& fout) {
// with no outputs
if(commandFiles.m_Outputs.size() == 0)
{
- fout << source.c_str() << ": ";
- // Write out all the dependencies for this rule.
- for(std::set<std::string>::const_iterator d =
- commandFiles.m_Depends.begin();
- d != commandFiles.m_Depends.end(); ++d)
- {
- std::string dep = cmSystemTools::EscapeSpaces(d->c_str());
- fout << " " << dep.c_str();
- }
- fout << "\n\t" << command.c_str() << "\n\n";
+ fout << source.c_str() << ": ";
+ // Write out all the dependencies for this rule.
+ for(std::set<std::string>::const_iterator d =
+ commandFiles.m_Depends.begin();
+ d != commandFiles.m_Depends.end(); ++d)
+ {
+ std::string dep = cmSystemTools::EscapeSpaces(d->c_str());
+ fout << " " << dep.c_str();
+ }
+ fout << "\n\t" << command.c_str() << "\n\n";
}
// Write a rule for every output generated by this command.
for(std::set<std::string>::const_iterator output =
@@ -576,7 +695,8 @@ void cmBorlandMakefileGenerator::OutputCustomRules(ostream& fout) {
}
-void cmBorlandMakefileGenerator::OutputMakeRules(ostream& fout) {
+void cmBorlandMakefileGenerator::OutputMakeRules(std::ostream& fout)
+{
this->OutputMakeRule(fout,
"Rule to build c file(s)",
".c.obj",
@@ -617,56 +737,64 @@ void cmBorlandMakefileGenerator::OutputMakeRules(ostream& fout) {
}
-void cmBorlandMakefileGenerator::OutputMakeRule(ostream& fout,
- const char* comment,
- const char* target,
- const char* depends,
- const char* command)
+void cmBorlandMakefileGenerator::OutputMakeRule(std::ostream& fout,
+ const char* comment,
+ const char* target,
+ const char* depends,
+ const char* command)
{
- string replace;
- if (comment) {
+ std::string replace;
+ if (comment)
+ {
replace = comment;
m_Makefile->ExpandVariablesInString(replace);
fout << "# " << comment << " \n";
- }
+ }
//
replace = target;
m_Makefile->ExpandVariablesInString(replace);
fout << replace.c_str() << ": ";
- if (depends) {
+ if (depends)
+ {
replace = depends;
m_Makefile->ExpandVariablesInString(replace);
fout << replace.c_str();
- }
+ }
fout << "\n";
//
- if (command) {
+ if (command)
+ {
replace = command;
m_Makefile->ExpandVariablesInString(replace);
fout << " " << replace.c_str() << " \n";
- }
+ }
fout << "\n";
}
-void cmBorlandMakefileGenerator::SetLocal (bool local) {
- if (local) {
+void cmBorlandMakefileGenerator::SetLocal (bool local)
+{
+ if (local)
+ {
m_CacheOnly = false;
m_Recurse = false;
- }
- else {
+ }
+ else
+ {
m_CacheOnly = true;
m_Recurse = true;
- }
+ }
}
-void cmBorlandMakefileGenerator::ComputeSystemInfo() {
+void cmBorlandMakefileGenerator::ComputeSystemInfo()
+{
// now load the settings
- if (!m_Makefile->GetDefinition("CMAKE_ROOT")) {
+ if (!m_Makefile->GetDefinition("CMAKE_ROOT"))
+ {
cmSystemTools::Error("CMAKE_ROOT has not been defined, bad GUI or driver program");
return;
- }
- string fpath = m_Makefile->GetDefinition("CMAKE_ROOT");
+ }
+ std::string fpath = m_Makefile->GetDefinition("CMAKE_ROOT");
fpath += "/Templates/CMakeWindowsBorlandConfig.cmake";
m_Makefile->ReadListFile(NULL,fpath.c_str());
}
diff --git a/Source/cmBorlandMakefileGenerator.h b/Source/cmBorlandMakefileGenerator.h
index 1646944..5ba6452 100644
--- a/Source/cmBorlandMakefileGenerator.h
+++ b/Source/cmBorlandMakefileGenerator.h
@@ -10,72 +10,82 @@
* cmBorlandMakefileGenerator produces a Unix makefile from its
* member m_Makefile.
*/
-class cmBorlandMakefileGenerator : public cmMakefileGenerator {
- public:
- ///! Set cache only and recurse to false by default.
- cmBorlandMakefileGenerator();
+class cmBorlandMakefileGenerator : public cmMakefileGenerator
+{
+public:
+ ///! Set cache only and recurse to false by default.
+ cmBorlandMakefileGenerator();
+
+ ///! Get the name for the generator.
+ virtual const char* GetName() {return "Borland Makefiles";}
- //! just sets the Cache Only and Recurse flags
- virtual void SetLocal(bool local);
+ ///! virtual copy constructor
+ virtual cmMakefileGenerator* CreateObject()
+ { return new cmBorlandMakefileGenerator;}
- /**
- * If cache only is on.
- * Only stub makefiles are generated, and no depends, for speed.
- * The default is OFF.
- **/
- void SetCacheOnlyOn() {m_CacheOnly = true;}
- void SetCacheOnlyOff() {m_CacheOnly = false;}
+ //! just sets the Cache Only and Recurse flags
+ virtual void SetLocal(bool local);
- /**
- * If recurse is on, then all the makefiles below this one are parsed as well.
- */
- void SetRecurseOn() {m_Recurse = true;}
- void SetRecurseOff() {m_Recurse = false;}
+ /**
+ * If cache only is on.
+ * Only stub makefiles are generated, and no depends, for speed.
+ * The default is OFF.
+ **/
+ void SetCacheOnlyOn() {m_CacheOnly = true;}
+ void SetCacheOnlyOff() {m_CacheOnly = false;}
- /**
- * Produce the makefile (in this case a Unix makefile).
- */
- virtual void GenerateMakefile();
+ /**
+ * If recurse is on, then all the makefiles below this one are parsed as well.
+ */
+ void SetRecurseOn() {m_Recurse = true;}
+ void SetRecurseOff() {m_Recurse = false;}
- /**
- * Output the depend information for all the classes
- * in the makefile. These would have been generated
- * by the class cmMakeDepend.
- */
- void OutputObjectDepends(std::ostream&);
+ /**
+ * Produce the makefile (in this case a Unix makefile).
+ */
+ virtual void GenerateMakefile();
- /**
- * Try to determine system infomation such as shared library
- * extension, pthreads, byte order etc.
- */
- virtual void ComputeSystemInfo();
+ /**
+ * Output the depend information for all the classes
+ * in the makefile. These would have been generated
+ * by the class cmMakeDepend.
+ */
+ void OutputObjectDepends(std::ostream&);
- private:
- void RecursiveGenerateCacheOnly();
- void GenerateCacheOnly();
- void OutputMakefile(const char* file);
- void OutputTargetRules(std::ostream& fout);
- void OutputTargets(std::ostream&);
- void OutputSubDirectoryRules(std::ostream&);
- void OutputDependInformation(std::ostream&);
- void OutputDependencies(std::ostream&);
- void OutputCustomRules(std::ostream&);
- void OutputMakeVariables(std::ostream&);
- void OutputMakeRules(std::ostream&);
- void OutputSubDirectoryVars(std::ostream& fout,
- const char* var,
- const char* target,
- const char* target1,
- const char* target2,
- const std::vector<std::string>& SubDirectories);
- void OutputMakeRule(std::ostream&,
- const char* comment,
- const char* target,
- const char* depends,
- const char* command);
- private:
- bool m_CacheOnly;
- bool m_Recurse;
+ /**
+ * Try to determine system infomation such as shared library
+ * extension, pthreads, byte order etc.
+ */
+ virtual void ComputeSystemInfo();
+
+private:
+ void RecursiveGenerateCacheOnly();
+ void GenerateCacheOnly();
+ void OutputMakefile(const char* file);
+ void OutputTargetRules(std::ostream& fout);
+ void OutputTargets(std::ostream&);
+ void OutputSubDirectoryRules(std::ostream&);
+ void OutputDependInformation(std::ostream&);
+ void OutputDependencies(std::ostream&);
+ void OutputCustomRules(std::ostream&);
+ void OutputMakeVariables(std::ostream&);
+ void OutputMakeRules(std::ostream&);
+ void OutputSubDirectoryVars(std::ostream& fout,
+ const char* var,
+ const char* target,
+ const char* target1,
+ const char* target2,
+ const std::vector<std::string>& SubDirectories);
+ void OutputMakeRule(std::ostream&,
+ const char* comment,
+ const char* target,
+ const char* depends,
+ const char* command);
+private:
+ bool m_CacheOnly;
+ bool m_Recurse;
+ std::string m_ExecutableOutputPath;
+ std::string m_LibraryOutputPath;
};
#endif
diff --git a/Source/cmMSProjectGenerator.h b/Source/cmMSProjectGenerator.h
index 08d8678..64bd936 100644
--- a/Source/cmMSProjectGenerator.h
+++ b/Source/cmMSProjectGenerator.h
@@ -55,22 +55,23 @@ class cmDSWWriter;
class cmMSProjectGenerator : public cmMakefileGenerator
{
public:
- /**
- * Constructor sets the generation of DSW files on.
- */
+ ///! Constructor sets the generation of DSW files on.
cmMSProjectGenerator();
- /**
- * Destructor.
- */
+ ///! Destructor.
~cmMSProjectGenerator();
-
- /**
- * Produce the makefile (in this case a Microsoft Visual C++ project).
- */
+
+ ///! Get the name for the generator.
+ virtual const char* GetName() {return "Visual Studio 6";}
+
+ ///! virtual copy constructor
+ virtual cmMakefileGenerator* CreateObject()
+ { return new cmMSProjectGenerator;}
+
+ ///! Produce the makefile (in this case a Microsoft Visual C++ project).
virtual void GenerateMakefile();
- //! controls the DSW/DSP settings
+ ///! controls the DSW/DSP settings
virtual void SetLocal(bool);
/**
@@ -81,20 +82,14 @@ public:
*/
void BuildDSWOff() {m_BuildDSW = false;}
- /**
- * Turn on the generation of a Microsoft Visual C++ DSW file.
- */
+ ///! Turn on the generation of a Microsoft Visual C++ DSW file.
void BuildDSWOn() {m_BuildDSW = true;}
- /**
- * Retrieve a pointer to a cmDSWWriter instance.
- */
+ ///! Retrieve a pointer to a cmDSWWriter instance.
cmDSWWriter* GetDSWWriter()
{return m_DSWWriter;}
- /**
- * Retrieve a pointer to a cmDSPWriter instance.
- */
+ ///! Retrieve a pointer to a cmDSPWriter instance.
cmDSPWriter* GetDSPWriter()
{return m_DSPWriter;}
diff --git a/Source/cmMakefileGenerator.cxx b/Source/cmMakefileGenerator.cxx
index d2c1b0c..a662029 100644
--- a/Source/cmMakefileGenerator.cxx
+++ b/Source/cmMakefileGenerator.cxx
@@ -40,8 +40,53 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#include "cmMakefileGenerator.h"
+// static list of registered generators
+std::map<cmStdString, cmMakefileGenerator*>
+cmMakefileGenerator::s_RegisteredGenerators;
+
+
void cmMakefileGenerator::SetMakefile(cmMakefile* mf)
{
m_Makefile = mf;
}
+void cmMakefileGenerator::GetRegisteredGenerators(std::vector<std::string>& names)
+{
+ for(std::map<cmStdString, cmMakefileGenerator*>::iterator i
+ = s_RegisteredGenerators.begin();
+ i != s_RegisteredGenerators.end(); ++i)
+ {
+ names.push_back(i->first);
+ }
+}
+
+
+void
+cmMakefileGenerator::RegisterGenerator(cmMakefileGenerator* mg)
+{
+ std::map<cmStdString, cmMakefileGenerator*>::iterator i =
+ s_RegisteredGenerators.find(mg->GetName());
+ // delete re-registered objects
+ if(i != s_RegisteredGenerators.end())
+ {
+ delete i->second;
+ }
+ s_RegisteredGenerators[mg->GetName()] = mg;
+}
+
+
+cmMakefileGenerator*
+cmMakefileGenerator::CreateGenerator(const char* name)
+{
+ std::map<cmStdString, cmMakefileGenerator*>::iterator i;
+ for(i = s_RegisteredGenerators.begin();
+ i != s_RegisteredGenerators.end(); ++i)
+ {
+ cmMakefileGenerator* gen = i->second;
+ if(strcmp(name, gen->GetName()) == 0)
+ {
+ return gen->CreateObject();
+ }
+ }
+ return 0;
+}
diff --git a/Source/cmMakefileGenerator.h b/Source/cmMakefileGenerator.h
index 688d31f..e2da856 100644
--- a/Source/cmMakefileGenerator.h
+++ b/Source/cmMakefileGenerator.h
@@ -55,9 +55,20 @@ class cmClassFile;
class cmMakefileGenerator
{
public:
- /**
- * Set the cmMakefile instance from which to generate the makefile.
- */
+ ///! Create a named generator
+ static cmMakefileGenerator* CreateGenerator(const char* name);
+ ///! Register a generator
+ static void RegisterGenerator(cmMakefileGenerator*);
+ ///! Get the names of the current registered generators
+ static void GetRegisteredGenerators(std::vector<std::string>& names);
+
+ ///! Get the name for the generator.
+ virtual const char* GetName() = 0;
+
+ ///! virtual copy constructor
+ virtual cmMakefileGenerator* CreateObject() = 0;
+
+ ///! Set the cmMakefile instance from which to generate the makefile.
void SetMakefile(cmMakefile*);
/**
@@ -84,6 +95,7 @@ public:
virtual ~cmMakefileGenerator(){};
protected:
+ static std::map<cmStdString, cmMakefileGenerator*> s_RegisteredGenerators;
cmMakefile* m_Makefile;
};
diff --git a/Source/cmUnixMakefileGenerator.h b/Source/cmUnixMakefileGenerator.h
index e0a2b15..0343951 100644
--- a/Source/cmUnixMakefileGenerator.h
+++ b/Source/cmUnixMakefileGenerator.h
@@ -56,6 +56,13 @@ public:
///! Set cache only and recurse to false by default.
cmUnixMakefileGenerator();
+ ///! Get the name for the generator.
+ virtual const char* GetName() {return "Unix Makefiles";}
+
+ ///! virtual copy constructor
+ virtual cmMakefileGenerator* CreateObject()
+ { return new cmUnixMakefileGenerator;}
+
//! just sets the Cache Only and Recurse flags
virtual void SetLocal(bool local);
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index c1c3128..18235ee 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -44,26 +44,48 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// include the generator
#if defined(_WIN32) && !defined(__CYGWIN__)
#include "cmMSProjectGenerator.h"
+#include "cmBorlandMakefileGenerator.h"
#else
#include "cmUnixMakefileGenerator.h"
#endif
+cmake::cmake()
+{
+ m_Verbose = false;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ cmMakefileGenerator::RegisterGenerator(new cmMSProjectGenerator);
+ cmMakefileGenerator::RegisterGenerator(new cmBorlandMakefileGenerator);
+#else
+ cmMakefileGenerator::RegisterGenerator(new cmUnixMakefileGenerator);
+#endif
+}
+
void cmake::Usage(const char* program)
{
std::cerr << "cmake version " << cmMakefile::GetMajorVersion()
<< "." << cmMakefile::GetMinorVersion() << "\n";
std::cerr << "Usage: " << program << " srcdir \n"
<< "Where cmake is run from the directory where you want the object files written\n";
+ std::cerr << "[-GgeneratorName] (where generator name can be: ";
+ std::vector<std::string> names;
+ cmMakefileGenerator::GetRegisteredGenerators(names);
+ for(std::vector<std::string>::iterator i =names.begin();
+ i != names.end(); ++i)
+ {
+ std::cerr << i->c_str() << " ";
+ }
+ std::cerr << ")\n";
}
// Parse the args
void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args)
{
m_Local = false;
-
+ bool directoriesSet = false;
// watch for cmake and cmake srcdir invocations
if (args.size() <= 2)
{
+ directoriesSet = true;
builder.SetHomeOutputDirectory
(cmSystemTools::GetCurrentWorkingDirectory().c_str());
builder.SetStartOutputDirectory
@@ -89,36 +111,78 @@ void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args)
std::string arg = args[i];
if(arg.find("-H",0) == 0)
{
+ directoriesSet = true;
std::string path = arg.substr(2);
builder.SetHomeDirectory(path.c_str());
}
- if(arg.find("-S",0) == 0)
+ else if(arg.find("-S",0) == 0)
{
+ directoriesSet = true;
m_Local = true;
std::string path = arg.substr(2);
builder.SetStartDirectory(path.c_str());
}
- if(arg.find("-O",0) == 0)
+ else if(arg.find("-O",0) == 0)
{
+ directoriesSet = true;
std::string path = arg.substr(2);
builder.SetStartOutputDirectory(path.c_str());
}
- if(arg.find("-B",0) == 0)
+ else if(arg.find("-B",0) == 0)
{
+ directoriesSet = true;
std::string path = arg.substr(2);
builder.SetHomeOutputDirectory(path.c_str());
}
- if(arg.find("-D",0) == 0)
+ else if(arg.find("-D",0) == 0)
{
std::string value = arg.substr(2);
builder.AddDefinition(value.c_str(), true);
}
- if(arg.find("-V",0) == 0)
+ else if(arg.find("-V",0) == 0)
{
m_Verbose = true;
}
+ else if(arg.find("-G",0) == 0)
+ {
+ std::string value = arg.substr(2);
+ cmMakefileGenerator* gen =
+ cmMakefileGenerator::CreateGenerator(value.c_str());
+ if(!gen)
+ {
+ cmSystemTools::Error("Could not create named generator ",
+ value.c_str());
+ }
+ else
+ {
+ builder.SetMakefileGenerator(gen);
+ }
+ }
+ // no option assume it is the path to the source
+ else
+ {
+ directoriesSet = true;
+ builder.SetHomeOutputDirectory
+ (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ builder.SetStartOutputDirectory
+ (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ builder.SetHomeDirectory
+ (cmSystemTools::CollapseFullPath(args[1].c_str()).c_str());
+ builder.SetStartDirectory
+ (cmSystemTools::CollapseFullPath(args[1].c_str()).c_str());
+ }
+ }
+ if(!directoriesSet)
+ {
+ builder.SetHomeOutputDirectory
+ (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ builder.SetStartOutputDirectory
+ (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ builder.SetHomeDirectory
+ (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ builder.SetStartDirectory
+ (cmSystemTools::GetCurrentWorkingDirectory().c_str());
}
-
if (!m_Local)
{
builder.SetStartDirectory(builder.GetHomeDirectory());
@@ -244,23 +308,46 @@ int cmake::Generate(const std::vector<std::string>& args, bool buildMakefiles)
}
// Create a makefile
cmMakefile mf;
-
- // extract the directory arguments
- cmake::SetArgs(mf, args);
-
- // create the generator
+ // extract the directory arguments, could create a Generator
+ this->SetArgs(mf, args);
+ // Read and parse the input makefile
+ mf.MakeStartDirectoriesCurrent();
+ cmCacheManager::GetInstance()->LoadCache(&mf);
+ // no generator specified on the command line
+ if(!mf.GetMakefileGenerator())
+ {
+ cmMakefileGenerator* gen;
+ const char* genName = mf.GetDefinition("CMAKE_GENERATOR");
+ if(genName)
+ {
+ gen = cmMakefileGenerator::CreateGenerator(genName);
+ }
+ else
+ {
#if defined(_WIN32) && !defined(__CYGWIN__)
- cmMSProjectGenerator* gen = new cmMSProjectGenerator;
+ gen = new cmMSProjectGenerator;
#else
- cmUnixMakefileGenerator* gen = new cmUnixMakefileGenerator;
+ gen = new cmUnixMakefileGenerator;
#endif
-
+ }
+ if(!gen)
+ {
+ cmSystemTools::Error("Could not create generator");
+ return -1;
+ }
+ mf.SetMakefileGenerator(gen);
+ // add the
+ }
+ cmMakefileGenerator* gen = mf.GetMakefileGenerator();
gen->SetLocal(m_Local);
-
- // Read and parse the input makefile
- mf.SetMakefileGenerator(gen);
- mf.MakeStartDirectoriesCurrent();
- cmCacheManager::GetInstance()->LoadCache(&mf);
+ if(!mf.GetDefinition("CMAKE_GENERATOR"))
+ {
+ mf.AddCacheDefinition("CMAKE_GENERATOR",
+ gen->GetName(),
+ "Name of generator.",
+ cmCacheManager::INTERNAL);
+ }
+
// setup CMAKE_ROOT and CMAKE_COMMAND
this->AddCMakePaths(args);
diff --git a/Source/cmake.h b/Source/cmake.h
index 5e272f9..ff9d11f 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -79,9 +79,9 @@ class cmake
/**
* constructor
*/
- cmake() {m_Verbose = false;}
+ cmake();
- private:
+private:
bool m_Verbose;
bool m_Local;
};
diff --git a/Templates/CMakeWindowsBorlandConfig.cmake b/Templates/CMakeWindowsBorlandConfig.cmake
index 47ac48a..1e5db1d 100644
--- a/Templates/CMakeWindowsBorlandConfig.cmake
+++ b/Templates/CMakeWindowsBorlandConfig.cmake
@@ -13,22 +13,12 @@ SET (CMAKE_CXX_COMPILER "Borland_BCB_5.5.1" CACHE STRING "C++ compiler used.")
FIND_PATH(BCB_BIN_PATH bcc32.exe
"C:/Program Files/Borland/CBuilder5/Bin"
+ "C:/Borland/Bcc55/Bin"
+ "/Borland/Bcc55/Bin"
[HKEY_LOCAL_MACHINE/SOFTWARE/Borland/C++Builder/5.0/RootDir]/Bin
)
#
-# Set default exe and lib directories
-#
-
-IF (NOT LIBRARY_OUTPUT_PATH)
- SET (LIBRARY_OUTPUT_PATH "c:/bin" CACHE STRING "Directory for libraries to be built into.")
-ENDIF (NOT LIBRARY_OUTPUT_PATH)
-
-IF (NOT EXECUTABLE_OUTPUT_PATH)
- SET (EXECUTABLE_OUTPUT_PATH "" CACHE STRING "Directory for executables to be built into.")
-ENDIF (NOT EXECUTABLE_OUTPUT_PATH)
-
-#
# override opengl library as it is bound to import32.lib already
#