summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2001-01-05 16:41:20 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2001-01-05 16:41:20 (GMT)
commitc54a05bfc799f3e88459956ec37698bab22c27f9 (patch)
tree400b2eb0b6853952a4faa8c0fc41b90eb06deaec
parentd888b5e39d4e01af538b48ad16c2a6a474de34a0 (diff)
downloadCMake-c54a05bfc799f3e88459956ec37698bab22c27f9.zip
CMake-c54a05bfc799f3e88459956ec37698bab22c27f9.tar.gz
CMake-c54a05bfc799f3e88459956ec37698bab22c27f9.tar.bz2
ENH: rework cmake, added ruleMaker classes and changed the syntax of the CMakeLists.txt files.
-rw-r--r--Source/CMakeBuildTargets.cxx21
-rw-r--r--Source/CMakeSetupCMD.cxx27
-rw-r--r--Source/CMakeSetupCMD.dsp224
-rw-r--r--Source/MFCDialog/CMakeSetup.dsp204
-rw-r--r--Source/MFCDialog/CMakeSetupDialog.cpp24
-rw-r--r--Source/Makefile.in76
-rw-r--r--Source/cmAbstractFilesRule.cxx26
-rw-r--r--Source/cmAbstractFilesRule.h37
-rw-r--r--Source/cmAddTargetRule.cxx19
-rw-r--r--Source/cmAddTargetRule.h37
-rw-r--r--Source/cmAuxSourceDirectoryRule.cxx46
-rw-r--r--Source/cmAuxSourceDirectoryRule.h38
-rw-r--r--Source/cmClassFile.cxx9
-rw-r--r--Source/cmClassFile.h9
-rw-r--r--Source/cmCollectFlags.cxx139
-rw-r--r--Source/cmCollectFlags.h107
-rw-r--r--Source/cmDSPMakefile.cxx90
-rw-r--r--Source/cmDSPMakefile.h14
-rw-r--r--Source/cmDSPWriter.cxx90
-rw-r--r--Source/cmDSPWriter.h14
-rw-r--r--Source/cmDSWMakefile.cxx100
-rw-r--r--Source/cmDSWMakefile.h19
-rw-r--r--Source/cmDSWWriter.cxx100
-rw-r--r--Source/cmDSWWriter.h19
-rw-r--r--Source/cmDirectory.cxx5
-rw-r--r--Source/cmDirectory.h7
-rw-r--r--Source/cmExecutablesRule.cxx20
-rw-r--r--Source/cmExecutablesRule.h37
-rw-r--r--Source/cmFindIncludeRule.cxx18
-rw-r--r--Source/cmFindIncludeRule.h38
-rw-r--r--Source/cmFindLibraryRule.cxx18
-rw-r--r--Source/cmFindLibraryRule.h38
-rw-r--r--Source/cmFindProgramRule.cxx65
-rw-r--r--Source/cmFindProgramRule.h39
-rw-r--r--Source/cmIncludeDirectoryRule.cxx18
-rw-r--r--Source/cmIncludeDirectoryRule.h38
-rw-r--r--Source/cmLibraryRule.cxx14
-rw-r--r--Source/cmLibraryRule.h37
-rw-r--r--Source/cmLinkDirectoriesRule.cxx18
-rw-r--r--Source/cmLinkDirectoriesRule.h42
-rw-r--r--Source/cmLinkLibrariesRule.cxx18
-rw-r--r--Source/cmLinkLibrariesRule.h45
-rw-r--r--Source/cmMSProjectGenerator.cxx31
-rw-r--r--Source/cmMSProjectGenerator.h45
-rw-r--r--Source/cmMakeDepend.cxx37
-rw-r--r--Source/cmMakeDepend.h3
-rw-r--r--Source/cmMakefile.cxx488
-rw-r--r--Source/cmMakefile.h131
-rw-r--r--Source/cmMakefileGenerator.cxx7
-rw-r--r--Source/cmMakefileGenerator.h20
-rw-r--r--Source/cmProjectRule.cxx14
-rw-r--r--Source/cmProjectRule.h38
-rw-r--r--Source/cmRegularExpression.cxx3
-rw-r--r--Source/cmRegularExpression.h2
-rw-r--r--Source/cmRuleMaker.h52
-rw-r--r--Source/cmSourceFilesRequireRule.cxx39
-rw-r--r--Source/cmSourceFilesRequireRule.h37
-rw-r--r--Source/cmSourceFilesRule.cxx21
-rw-r--r--Source/cmSourceFilesRule.h37
-rw-r--r--Source/cmStandardIncludes.h29
-rw-r--r--Source/cmSubdirRule.cxx18
-rw-r--r--Source/cmSubdirRule.h40
-rw-r--r--Source/cmSystemTools.cxx227
-rw-r--r--Source/cmSystemTools.h43
-rw-r--r--Source/cmTestsRule.cxx20
-rw-r--r--Source/cmTestsRule.h37
-rw-r--r--Source/cmUnixDefinesRule.cxx25
-rw-r--r--Source/cmUnixDefinesRule.h40
-rw-r--r--Source/cmUnixLibrariesRule.cxx25
-rw-r--r--Source/cmUnixLibrariesRule.h39
-rw-r--r--Source/cmUnixMakefileGenerator.cxx (renamed from Source/cmUnixMakefile.cxx)148
-rw-r--r--Source/cmUnixMakefileGenerator.h (renamed from Source/cmUnixMakefile.h)13
-rw-r--r--Source/cmWin32DefinesRule.cxx28
-rw-r--r--Source/cmWin32DefinesRule.h39
-rw-r--r--Source/cmWin32LibrariesRule.cxx25
-rw-r--r--Source/cmWin32LibrariesRule.h42
-rw-r--r--Source/cmWindowsConfigure.cxx3
-rw-r--r--Source/cmWindowsConfigure.h2
78 files changed, 2941 insertions, 911 deletions
diff --git a/Source/CMakeBuildTargets.cxx b/Source/CMakeBuildTargets.cxx
index d29ce74..c87ecb7 100644
--- a/Source/CMakeBuildTargets.cxx
+++ b/Source/CMakeBuildTargets.cxx
@@ -1,7 +1,7 @@
-#include "cmUnixMakefile.h"
+#include "cmMakefile.h"
+#include "cmStandardIncludes.h"
#include "cmMakeDepend.h"
-#include <iostream>
-
+#include "cmUnixMakefileGenerator.h"
// This is the main program used to gentrate makefile fragments
// from CMakeLists.txt input files.
@@ -12,10 +12,9 @@ main(int ac, char** av)
std::cerr << "Usage: " << av[0] << " Makefile.in -Ipath ..." << std::endl;
return -1;
}
- // Create a unix makefile
- cmUnixMakefile mf;
- // Create a depends object
- cmMakeDepend md;
+ // Create a makefile
+ cmMakefile mf;
+ mf.AddDefinition("UNIX", "1");
// Parse the command line
if(ac > 2)
{
@@ -42,16 +41,12 @@ main(int ac, char** av)
}
}
}
+ mf.SetMakefileGenerator(new cmUnixMakefileGenerator);
// Read and parse the input makefile
if(!mf.ReadMakefile(av[1]))
{
std::cerr << "Usage: " << av[0] << " Makefile.in -Ipath ..." << std::endl;
return -1;
}
- // Set the makefile object on the depend object
- md.SetMakefile(&mf);
- // compute the depend information
- md.DoDepends();
- // Ouput the result
- mf.OutputMakefile("CMakeTargets.make");
+ mf.GenerateMakefile();
}
diff --git a/Source/CMakeSetupCMD.cxx b/Source/CMakeSetupCMD.cxx
index 8e64324..8fecfad 100644
--- a/Source/CMakeSetupCMD.cxx
+++ b/Source/CMakeSetupCMD.cxx
@@ -1,6 +1,7 @@
-#include "cmDSWMakefile.h"
-#include "cmDSPMakefile.h"
-#include <iostream>
+#include "cmStandardIncludes.h"
+#include "cmMakefile.h"
+#include "cmMSProjectGenerator.h"
+
// this is the command line version of CMakeSetup.
// It is called from Visual Studio when a CMakeLists.txt
@@ -21,7 +22,6 @@ void SetArgs(cmMakefile& builder, int ac, char** av)
if(arg.find("-D",0) != std::string::npos)
{
std::string path = arg.substr(2);
- std::cerr << "set makefile dir " << path.c_str() << std::endl;
builder.SetCurrentDirectory(path.c_str());
}
if(arg.find("-O",0) != std::string::npos)
@@ -44,24 +44,25 @@ main(int ac, char** av)
if(ac < 3)
{
std::cerr << "Usage: " << av[0] <<
- " Makefile.in -[DSP|DSW] -Hinsighthome -Dcurrentdir -Ooutput directory" << std::endl;
+ " CMakeLists.txt -[DSP|DSW] -Hinsighthome -Dcurrentdir"
+ " -Ooutput directory" << std::endl;
return -1;
}
std::string arg = av[2];
+ cmMakefile builder;
+ SetArgs(builder, ac, av);
+ cmMSProjectGenerator* pg = new cmMSProjectGenerator;
if(arg.find("-DSP", 0) != std::string::npos)
{
- cmDSPMakefile builder;
- SetArgs(builder, ac, av);
- builder.ReadMakefile(av[1]);
- builder.OutputDSPFile();
+ pg->SetBuildDSP();
}
else
{
- cmDSWMakefile builder;
- SetArgs(builder, ac, av);
- builder.ReadMakefile(av[1]);
- builder.OutputDSWFile();
+ pg->SetBuildDSW();
}
+ builder.SetMakefileGenerator(pg);
+ builder.ReadMakefile(av[1]);
+ builder.GenerateMakefile();
return 0;
}
diff --git a/Source/CMakeSetupCMD.dsp b/Source/CMakeSetupCMD.dsp
index 7afdec1..f24c193 100644
--- a/Source/CMakeSetupCMD.dsp
+++ b/Source/CMakeSetupCMD.dsp
@@ -91,15 +91,23 @@ LINK32=link.exe
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
+SOURCE=.\cmAbstractFilesRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmAddTargetRule.cxx
+# End Source File
+# Begin Source File
+
SOURCE=.\CMakeSetupCMD.cxx
# End Source File
# Begin Source File
-SOURCE=.\cmClassFile.cxx
+SOURCE=.\cmAuxSourceDirectoryRule.cxx
# End Source File
# Begin Source File
-SOURCE=.\cmCollectFlags.cxx
+SOURCE=.\cmClassFile.cxx
# End Source File
# Begin Source File
@@ -115,6 +123,38 @@ SOURCE=.\cmDSWMakefile.cxx
# End Source File
# Begin Source File
+SOURCE=.\cmExecutablesRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmFindIncludeRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmFindLibraryRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmFindProgramRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmIncludeDirectoryRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmLibraryRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmLinkDirectoriesRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmLinkLibrariesRule.cxx
+# End Source File
+# Begin Source File
+
SOURCE=.\cmMakeDepend.cxx
# End Source File
# Begin Source File
@@ -123,16 +163,196 @@ SOURCE=.\cmMakefile.cxx
# End Source File
# Begin Source File
+SOURCE=.\cmMakefileGenerator.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmMSProjectGenerator.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmProjectRule.cxx
+# End Source File
+# Begin Source File
+
SOURCE=.\cmRegularExpression.cxx
# End Source File
# Begin Source File
+SOURCE=.\cmSourceFilesRequireRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmSourceFilesRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmSubdirRule.cxx
+# End Source File
+# Begin Source File
+
SOURCE=.\cmSystemTools.cxx
# End Source File
+# Begin Source File
+
+SOURCE=.\cmTestsRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmUnixDefinesRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmUnixLibrariesRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmWin32DefinesRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmWin32LibrariesRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmWindowsConfigure.cxx
+# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\cmAbstractFilesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmAddTargetRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmAuxSourceDirectoryRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmClassFile.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmDirectory.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmDSPMakefile.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmDSWMakefile.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmExecutablesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmFindIncludeRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmFindLibraryRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmFindProgramRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmIncludeDirectoryRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmLibraryRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmLinkDirectoriesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmLinkLibrariesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmMakeDepend.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmMakefile.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmMakefile2.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmMakefileGenerator.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmMSProjectGenerator.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmProjectRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmRegularExpression.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmRuleMaker.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmSourceFilesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmStandardIncludes.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmSubdirRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmSystemTools.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmTestsRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmUnixDefinesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmUnixLibrariesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmWin32DefinesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmWin32LibrariesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cmWindowsConfigure.h
+# End Source File
# End Group
# Begin Group "Resource Files"
diff --git a/Source/MFCDialog/CMakeSetup.dsp b/Source/MFCDialog/CMakeSetup.dsp
index 359c315..b8dc31c 100644
--- a/Source/MFCDialog/CMakeSetup.dsp
+++ b/Source/MFCDialog/CMakeSetup.dsp
@@ -92,6 +92,14 @@ LINK32=link.exe
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
+SOURCE=..\cmAbstractFilesRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmAddTargetRule.cxx
+# End Source File
+# Begin Source File
+
SOURCE=.\CMakeSetup.cpp
# End Source File
# Begin Source File
@@ -100,15 +108,19 @@ SOURCE=.\CMakeSetup.rc
# End Source File
# Begin Source File
+SOURCE=..\CMakeSetupCMD.cxx
+# End Source File
+# Begin Source File
+
SOURCE=.\CMakeSetupDialog.cpp
# End Source File
# Begin Source File
-SOURCE=..\cmClassFile.cxx
+SOURCE=..\cmAuxSourceDirectoryRule.cxx
# End Source File
# Begin Source File
-SOURCE=..\cmCollectFlags.cxx
+SOURCE=..\cmClassFile.cxx
# End Source File
# Begin Source File
@@ -124,6 +136,38 @@ SOURCE=..\cmDSWMakefile.cxx
# End Source File
# Begin Source File
+SOURCE=..\cmExecutablesRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmFindIncludeRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmFindLibraryRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmFindProgramRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmIncludeDirectoryRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmLibraryRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmLinkDirectoriesRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmLinkLibrariesRule.cxx
+# End Source File
+# Begin Source File
+
SOURCE=..\cmMakeDepend.cxx
# End Source File
# Begin Source File
@@ -132,14 +176,58 @@ SOURCE=..\cmMakefile.cxx
# End Source File
# Begin Source File
+SOURCE=..\cmMakefileGenerator.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmMSProjectGenerator.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmProjectRule.cxx
+# End Source File
+# Begin Source File
+
SOURCE=..\cmRegularExpression.cxx
# End Source File
# Begin Source File
+SOURCE=..\cmSourceFilesRequireRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmSourceFilesRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmSubdirRule.cxx
+# End Source File
+# Begin Source File
+
SOURCE=..\cmSystemTools.cxx
# End Source File
# Begin Source File
+SOURCE=..\cmTestsRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmUnixDefinesRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmUnixLibrariesRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmWin32DefinesRule.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmWin32LibrariesRule.cxx
+# End Source File
+# Begin Source File
+
SOURCE=..\cmWindowsConfigure.cxx
# End Source File
# Begin Source File
@@ -153,6 +241,14 @@ SOURCE=.\StdAfx.cpp
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
+SOURCE=..\cmAbstractFilesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmAddTargetRule.h
+# End Source File
+# Begin Source File
+
SOURCE=..\CMakeSetup.h
# End Source File
# Begin Source File
@@ -165,10 +261,18 @@ SOURCE=.\CMakeSetupDialog.h
# End Source File
# Begin Source File
+SOURCE=..\cmAuxSourceDirectoryRule.h
+# End Source File
+# Begin Source File
+
SOURCE=..\cmClassFile.h
# End Source File
# Begin Source File
+SOURCE=..\cmDirectory.h
+# End Source File
+# Begin Source File
+
SOURCE=..\cmDSPBuilder.h
# End Source File
# Begin Source File
@@ -185,6 +289,38 @@ SOURCE=..\cmDSWMakefile.h
# End Source File
# Begin Source File
+SOURCE=..\cmExecutablesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmFindIncludeRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmFindLibraryRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmFindProgramRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmIncludeDirectoryRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmLibraryRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmLinkDirectoriesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmLinkLibrariesRule.h
+# End Source File
+# Begin Source File
+
SOURCE=..\cmMakeDepend.h
# End Source File
# Begin Source File
@@ -193,10 +329,74 @@ SOURCE=..\cmMakefile.h
# End Source File
# Begin Source File
+SOURCE=..\cmMakefile2.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmMakefileGenerator.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmMSProjectGenerator.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmProjectRule.h
+# End Source File
+# Begin Source File
+
SOURCE=..\cmRegularExpression.h
# End Source File
# Begin Source File
+SOURCE=..\cmRuleMaker.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmSourceFilesRequireRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmSourceFilesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmStandardIncludes.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmSubdirRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmSystemTools.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmTestsRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmUnixDefinesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmUnixLibrariesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmWin32DefinesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmWin32LibrariesRule.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\cmWindowsConfigure.h
+# End Source File
+# Begin Source File
+
SOURCE=.\Resource.h
# End Source File
# Begin Source File
diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp
index 0775857..2a01d2c 100644
--- a/Source/MFCDialog/CMakeSetupDialog.cpp
+++ b/Source/MFCDialog/CMakeSetupDialog.cpp
@@ -6,7 +6,7 @@
#include "CMakeSetupDialog.h"
#include "../cmDSWMakefile.h"
#include "../cmWindowsConfigure.h"
-
+#include "../cmMSProjectGenerator.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
@@ -269,19 +269,21 @@ void CMakeSetupDialog::OnOK()
}
- cmDSWMakefile builder;
- // Set the ITK home directory
- builder.SetHomeDirectory(m_WhereSource);
- // Set the CMakeLists.txt file
- CString makefileIn = m_WhereSource;
- makefileIn += "/CMakeLists.txt";
- builder.ReadMakefile(makefileIn);
+ cmMakefile mf;
+ mf.SetMakefileGenerator(new cmMSProjectGenerator);
+ mf.SetHomeDirectory(m_WhereSource);
+
// Set the output directory
- builder.SetOutputDirectory(m_WhereBuild);
+ mf.SetOutputDirectory(m_WhereBuild);
// set the directory which contains the CMakeLists.txt
- builder.SetCurrentDirectory(m_WhereSource);
+ mf.SetCurrentDirectory(m_WhereSource);
// Create the master DSW file and all children dsp files for ITK
- builder.OutputDSWFile();
+ // Set the CMakeLists.txt file
+ CString makefileIn = m_WhereSource;
+ makefileIn += "/CMakeLists.txt";
+ mf.ReadMakefile(makefileIn);
+ // Move this to the cache editor
+ mf.GenerateMakefile();
CDialog::OnOK();
this->SaveToRegistry();
}
diff --git a/Source/Makefile.in b/Source/Makefile.in
index b9d5ca0..b401795 100644
--- a/Source/Makefile.in
+++ b/Source/Makefile.in
@@ -10,26 +10,68 @@ VPATH = @srcdir@
@MAKEINCLUDE@ @MAKEQUOTE@@CMAKE_CONFIG_DIR@/CMake/CMakeSimpleRules.make@MAKEQUOTE@
OBJS = \
-cmClassFile.o \
-cmDirectory.o \
-cmMakefile.o \
-cmUnixMakefile.o \
+CMakeBuildTargets.o \
cmMakeDepend.o \
+cmMakefile.o \
+cmAbstractFilesRule.o \
+cmMakefileGenerator.o \
+cmAddTargetRule.o \
+cmProjectRule.o \
+cmAuxSourceDirectoryRule.o \
cmRegularExpression.o \
+cmClassFile.o \
+cmSourceFilesRule.o \
+cmSourceFilesRequireRule.o \
+cmSubdirRule.o \
cmSystemTools.o \
-CMakeBuildTargets.o \
-cmCollectFlags.o
-
-
-cmCollectFlags.o : cmCollectFlags.h cmCollectFlags.cxx cmSystemTools.h
-cmSystemTools.o : cmSystemTools.h cmSystemTools.cxx cmSystemTools.h
-cmDirectory.o : cmDirectory.h cmDirectory.cxx cmSystemTools.h
-cmClassFile.o : cmClassFile.h cmClassFile.cxx cmSystemTools.h
-cmMakefile.o : cmMakefile.h cmMakefile.cxx cmClassFile.h cmSystemTools.h
-cmUnixMakefile.o : cmUnixMakefile.h cmUnixMakefile.cxx cmMakefile.h cmClassFile.h
-cmMakeDepend.o : cmMakeDepend.h cmMakeDepend.cxx cmMakefile.h cmClassFile.h cmRegularExpression.h
-cmRegularExpression.o : cmRegularExpression.h cmRegularExpression.cxx
-CMakeBuildTargets.o : CMakeBuildTargets.cxx cmMakefile.h cmMakeDepend.h
+cmDirectory.o \
+cmUnixDefinesRule.o \
+cmExecutablesRule.o \
+cmTestsRule.o \
+cmUnixLibrariesRule.o \
+cmFindIncludeRule.o \
+cmFindLibraryRule.o \
+cmUnixMakefileGenerator.o \
+cmFindProgramRule.o \
+cmIncludeDirectoryRule.o \
+cmWin32DefinesRule.o \
+cmLibraryRule.o \
+cmWin32LibrariesRule.o \
+cmLinkDirectoriesRule.o \
+cmLinkLibrariesRule.o
+
+
+cmCollectFlags.o : $(srcdir)/*.h
+CMakeBuildTargets.o : $(srcdir)/*.h
+cmMakeDepend.o : $(srcdir)/*.h
+cmMakefile.o : $(srcdir)/*.h
+cmAbstractFilesRule.o : $(srcdir)/*.h
+cmMakefileGenerator.o : $(srcdir)/*.h
+cmAddTargetRule.o : $(srcdir)/*.h
+cmProjectRule.o : $(srcdir)/*.h
+cmAuxSourceDirectoryRule.o : $(srcdir)/*.h
+cmRegularExpression.o : $(srcdir)/*.h
+cmClassFile.o : $(srcdir)/*.h
+cmSourceFilesRule.o : $(srcdir)/*.h
+cmSourceFilesRequireRule.o : $(srcdir)/*.h
+cmSubdirRule.o : $(srcdir)/*.h
+cmSystemTools.o : $(srcdir)/*.h
+cmDirectory.o : $(srcdir)/*.h
+cmUnixDefinesRule.o : $(srcdir)/*.h
+cmExecutablesRule.o : $(srcdir)/*.h
+cmTestsRule.o : $(srcdir)/*.h
+cmUnixLibrariesRule.o : $(srcdir)/*.h
+cmFindIncludeRule.o : $(srcdir)/*.h
+cmFindLibraryRule.o : $(srcdir)/*.h
+cmUnixMakefileGenerator.o : $(srcdir)/*.h
+cmFindProgramRule.o : $(srcdir)/*.h
+cmIncludeDirectoryRule.o : $(srcdir)/*.h
+cmWin32DefinesRule.o : $(srcdir)/*.h
+cmLibraryRule.o : $(srcdir)/*.h
+cmWin32LibrariesRule.o : $(srcdir)/*.h
+cmLinkDirectoriesRule.o : $(srcdir)/*.h
+cmLinkLibrariesRule.o : $(srcdir)/*.h
+
CMakeBuildTargets: ${OBJS}
${CXX} ${OBJS} ${CXX_FLAGS} -o CMakeBuildTargets
diff --git a/Source/cmAbstractFilesRule.cxx b/Source/cmAbstractFilesRule.cxx
new file mode 100644
index 0000000..3f2e4dc
--- /dev/null
+++ b/Source/cmAbstractFilesRule.cxx
@@ -0,0 +1,26 @@
+#include "cmAbstractFilesRule.h"
+
+// cmAbstractFilesRule
+bool cmAbstractFilesRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 1 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ for(std::vector<std::string>::iterator j = args.begin();
+ j != args.end(); ++j)
+ {
+ std::vector<cmClassFile>& Classes = m_Makefile->GetClasses();
+ for(int i = 0; i < Classes.size(); i++)
+ {
+ if(Classes[i].m_ClassName == (*j))
+ {
+ Classes[i].m_AbstractClass = true;
+ break;
+ }
+ }
+ }
+ return true;
+}
+
diff --git a/Source/cmAbstractFilesRule.h b/Source/cmAbstractFilesRule.h
new file mode 100644
index 0000000..9d22372
--- /dev/null
+++ b/Source/cmAbstractFilesRule.h
@@ -0,0 +1,37 @@
+#ifndef cmAbstractFilesRule_h
+#define cmAbstractFilesRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmAbstractFilesRule : public cmRuleMaker
+{
+public:
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmAbstractFilesRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "ABSTRACT_FILES";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "A list of abstract classes, useful for wrappers.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "ABSTRACT_FILES(file1 file2 ..)";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmAddTargetRule.cxx b/Source/cmAddTargetRule.cxx
new file mode 100644
index 0000000..ff1c728
--- /dev/null
+++ b/Source/cmAddTargetRule.cxx
@@ -0,0 +1,19 @@
+#include "cmAddTargetRule.h"
+
+// cmAddTargetRule
+bool cmAddTargetRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 1 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ return false;
+
+// for(std::vector<std::string>::iterator i = args.begin();
+// i != args.end(); ++i)
+// {
+// m_Makefile->Add((*i).c_str());
+// }
+}
+
diff --git a/Source/cmAddTargetRule.h b/Source/cmAddTargetRule.h
new file mode 100644
index 0000000..232e0f7
--- /dev/null
+++ b/Source/cmAddTargetRule.h
@@ -0,0 +1,37 @@
+#ifndef cmAddTargetRule_h
+#define cmAddTargetRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmAddTargetRule : public cmRuleMaker
+{
+public:
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmAddTargetRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "ADD_TARGET";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Add an extra target to the build system.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "ADD_TARGET(Name \"command to run\");";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmAuxSourceDirectoryRule.cxx b/Source/cmAuxSourceDirectoryRule.cxx
new file mode 100644
index 0000000..e7c5211
--- /dev/null
+++ b/Source/cmAuxSourceDirectoryRule.cxx
@@ -0,0 +1,46 @@
+#include "cmAuxSourceDirectoryRule.h"
+#include "cmDirectory.h"
+
+// cmAuxSourceDirectoryRule
+bool cmAuxSourceDirectoryRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 1 || args.size() > 1)
+ {
+ this->SetError("PROJECT called with incorrect number of arguments");
+ return false;
+ }
+
+ std::string templateDirectory = args[0];
+ m_Makefile->AddExtraDirectory(templateDirectory.c_str());
+ std::string tdir = m_Makefile->GetCurrentDirectory();
+ tdir += "/";
+ tdir += templateDirectory;
+ // Load all the files in the directory
+ cmDirectory dir;
+ if(dir.Load(tdir.c_str()))
+ {
+ int numfiles = dir.GetNumberOfFiles();
+ for(int i =0; i < numfiles; ++i)
+ {
+ std::string file = dir.GetFile(i);
+ // ignore files less than f.cxx in length
+ if(file.size() > 4)
+ {
+ // Remove the extension
+ std::string::size_type dotpos = file.rfind(".");
+ file = file.substr(0, dotpos);
+ std::string fullname = templateDirectory;
+ fullname += "/";
+ fullname += file;
+ // add the file as a class file so
+ // depends can be done
+ cmClassFile cmfile;
+ cmfile.SetName(fullname.c_str(), m_Makefile->GetCurrentDirectory());
+ cmfile.m_AbstractClass = false;
+ m_Makefile->AddClass(cmfile);
+ }
+ }
+ }
+ return true;
+}
+
diff --git a/Source/cmAuxSourceDirectoryRule.h b/Source/cmAuxSourceDirectoryRule.h
new file mode 100644
index 0000000..ab97e93
--- /dev/null
+++ b/Source/cmAuxSourceDirectoryRule.h
@@ -0,0 +1,38 @@
+#ifndef cmAuxSourceDirectoryRule_h
+#define cmAuxSourceDirectoryRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmAuxSourceDirectoryRule : public cmRuleMaker
+{
+public:
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmAuxSourceDirectoryRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "AUX_SOURCE_DIRECTORY";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Add all the source files found in the specified directory to\n"
+ " the build.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "AUX_SOURCE_DIRECTORY(dir)";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmClassFile.cxx b/Source/cmClassFile.cxx
index 21af889..69a720e 100644
--- a/Source/cmClassFile.cxx
+++ b/Source/cmClassFile.cxx
@@ -1,9 +1,6 @@
-#ifdef _MSC_VER
-#pragma warning ( disable : 4786 )
-#endif
#include "cmClassFile.h"
+#include "cmStandardIncludes.h"
#include "cmSystemTools.h"
-#include <iostream>
@@ -62,8 +59,8 @@ void cmClassFile::SetName(const char* name, const char* dir)
hname += ".h";
if(!cmSystemTools::FileExists(hname.c_str()))
{
- std::cerr << "ERROR, can not find file " << hname;
- std::cerr << "Tried .txx .cxx .c " << std::endl;
+ cmSystemTools::Error("can not find file ", hname.c_str());
+ cmSystemTools::Error("Tried .txx .cxx .c for ", hname.c_str());
}
}
diff --git a/Source/cmClassFile.h b/Source/cmClassFile.h
index a8ad7b3..307d13c 100644
--- a/Source/cmClassFile.h
+++ b/Source/cmClassFile.h
@@ -19,12 +19,17 @@
*/
#ifndef cmClassFile_h
#define cmClassFile_h
-#include <string>
-#include <vector>
+#include "cmStandardIncludes.h"
struct cmClassFile
{
+ cmClassFile()
+ {
+ m_AbstractClass = false;
+ m_HeaderFileOnly = false;
+ }
+
/**
* Set the name of the file, given the directory
* the file should be in. Extensions are tried on
diff --git a/Source/cmCollectFlags.cxx b/Source/cmCollectFlags.cxx
deleted file mode 100644
index 855dd20..0000000
--- a/Source/cmCollectFlags.cxx
+++ /dev/null
@@ -1,139 +0,0 @@
-#include "cmCollectFlags.h"
-#include "cmMakefile.h"
-#include "cmSystemTools.h"
-#include <fstream>
-#include <iterator>
-#include <iostream>
-
-cmCollectFlags::cmCollectFlags()
-{
-}
-
-cmCollectFlags::~cmCollectFlags()
-{
-}
-
-void cmCollectFlags::Print()
-{
- std::ostream_iterator<std::string> out(std::cout, "\n");
- std::cout << "m_IncludeDirectories " << std::endl;
- std::copy(m_IncludeDirectories.begin(), m_IncludeDirectories.end(), out);
- std::cout << "m_linkdirectories " << std::endl;
- std::copy(m_LinkDirectories.begin(), m_LinkDirectories.end(), out);
- std::cout << "m_LinkLibraries " << std::endl;
- std::copy(m_LinkLibraries.begin(), m_LinkLibraries.end(), out);
- std::cout << "m_LinkLibrariesWin32 " << std::endl;
- std::copy(m_LinkLibrariesWin32.begin(), m_LinkLibrariesWin32.end(), out);
- std::cout << "m_LinkLibrariesUnix " << std::endl;
- std::copy(m_LinkLibrariesUnix.begin(), m_LinkLibrariesUnix.end(), out);
-}
-
-void cmCollectFlags::SetSourceHomeDirectory(const char* dir)
-{
- m_SourceHomeDirectory = dir;
- cmSystemTools::ConvertToUnixSlashes(m_SourceHomeDirectory);
-}
-
-void cmCollectFlags::SetStartDirectory(const char* dir)
-{
- m_StartDirectory = dir;
- cmSystemTools::ConvertToUnixSlashes(m_StartDirectory);
-}
-
-
-void cmCollectFlags::ParseDirectories()
-{
- this->ParseDirectory(m_StartDirectory.c_str());
-}
-
-
-void cmCollectFlags::ParseFile(const char* filename)
-{
- std::ifstream fin(filename);
- if(!fin)
- {
- std::cerr << "error can not open file " << filename << std::endl;
- return;
- }
- char inbuffer[2048];
- while ( fin.getline(inbuffer, 2047 ) )
- {
- std::string line = inbuffer;
- if(line.find("INCLUDE_DIRECTORIES") != std::string::npos)
- {
- cmSystemTools::ReadList(m_IncludeDirectories, fin);
- }
- if(line.find("LINK_DIRECTORIES") != std::string::npos)
- {
- cmSystemTools::ReadList(m_LinkDirectories, fin);
- }
- if(line.find("LINK_LIBRARIES") != std::string::npos)
- {
- cmSystemTools::ReadList(m_LinkLibraries, fin);
- }
- if(line.find("WIN32_LIBRARIES") != std::string::npos)
- {
- cmSystemTools::ReadList(m_LinkLibrariesWin32, fin);
- }
- if(line.find("UNIX_LIBRARIES") != std::string::npos)
- {
- cmSystemTools::ReadList(m_LinkLibrariesUnix, fin);
- }
- }
-}
-
-
-
-// Go until directory == m_cmHomeDirectory
-// 1. fix slashes
-// 2. peal off /dir until home found, go no higher
-void cmCollectFlags::ParseDirectory(const char* dir)
-{
- std::string listsFile = dir;
- listsFile += "/CMakeLists.txt";
- if(cmSystemTools::FileExists(listsFile.c_str()))
- {
- this->ParseFile(listsFile.c_str());
- }
- if(m_SourceHomeDirectory == dir)
- {
- return;
- }
-
- std::string dotdotDir = dir;
- std::string::size_type pos = dotdotDir.rfind('/');
- if(pos != std::string::npos)
- {
- dotdotDir = dotdotDir.substr(0, pos);
- this->ParseDirectory(dotdotDir.c_str());
- }
-}
-
-
-// expance CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR in the
-// include and library directories.
-
-void cmCollectFlags::ExpandVaribles(cmMakefile* makefile)
-{
- // Now replace varibles
- std::vector<std::string>& includes = m_IncludeDirectories;
- std::vector<std::string>::iterator j, begin, end;
- begin = m_IncludeDirectories.begin();
- end = m_IncludeDirectories.end();
- for(j = begin; j != end; ++j)
- {
- cmSystemTools::ReplaceString(*j, "${CMAKE_BINARY_DIR}",
- makefile->GetOutputHomeDirectory() );
- cmSystemTools::ReplaceString(*j, "${CMAKE_SOURCE_DIR}",
- makefile->GetHomeDirectory() );
- }
- begin = m_LinkDirectories.begin();
- end = m_LinkDirectories.end();
- for(j = begin; j != end; ++j)
- {
- cmSystemTools::ReplaceString(*j, "${CMAKE_BINARY_DIR}",
- makefile->GetOutputHomeDirectory() );
- cmSystemTools::ReplaceString(*j, "${CMAKE_SOURCE_DIR}",
- makefile->GetHomeDirectory() );
- }
-}
diff --git a/Source/cmCollectFlags.h b/Source/cmCollectFlags.h
deleted file mode 100644
index d37afb0..0000000
--- a/Source/cmCollectFlags.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*=========================================================================
-
- Program: Insight Segmentation & Registration Toolkit
- Module: $RCSfile$
- Language: C++
- Date: $Date$
- Version: $Revision$
-
-
- Copyright (c) 2000 National Library of Medicine
- All rights reserved.
-
- See COPYRIGHT.txt for copyright details.
-
-=========================================================================*/
-/**
- * cmCollectFlags - collect flags from CMakeLists.txt files.
- * This class collects include and link flags from a CMakeLists.txt
- * file and any CMakeLists.txt files above it in the directory tree.
- * It stops searching wen the home directory is found.
- */
-#ifndef cmCollectFlags_h
-#define cmCollectFlags_h
-
-#include <vector>
-#include <string>
-class cmMakefile;
-
-class cmCollectFlags
-{
-public:
- cmCollectFlags();
- ~cmCollectFlags ();
- /**
- * Set the home directory for the source code.
- */
- void SetSourceHomeDirectory(const char* dir);
- /**
- * Set the start directory to look for flags
- */
- void SetStartDirectory(const char* dir);
- /**
- * Parse the directory and all of it's parents for config
- * information
- */
- void ParseDirectories();
- /**
- * Print to standard out
- */
- void Print();
-
- /**
- * Expance varibles for home and binary root in the collected flags.
- * CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR are replaced with
- * makefile->GetOutputHomeDirectory() and
- * makefile->GetHomeDirectory()
- */
- void ExpandVaribles(cmMakefile* makefile);
-
- std::vector<std::string>& GetIncludeDirectories()
- {
- return m_IncludeDirectories;
- }
-
- std::vector<std::string>& GetLinkDirectories()
- {
- return m_LinkDirectories;
- }
-
- std::vector<std::string>& GetLinkLibraries()
- {
- return m_LinkLibraries;
- }
-
- std::vector<std::string>& GetLinkLibrariesWin32()
- {
- return m_LinkLibrariesWin32;
- }
-
- std::vector<std::string>& GetLinkLibrariesUnix()
- {
- return m_LinkLibrariesUnix;
- }
-
-private:
- /**
- * Look for CMakeLists.txt files to parse in dir,
- * then in dir's parents, until the SourceHome directory
- * is found.
- */
- void ParseDirectory(const char* dir);
- /**
- * Parse a file for includes links and libs
- */
- void ParseFile(const char* dir);
-
-
- std::string m_SourceHomeDirectory; // source code top level dir
- std::string m_StartDirectory; // source code sub directory
- std::vector<std::string> m_IncludeDirectories;
- std::vector<std::string> m_LinkDirectories;
- std::vector<std::string> m_LinkLibraries;
- std::vector<std::string> m_LinkLibrariesWin32;
- std::vector<std::string> m_LinkLibrariesUnix;
-};
-
-#endif
diff --git a/Source/cmDSPMakefile.cxx b/Source/cmDSPMakefile.cxx
index 9147bcb..1d62694 100644
--- a/Source/cmDSPMakefile.cxx
+++ b/Source/cmDSPMakefile.cxx
@@ -1,8 +1,6 @@
#include "cmDSPMakefile.h"
+#include "cmStandardIncludes.h"
#include "cmSystemTools.h"
-#include "cmCollectFlags.h"
-#include <iostream>
-#include <fstream>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef GetCurrentDirectory
@@ -12,12 +10,20 @@ static void Die(const char* message)
MessageBox(0, message, 0, MB_OK);
exit(-1);
}
+cmDSPMakefile::~cmDSPMakefile()
+{
+}
+
+cmDSPMakefile::cmDSPMakefile(cmMakefile*mf)
+{
+ m_Makefile = mf;
+}
void cmDSPMakefile::OutputDSPFile()
{
// Setup /I and /LIBPATH options
- std::vector<std::string>& includes = m_BuildFlags.GetIncludeDirectories();
+ std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
std::vector<std::string>::iterator i;
for(i = includes.begin(); i != includes.end(); ++i)
{
@@ -25,21 +31,21 @@ void cmDSPMakefile::OutputDSPFile()
m_IncludeOptions += *i;
m_IncludeOptions += "\" ";
}
- std::vector<std::string>& libs = m_BuildFlags.GetLinkLibraries();
+ std::vector<std::string>& libs = m_Makefile->GetLinkLibraries();
for(i = libs.begin(); i != libs.end(); ++i)
{
m_DebugLibraryOptions += " ";
m_DebugLibraryOptions += *i;
m_DebugLibraryOptions += ".lib ";
}
- std::vector<std::string>& libswin32 = m_BuildFlags.GetLinkLibrariesWin32();
+ std::vector<std::string>& libswin32 = m_Makefile->GetLinkLibrariesWin32();
for(i = libswin32.begin(); i != libswin32.end(); ++i)
{
m_DebugLibraryOptions += " ";
m_DebugLibraryOptions += *i;
m_DebugLibraryOptions += ".lib ";
}
- std::vector<std::string>& libdirs = m_BuildFlags.GetLinkDirectories();
+ std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
for(i = libdirs.begin(); i != libdirs.end(); ++i)
{
m_DebugLibraryOptions += " /LIBPATH:\"";
@@ -53,23 +59,27 @@ void cmDSPMakefile::OutputDSPFile()
}
}
m_DebugLibraryOptions += "/STACK:10000000 ";
+ // add any extra define flags
+ m_DebugLibraryOptions += m_Makefile->GetDefineFlags();
m_ReleaseLibraryOptions = m_DebugLibraryOptions;
cmSystemTools::ReplaceString(m_ReleaseLibraryOptions, "Debug", "Release");
+
// If the output directory is not the m_cmHomeDirectory
// then create it.
- if(m_OutputDirectory != m_cmHomeDirectory)
+ if(strcmp(m_Makefile->GetOutputDirectory(),
+ m_Makefile->GetHomeDirectory()) != 0)
{
- if(!cmSystemTools::MakeDirectory(m_OutputDirectory.c_str()))
+ if(!cmSystemTools::MakeDirectory(m_Makefile->GetOutputDirectory()))
{
std::string message = "Error creating directory ";
- message += m_OutputDirectory;
+ message += m_Makefile->GetOutputDirectory();
Die(message.c_str());
}
}
- if(!m_Executables)
+ if(!m_Makefile->HasExecutables())
{
- if(this->m_LibraryName == "")
+ if(strlen(m_Makefile->GetLibraryName()) == 0)
{
// if no library silently give up
return;
@@ -84,10 +94,11 @@ void cmDSPMakefile::OutputDSPFile()
}
void cmDSPMakefile::CreateExecutableDSPFiles()
{
- for(int i = 0; i < m_Classes.size(); ++i)
+ std::vector<cmClassFile>& Classes = m_Makefile->GetClasses();
+ for(int i = 0; i < Classes.size(); ++i)
{
- cmClassFile& classfile = m_Classes[i];
- std::string fname = m_OutputDirectory;
+ cmClassFile& classfile = Classes[i];
+ std::string fname = m_Makefile->GetOutputDirectory();
fname += "/";
fname += classfile.m_ClassName;
fname += ".dsp";
@@ -100,9 +111,9 @@ void cmDSPMakefile::CreateExecutableDSPFiles()
}
else
{
- m_LibraryName = classfile.m_ClassName;
+ m_Makefile->SetLibraryName(classfile.m_ClassName.c_str());
this->SetBuildType(EXECUTABLE);
- std::string pname = m_LibraryName;
+ std::string pname = m_Makefile->GetLibraryName();
m_CreatedProjectNames.push_back(pname);
this->WriteDSPHeader(fout);
@@ -120,12 +131,12 @@ void cmDSPMakefile::CreateExecutableDSPFiles()
void cmDSPMakefile::CreateSingleDSP()
{
std::string fname;
- fname = m_OutputDirectory;
+ fname = m_Makefile->GetOutputDirectory();
fname += "/";
- fname += this->m_LibraryName;
+ fname += m_Makefile->GetLibraryName();
fname += ".dsp";
m_CreatedProjectNames.clear();
- std::string pname = m_LibraryName;
+ std::string pname = m_Makefile->GetLibraryName();
m_CreatedProjectNames.push_back(pname);
std::ofstream fout(fname.c_str());
if(!fout)
@@ -141,20 +152,20 @@ void cmDSPMakefile::WriteDSPBuildRule(std::ostream& fout)
{
std::string dspname = *(m_CreatedProjectNames.end()-1);
dspname += ".dsp";
- std::string makefileIn = this->GetCurrentDirectory();
+ std::string makefileIn = m_Makefile->GetCurrentDirectory();
makefileIn += "/";
makefileIn += "CMakeLists.txt";
- std::string dsprule = GetHomeDirectory();
+ std::string dsprule = m_Makefile->GetHomeDirectory();
dsprule += "/CMake/Source/CMakeSetupCMD ";
dsprule += makefileIn;
dsprule += " -DSP -H";
- dsprule += this->GetHomeDirectory();
+ dsprule += m_Makefile->GetHomeDirectory();
dsprule += " -D";
- dsprule += this->GetCurrentDirectory();
+ dsprule += m_Makefile->GetCurrentDirectory();
dsprule += " -O";
- dsprule += this->GetOutputDirectory();
+ dsprule += m_Makefile->GetOutputDirectory();
dsprule += " -B";
- dsprule += this->GetOutputHomeDirectory();
+ dsprule += m_Makefile->GetOutputHomeDirectory();
this->WriteCustomRule(fout, makefileIn.c_str(),
dspname.c_str(),
dsprule.c_str());
@@ -172,9 +183,9 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout)
void cmDSPMakefile::WriteCustomRule(std::ostream& fout,
- const char* source,
- const char* result,
- const char* command)
+ const char* source,
+ const char* result,
+ const char* command)
{
fout << "# Begin Source File\n\n";
fout << "SOURCE=" << source << "\n\n";
@@ -208,21 +219,21 @@ void cmDSPMakefile::SetBuildType(BuildType b)
switch(b)
{
case STATIC_LIBRARY:
- m_DSPHeaderTemplate = m_cmHomeDirectory;
+ m_DSPHeaderTemplate = m_Makefile->GetHomeDirectory();
m_DSPHeaderTemplate += "/CMake/Source/staticLibHeader.dsptemplate";
- m_DSPFooterTemplate = m_cmHomeDirectory;
+ m_DSPFooterTemplate = m_Makefile->GetHomeDirectory();
m_DSPFooterTemplate += "/CMake/Source/staticLibFooter.dsptemplate";
break;
case DLL:
- m_DSPHeaderTemplate = m_cmHomeDirectory;
+ m_DSPHeaderTemplate = m_Makefile->GetHomeDirectory();
m_DSPHeaderTemplate += "/CMake/Source/DLLHeader.dsptemplate";
- m_DSPFooterTemplate = m_cmHomeDirectory;
+ m_DSPFooterTemplate = m_Makefile->GetHomeDirectory();
m_DSPFooterTemplate += "/CMake/Source/DLLFooter.dsptemplate";
break;
case EXECUTABLE:
- m_DSPHeaderTemplate = m_cmHomeDirectory;
+ m_DSPHeaderTemplate = m_Makefile->GetHomeDirectory();
m_DSPHeaderTemplate += "/CMake/Source/EXEHeader.dsptemplate";
- m_DSPFooterTemplate = m_cmHomeDirectory;
+ m_DSPFooterTemplate = m_Makefile->GetHomeDirectory();
m_DSPFooterTemplate += "/CMake/Source/EXEFooter.dsptemplate";
break;
}
@@ -250,7 +261,7 @@ void cmDSPMakefile::WriteDSPHeader(std::ostream& fout)
cmSystemTools::ReplaceString(line, "BUILD_INCLUDES",
m_IncludeOptions.c_str());
cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",
- m_LibraryName.c_str());
+ m_Makefile->GetLibraryName());
cmSystemTools::ReplaceString(line,
"EXTRA_DEFINES", "");
fout << line.c_str() << std::endl;
@@ -278,11 +289,12 @@ void cmDSPMakefile::WriteDSPFooter(std::ostream& fout)
void cmDSPMakefile::WriteDSPBuildRules(std::ostream& fout)
{
- for(int i = 0; i < m_Classes.size(); ++i)
+ std::vector<cmClassFile>& Classes = m_Makefile->GetClasses();
+ for(int i = 0; i < Classes.size(); ++i)
{
- if(!m_Classes[i].m_AbstractClass && !m_Classes[i].m_HeaderFileOnly)
+ if(!Classes[i].m_AbstractClass && !Classes[i].m_HeaderFileOnly)
{
- this->WriteDSPBuildRule(fout, m_Classes[i].m_FullPath.c_str());
+ this->WriteDSPBuildRule(fout, Classes[i].m_FullPath.c_str());
}
}
}
diff --git a/Source/cmDSPMakefile.h b/Source/cmDSPMakefile.h
index bdc2a3b..6021842 100644
--- a/Source/cmDSPMakefile.h
+++ b/Source/cmDSPMakefile.h
@@ -20,15 +20,14 @@
*/
#ifndef cmDSPMakefile_h
#define cmDSPMakefile_h
-#ifdef _MSC_VER
-#pragma warning ( disable : 4786 )
-#endif
+#include "cmStandardIncludes.h"
#include "cmMakefile.h"
-#include <vector>
-class cmDSPMakefile : public cmMakefile
+class cmDSPMakefile
{
public:
+ cmDSPMakefile(cmMakefile*);
+ ~cmDSPMakefile();
void OutputDSPFile();
enum BuildType { STATIC_LIBRARY, DLL, EXECUTABLE };
void SetBuildType(BuildType );
@@ -38,6 +37,10 @@ public:
{
return m_CreatedProjectNames;
}
+ cmMakefile* GetMakefile()
+ {
+ return m_Makefile;
+ }
private:
std::string m_DSPHeaderTemplate;
@@ -64,6 +67,7 @@ private:
std::string m_IncludeOptions;
std::string m_DebugLibraryOptions;
std::string m_ReleaseLibraryOptions;
+ cmMakefile* m_Makefile;
};
#endif
diff --git a/Source/cmDSPWriter.cxx b/Source/cmDSPWriter.cxx
index 9147bcb..1d62694 100644
--- a/Source/cmDSPWriter.cxx
+++ b/Source/cmDSPWriter.cxx
@@ -1,8 +1,6 @@
#include "cmDSPMakefile.h"
+#include "cmStandardIncludes.h"
#include "cmSystemTools.h"
-#include "cmCollectFlags.h"
-#include <iostream>
-#include <fstream>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef GetCurrentDirectory
@@ -12,12 +10,20 @@ static void Die(const char* message)
MessageBox(0, message, 0, MB_OK);
exit(-1);
}
+cmDSPMakefile::~cmDSPMakefile()
+{
+}
+
+cmDSPMakefile::cmDSPMakefile(cmMakefile*mf)
+{
+ m_Makefile = mf;
+}
void cmDSPMakefile::OutputDSPFile()
{
// Setup /I and /LIBPATH options
- std::vector<std::string>& includes = m_BuildFlags.GetIncludeDirectories();
+ std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
std::vector<std::string>::iterator i;
for(i = includes.begin(); i != includes.end(); ++i)
{
@@ -25,21 +31,21 @@ void cmDSPMakefile::OutputDSPFile()
m_IncludeOptions += *i;
m_IncludeOptions += "\" ";
}
- std::vector<std::string>& libs = m_BuildFlags.GetLinkLibraries();
+ std::vector<std::string>& libs = m_Makefile->GetLinkLibraries();
for(i = libs.begin(); i != libs.end(); ++i)
{
m_DebugLibraryOptions += " ";
m_DebugLibraryOptions += *i;
m_DebugLibraryOptions += ".lib ";
}
- std::vector<std::string>& libswin32 = m_BuildFlags.GetLinkLibrariesWin32();
+ std::vector<std::string>& libswin32 = m_Makefile->GetLinkLibrariesWin32();
for(i = libswin32.begin(); i != libswin32.end(); ++i)
{
m_DebugLibraryOptions += " ";
m_DebugLibraryOptions += *i;
m_DebugLibraryOptions += ".lib ";
}
- std::vector<std::string>& libdirs = m_BuildFlags.GetLinkDirectories();
+ std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
for(i = libdirs.begin(); i != libdirs.end(); ++i)
{
m_DebugLibraryOptions += " /LIBPATH:\"";
@@ -53,23 +59,27 @@ void cmDSPMakefile::OutputDSPFile()
}
}
m_DebugLibraryOptions += "/STACK:10000000 ";
+ // add any extra define flags
+ m_DebugLibraryOptions += m_Makefile->GetDefineFlags();
m_ReleaseLibraryOptions = m_DebugLibraryOptions;
cmSystemTools::ReplaceString(m_ReleaseLibraryOptions, "Debug", "Release");
+
// If the output directory is not the m_cmHomeDirectory
// then create it.
- if(m_OutputDirectory != m_cmHomeDirectory)
+ if(strcmp(m_Makefile->GetOutputDirectory(),
+ m_Makefile->GetHomeDirectory()) != 0)
{
- if(!cmSystemTools::MakeDirectory(m_OutputDirectory.c_str()))
+ if(!cmSystemTools::MakeDirectory(m_Makefile->GetOutputDirectory()))
{
std::string message = "Error creating directory ";
- message += m_OutputDirectory;
+ message += m_Makefile->GetOutputDirectory();
Die(message.c_str());
}
}
- if(!m_Executables)
+ if(!m_Makefile->HasExecutables())
{
- if(this->m_LibraryName == "")
+ if(strlen(m_Makefile->GetLibraryName()) == 0)
{
// if no library silently give up
return;
@@ -84,10 +94,11 @@ void cmDSPMakefile::OutputDSPFile()
}
void cmDSPMakefile::CreateExecutableDSPFiles()
{
- for(int i = 0; i < m_Classes.size(); ++i)
+ std::vector<cmClassFile>& Classes = m_Makefile->GetClasses();
+ for(int i = 0; i < Classes.size(); ++i)
{
- cmClassFile& classfile = m_Classes[i];
- std::string fname = m_OutputDirectory;
+ cmClassFile& classfile = Classes[i];
+ std::string fname = m_Makefile->GetOutputDirectory();
fname += "/";
fname += classfile.m_ClassName;
fname += ".dsp";
@@ -100,9 +111,9 @@ void cmDSPMakefile::CreateExecutableDSPFiles()
}
else
{
- m_LibraryName = classfile.m_ClassName;
+ m_Makefile->SetLibraryName(classfile.m_ClassName.c_str());
this->SetBuildType(EXECUTABLE);
- std::string pname = m_LibraryName;
+ std::string pname = m_Makefile->GetLibraryName();
m_CreatedProjectNames.push_back(pname);
this->WriteDSPHeader(fout);
@@ -120,12 +131,12 @@ void cmDSPMakefile::CreateExecutableDSPFiles()
void cmDSPMakefile::CreateSingleDSP()
{
std::string fname;
- fname = m_OutputDirectory;
+ fname = m_Makefile->GetOutputDirectory();
fname += "/";
- fname += this->m_LibraryName;
+ fname += m_Makefile->GetLibraryName();
fname += ".dsp";
m_CreatedProjectNames.clear();
- std::string pname = m_LibraryName;
+ std::string pname = m_Makefile->GetLibraryName();
m_CreatedProjectNames.push_back(pname);
std::ofstream fout(fname.c_str());
if(!fout)
@@ -141,20 +152,20 @@ void cmDSPMakefile::WriteDSPBuildRule(std::ostream& fout)
{
std::string dspname = *(m_CreatedProjectNames.end()-1);
dspname += ".dsp";
- std::string makefileIn = this->GetCurrentDirectory();
+ std::string makefileIn = m_Makefile->GetCurrentDirectory();
makefileIn += "/";
makefileIn += "CMakeLists.txt";
- std::string dsprule = GetHomeDirectory();
+ std::string dsprule = m_Makefile->GetHomeDirectory();
dsprule += "/CMake/Source/CMakeSetupCMD ";
dsprule += makefileIn;
dsprule += " -DSP -H";
- dsprule += this->GetHomeDirectory();
+ dsprule += m_Makefile->GetHomeDirectory();
dsprule += " -D";
- dsprule += this->GetCurrentDirectory();
+ dsprule += m_Makefile->GetCurrentDirectory();
dsprule += " -O";
- dsprule += this->GetOutputDirectory();
+ dsprule += m_Makefile->GetOutputDirectory();
dsprule += " -B";
- dsprule += this->GetOutputHomeDirectory();
+ dsprule += m_Makefile->GetOutputHomeDirectory();
this->WriteCustomRule(fout, makefileIn.c_str(),
dspname.c_str(),
dsprule.c_str());
@@ -172,9 +183,9 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout)
void cmDSPMakefile::WriteCustomRule(std::ostream& fout,
- const char* source,
- const char* result,
- const char* command)
+ const char* source,
+ const char* result,
+ const char* command)
{
fout << "# Begin Source File\n\n";
fout << "SOURCE=" << source << "\n\n";
@@ -208,21 +219,21 @@ void cmDSPMakefile::SetBuildType(BuildType b)
switch(b)
{
case STATIC_LIBRARY:
- m_DSPHeaderTemplate = m_cmHomeDirectory;
+ m_DSPHeaderTemplate = m_Makefile->GetHomeDirectory();
m_DSPHeaderTemplate += "/CMake/Source/staticLibHeader.dsptemplate";
- m_DSPFooterTemplate = m_cmHomeDirectory;
+ m_DSPFooterTemplate = m_Makefile->GetHomeDirectory();
m_DSPFooterTemplate += "/CMake/Source/staticLibFooter.dsptemplate";
break;
case DLL:
- m_DSPHeaderTemplate = m_cmHomeDirectory;
+ m_DSPHeaderTemplate = m_Makefile->GetHomeDirectory();
m_DSPHeaderTemplate += "/CMake/Source/DLLHeader.dsptemplate";
- m_DSPFooterTemplate = m_cmHomeDirectory;
+ m_DSPFooterTemplate = m_Makefile->GetHomeDirectory();
m_DSPFooterTemplate += "/CMake/Source/DLLFooter.dsptemplate";
break;
case EXECUTABLE:
- m_DSPHeaderTemplate = m_cmHomeDirectory;
+ m_DSPHeaderTemplate = m_Makefile->GetHomeDirectory();
m_DSPHeaderTemplate += "/CMake/Source/EXEHeader.dsptemplate";
- m_DSPFooterTemplate = m_cmHomeDirectory;
+ m_DSPFooterTemplate = m_Makefile->GetHomeDirectory();
m_DSPFooterTemplate += "/CMake/Source/EXEFooter.dsptemplate";
break;
}
@@ -250,7 +261,7 @@ void cmDSPMakefile::WriteDSPHeader(std::ostream& fout)
cmSystemTools::ReplaceString(line, "BUILD_INCLUDES",
m_IncludeOptions.c_str());
cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",
- m_LibraryName.c_str());
+ m_Makefile->GetLibraryName());
cmSystemTools::ReplaceString(line,
"EXTRA_DEFINES", "");
fout << line.c_str() << std::endl;
@@ -278,11 +289,12 @@ void cmDSPMakefile::WriteDSPFooter(std::ostream& fout)
void cmDSPMakefile::WriteDSPBuildRules(std::ostream& fout)
{
- for(int i = 0; i < m_Classes.size(); ++i)
+ std::vector<cmClassFile>& Classes = m_Makefile->GetClasses();
+ for(int i = 0; i < Classes.size(); ++i)
{
- if(!m_Classes[i].m_AbstractClass && !m_Classes[i].m_HeaderFileOnly)
+ if(!Classes[i].m_AbstractClass && !Classes[i].m_HeaderFileOnly)
{
- this->WriteDSPBuildRule(fout, m_Classes[i].m_FullPath.c_str());
+ this->WriteDSPBuildRule(fout, Classes[i].m_FullPath.c_str());
}
}
}
diff --git a/Source/cmDSPWriter.h b/Source/cmDSPWriter.h
index bdc2a3b..6021842 100644
--- a/Source/cmDSPWriter.h
+++ b/Source/cmDSPWriter.h
@@ -20,15 +20,14 @@
*/
#ifndef cmDSPMakefile_h
#define cmDSPMakefile_h
-#ifdef _MSC_VER
-#pragma warning ( disable : 4786 )
-#endif
+#include "cmStandardIncludes.h"
#include "cmMakefile.h"
-#include <vector>
-class cmDSPMakefile : public cmMakefile
+class cmDSPMakefile
{
public:
+ cmDSPMakefile(cmMakefile*);
+ ~cmDSPMakefile();
void OutputDSPFile();
enum BuildType { STATIC_LIBRARY, DLL, EXECUTABLE };
void SetBuildType(BuildType );
@@ -38,6 +37,10 @@ public:
{
return m_CreatedProjectNames;
}
+ cmMakefile* GetMakefile()
+ {
+ return m_Makefile;
+ }
private:
std::string m_DSPHeaderTemplate;
@@ -64,6 +67,7 @@ private:
std::string m_IncludeOptions;
std::string m_DebugLibraryOptions;
std::string m_ReleaseLibraryOptions;
+ cmMakefile* m_Makefile;
};
#endif
diff --git a/Source/cmDSWMakefile.cxx b/Source/cmDSWMakefile.cxx
index 3ee71f9..fb5c718 100644
--- a/Source/cmDSWMakefile.cxx
+++ b/Source/cmDSWMakefile.cxx
@@ -1,46 +1,47 @@
-#ifdef _MSC_VER
-#pragma warning ( disable : 4786 )
-#endif
#include "cmDSWMakefile.h"
+#include "cmStandardIncludes.h"
#include "cmSystemTools.h"
#include "cmDSPMakefile.h"
-#include <iostream>
-#include <fstream>
+#include "cmMSProjectGenerator.h"
#include <windows.h>
// microsoft nonsense
#undef GetCurrentDirectory
#undef SetCurrentDirectory
+cmDSWMakefile::cmDSWMakefile(cmMakefile* m)
+{
+ m_Makefile = m;
+}
+
// output the DSW file
void cmDSWMakefile::OutputDSWFile()
{
- if(m_OutputDirectory == "")
+ if(m_Makefile->GetOutputDirectory() == "")
{
// default to build in place
- m_OutputDirectory = m_cmHomeDirectory;
+ m_Makefile->SetOutputDirectory(m_Makefile->GetHomeDirectory());
}
// If the output directory is not the m_cmHomeDirectory
// then create it.
- if(m_OutputDirectory != m_cmHomeDirectory)
+ if(strcmp(m_Makefile->GetOutputDirectory(),
+ m_Makefile->GetHomeDirectory()) != 0)
{
- if(!cmSystemTools::MakeDirectory(m_OutputDirectory.c_str()))
+ if(!cmSystemTools::MakeDirectory(m_Makefile->GetOutputDirectory()))
{
MessageBox(0, "Error creating directory ", 0, MB_OK);
- MessageBox(0, m_OutputDirectory.c_str(), 0, MB_OK);
+ MessageBox(0, m_Makefile->GetOutputDirectory(), 0, MB_OK);
}
}
std::string fname;
- fname = m_OutputDirectory;
+ fname = m_Makefile->GetOutputDirectory();
fname += "/";
- fname += this->m_ProjectName;
+ fname += m_Makefile->GetProjectName();
fname += ".dsw";
- std::cerr << "writting dsw file " << fname.c_str() << std::endl;
std::ofstream fout(fname.c_str());
if(!fout)
{
- std::cerr << "Error can not open "
- << fname.c_str() << " for write" << std::endl;
+ cmSystemTools::Error("Error can not open for write: " , fname.c_str());
return;
}
this->WriteDSWFile(fout);
@@ -53,10 +54,12 @@ void cmDSWMakefile::OutputDSWFile()
// The result is a vector of cmDSPMakefile objects, one for
// each directory with a CMakeLists.txt file
//
-void cmDSWMakefile::FindAllCMakeListsFiles(const char* subdir,
- std::vector<cmDSPMakefile*>& makefiles)
+void
+cmDSWMakefile
+::FindAllCMakeListsFiles(const char* subdir,
+ std::vector<cmMSProjectGenerator*>& makefiles)
{
- std::string currentDir = this->GetCurrentDirectory();
+ std::string currentDir = m_Makefile->GetCurrentDirectory();
currentDir += "/";
currentDir += subdir;
currentDir += "/";
@@ -66,31 +69,34 @@ void cmDSWMakefile::FindAllCMakeListsFiles(const char* subdir,
if(cmSystemTools::FileExists(currentDir.c_str()))
{
// Create a new cmDSPMakefile to read the currentDir CMakeLists.txt file
- cmDSPMakefile* dsp = new cmDSPMakefile;
+ cmMSProjectGenerator* pg = new cmMSProjectGenerator;
+ pg->SetBuildDSP();
+ cmMakefile* mf = new cmMakefile;
+ mf->SetMakefileGenerator(pg);
// add it to the vector
- makefiles.push_back(dsp);
+ makefiles.push_back(pg);
// Set up the file with the current context
- dsp->SetOutputHomeDirectory(this->GetOutputDirectory());
- dsp->SetHomeDirectory(this->GetHomeDirectory());
+ mf->SetOutputHomeDirectory(m_Makefile->GetOutputDirectory());
+ mf->SetHomeDirectory(m_Makefile->GetHomeDirectory());
// set the current directory in the Source as a full
// path
- std::string currentDir = this->GetCurrentDirectory();
+ std::string currentDir = m_Makefile->GetCurrentDirectory();
currentDir += "/";
currentDir += subdir;
- dsp->SetCurrentDirectory(currentDir.c_str());
+ mf->SetCurrentDirectory(currentDir.c_str());
// Parse the CMakeLists.txt file
currentDir += "/CMakeLists.txt";
- dsp->ReadMakefile(currentDir.c_str());
+ mf->ReadMakefile(currentDir.c_str());
// Set the output directory which may be different than the source
- std::string outdir = m_OutputDirectory;
+ std::string outdir = m_Makefile->GetOutputDirectory();
outdir += "/";
outdir += subdir;
- dsp->SetOutputDirectory(outdir.c_str());
+ mf->SetOutputDirectory(outdir.c_str());
// Create the DSP file
- dsp->OutputDSPFile();
+ mf->GenerateMakefile();
// Look at any sub directories parsed (SUBDIRS) and
// recurse into them
- const std::vector<std::string>& subdirs = dsp->GetSubDirectories();
+ const std::vector<std::string>& subdirs = mf->GetSubDirectories();
for(std::vector<std::string>::const_iterator i = subdirs.begin();
i != subdirs.end(); ++i)
{
@@ -105,8 +111,8 @@ void cmDSWMakefile::FindAllCMakeListsFiles(const char* subdir,
}
else
{
- std::cerr << "Can not find CMakeLists.txt in " << currentDir.c_str()
- << std::endl;
+ cmSystemTools::Error("Can not find CMakeLists.txt in ",
+ currentDir.c_str());
}
}
@@ -117,43 +123,43 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
// Write out the header for a DSW file
this->WriteDSWHeader(fout);
// Create an array of dsp files for the project
- std::vector<cmDSPMakefile*> dspfiles;
+ std::vector<cmMSProjectGenerator*> dspfiles;
// loop over all the subdirectories for the DSW file,
// and find all sub directory projects
- for(std::vector<std::string>::iterator j = m_SubDirectories.begin();
- j != m_SubDirectories.end(); ++j)
+ const std::vector<std::string>& dirs = m_Makefile->GetSubDirectories();
+ for(std::vector<std::string>::const_iterator j = dirs.begin();
+ j != dirs.end(); ++j)
{
this->FindAllCMakeListsFiles(j->c_str(), dspfiles);
}
// For each DSP file created insert them into the DSW file
- for(std::vector<cmDSPMakefile*>::iterator k = dspfiles.begin();
+ for(std::vector<cmMSProjectGenerator*>::iterator k = dspfiles.begin();
k != dspfiles.end(); ++k)
{
// Get the directory for the dsp file, it comes
// from the source, so it has the source path which needs
// to be removed as this may be built in a different directory
// than the source
- std::string dir = (*k)->GetCurrentDirectory();
+ std::string dir = (*k)->GetDSPMakefile()->
+ GetMakefile()->GetCurrentDirectory();
// Get the home directory with the trailing slash
- std::string homedir = this->GetHomeDirectory();
+ std::string homedir = m_Makefile->GetHomeDirectory();
homedir += "/";
// make the directory relative by removing the home directory part
cmSystemTools::ReplaceString(dir, homedir.c_str(), "");
// Get the list of create dsp files from the cmDSPMakefile, more
// than one dsp could have been created per input CMakeLists.txt file
- std::vector<std::string> dspnames = (*k)->GetCreatedProjectNames();
- std::cerr << "Create dsp for "
- << dspnames.size()
- << " number of dsp files in " << dir << std::endl;
+ std::vector<std::string> dspnames = (*k)->GetDSPMakefile()->GetCreatedProjectNames();
for(std::vector<std::string>::iterator si = dspnames.begin();
si != dspnames.end(); ++si)
{
// Write the project into the DSW file
- this->WriteProject(fout, si->c_str(), dir.c_str(), *k);
+ this->WriteProject(fout, si->c_str(), dir.c_str(),
+ (*k)->GetDSPMakefile());
}
// delete the cmDSPMakefile object once done with it to avoid
// leaks
- delete *k;
+ delete (*k)->GetDSPMakefile()->GetMakefile();
}
// Write the footer for the DSW file
this->WriteDSWFooter(fout);
@@ -163,7 +169,7 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
void cmDSWMakefile::WriteProject(std::ostream& fout,
const char* dspname,
const char* dir,
- cmMakefile* project)
+ cmDSPMakefile* project)
{
fout << "###############################################################################\n\n";
fout << "Project: \"" << dspname << "\"="
@@ -171,12 +177,12 @@ void cmDSWMakefile::WriteProject(std::ostream& fout,
fout << "Package=<5>\n{{{\n}}}\n\n";
fout << "Package=<4>\n";
fout << "{{{\n";
- if(project->HasExecutables())
+ if(project->GetMakefile()->HasExecutables())
{
// insert Begin Project Dependency Project_Dep_Name project stuff here
std::vector<std::string>::iterator i, end;
- i = project->GetBuildFlags().GetLinkLibraries().begin();
- end = project->GetBuildFlags().GetLinkLibraries().end();
+ i = project->GetMakefile()->GetLinkLibraries().begin();
+ end = project->GetMakefile()->GetLinkLibraries().end();
for(;i!= end; ++i)
{
fout << "Begin Project Dependency\n";
diff --git a/Source/cmDSWMakefile.h b/Source/cmDSWMakefile.h
index 4a2fbf9..6a476b7 100644
--- a/Source/cmDSWMakefile.h
+++ b/Source/cmDSWMakefile.h
@@ -18,28 +18,27 @@
*/
#ifndef cmDSWMakefile_h
#define cmDSWMakefile_h
-#ifdef _MSC_VER
-#pragma warning ( disable : 4786 )
-#endif
-
+#include "cmStandardIncludes.h"
#include "cmMakefile.h"
-#include <vector>
-class cmDSPMakefile;
+class cmDSPMakefile;
+class cmMSProjectGenerator;
-class cmDSWMakefile : public cmMakefile
+class cmDSWMakefile
{
public:
+ cmDSWMakefile(cmMakefile*);
virtual void OutputDSWFile();
private:
void FindAllCMakeListsFiles(const char* subdir,
- std::vector<cmDSPMakefile*>&);
+ std::vector<cmMSProjectGenerator*>&);
void WriteDSWFile(std::ostream& fout);
void WriteDSWHeader(std::ostream& fout);
void WriteProject(std::ostream& fout,
- const char* name, const char* path,
- cmMakefile* project);
+ const char* name, const char* path,
+ cmDSPMakefile* project);
void WriteDSWFooter(std::ostream& fout);
+ cmMakefile* m_Makefile;
};
#endif
diff --git a/Source/cmDSWWriter.cxx b/Source/cmDSWWriter.cxx
index 3ee71f9..fb5c718 100644
--- a/Source/cmDSWWriter.cxx
+++ b/Source/cmDSWWriter.cxx
@@ -1,46 +1,47 @@
-#ifdef _MSC_VER
-#pragma warning ( disable : 4786 )
-#endif
#include "cmDSWMakefile.h"
+#include "cmStandardIncludes.h"
#include "cmSystemTools.h"
#include "cmDSPMakefile.h"
-#include <iostream>
-#include <fstream>
+#include "cmMSProjectGenerator.h"
#include <windows.h>
// microsoft nonsense
#undef GetCurrentDirectory
#undef SetCurrentDirectory
+cmDSWMakefile::cmDSWMakefile(cmMakefile* m)
+{
+ m_Makefile = m;
+}
+
// output the DSW file
void cmDSWMakefile::OutputDSWFile()
{
- if(m_OutputDirectory == "")
+ if(m_Makefile->GetOutputDirectory() == "")
{
// default to build in place
- m_OutputDirectory = m_cmHomeDirectory;
+ m_Makefile->SetOutputDirectory(m_Makefile->GetHomeDirectory());
}
// If the output directory is not the m_cmHomeDirectory
// then create it.
- if(m_OutputDirectory != m_cmHomeDirectory)
+ if(strcmp(m_Makefile->GetOutputDirectory(),
+ m_Makefile->GetHomeDirectory()) != 0)
{
- if(!cmSystemTools::MakeDirectory(m_OutputDirectory.c_str()))
+ if(!cmSystemTools::MakeDirectory(m_Makefile->GetOutputDirectory()))
{
MessageBox(0, "Error creating directory ", 0, MB_OK);
- MessageBox(0, m_OutputDirectory.c_str(), 0, MB_OK);
+ MessageBox(0, m_Makefile->GetOutputDirectory(), 0, MB_OK);
}
}
std::string fname;
- fname = m_OutputDirectory;
+ fname = m_Makefile->GetOutputDirectory();
fname += "/";
- fname += this->m_ProjectName;
+ fname += m_Makefile->GetProjectName();
fname += ".dsw";
- std::cerr << "writting dsw file " << fname.c_str() << std::endl;
std::ofstream fout(fname.c_str());
if(!fout)
{
- std::cerr << "Error can not open "
- << fname.c_str() << " for write" << std::endl;
+ cmSystemTools::Error("Error can not open for write: " , fname.c_str());
return;
}
this->WriteDSWFile(fout);
@@ -53,10 +54,12 @@ void cmDSWMakefile::OutputDSWFile()
// The result is a vector of cmDSPMakefile objects, one for
// each directory with a CMakeLists.txt file
//
-void cmDSWMakefile::FindAllCMakeListsFiles(const char* subdir,
- std::vector<cmDSPMakefile*>& makefiles)
+void
+cmDSWMakefile
+::FindAllCMakeListsFiles(const char* subdir,
+ std::vector<cmMSProjectGenerator*>& makefiles)
{
- std::string currentDir = this->GetCurrentDirectory();
+ std::string currentDir = m_Makefile->GetCurrentDirectory();
currentDir += "/";
currentDir += subdir;
currentDir += "/";
@@ -66,31 +69,34 @@ void cmDSWMakefile::FindAllCMakeListsFiles(const char* subdir,
if(cmSystemTools::FileExists(currentDir.c_str()))
{
// Create a new cmDSPMakefile to read the currentDir CMakeLists.txt file
- cmDSPMakefile* dsp = new cmDSPMakefile;
+ cmMSProjectGenerator* pg = new cmMSProjectGenerator;
+ pg->SetBuildDSP();
+ cmMakefile* mf = new cmMakefile;
+ mf->SetMakefileGenerator(pg);
// add it to the vector
- makefiles.push_back(dsp);
+ makefiles.push_back(pg);
// Set up the file with the current context
- dsp->SetOutputHomeDirectory(this->GetOutputDirectory());
- dsp->SetHomeDirectory(this->GetHomeDirectory());
+ mf->SetOutputHomeDirectory(m_Makefile->GetOutputDirectory());
+ mf->SetHomeDirectory(m_Makefile->GetHomeDirectory());
// set the current directory in the Source as a full
// path
- std::string currentDir = this->GetCurrentDirectory();
+ std::string currentDir = m_Makefile->GetCurrentDirectory();
currentDir += "/";
currentDir += subdir;
- dsp->SetCurrentDirectory(currentDir.c_str());
+ mf->SetCurrentDirectory(currentDir.c_str());
// Parse the CMakeLists.txt file
currentDir += "/CMakeLists.txt";
- dsp->ReadMakefile(currentDir.c_str());
+ mf->ReadMakefile(currentDir.c_str());
// Set the output directory which may be different than the source
- std::string outdir = m_OutputDirectory;
+ std::string outdir = m_Makefile->GetOutputDirectory();
outdir += "/";
outdir += subdir;
- dsp->SetOutputDirectory(outdir.c_str());
+ mf->SetOutputDirectory(outdir.c_str());
// Create the DSP file
- dsp->OutputDSPFile();
+ mf->GenerateMakefile();
// Look at any sub directories parsed (SUBDIRS) and
// recurse into them
- const std::vector<std::string>& subdirs = dsp->GetSubDirectories();
+ const std::vector<std::string>& subdirs = mf->GetSubDirectories();
for(std::vector<std::string>::const_iterator i = subdirs.begin();
i != subdirs.end(); ++i)
{
@@ -105,8 +111,8 @@ void cmDSWMakefile::FindAllCMakeListsFiles(const char* subdir,
}
else
{
- std::cerr << "Can not find CMakeLists.txt in " << currentDir.c_str()
- << std::endl;
+ cmSystemTools::Error("Can not find CMakeLists.txt in ",
+ currentDir.c_str());
}
}
@@ -117,43 +123,43 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
// Write out the header for a DSW file
this->WriteDSWHeader(fout);
// Create an array of dsp files for the project
- std::vector<cmDSPMakefile*> dspfiles;
+ std::vector<cmMSProjectGenerator*> dspfiles;
// loop over all the subdirectories for the DSW file,
// and find all sub directory projects
- for(std::vector<std::string>::iterator j = m_SubDirectories.begin();
- j != m_SubDirectories.end(); ++j)
+ const std::vector<std::string>& dirs = m_Makefile->GetSubDirectories();
+ for(std::vector<std::string>::const_iterator j = dirs.begin();
+ j != dirs.end(); ++j)
{
this->FindAllCMakeListsFiles(j->c_str(), dspfiles);
}
// For each DSP file created insert them into the DSW file
- for(std::vector<cmDSPMakefile*>::iterator k = dspfiles.begin();
+ for(std::vector<cmMSProjectGenerator*>::iterator k = dspfiles.begin();
k != dspfiles.end(); ++k)
{
// Get the directory for the dsp file, it comes
// from the source, so it has the source path which needs
// to be removed as this may be built in a different directory
// than the source
- std::string dir = (*k)->GetCurrentDirectory();
+ std::string dir = (*k)->GetDSPMakefile()->
+ GetMakefile()->GetCurrentDirectory();
// Get the home directory with the trailing slash
- std::string homedir = this->GetHomeDirectory();
+ std::string homedir = m_Makefile->GetHomeDirectory();
homedir += "/";
// make the directory relative by removing the home directory part
cmSystemTools::ReplaceString(dir, homedir.c_str(), "");
// Get the list of create dsp files from the cmDSPMakefile, more
// than one dsp could have been created per input CMakeLists.txt file
- std::vector<std::string> dspnames = (*k)->GetCreatedProjectNames();
- std::cerr << "Create dsp for "
- << dspnames.size()
- << " number of dsp files in " << dir << std::endl;
+ std::vector<std::string> dspnames = (*k)->GetDSPMakefile()->GetCreatedProjectNames();
for(std::vector<std::string>::iterator si = dspnames.begin();
si != dspnames.end(); ++si)
{
// Write the project into the DSW file
- this->WriteProject(fout, si->c_str(), dir.c_str(), *k);
+ this->WriteProject(fout, si->c_str(), dir.c_str(),
+ (*k)->GetDSPMakefile());
}
// delete the cmDSPMakefile object once done with it to avoid
// leaks
- delete *k;
+ delete (*k)->GetDSPMakefile()->GetMakefile();
}
// Write the footer for the DSW file
this->WriteDSWFooter(fout);
@@ -163,7 +169,7 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
void cmDSWMakefile::WriteProject(std::ostream& fout,
const char* dspname,
const char* dir,
- cmMakefile* project)
+ cmDSPMakefile* project)
{
fout << "###############################################################################\n\n";
fout << "Project: \"" << dspname << "\"="
@@ -171,12 +177,12 @@ void cmDSWMakefile::WriteProject(std::ostream& fout,
fout << "Package=<5>\n{{{\n}}}\n\n";
fout << "Package=<4>\n";
fout << "{{{\n";
- if(project->HasExecutables())
+ if(project->GetMakefile()->HasExecutables())
{
// insert Begin Project Dependency Project_Dep_Name project stuff here
std::vector<std::string>::iterator i, end;
- i = project->GetBuildFlags().GetLinkLibraries().begin();
- end = project->GetBuildFlags().GetLinkLibraries().end();
+ i = project->GetMakefile()->GetLinkLibraries().begin();
+ end = project->GetMakefile()->GetLinkLibraries().end();
for(;i!= end; ++i)
{
fout << "Begin Project Dependency\n";
diff --git a/Source/cmDSWWriter.h b/Source/cmDSWWriter.h
index 4a2fbf9..6a476b7 100644
--- a/Source/cmDSWWriter.h
+++ b/Source/cmDSWWriter.h
@@ -18,28 +18,27 @@
*/
#ifndef cmDSWMakefile_h
#define cmDSWMakefile_h
-#ifdef _MSC_VER
-#pragma warning ( disable : 4786 )
-#endif
-
+#include "cmStandardIncludes.h"
#include "cmMakefile.h"
-#include <vector>
-class cmDSPMakefile;
+class cmDSPMakefile;
+class cmMSProjectGenerator;
-class cmDSWMakefile : public cmMakefile
+class cmDSWMakefile
{
public:
+ cmDSWMakefile(cmMakefile*);
virtual void OutputDSWFile();
private:
void FindAllCMakeListsFiles(const char* subdir,
- std::vector<cmDSPMakefile*>&);
+ std::vector<cmMSProjectGenerator*>&);
void WriteDSWFile(std::ostream& fout);
void WriteDSWHeader(std::ostream& fout);
void WriteProject(std::ostream& fout,
- const char* name, const char* path,
- cmMakefile* project);
+ const char* name, const char* path,
+ cmDSPMakefile* project);
void WriteDSWFooter(std::ostream& fout);
+ cmMakefile* m_Makefile;
};
#endif
diff --git a/Source/cmDirectory.cxx b/Source/cmDirectory.cxx
index a11d25b..4eefccf 100644
--- a/Source/cmDirectory.cxx
+++ b/Source/cmDirectory.cxx
@@ -91,9 +91,8 @@ cmDirectory
return 0;
}
- dirent* d =0;
dir = opendir(name);
- for ( d = readdir(dir); d; d = readdir(dir) )
+ for (dirent* d = readdir(dir); d; d = readdir(dir) )
{
m_Files.push_back(d->d_name);
}
@@ -114,7 +113,7 @@ cmDirectory
{
if ( index >= m_Files.size() )
{
- std::cerr << "Bad index for GetFile on cmDirectory\n";
+ cmSystemTools::Error("Bad index for GetFile on cmDirectory\n", 0);
return 0;
}
return m_Files[index].c_str();
diff --git a/Source/cmDirectory.h b/Source/cmDirectory.h
index 44d9593..e2b92c3 100644
--- a/Source/cmDirectory.h
+++ b/Source/cmDirectory.h
@@ -16,11 +16,8 @@
#ifndef __cmDirectory_h
#define __cmDirectory_h
-#include <iostream>
-#include <string>
-#include <vector>
-
-
+#include "cmStandardIncludes.h"
+#include "cmSystemTools.h"
/** \class cmDirectory
* \brief Portable directory/filename traversal.
*
diff --git a/Source/cmExecutablesRule.cxx b/Source/cmExecutablesRule.cxx
new file mode 100644
index 0000000..80be032
--- /dev/null
+++ b/Source/cmExecutablesRule.cxx
@@ -0,0 +1,20 @@
+#include "cmExecutablesRule.h"
+
+// cmExecutableRule
+bool cmExecutablesRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 1 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ for(std::vector<std::string>::iterator i = args.begin();
+ i != args.end(); ++i)
+ {
+ cmClassFile file;
+ file.SetName((*i).c_str(), m_Makefile->GetCurrentDirectory());
+ m_Makefile->AddExecutable(file);
+ }
+ return true;
+}
+
diff --git a/Source/cmExecutablesRule.h b/Source/cmExecutablesRule.h
new file mode 100644
index 0000000..88219f1
--- /dev/null
+++ b/Source/cmExecutablesRule.h
@@ -0,0 +1,37 @@
+#ifndef cmExecutablesRule_h
+#define cmExecutablesRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmExecutablesRule : public cmRuleMaker
+{
+public:
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmExecutablesRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "EXECUTABLES";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Add a list of executables files.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "EXECUTABLES(file1 file2 ...)";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmFindIncludeRule.cxx b/Source/cmFindIncludeRule.cxx
new file mode 100644
index 0000000..fc5ff8a
--- /dev/null
+++ b/Source/cmFindIncludeRule.cxx
@@ -0,0 +1,18 @@
+#include "cmFindIncludeRule.h"
+
+// cmFindIncludeRule
+bool cmFindIncludeRule::Invoke(std::vector<std::string>& args)
+{
+ return false;
+ if(args.size() < 1 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ for(std::vector<std::string>::iterator i = args.begin();
+ i != args.end(); ++i)
+ {
+ m_Makefile->AddDefineFlag((*i).c_str());
+ }
+}
+
diff --git a/Source/cmFindIncludeRule.h b/Source/cmFindIncludeRule.h
new file mode 100644
index 0000000..113c3e1
--- /dev/null
+++ b/Source/cmFindIncludeRule.h
@@ -0,0 +1,38 @@
+#ifndef cmFindIncludeRule_h
+#define cmFindIncludeRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmFindIncludeRule : public cmRuleMaker
+{
+public:
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmFindIncludeRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+ virtual bool IsInherited() { return true; }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "FIND_INCLUDE";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Find an include path.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "FIND_INCLUDE(DEFINE try1 try2 ...);";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmFindLibraryRule.cxx b/Source/cmFindLibraryRule.cxx
new file mode 100644
index 0000000..b82180f
--- /dev/null
+++ b/Source/cmFindLibraryRule.cxx
@@ -0,0 +1,18 @@
+#include "cmFindLibraryRule.h"
+
+// cmFindLibraryRule
+bool cmFindLibraryRule::Invoke(std::vector<std::string>& args)
+{
+ return false;
+ if(args.size() < 1 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ for(std::vector<std::string>::iterator i = args.begin();
+ i != args.end(); ++i)
+ {
+ m_Makefile->AddDefineFlag((*i).c_str());
+ }
+}
+
diff --git a/Source/cmFindLibraryRule.h b/Source/cmFindLibraryRule.h
new file mode 100644
index 0000000..2707ff8
--- /dev/null
+++ b/Source/cmFindLibraryRule.h
@@ -0,0 +1,38 @@
+#ifndef cmFindLibraryRule_h
+#define cmFindLibraryRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmFindLibraryRule : public cmRuleMaker
+{
+public:
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmFindLibraryRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+ virtual bool IsInherited() { return true; }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "FIND_LIBRARY";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Set a name for the entire project. One argument.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "FIND_LIBRARY(DEFINE try1 try2);";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmFindProgramRule.cxx b/Source/cmFindProgramRule.cxx
new file mode 100644
index 0000000..432151f
--- /dev/null
+++ b/Source/cmFindProgramRule.cxx
@@ -0,0 +1,65 @@
+#include "cmFindProgramRule.h"
+#include <stdlib.h>
+#include <stdio.h>
+
+static void GetPath(std::vector<std::string>& path)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ char* pathSep = ";";
+#else
+ char* pathSep = ":";
+#endif
+ std::string pathEnv = getenv("PATH");
+ std::string::size_type start =0;
+ bool done = false;
+ while(!done)
+ {
+ std::string::size_type endpos = pathEnv.find(pathSep, start);
+ if(endpos != std::string::npos)
+ {
+ path.push_back(pathEnv.substr(start, endpos-start));
+ start = endpos+1;
+ }
+ else
+ {
+ done = true;
+ }
+ }
+}
+
+
+
+// cmFindProgramRule
+bool cmFindProgramRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 2 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+
+ std::vector<std::string> path;
+ GetPath(path);
+ std::vector<std::string>::iterator i = args.begin();
+ const char* define = (*i).c_str();
+ i++;
+ for(; i != args.end(); ++i)
+ {
+ for(int k=0; k < path.size(); k++)
+ {
+ std::string tryPath = path[k];
+ tryPath += "/";
+ tryPath += *i;
+#ifdef _WIN32
+ tryPath += ".exe";
+#endif
+ if(cmSystemTools::FileExists(tryPath.c_str()))
+ {
+ m_Makefile->AddDefinition(define, tryPath.c_str());
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
diff --git a/Source/cmFindProgramRule.h b/Source/cmFindProgramRule.h
new file mode 100644
index 0000000..c7d8c6f
--- /dev/null
+++ b/Source/cmFindProgramRule.h
@@ -0,0 +1,39 @@
+#ifndef cmFindProgramRule_h
+#define cmFindProgramRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmFindProgramRule : public cmRuleMaker
+{
+public:
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmFindProgramRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+ virtual bool IsInherited() { return true; }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "FIND_PROGRARM";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "not implemented.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "not implemented.\n"
+ "FIND_PROGRARM(NAME try1 try2 ...);";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmIncludeDirectoryRule.cxx b/Source/cmIncludeDirectoryRule.cxx
new file mode 100644
index 0000000..334537a
--- /dev/null
+++ b/Source/cmIncludeDirectoryRule.cxx
@@ -0,0 +1,18 @@
+#include "cmIncludeDirectoryRule.h"
+
+// cmIncludeDirectoryRule
+bool cmIncludeDirectoryRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 1 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ for(std::vector<std::string>::iterator i = args.begin();
+ i != args.end(); ++i)
+ {
+ m_Makefile->AddIncludeDirectory((*i).c_str());
+ }
+ return true;
+}
+
diff --git a/Source/cmIncludeDirectoryRule.h b/Source/cmIncludeDirectoryRule.h
new file mode 100644
index 0000000..0ec61c2
--- /dev/null
+++ b/Source/cmIncludeDirectoryRule.h
@@ -0,0 +1,38 @@
+#ifndef cmIncludeDirectoryRule_h
+#define cmIncludeDirectoryRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmIncludeDirectoryRule : public cmRuleMaker
+{
+public:
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmIncludeDirectoryRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+ virtual bool IsInherited() { return true; }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "INCLUDE_DIRECTORIES";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Add include directories to the build.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "INCLUDE_DIRECTORIES(dir1 dir2 ...).\n";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmLibraryRule.cxx b/Source/cmLibraryRule.cxx
new file mode 100644
index 0000000..703ec9c
--- /dev/null
+++ b/Source/cmLibraryRule.cxx
@@ -0,0 +1,14 @@
+#include "cmLibraryRule.h"
+
+// cmLibraryRule
+bool cmLibraryRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 1 || args.size() > 1)
+ {
+ this->SetError("PROJECT called with incorrect number of arguments");
+ return false;
+ }
+ m_Makefile->SetLibraryName(args[0].c_str());
+ return true;
+}
+
diff --git a/Source/cmLibraryRule.h b/Source/cmLibraryRule.h
new file mode 100644
index 0000000..51262e9
--- /dev/null
+++ b/Source/cmLibraryRule.h
@@ -0,0 +1,37 @@
+#ifndef cmLibraryRule_h
+#define cmLibraryRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmLibraryRule : public cmRuleMaker
+{
+public:
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmLibraryRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "LIBRARY";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Set a name for the Library.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "LIBRARY(libraryname);";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmLinkDirectoriesRule.cxx b/Source/cmLinkDirectoriesRule.cxx
new file mode 100644
index 0000000..1413376
--- /dev/null
+++ b/Source/cmLinkDirectoriesRule.cxx
@@ -0,0 +1,18 @@
+#include "cmLinkDirectoriesRule.h"
+
+// cmLinkDirectoriesRule
+bool cmLinkDirectoriesRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 1 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ for(std::vector<std::string>::iterator i = args.begin();
+ i != args.end(); ++i)
+ {
+ m_Makefile->AddLinkDirectory((*i).c_str());
+ }
+ return true;
+}
+
diff --git a/Source/cmLinkDirectoriesRule.h b/Source/cmLinkDirectoriesRule.h
new file mode 100644
index 0000000..e449c29
--- /dev/null
+++ b/Source/cmLinkDirectoriesRule.h
@@ -0,0 +1,42 @@
+#ifndef cmLinkDirectoriesRule_h
+#define cmLinkDirectoriesRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmLinkDirectoriesRule : public cmRuleMaker
+{
+public:
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmLinkDirectoriesRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+ virtual bool IsInherited() { return true; }
+
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "LINK_DIRECTORIES";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Specify link directories.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "Specify the paths to the libraries that will be linked in.\n"
+ "LINK_DIRECTORIES(directory1 directory2 ...);\n"
+ "The directories can use built in definitions like \n"
+ "CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR.";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmLinkLibrariesRule.cxx b/Source/cmLinkLibrariesRule.cxx
new file mode 100644
index 0000000..fe3953d
--- /dev/null
+++ b/Source/cmLinkLibrariesRule.cxx
@@ -0,0 +1,18 @@
+#include "cmLinkLibrariesRule.h"
+
+// cmLinkLibrariesRule
+bool cmLinkLibrariesRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 1 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ for(std::vector<std::string>::iterator i = args.begin();
+ i != args.end(); ++i)
+ {
+ m_Makefile->AddLinkLibrary((*i).c_str());
+ }
+ return true;
+}
+
diff --git a/Source/cmLinkLibrariesRule.h b/Source/cmLinkLibrariesRule.h
new file mode 100644
index 0000000..79883b1
--- /dev/null
+++ b/Source/cmLinkLibrariesRule.h
@@ -0,0 +1,45 @@
+#ifndef cmLinkLibrariesRule_h
+#define cmLinkLibrariesRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmLinkLibrariesRule : public cmRuleMaker
+{
+public:
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmLinkLibrariesRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+ virtual bool IsInherited() { return true; }
+
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "LINK_LIBRARIES";}
+ virtual const char* TerseDocumentaion()
+ {
+ return
+ "Specify a list of libraries to be linked into executables or \n"
+ "shared objects.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "Specify a list of libraries to be linked into executables or \n"
+ "shared objects. This rule is passed down to all other rules."
+ "LINK_LIBRARIES(library1 library2).\n"
+ "The library name should be the same as the name used in the\n"
+ "LIBRARY(library) rule.";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmMSProjectGenerator.cxx b/Source/cmMSProjectGenerator.cxx
new file mode 100644
index 0000000..f029035
--- /dev/null
+++ b/Source/cmMSProjectGenerator.cxx
@@ -0,0 +1,31 @@
+#include "cmMSProjectGenerator.h"
+#include "cmDSWMakefile.h"
+#include "cmDSPMakefile.h"
+
+cmMSProjectGenerator::cmMSProjectGenerator()
+{
+ m_DSWMakefile = 0;
+ m_DSPMakefile = 0;
+ SetBuildDSW();
+}
+
+void cmMSProjectGenerator::GenerateMakefile()
+{
+ if(m_BuildDSW)
+ {
+ m_DSWMakefile = new cmDSWMakefile(m_Makefile);
+ m_DSWMakefile->OutputDSWFile();
+ }
+ else
+ {
+ m_DSPMakefile = new cmDSPMakefile(m_Makefile);
+ m_DSPMakefile->OutputDSPFile();
+ }
+}
+
+cmMSProjectGenerator::~cmMSProjectGenerator()
+{
+ delete m_DSPMakefile;
+ delete m_DSWMakefile;
+}
+
diff --git a/Source/cmMSProjectGenerator.h b/Source/cmMSProjectGenerator.h
new file mode 100644
index 0000000..3272a42
--- /dev/null
+++ b/Source/cmMSProjectGenerator.h
@@ -0,0 +1,45 @@
+/*=========================================================================
+
+ Program: Insight Segmentation & Registration Toolkit
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+
+ Copyright (c) 2000 National Library of Medicine
+ All rights reserved.
+
+ See COPYRIGHT.txt for copyright details.
+
+=========================================================================*/
+/**
+ * cmMSProjectGenerator - class to write a microsoft DSW file.
+ */
+#ifndef cmMSProjectGenerator_h
+#define cmMSProjectGenerator_h
+#include "cmStandardIncludes.h"
+#include "cmMakefileGenerator.h"
+
+class cmDSPMakefile;
+class cmDSWMakefile;
+
+
+class cmMSProjectGenerator : public cmMakefileGenerator
+{
+public:
+ cmMSProjectGenerator();
+ ~cmMSProjectGenerator();
+ virtual void GenerateMakefile();
+ void SetBuildDSP() { m_BuildDSW = false;}
+ void SetBuildDSW() { m_BuildDSW = true;}
+ cmDSWMakefile* GetDSWMakefile() { return m_DSWMakefile;}
+ cmDSPMakefile* GetDSPMakefile() { return m_DSPMakefile;}
+private:
+ cmDSWMakefile* m_DSWMakefile;
+ cmDSPMakefile* m_DSPMakefile;
+ bool m_BuildDSW;
+};
+
+
+#endif
diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx
index 44b0fe4..82b5a8d 100644
--- a/Source/cmMakeDepend.cxx
+++ b/Source/cmMakeDepend.cxx
@@ -1,13 +1,6 @@
-#ifdef _MSC_VER
-#pragma warning ( disable : 4786 )
-#endif
#include "cmMakeDepend.h"
+#include "cmStandardIncludes.h"
#include "cmSystemTools.h"
-#include <fstream>
-#include <iostream>
-#include <algorithm>
-#include <functional>
-
cmMakeDepend::cmMakeDepend()
{
@@ -43,8 +36,7 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile)
m_Makefile = makefile;
// Now extract any include paths from the makefile flags
- cmCollectFlags& flags = m_Makefile->GetBuildFlags();
- std::vector<std::string>& includes = flags.GetIncludeDirectories();
+ std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
std::vector<std::string>::iterator j;
for(j = includes.begin(); j != includes.end(); ++j)
{
@@ -76,7 +68,7 @@ void cmMakeDepend::DoDepends()
// The size of the m_DependInformation will change as
// Depend is called so do not use an iterater but rather
// depend on the size of the array.
- int j = 0;
+ unsigned int j = 0;
while(j != m_DependInformation.size())
{
cmDependInformation* info = m_DependInformation[j];
@@ -94,7 +86,6 @@ void cmMakeDepend::DoDepends()
cmDependInformation* info = *i;
// Remove duplicate depends
info->RemoveDuplicateIndices();
- std::vector<cmClassFile>::iterator j = m_Makefile->m_Classes.begin();
// find the class
if(info->m_ClassFileIndex != -1)
{
@@ -115,14 +106,14 @@ void cmMakeDepend::Depend(cmDependInformation* info)
const char* path = info->m_FullPath.c_str();
if(!path)
{
- std::cerr << "no full path for object" << std::endl;
+ cmSystemTools::Error("no full path for object", 0);
return;
}
std::ifstream fin(path);
if(!fin)
{
- std::cerr << "error can not open " << info->m_FullPath << std::endl;
+ cmSystemTools::Error("error can not open ", info->m_FullPath.c_str());
return;
}
char line[255];
@@ -142,8 +133,8 @@ void cmMakeDepend::Depend(cmDependInformation* info)
// if a < is not found then move on
if(qstart == std::string::npos)
{
- std::cerr << "unknown include directive " << currentline
- << std::endl;
+ cmSystemTools::Error("unknown include directive ",
+ currentline.c_str() );
continue;
}
else
@@ -162,7 +153,11 @@ void cmMakeDepend::Depend(cmDependInformation* info)
{
if(m_Verbose)
{
- std::cerr << "skipping " << includeFile << " for file " << path << std::endl;
+ std::string message = "Skipping ";
+ message += includeFile;
+ message += " for file ";
+ message += path;
+ cmSystemTools::Error(message.c_str(), 0);
}
continue;
}
@@ -196,7 +191,7 @@ void cmMakeDepend::Depend(cmDependInformation* info)
// object if one is not found
int cmMakeDepend::FindInformation(const char* fname)
{
- int i = 0;
+ unsigned int i = 0;
while(i < m_DependInformation.size())
{
@@ -245,6 +240,7 @@ std::string cmMakeDepend::FullPath(const char* fname)
{
return std::string(fname);
}
+
for(std::vector<std::string>::iterator i = m_IncludeDirectories.begin();
i != m_IncludeDirectories.end(); ++i)
{
@@ -256,7 +252,7 @@ std::string cmMakeDepend::FullPath(const char* fname)
return path;
}
}
- std::cerr << "Depend: File not found " << fname << std::endl;
+ cmSystemTools::Error("Depend: File not found ", fname);
return std::string(fname);
}
@@ -274,7 +270,8 @@ void cmMakeDepend::AddFileToSearchPath(const char* file)
if(pos != std::string::npos)
{
std::string path = filepath.substr(0, pos);
- if(std::find(m_IncludeDirectories.begin(), m_IncludeDirectories.end(), path)
+ if(std::find(m_IncludeDirectories.begin(),
+ m_IncludeDirectories.end(), path)
== m_IncludeDirectories.end())
{
m_IncludeDirectories.push_back(path);
diff --git a/Source/cmMakeDepend.h b/Source/cmMakeDepend.h
index c6b9a34..e383910 100644
--- a/Source/cmMakeDepend.h
+++ b/Source/cmMakeDepend.h
@@ -22,8 +22,7 @@
#include "cmMakefile.h"
#include "cmClassFile.h"
#include "cmRegularExpression.h"
-#include <vector>
-#include <string>
+#include "cmStandardIncludes.h"
// This structure stores the depend information
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 426f956..d93fe1a 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1,225 +1,359 @@
-#ifdef _MSC_VER
-#pragma warning ( disable : 4786 )
-#endif
#include "cmMakefile.h"
+#include "cmRuleMaker.h"
+#include "cmStandardIncludes.h"
#include "cmClassFile.h"
#include "cmDirectory.h"
#include "cmSystemTools.h"
-#include <fstream>
-#include <iostream>
+#include "cmMakefileGenerator.h"
+#include "cmAbstractFilesRule.h"
+#include "cmAddTargetRule.h"
+#include "cmAuxSourceDirectoryRule.h"
+#include "cmExecutablesRule.h"
+#include "cmFindIncludeRule.h"
+#include "cmFindLibraryRule.h"
+#include "cmFindProgramRule.h"
+#include "cmIncludeDirectoryRule.h"
+#include "cmLibraryRule.h"
+#include "cmLinkDirectoriesRule.h"
+#include "cmLinkLibrariesRule.h"
+#include "cmProjectRule.h"
+#include "cmSourceFilesRule.h"
+#include "cmSourceFilesRequireRule.h"
+#include "cmSubdirRule.h"
+#include "cmUnixDefinesRule.h"
+#include "cmUnixLibrariesRule.h"
+#include "cmWin32DefinesRule.h"
+#include "cmWin32LibrariesRule.h"
+#include "cmTestsRule.h"
// default is not to be building executables
cmMakefile::cmMakefile()
{
+ m_DefineFlags = " ";
m_Executables = false;
+ m_MakefileGenerator = 0;
+ this->AddDefaultRules();
+}
+
+void cmMakefile::AddDefaultRules()
+{
+ this->AddRuleMaker(new cmAbstractFilesRule);
+ this->AddRuleMaker(new cmAddTargetRule);
+ this->AddRuleMaker(new cmAuxSourceDirectoryRule);
+ this->AddRuleMaker(new cmExecutablesRule);
+ this->AddRuleMaker(new cmFindIncludeRule);
+ this->AddRuleMaker(new cmFindLibraryRule);
+ this->AddRuleMaker(new cmFindProgramRule);
+ this->AddRuleMaker(new cmIncludeDirectoryRule);
+ this->AddRuleMaker(new cmLibraryRule);
+ this->AddRuleMaker(new cmLinkDirectoriesRule);
+ this->AddRuleMaker(new cmLinkLibrariesRule);
+ this->AddRuleMaker(new cmProjectRule);
+ this->AddRuleMaker(new cmSourceFilesRule);
+ this->AddRuleMaker(new cmSourceFilesRequireRule);
+ this->AddRuleMaker(new cmSubdirRule);
+ this->AddRuleMaker(new cmUnixLibrariesRule);
+ this->AddRuleMaker(new cmUnixDefinesRule);
+ this->AddRuleMaker(new cmWin32LibrariesRule);
+ this->AddRuleMaker(new cmWin32DefinesRule);
+ this->AddRuleMaker(new cmTestsRule);
+#ifdef _WIN32
+ this->AddDefinition("WIN32", "1");
+#else
+ this->AddDefinition("UNIX", "1");
+#endif
+ // Cygwin is more like unix so enable the unix rules
+#if defined(__CYGWIN__)
+ this->AddDefinition("UNIX", "1");
+#endif
+}
+
+
+cmMakefile::~cmMakefile()
+{
+ for(int i=0; i < m_UsedRuleMakers.size(); i++)
+ {
+ delete m_UsedRuleMakers[i];
+ }
+ for(StringRuleMakerMap::iterator j = m_RuleMakers.begin();
+ j != m_RuleMakers.end(); ++j)
+ {
+ delete (*j).second;
+ }
+ delete m_MakefileGenerator;
+}
+
+void cmMakefile::PrintStringVector(const char* s, std::vector<std::string>& v)
+{
+ std::cout << s << ": ( \n";
+ for(std::vector<std::string>::iterator i = v.begin();
+ i != v.end(); ++i)
+ {
+ std::cout << (*i).c_str() << " ";
+ }
+ std::cout << " )\n";
}
// call print on all the classes in the makefile
void cmMakefile::Print()
{
- for(int i = 0; i < m_Classes.size(); i++)
+ std::cout << "classes:\n";
+ for(unsigned int i = 0; i < m_Classes.size(); i++)
m_Classes[i].Print();
+ std::cout << " m_OutputDirectory; " <<
+ m_OutputDirectory.c_str() << std::endl;
+ std::cout << " m_OutputHomeDirectory; " <<
+ m_OutputHomeDirectory.c_str() << std::endl;
+ std::cout << " m_cmHomeDirectory; " <<
+ m_cmHomeDirectory.c_str() << std::endl;
+ std::cout << " m_cmCurrentDirectory; " <<
+ m_cmCurrentDirectory.c_str() << std::endl;
+ std::cout << " m_LibraryName; " << m_LibraryName.c_str() << std::endl;
+ std::cout << " m_ProjectName; " << m_ProjectName.c_str() << std::endl;
+ this->PrintStringVector("m_SubDirectories ", m_SubDirectories);
+ this->PrintStringVector("m_MakeVerbatim ", m_MakeVerbatim);
+ this->PrintStringVector("m_IncludeDirectories;", m_IncludeDirectories);
+ this->PrintStringVector("m_LinkDirectories", m_LinkDirectories);
+ this->PrintStringVector("m_LinkLibraries", m_LinkLibraries);
+ this->PrintStringVector("m_LinkLibrariesWin32", m_LinkLibrariesWin32);
+ this->PrintStringVector("m_LinkLibrariesUnix", m_LinkLibrariesUnix);
}
// Parse the given CMakeLists.txt file into a list of classes.
-bool cmMakefile::ReadMakefile(const char* filename)
+bool cmMakefile::ReadMakefile(const char* filename, bool inheriting)
{
- m_BuildFlags.SetSourceHomeDirectory(this->GetHomeDirectory());
- m_BuildFlags.SetStartDirectory(this->GetCurrentDirectory());
- m_BuildFlags.ParseDirectories();
- m_BuildFlags.ExpandVaribles(this);
-
+ // If not being called from ParseDirectory which
+ // sets the inheriting flag, then parse up the
+ // tree and collect inherited parameters
+ if(!inheriting)
+ {
+ cmSystemTools::ConvertToUnixSlashes(m_cmCurrentDirectory);
+ m_SourceHomeDirectory = m_cmHomeDirectory;
+ cmSystemTools::ConvertToUnixSlashes(m_SourceHomeDirectory);
+ this->ParseDirectory(m_cmCurrentDirectory.c_str());
+ }
+ // Now read the input file
std::ifstream fin(filename);
if(!fin)
{
- std::cerr << "error can not open file " << filename << std::endl;
+ cmSystemTools::Error("error can not open file ", filename);
return false;
}
- char inbuffer[2048];
- while ( fin.getline(inbuffer, 2047 ) )
+ std::string name;
+ std::vector<std::string> arguments;
+ while ( fin )
{
- std::string line = inbuffer;
- cmClassFile file;
- std::string::size_type pos = line.find("SOURCE_FILES");
- if((pos != std::string::npos) && (pos == 0 ) )
- {
- if(line.find("\\") != std::string::npos)
- {
- this->ReadClasses(fin, false);
- }
- }
-#ifdef _WIN32
- else if(line.find("WIN32_SOURCE_FILES") != std::string::npos)
- {
- if(line.find("\\") != std::string::npos)
- {
- this->ReadClasses(fin, false);
- }
- }
-#else
- else if(line.find("UNIX_SOURCE_FILES") != std::string::npos)
- {
- if(line.find("\\") != std::string::npos)
- {
- this->ReadClasses(fin, false);
- }
- }
-#endif
- else if(line.find("ABSTRACT_CLASSES") != std::string::npos)
+ if(cmSystemTools::ParseFunction(fin, name, arguments) )
{
- if(line.find("\\") != std::string::npos)
- {
- this->ReadClasses(fin, true);
- }
- }
- else if(line.find("AUX_SOURCE_DIRECTORY") != std::string::npos)
- {
- this->ReadTemplateInstanceDirectory(line);
- }
- else if(line.find("SUBDIRS") != std::string::npos)
- {
- if(line.find("\\") != std::string::npos)
- {
- cmSystemTools::ReadList(m_SubDirectories, fin);
- }
- }
- else if(line.find("EXECUTABLES") != std::string::npos || line.find("TESTS") != std::string::npos )
- {
- if(line.find("\\") != std::string::npos)
- {
- this->ReadClasses(fin, false);
- m_Executables = true;
- }
- }
- else if(line.find("BEGIN MAKE VERBATIM") != std::string::npos)
- {
- char inbuffer[2048];
- bool done = false;
- m_MakeVerbatim.push_back("# Begin CMakeLists Verbatim\n");
- while(!done)
+ // Special rule that needs to be removed when
+ // ADD_RULE is implemented
+ if(name == "VERBATIM")
{
- fin.getline(inbuffer, 2047);
- m_MakeVerbatim.push_back(inbuffer);
- if((m_MakeVerbatim.end()-1)->find("END MAKE VERBATIM")
- != std::string::npos )
+ if(!inheriting)
{
- done = true;
- *(m_MakeVerbatim.end()-1) = "# End CMakeLists VERBATIM\n\n";
+ m_MakeVerbatim = arguments;
+ }
+ }
+ else
+ {
+ StringRuleMakerMap::iterator pos = m_RuleMakers.find(name);
+ if(pos != m_RuleMakers.end())
+ {
+ cmRuleMaker* rm = (*pos).second;
+ cmRuleMaker* usedMaker = rm->Clone();
+ usedMaker->SetMakefile(this);
+ usedMaker->LoadCache();
+ m_UsedRuleMakers.push_back(usedMaker);
+ if(usedMaker->GetEnabled())
+ {
+ // if not running in inherit mode or
+ // if the rule is inherited then Invoke it.
+ if(!inheriting || usedMaker->IsInherited())
+ {
+ if(!usedMaker->Invoke(arguments))
+ {
+ cmSystemTools::Error(usedMaker->GetError());
+ }
+ }
+ }
+ }
+ else
+ {
+ cmSystemTools::Error("unknown CMake function", name.c_str());
}
}
- }
- else if(line.find("LIBRARY") != std::string::npos)
- {
- std::string libname = cmSystemTools::ExtractVariable("LIBRARY",
- line.c_str());
- this->SetLibraryName(libname.c_str());
- }
- else if(line.find("PROJECT") != std::string::npos)
- {
- std::string libname = cmSystemTools::ExtractVariable("PROJECT",
- line.c_str());
- this->SetProjectName(libname.c_str());
}
}
return true;
}
-// Read a list from the Makefile stream
-void cmMakefile::ReadClasses(std::ifstream& fin,
- bool abstract)
-{
- char inbuffer[2048];
- bool done = false;
- while (!done)
- {
- // read a line from the makefile
- fin.getline(inbuffer, 2047);
- // convert to a string class
- std::string classname = inbuffer;
- // if the line does not end in \ then we are at the
- // end of the list
- if(classname.find('\\') == std::string::npos)
- {
- done = true;
- }
- // remove extra spaces and \ from the class name
- classname = cmSystemTools::CleanUpName(classname.c_str());
-
- // if this is not an abstract list then add new class
- // to the list of classes in this makefile
- if(!abstract)
- {
- cmClassFile file;
- file.SetName(classname.c_str(), this->GetCurrentDirectory());
- file.m_AbstractClass = false;
- m_Classes.push_back(file);
- }
- else
- {
- // if this is an abstract list, then look
- // for an existing class and set it to abstract
- for(int i = 0; i < m_Classes.size(); i++)
- {
- if(m_Classes[i].m_ClassName == classname)
- {
- m_Classes[i].m_AbstractClass = true;
- break;
- }
- }
- }
+void cmMakefile::AddRuleMaker(cmRuleMaker* wg)
+{
+ std::string name = wg->GetName();
+ m_RuleMakers.insert( StringRuleMakerMap::value_type(name, wg));
+}
+
+ // Set the make file
+void cmMakefile::SetMakefileGenerator(cmMakefileGenerator* mf)
+{
+ delete m_MakefileGenerator;
+ m_MakefileGenerator = mf;
+}
+
+ // Generate the output file
+void cmMakefile::GenerateMakefile()
+{
+ // do all the variable expansions here
+ this->ExpandVaribles();
+ // set the makefile on the generator
+ m_MakefileGenerator->SetMakefile(this);
+ // give all the rules a chance to do something
+ // after the file has been parsed before generation
+ for(std::vector<cmRuleMaker*>::iterator i = m_UsedRuleMakers.begin();
+ i != m_UsedRuleMakers.end(); ++i)
+ {
+ (*i)->FinalPass();
}
+ // now do the generation
+ m_MakefileGenerator->GenerateMakefile();
}
-// Find all of the files in dir as specified from this line:
-// AUX_SOURCE_DIRECTORY = dir
-// Add all the files to the m_Classes array.
+void cmMakefile::AddClass(cmClassFile& cmfile)
+{
+ m_Classes.push_back(cmfile);
+}
+
+
+
+void cmMakefile::AddCustomRule(const char* source,
+ const char* result,
+ const char* command,
+ std::vector<std::string>& depends)
+{
+ cmMakefile::customRule rule;
+ rule.m_Source = source;
+ rule.m_Result = result;
+ rule.m_Command = command;
+ rule.m_Depends = depends;
+ m_CustomRules.push_back(rule);
+}
+
+void cmMakefile::AddDefineFlag(const char* flag)
+{
+ m_DefineFlags += " ";
+ m_DefineFlags += flag;
+}
+
+void cmMakefile::AddExecutable(cmClassFile& cf)
+{
+ m_Classes.push_back(cf);
+ m_Executables = true;
+}
+
+void cmMakefile::AddLinkLibrary(const char* lib)
+{
+ m_LinkLibraries.push_back(lib);
+}
+
+void cmMakefile::AddLinkDirectory(const char* dir)
+{
+ m_LinkDirectories.push_back(dir);
+}
+
+void cmMakefile::AddSubDirectory(const char* sub)
+{
+ m_SubDirectories.push_back(sub);
+}
+
+void cmMakefile::AddIncludeDirectory(const char* inc)
+{
+ m_IncludeDirectories.push_back(inc);
+}
+
+void cmMakefile::AddDefinition(const char* name, const char* value)
+{
+ m_Definitions.insert(DefinitionMap::value_type(name, value));
+}
+
+void cmMakefile::SetProjectName(const char* p)
+{
+ m_ProjectName = p;
+}
+
+void cmMakefile::SetLibraryName(const char* l)
+{
+ m_LibraryName = l;
+}
+
+
+void cmMakefile::AddExtraDirectory(const char* dir)
+{
+ m_AuxSourceDirectories.push_back(dir);
+}
-void cmMakefile::ReadTemplateInstanceDirectory(std::string& line)
+
+// Go until directory == m_cmHomeDirectory
+// 1. fix slashes
+// 2. peal off /dir until home found, go no higher
+void cmMakefile::ParseDirectory(const char* dir)
{
- std::string::size_type start = line.find("=");
- if(start != std::string::npos)
+ std::string listsFile = dir;
+ listsFile += "/CMakeLists.txt";
+ if(cmSystemTools::FileExists(listsFile.c_str()))
{
- std::string templateDirectory = line.substr(start+1, line.size());
- templateDirectory = cmSystemTools::CleanUpName(templateDirectory.c_str());
- m_TemplateDirectories.push_back(templateDirectory);
- std::string tdir = this->GetCurrentDirectory();
- tdir += "/";
- tdir += templateDirectory;
- // Load all the files in the directory
- cmDirectory dir;
- if(dir.Load(tdir.c_str()))
- {
- int numfiles = dir.GetNumberOfFiles();
- for(int i =0; i < numfiles; ++i)
- {
- std::string file = dir.GetFile(i);
- // ignore files less than f.cxx in length
- if(file.size() > 4)
- {
- // Remove the extension
- std::string::size_type dotpos = file.rfind(".");
- file = file.substr(0, dotpos);
- std::string fullname = templateDirectory;
- fullname += "/";
- fullname += file;
- // add the file as a class file so
- // depends can be done
- cmClassFile cmfile;
- cmfile.SetName(fullname.c_str(), this->GetCurrentDirectory());
- cmfile.m_AbstractClass = false;
- m_Classes.push_back(cmfile);
- }
- }
- }
- else
- {
- std::cerr << "Warning can not open template instance directory "
- << templateDirectory.c_str() << std::endl;
- }
+ this->ReadMakefile(listsFile.c_str(), true);
+ }
+ if(m_SourceHomeDirectory == dir)
+ {
+ return;
+ }
+
+ std::string dotdotDir = dir;
+ std::string::size_type pos = dotdotDir.rfind('/');
+ if(pos != std::string::npos)
+ {
+ dotdotDir = dotdotDir.substr(0, pos);
+ this->ParseDirectory(dotdotDir.c_str());
}
}
+// expance CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR in the
+// include and library directories.
+
+void cmMakefile::ExpandVaribles()
+{
+ // Now replace varibles
+ std::vector<std::string>::iterator j, begin, end;
+ begin = m_IncludeDirectories.begin();
+ end = m_IncludeDirectories.end();
+ for(j = begin; j != end; ++j)
+ {
+ cmSystemTools::ReplaceString(*j, "${CMAKE_BINARY_DIR}",
+ this->GetOutputHomeDirectory() );
+ cmSystemTools::ReplaceString(*j, "${CMAKE_SOURCE_DIR}",
+ this->GetHomeDirectory() );
+ }
+ begin = m_LinkDirectories.begin();
+ end = m_LinkDirectories.end();
+ for(j = begin; j != end; ++j)
+ {
+ cmSystemTools::ReplaceString(*j, "${CMAKE_BINARY_DIR}",
+ this->GetOutputHomeDirectory() );
+ cmSystemTools::ReplaceString(*j, "${CMAKE_SOURCE_DIR}",
+ this->GetHomeDirectory() );
+ }
+}
+
+const char* cmMakefile::GetDefinition(const char* name)
+{
+ DefinitionMap::iterator pos = m_Definitions.find(name);
+ if(pos != m_Definitions.end())
+ {
+ return (*pos).second.c_str();
+ }
+ return 0;
+}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 6541cff..c377e90 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -19,28 +19,52 @@
*/
#ifndef cmMakefile_h
#define cmMakefile_h
-#ifdef _MSC_VER
-#pragma warning ( disable : 4786 )
-#endif
-
+#include "cmStandardIncludes.h"
#include "cmClassFile.h"
-#include "cmCollectFlags.h"
-#include <vector>
-#include <fstream>
-#include <iostream>
+#include "cmSystemTools.h"
+class cmRuleMaker;
+class cmMakefileGenerator;
+
class cmMakefile
{
public:
cmMakefile();
- // Parse a Makfile.in file
- bool ReadMakefile(const char* makefile);
+ ~cmMakefile();
+ // Parse a CMakeLists.txt file
+ bool ReadMakefile(const char* makefile, bool inheriting = false);
+ // Add a wrap generator
+ void AddRuleMaker(cmRuleMaker* );
+ // Set the make file
+ void SetMakefileGenerator(cmMakefileGenerator*);
+ // Generate the output file
+ void GenerateMakefile();
+
// Print useful stuff to stdout
void Print();
+
+ // cmRuleMaker interfaces
+ void AddCustomRule(const char* source,
+ const char* result,
+ const char* command,
+ std::vector<std::string>& depends);
+ void AddDefineFlag(const char* definition);
+ void AddExecutable(cmClassFile&);
+ void AddLinkLibrary(const char*);
+ void AddLinkDirectory(const char*);
+ void AddSubDirectory(const char*);
+ void AddIncludeDirectory(const char*);
+ void AddDefinition(const char* name, const char* value);
+ void SetProjectName(const char*);
+ void SetLibraryName(const char*);
+ void AddClass(cmClassFile& );
+ void AddExtraDirectory(const char* dir);
+
// Set the home directory for the project
void SetHomeDirectory(const char* dir)
{
m_cmHomeDirectory = dir;
+ cmSystemTools::ConvertToUnixSlashes(m_cmHomeDirectory);
}
const char* GetHomeDirectory()
{
@@ -56,19 +80,11 @@ public:
return m_cmCurrentDirectory.c_str();
}
// Set the name of the library that is built by this makefile
- void SetLibraryName(const char* lib)
- {
- m_LibraryName = lib;
- }
const char* GetLibraryName()
{
return m_LibraryName.c_str();
}
- // Set the name of the library that is built by this makefile
- void SetProjectName(const char* lib)
- {
- m_ProjectName = lib;
- }
+
const char* GetProjectName()
{
return m_ProjectName.c_str();
@@ -93,10 +109,6 @@ public:
{
return m_OutputHomeDirectory.c_str();
}
- cmCollectFlags& GetBuildFlags()
- {
- return m_BuildFlags;
- }
const std::vector<std::string>& GetSubDirectories()
{
return m_SubDirectories;
@@ -107,15 +119,60 @@ public:
return m_Executables;
}
+ std::vector<std::string>& GetIncludeDirectories()
+ {
+ return m_IncludeDirectories;
+ }
+
+ std::vector<std::string>& GetLinkDirectories()
+ {
+ return m_LinkDirectories;
+ }
+
+ std::vector<std::string>& GetLinkLibraries()
+ {
+ return m_LinkLibraries;
+ }
+
+ std::vector<std::string>& GetLinkLibrariesWin32()
+ {
+ return m_LinkLibrariesWin32;
+ }
+
+ std::vector<std::string>& GetLinkLibrariesUnix()
+ {
+ return m_LinkLibrariesUnix;
+ }
+ std::vector<cmClassFile>& GetClasses(){ return m_Classes;}
+ std::vector<std::string>& GetAuxSourceDirectories()
+ { return m_AuxSourceDirectories; }
+ std::vector<std::string>& GetMakeVerbatim()
+ { return m_MakeVerbatim;}
+ const char* GetDefinition(const char*);
+
+ const char* GetDefineFlags()
+ { return m_DefineFlags.c_str();}
+
private:
- void ReadTemplateInstanceDirectory(std::string&);
+ /**
+ * Look for CMakeLists.txt files to parse in dir,
+ * then in dir's parents, until the SourceHome directory
+ * is found.
+ */
+ void ParseDirectory(const char* dir);
+ /**
+ * Parse a file for includes links and libs
+ */
+ void ExpandVaribles();
void ReadClasses(std::ifstream& fin, bool t);
friend class cmMakeDepend; // make depend needs direct access
- // to the m_Classes array
+ // to the m_Classes array
+ void PrintStringVector(const char* s, std::vector<std::string>& v);
+ void AddDefaultRules();
protected:
bool m_Executables;
std::string m_Prefix;
- std::vector<std::string> m_TemplateDirectories; // Template directory name if found in file
+ std::vector<std::string> m_AuxSourceDirectories; //
std::string m_OutputDirectory; // Current output directory for makefile
std::string m_OutputHomeDirectory; // Top level output directory
std::string m_cmHomeDirectory; // Home directory for source
@@ -125,7 +182,27 @@ protected:
std::vector<cmClassFile> m_Classes; // list of classes in makefile
std::vector<std::string> m_SubDirectories; // list of sub directories
std::vector<std::string> m_MakeVerbatim; // lines copied from input file
- cmCollectFlags m_BuildFlags;
+ std::vector<std::string> m_IncludeDirectories;
+ std::vector<std::string> m_LinkDirectories;
+ std::vector<std::string> m_LinkLibraries;
+ std::vector<std::string> m_LinkLibrariesWin32;
+ std::vector<std::string> m_LinkLibrariesUnix;
+ std::string m_DefineFlags;
+ std::string m_SourceHomeDirectory;
+ struct customRule
+ {
+ std::string m_Source;
+ std::string m_Result;
+ std::string m_Command;
+ std::vector<std::string> m_Depends;
+ };
+ std::vector<customRule> m_CustomRules;
+ typedef std::map<std::string, cmRuleMaker*> StringRuleMakerMap;
+ typedef std::map<std::string, std::string> DefinitionMap;
+ DefinitionMap m_Definitions;
+ StringRuleMakerMap m_RuleMakers;
+ std::vector<cmRuleMaker*> m_UsedRuleMakers;
+ cmMakefileGenerator* m_MakefileGenerator;
};
diff --git a/Source/cmMakefileGenerator.cxx b/Source/cmMakefileGenerator.cxx
new file mode 100644
index 0000000..ee44a6e
--- /dev/null
+++ b/Source/cmMakefileGenerator.cxx
@@ -0,0 +1,7 @@
+#include "cmMakeFileGenerator.h"
+
+void cmMakefileGenerator::SetMakefile(cmMakefile* mf)
+{
+ m_Makefile = mf;
+}
+
diff --git a/Source/cmMakefileGenerator.h b/Source/cmMakefileGenerator.h
new file mode 100644
index 0000000..f676cc6
--- /dev/null
+++ b/Source/cmMakefileGenerator.h
@@ -0,0 +1,20 @@
+#ifndef cmMakeFileGenerator_h
+#define cmMakeFileGenerator_h
+
+#include "cmStandardIncludes.h"
+
+class cmMakefile;
+struct cmClassFile;
+
+class cmMakefileGenerator
+{
+public:
+ // use the m_Makefile and the m_CustomRules and m_ExtraSourceFiles
+ // to generate the makefile
+ virtual void GenerateMakefile() = 0;
+ void SetMakefile(cmMakefile*);
+protected:
+ cmMakefile* m_Makefile;
+};
+
+#endif
diff --git a/Source/cmProjectRule.cxx b/Source/cmProjectRule.cxx
new file mode 100644
index 0000000..77354e5
--- /dev/null
+++ b/Source/cmProjectRule.cxx
@@ -0,0 +1,14 @@
+#include "cmProjectRule.h"
+
+// cmProjectRule
+bool cmProjectRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 1 || args.size() > 1)
+ {
+ this->SetError("PROJECT called with incorrect number of arguments");
+ return false;
+ }
+ m_Makefile->SetProjectName(args[0].c_str());
+ return true;
+}
+
diff --git a/Source/cmProjectRule.h b/Source/cmProjectRule.h
new file mode 100644
index 0000000..2fe6df0
--- /dev/null
+++ b/Source/cmProjectRule.h
@@ -0,0 +1,38 @@
+#ifndef cmProjectRule_h
+#define cmProjectRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmProjectRule : public cmRuleMaker
+{
+public:
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmProjectRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "PROJECT";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Set a name for the entire project. One argument.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "Set the name for the entire project. This takes one argument.\n"
+ "PROJECT(projectname);";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmRegularExpression.cxx b/Source/cmRegularExpression.cxx
index 0867e97..f97fc02 100644
--- a/Source/cmRegularExpression.cxx
+++ b/Source/cmRegularExpression.cxx
@@ -115,8 +115,9 @@
//
#include "cmRegularExpression.h" // Include class specification
+#include "cmStandardIncludes.h"
#include <stdio.h>
-#include <string>
+
// cmRegularExpression -- Copies the given regular expression.
diff --git a/Source/cmRegularExpression.h b/Source/cmRegularExpression.h
index fd11293..b713de4 100644
--- a/Source/cmRegularExpression.h
+++ b/Source/cmRegularExpression.h
@@ -32,7 +32,7 @@
#ifndef cmRegularExpression_h
#define cmRegularExpression_h
-#include <string>
+#include "cmStandardIncludes.h"
const int NSUBEXP = 10;
diff --git a/Source/cmRuleMaker.h b/Source/cmRuleMaker.h
new file mode 100644
index 0000000..e013ea5
--- /dev/null
+++ b/Source/cmRuleMaker.h
@@ -0,0 +1,52 @@
+#ifndef cmRuleMaker_h
+#define cmRuleMaker_h
+#include "cmStandardIncludes.h"
+#include "cmMakefile.h"
+
+class cmRuleMaker
+{
+public:
+ cmRuleMaker() { m_Makefile = 0; m_Enabled = true; }
+ void SetMakefile(cmMakefile*m) {m_Makefile = m; }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args) = 0;
+ // This is called after the entire file has been parsed.
+ virtual void FinalPass() = 0;
+ // This is called to let the rule check the cache
+ virtual void LoadCache() { }
+
+ virtual cmRuleMaker* Clone() = 0;
+
+ // This determines if the rule gets passed down
+ // to sub directory makefiles
+ virtual bool IsInherited()
+ {
+ return false;
+ }
+ // This is the name used in the input file.
+ virtual const char* GetName() = 0;
+ // Return the terse documentaion for the rule
+ virtual const char* TerseDocumentaion() = 0;
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion() = 0;
+ // enable or disable this rule
+ bool GetEnabled() { return m_Enabled; }
+ void SetEnableOn() { m_Enabled = true; }
+ void SetEnableOff() { m_Enabled = false; }
+ const char* GetError() { return m_Error.c_str();}
+protected:
+ void SetError(const char* e)
+ {
+ m_Error = this->GetName();
+ m_Error += " ";
+ m_Error += e;
+ }
+ cmMakefile* m_Makefile;
+private:
+ bool m_Enabled;
+ std::string m_Error;
+};
+
+
+#endif
diff --git a/Source/cmSourceFilesRequireRule.cxx b/Source/cmSourceFilesRequireRule.cxx
new file mode 100644
index 0000000..20c82c0
--- /dev/null
+++ b/Source/cmSourceFilesRequireRule.cxx
@@ -0,0 +1,39 @@
+#include "cmSourceFilesRequireRule.h"
+
+// cmSourceFilesRequireRule
+bool cmSourceFilesRequireRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 3 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ std::vector<std::string>::iterator i = args.begin();
+ // Search to the key word SOURCES_BEGIN is found
+ // if one of the required defines is not there, then
+ // return as none of the source files will be added
+ // if the required definition is not there.
+ while(i != args.end() && (*i) != "SOURCES_BEGIN" )
+ {
+ if(!m_Makefile->GetDefinition((*i).c_str()))
+ {
+ return true;
+ }
+ i++;
+ }
+ if(i != args.end())
+ {
+ i++;
+ }
+
+ // Add the rest of the arguments as source files
+ for(; i != args.end(); ++i)
+ {
+ cmClassFile file;
+ file.m_AbstractClass = false;
+ file.SetName((*i).c_str(), m_Makefile->GetCurrentDirectory());
+ m_Makefile->AddClass(file);
+ }
+ return true;
+}
+
diff --git a/Source/cmSourceFilesRequireRule.h b/Source/cmSourceFilesRequireRule.h
new file mode 100644
index 0000000..f704c0d
--- /dev/null
+++ b/Source/cmSourceFilesRequireRule.h
@@ -0,0 +1,37 @@
+#ifndef cmSourceFilesRequireRule_h
+#define cmSourceFilesRequireRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmSourceFilesRequireRule : public cmRuleMaker
+{
+public:
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmSourceFilesRequireRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "SOURCE_FILES_REQUIRE";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Add a list of source files.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "SOURCE_FILES(file1 file2 ...)";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmSourceFilesRule.cxx b/Source/cmSourceFilesRule.cxx
new file mode 100644
index 0000000..fe2a424
--- /dev/null
+++ b/Source/cmSourceFilesRule.cxx
@@ -0,0 +1,21 @@
+#include "cmSourceFilesRule.h"
+
+// cmSourceFilesRule
+bool cmSourceFilesRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 1 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ for(std::vector<std::string>::iterator i = args.begin();
+ i != args.end(); ++i)
+ {
+ cmClassFile file;
+ file.m_AbstractClass = false;
+ file.SetName((*i).c_str(), m_Makefile->GetCurrentDirectory());
+ m_Makefile->AddClass(file);
+ }
+ return true;
+}
+
diff --git a/Source/cmSourceFilesRule.h b/Source/cmSourceFilesRule.h
new file mode 100644
index 0000000..216d697
--- /dev/null
+++ b/Source/cmSourceFilesRule.h
@@ -0,0 +1,37 @@
+#ifndef cmSourceFilesRule_h
+#define cmSourceFilesRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmSourceFilesRule : public cmRuleMaker
+{
+public:
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmSourceFilesRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "SOURCE_FILES";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Add a list of source files.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "SOURCE_FILES(file1 file2 ...)";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h
new file mode 100644
index 0000000..5a78e9b
--- /dev/null
+++ b/Source/cmStandardIncludes.h
@@ -0,0 +1,29 @@
+#ifndef cmStandardIncludes_h
+#define cmStandardIncludes_h
+
+
+#ifdef _MSC_VER
+#pragma warning ( disable : 4786 )
+#endif
+
+#ifndef CMAKE_NO_ANSI_STREAM_HEADERS
+#include <fstream>
+#include <iostream>
+#else
+#include <fsream.h>
+#include <iostream.h>
+#endif
+
+#include <vector>
+#include <string>
+#include <iterator>
+#include <algorithm>
+#include <functional>
+#include <map>
+
+#ifdef CMAKE_NO_STD_NAMESPACE
+#define std
+#endif
+
+
+#endif
diff --git a/Source/cmSubdirRule.cxx b/Source/cmSubdirRule.cxx
new file mode 100644
index 0000000..fc6334e
--- /dev/null
+++ b/Source/cmSubdirRule.cxx
@@ -0,0 +1,18 @@
+#include "cmSubdirRule.h"
+
+// cmSubdirRule
+bool cmSubdirRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 1 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ for(std::vector<std::string>::iterator i = args.begin();
+ i != args.end(); ++i)
+ {
+ m_Makefile->AddSubDirectory((*i).c_str());
+ }
+ return true;
+}
+
diff --git a/Source/cmSubdirRule.h b/Source/cmSubdirRule.h
new file mode 100644
index 0000000..cc41bb6
--- /dev/null
+++ b/Source/cmSubdirRule.h
@@ -0,0 +1,40 @@
+#ifndef cmSubdirRule_h
+#define cmSubdirRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmSubdirRule : public cmRuleMaker
+{
+public:
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmSubdirRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "SUBDIRS";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Add a list of subdirectories to the build.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "Add a list of subdirectories to the build.\n"
+ "SUBDIRS(dir1 dir2 ...)\n"
+ "This will cause any CMakeLists.txt files in the sub directories\n"
+ "to be parsed by cmake.";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index a7d7353..8e0eb57 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -3,7 +3,7 @@
#include <sys/stat.h>
#include "cmRegularExpression.h"
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__BORLANDC__)
#include <windows.h>
#include <direct.h>
inline int Mkdir(const char* dir)
@@ -20,39 +20,6 @@ inline int Mkdir(const char* dir)
}
#endif
-// remove extra spaces and the "\" character from the name
-// of the class as it is in the CMakeLists.txt
-std::string cmSystemTools::CleanUpName(const char* name)
-{
- std::string className = name;
- size_t i =0;
- while(className[i] == ' ' || className[i] == '\t')
- {
- i++;
- }
- if(i)
- {
- className = className.substr(i, className.size());
- }
- size_t pos = className.find('\\');
- if(pos != std::string::npos)
- {
- className = className.substr(0, pos);
- }
-
- pos = className.find(' ');
- if(pos != std::string::npos)
- {
- className = className.substr(0, pos);
- }
- pos = className.find('\t');
- if(pos != std::string::npos)
- {
- className = className.substr(0, pos);
- }
- return className;
-}
-
bool cmSystemTools::MakeDirectory(const char* path)
{
@@ -121,29 +88,6 @@ bool cmSystemTools::FileExists(const char* filename)
}
}
-// Read a list from a CMakeLists.txt file open stream.
-// assume the stream has just read "VAR = \"
-// read until there is not a "\" at the end of the line.
-void cmSystemTools::ReadList(std::vector<std::string>& stringList,
- std::ifstream& fin)
-{
- char inbuffer[2048];
- bool done = false;
- while ( !done )
- {
- fin.getline(inbuffer, sizeof(inbuffer) );
- std::string inname = inbuffer;
- if(inname.find('\\') == std::string::npos)
- {
- done = true;
- }
- if(inname.size())
- {
- stringList.push_back(cmSystemTools::CleanUpName(inname.c_str()));
- }
- }
-}
-
// convert windows slashes to unix slashes \ with /
void cmSystemTools::ConvertToUnixSlashes(std::string& path)
@@ -179,26 +123,167 @@ int cmSystemTools::Grep(const char* dir, const char* file, const char* expressio
return count;
}
-std::string cmSystemTools::ExtractVariable(const char* variable,
- const char* l)
+
+void cmSystemTools::ConvertCygwinPath(std::string& pathname)
+{
+ if(pathname.find("/cygdrive/") != std::string::npos)
+ {
+ std::string cygStuff = pathname.substr(0, 11);
+ std::string replace;
+ replace += cygStuff.at(10);
+ replace += ":";
+ cmSystemTools::ReplaceString(pathname, cygStuff.c_str(), replace.c_str());
+ }
+}
+
+
+bool cmSystemTools::ParseFunction(std::ifstream& fin,
+ std::string& name,
+ std::vector<std::string>& arguments)
+{
+ name = "";
+ arguments = std::vector<std::string>();
+ const int BUFFER_SIZE = 4096;
+ char inbuffer[BUFFER_SIZE];
+ if(!fin)
+ {
+ return false;
+ }
+
+ if(fin.getline(inbuffer, BUFFER_SIZE ) )
+ {
+ cmRegularExpression blankLine("^$");
+ cmRegularExpression comment("^#.*");
+ cmRegularExpression oneLiner("[ \t]*([A-Za-z_0-9]*).*\\((.*)\\)");
+ cmRegularExpression multiLine("[ \t]*([A-Za-z_0-9]*).*\\((.*)");
+ cmRegularExpression lastLine("(.*)\\)");
+
+ // BEGIN VERBATIM JUNK SHOULD BE REMOVED
+ cmRegularExpression verbatim("BEGIN MAKE VERBATIM");
+ if(verbatim.find(inbuffer))
+ {
+ cmRegularExpression endVerbatim("END MAKE VERBATIM");
+ name = "VERBATIM";
+ bool done = false;
+ while(!done)
+ {
+ if(fin.getline(inbuffer, BUFFER_SIZE))
+ {
+ if(endVerbatim.find(inbuffer))
+ {
+ done = true;
+ }
+ else
+ {
+ arguments.push_back(inbuffer);
+ }
+ }
+ else
+ {
+ done = true;
+ }
+ }
+ return true;
+ }
+ // END VERBATIM JUNK SHOULD BE REMOVED
+
+ // check for black line or comment
+ if(blankLine.find(inbuffer) || comment.find(inbuffer))
+ {
+ return false;
+ }
+ // look for a oneline fun(arg arg2)
+ else if(oneLiner.find(inbuffer))
+ {
+ // the arguments are the second match
+ std::string args = oneLiner.match(2);
+ name = oneLiner.match(1);
+ // break up the arguments
+ cmSystemTools::GetArguments(args, arguments);
+ return true;
+ }
+ // look for a start of a multiline with no trailing ")" fun(arg arg2
+ else if(multiLine.find(inbuffer))
+ {
+ name = multiLine.match(1);
+ std::string args = multiLine.match(2);
+ cmSystemTools::GetArguments(args, arguments);
+ // Read lines until the closing paren is hit
+ bool done = false;
+ while(!done)
+ {
+ // read lines until the end paren is found
+ if(fin.getline(inbuffer, BUFFER_SIZE ) )
+ {
+ if(lastLine.find(inbuffer))
+ {
+ done = true;
+ std::string args = lastLine.match(1);
+ cmSystemTools::GetArguments(args, arguments);
+ }
+ else
+ {
+ std::string line = inbuffer;
+ cmSystemTools::GetArguments(line, arguments);
+ }
+ }
+ }
+ return true;
+ }
+ else
+ {
+ cmSystemTools::Error("Parse error in read function ", inbuffer);
+ return false;
+ }
+ }
+ return false;
+
+}
+
+void cmSystemTools::GetArguments(std::string& line,
+ std::vector<std::string>& arguments)
{
- std::string line = l;
- size_t varstart = line.find(variable);
- size_t start = line.find("=");
- if(start != std::string::npos && start > varstart )
+ cmRegularExpression argument("[\t ]*([-/\\\\{}\\$A-Za-z_0-9]+)[\t ]*");
+ cmRegularExpression argumentWithSpaces("[\t ]*\"([- /\\\\{}\\$A-Za-z_0-9]+)\"[\t ]*");
+ std::string arg(" ");
+ while(arg.length() )
{
- start++;
- while(line[start] == ' ' && start < line.size())
+ arg = "";
+ long endpos;
+
+ if (argumentWithSpaces.find(line.c_str()))
+ {
+ arg = argumentWithSpaces.match(1);
+ endpos = argumentWithSpaces.end(1);
+ }
+ else if(argument.find(line.c_str()))
{
- start++;
+ arg = argument.match(1);
+ endpos = argument.end(1);
}
- size_t end = line.size()-1;
- while(line[end] == ' ' && end > start)
+ if(arg.length())
{
- end--;
+ arguments.push_back(arg);
+ line = line.substr(endpos, line.length() - endpos);
}
- return line.substr(start, end).c_str();
}
- return std::string("");
}
+void cmSystemTools::Error(const char* m1, const char* m2)
+{
+ std::string message = "CMake Error: ";
+ if(m1)
+ {
+ message += m1;
+ }
+ if(m2)
+ {
+ message += m2;
+ }
+#ifdef _WIN32
+// MessageBox(0, message.c_str(), 0, MB_OK);
+ std::cerr << message.c_str() << std::endl;
+#else
+ std::cerr << message.c_str() << std::endl;
+#endif
+}
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index ec80573..4d98dc8 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -18,13 +18,8 @@
*/
#ifndef cmSystemTools_h
#define cmSystemTools_h
-#ifdef _MSC_VER
-#pragma warning ( disable : 4786 )
-#endif
-#include <string>
-#include <vector>
-#include <fstream>
+#include "cmStandardIncludes.h"
class cmSystemTools
{
@@ -43,10 +38,6 @@ public:
const char* replace,
const char* with);
/**
- * Remove extra spaces and the trailing \ from a string.
- */
- static std::string CleanUpName(const char* name);
- /**
* Replace windows slashes with unix style slashes
*/
static void ConvertToUnixSlashes(std::string& path);
@@ -61,20 +52,30 @@ public:
static int Grep(const char* dir, const char* file, const char* expression);
/**
- * Extract the right hand side of an asignment varibale = value
+ * remove /cygdrive/d and replace with d:/
*/
- static std::string ExtractVariable(const char* varible,
- const char* line);
-
+ static void ConvertCygwinPath(std::string& pathname);
+
/**
- * Read a list from a file into the array of strings.
- * This function assumes that the first line of the
- * list has been read. For example: NAME = \ was already
- * read in. The reading stops when there are no more
- * continuation characters.
+ * Read a cmake function from an input file. This
+ * returns the name of the function and a list of its
+ * arguments.
*/
- static void ReadList(std::vector<std::string>& stringList,
- std::ifstream& fin);
+ static bool ParseFunction(std::ifstream&,
+ std::string& name,
+ std::vector<std::string>& arguments);
+ /**
+ * Extract space separated arguments from a string.
+ * Double quoted strings are accepted with spaces.
+ * This is called by ParseFunction.
+ */
+ static void GetArguments(std::string& line,
+ std::vector<std::string>& arguments);
+ /**
+ * Display an error message.
+ */
+ static void Error(const char* m, const char* m2=0 );
+
};
diff --git a/Source/cmTestsRule.cxx b/Source/cmTestsRule.cxx
new file mode 100644
index 0000000..19b6b88
--- /dev/null
+++ b/Source/cmTestsRule.cxx
@@ -0,0 +1,20 @@
+#include "cmTestsRule.h"
+
+// cmExecutableRule
+bool cmTestsRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 1 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ for(std::vector<std::string>::iterator i = args.begin();
+ i != args.end(); ++i)
+ {
+ cmClassFile file;
+ file.SetName((*i).c_str(), m_Makefile->GetCurrentDirectory());
+ m_Makefile->AddExecutable(file);
+ }
+ return true;
+}
+
diff --git a/Source/cmTestsRule.h b/Source/cmTestsRule.h
new file mode 100644
index 0000000..4bcbd4a
--- /dev/null
+++ b/Source/cmTestsRule.h
@@ -0,0 +1,37 @@
+#ifndef cmTestsRule_h
+#define cmTestsRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmTestsRule : public cmRuleMaker
+{
+public:
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmTestsRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "TESTS";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Add a list of executables files that are run as tests.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "TESTS(file1 file2 ...)";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmUnixDefinesRule.cxx b/Source/cmUnixDefinesRule.cxx
new file mode 100644
index 0000000..9922d4d
--- /dev/null
+++ b/Source/cmUnixDefinesRule.cxx
@@ -0,0 +1,25 @@
+#include "cmUnixDefinesRule.h"
+
+cmUnixDefinesRule::cmUnixDefinesRule()
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ this->SetEnableOff();
+#endif
+}
+
+// cmUNIXDefinesRule
+bool cmUnixDefinesRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 1 )
+ {
+ this->SetError("Win32Defines called with incorrect number of arguments");
+ return false;
+ }
+ for(std::vector<std::string>::iterator i = args.begin();
+ i != args.end(); ++i)
+ {
+ m_Makefile->AddDefineFlag((*i).c_str());
+ }
+ return true;
+}
+
diff --git a/Source/cmUnixDefinesRule.h b/Source/cmUnixDefinesRule.h
new file mode 100644
index 0000000..c799c4e
--- /dev/null
+++ b/Source/cmUnixDefinesRule.h
@@ -0,0 +1,40 @@
+#ifndef cmUnixDefinesRule_h
+#define cmUnixDefinesRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmUnixDefinesRule : public cmRuleMaker
+{
+public:
+ cmUnixDefinesRule();
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmUnixDefinesRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+ virtual bool IsInherited() { return true; }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "UNIX_DEFINES";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Add -D flags to the command line for unix only.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "Add -D flags to the command line for unix only.\n"
+ "UNIX_DEFINES(-DFOO -DBAR);";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmUnixLibrariesRule.cxx b/Source/cmUnixLibrariesRule.cxx
new file mode 100644
index 0000000..84e8ecc
--- /dev/null
+++ b/Source/cmUnixLibrariesRule.cxx
@@ -0,0 +1,25 @@
+#include "cmUnixLibrariesRule.h"
+
+cmUnixLibrariesRule::cmUnixLibrariesRule()
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ this->SetEnableOff();
+#endif
+}
+
+// cmUnixLibrariesRule
+bool cmUnixLibrariesRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 1 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ for(std::vector<std::string>::iterator i = args.begin();
+ i != args.end(); ++i)
+ {
+ m_Makefile->AddLinkLibrary((*i).c_str());
+ }
+ return true;
+}
+
diff --git a/Source/cmUnixLibrariesRule.h b/Source/cmUnixLibrariesRule.h
new file mode 100644
index 0000000..f936728
--- /dev/null
+++ b/Source/cmUnixLibrariesRule.h
@@ -0,0 +1,39 @@
+#ifndef cmUnixLibrariesRule_h
+#define cmUnixLibrariesRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmUnixLibrariesRule : public cmRuleMaker
+{
+public:
+ cmUnixLibrariesRule();
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmUnixLibrariesRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+ virtual bool IsInherited() { return true; }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "UNIX_LIBRARIES";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Add libraries that are only used for unix programs.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "UNIX_LIBRARIES(library -lm ...);";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmUnixMakefile.cxx b/Source/cmUnixMakefileGenerator.cxx
index 11964b4..218d197 100644
--- a/Source/cmUnixMakefile.cxx
+++ b/Source/cmUnixMakefileGenerator.cxx
@@ -1,25 +1,37 @@
-#include "cmUnixMakefile.h"
+#include "cmUnixMakefileGenerator.h"
+#include "cmMakefile.h"
+#include "cmStandardIncludes.h"
#include "cmSystemTools.h"
-#include <fstream>
-#include <iostream>
+#include "cmClassFile.h"
+#include "cmMakeDepend.h"
+
+void cmUnixMakefileGenerator::GenerateMakefile()
+{
+ cmMakeDepend md;
+ md.SetMakefile(m_Makefile);
+ md.DoDepends();
+ this->OutputMakefile("CMakeTargets.make");
+}
+
// Output the depend information for all the classes
// in the makefile. These would have been generated
-// by the class cmMakeDepend in the main of CMakeBuildTargets.
-void cmUnixMakefile::OutputDepends(std::ostream& fout)
+// by the class cmMakeDepend GenerateMakefile
+void cmUnixMakefileGenerator::OutputDepends(std::ostream& fout)
{
- for(int i = 0; i < m_Classes.size(); i++)
+ std::vector<cmClassFile>& Classes = m_Makefile->GetClasses();
+ for(unsigned int i = 0; i < Classes.size(); i++)
{
- if(!m_Classes[i].m_AbstractClass && !m_Classes[i].m_HeaderFileOnly)
+ if(!Classes[i].m_AbstractClass && !Classes[i].m_HeaderFileOnly)
{
- if( m_Classes[i].m_Depends.size())
+ if( Classes[i].m_Depends.size())
{
- fout << m_Classes[i].m_ClassName << ".o : \\\n";
+ fout << Classes[i].m_ClassName << ".o : \\\n";
for(std::vector<std::string>::iterator j =
- m_Classes[i].m_Depends.begin();
- j != m_Classes[i].m_Depends.end(); ++j)
+ Classes[i].m_Depends.begin();
+ j != Classes[i].m_Depends.end(); ++j)
{
- if(j+1 == m_Classes[i].m_Depends.end())
+ if(j+1 == Classes[i].m_Depends.end())
{
fout << *j << " \n";
}
@@ -63,15 +75,16 @@ inline std::string FixDirectoryName(const char* dir)
// 4. Rules to build in sub directories
// 5. The name of the library being built, if it is a library
-void cmUnixMakefile::OutputMakefile(const char* file)
+void cmUnixMakefileGenerator::OutputMakefile(const char* file)
{
- if( m_TemplateDirectories.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(std::vector<std::string>::iterator i = m_TemplateDirectories.begin();
- i != m_TemplateDirectories.end(); ++i)
+ for(std::vector<std::string>::iterator i = auxSourceDirs.begin();
+ i != auxSourceDirs.end(); ++i)
{
cmSystemTools::MakeDirectory(i->c_str());
}
@@ -80,12 +93,12 @@ void cmUnixMakefile::OutputMakefile(const char* file)
std::ofstream fout(file);
if(!fout)
{
- std::cerr << "Error can not open " << file << " for write" << std::endl;
+ cmSystemTools::Error("Error can not open for write: ", file);
return;
}
// Output Include paths
fout << "INCLUDE_FLAGS = ";
- std::vector<std::string>& includes = m_BuildFlags.GetIncludeDirectories();
+ std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
std::vector<std::string>::iterator i;
for(i = includes.begin(); i != includes.end(); ++i)
{
@@ -96,22 +109,23 @@ void cmUnixMakefile::OutputMakefile(const char* file)
fout << "\n";
// see if there are files to compile in this makefile
// These are used for both libraries and executables
- if(m_Classes.size() )
+ std::vector<cmClassFile>& Classes = m_Makefile->GetClasses();
+ if(Classes.size() )
{
// Ouput Library name if there are SRC_OBJS
- if(strlen(this->GetLibraryName()) > 0)
+ if(strlen(m_Makefile->GetLibraryName()) > 0)
{
- fout << "LIBRARY = " << this->GetLibraryName() << "\n\n";
+ fout << "LIBRARY = " << m_Makefile->GetLibraryName() << "\n\n";
fout << "BUILD_LIB_FILE = lib${LIBRARY}${CMAKE_LIB_EXT}\n\n";
}
// Output SRC_OBJ list for all the classes to be compiled
fout << "SRC_OBJ = \\\n";
- for(int i = 0; i < m_Classes.size(); i++)
+ for(unsigned int i = 0; i < Classes.size(); i++)
{
- if(!m_Classes[i].m_AbstractClass && !m_Classes[i].m_HeaderFileOnly)
+ if(!Classes[i].m_AbstractClass && !Classes[i].m_HeaderFileOnly)
{
- fout << m_Classes[i].m_ClassName << ".o ";
- if(i == m_Classes.size() -1)
+ fout << Classes[i].m_ClassName << ".o ";
+ if(i == Classes.size() -1)
{
fout << "\n\n";
}
@@ -123,34 +137,43 @@ void cmUnixMakefile::OutputMakefile(const char* file)
}
fout << "\n";
}
+ std::vector<std::string>& MakeVerbatim = m_Makefile->GetMakeVerbatim();
// Ouput user make text embeded in the input file
- for(int i =0; i < m_MakeVerbatim.size(); i++)
+ for(unsigned int i =0; i < MakeVerbatim.size(); i++)
{
- fout << m_MakeVerbatim[i] << "\n";
+ fout << MakeVerbatim[i] << "\n";
}
fout << "\n\n";
// Output rules for building executables
- if( m_Executables )
+ if( m_Makefile->HasExecutables() )
{
// collect all the flags needed for linking libraries
std::string linkLibs;
std::vector<std::string>::iterator j;
- std::vector<std::string>& libdirs = m_BuildFlags.GetLinkDirectories();
+ std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
for(j = libdirs.begin(); j != libdirs.end(); ++j)
- {
- linkLibs += "-L";
+ {
+ if((*j).find("-L") == std::string::npos
+ && (*j).find("${") == std::string::npos)
+ {
+ linkLibs += "-L";
+ }
linkLibs += *j;
linkLibs += " ";
}
- std::vector<std::string>& libs = m_BuildFlags.GetLinkLibraries();
+ std::vector<std::string>& libs = m_Makefile->GetLinkLibraries();
for(j = libs.begin(); j != libs.end(); ++j)
{
- linkLibs += "-l";
+ if((*j).find("-l") == std::string::npos
+ && (*j).find("${") == std::string::npos)
+ {
+ linkLibs += "-l";
+ }
linkLibs += *j;
linkLibs += " ";
}
- std::vector<std::string>& libsUnix = m_BuildFlags.GetLinkLibrariesUnix();
+ std::vector<std::string>& libsUnix = m_Makefile->GetLinkLibrariesUnix();
for(j = libsUnix.begin(); j != libsUnix.end(); ++j)
{
linkLibs += *j;
@@ -163,16 +186,15 @@ void cmUnixMakefile::OutputMakefile(const char* file)
fout << "CMAKE_DEPEND_LIBS = ";
this->OutputDependLibraries(fout);
// Now create rules for all of the executables to be built
- for(int i = 0; i < m_Classes.size(); i++)
+ for(unsigned int i = 0; i < Classes.size(); i++)
{
- if(!m_Classes[i].m_AbstractClass && !m_Classes[i].m_HeaderFileOnly)
+ if(!Classes[i].m_AbstractClass && !Classes[i].m_HeaderFileOnly)
{
- std::string DotO = m_Classes[i].m_ClassName;
+ std::string DotO = Classes[i].m_ClassName;
DotO += ".o";
-
- fout << m_Classes[i].m_ClassName << ": " << DotO << " ";
+ fout << Classes[i].m_ClassName << ": " << DotO << " ";
fout << "${CMAKE_DEPEND_LIBS}\n";
- fout << "\t${CXX} ${CXX_FLAGS} "
+ fout << "\t${CXX} ${CXX_FLAGS} " << m_Makefile->GetDefineFlags()
<< DotO.c_str() << " "
<< linkLibs.c_str()
<< " -o $@ ""\n\n";
@@ -180,12 +202,12 @@ void cmUnixMakefile::OutputMakefile(const char* file)
}
// ouput the list of executables
fout << "EXECUTABLES = \\\n";
- for(int i = 0; i < m_Classes.size(); i++)
+ for(unsigned int i = 0; i < Classes.size(); i++)
{
- if(!m_Classes[i].m_AbstractClass && !m_Classes[i].m_HeaderFileOnly)
+ if(!Classes[i].m_AbstractClass && !Classes[i].m_HeaderFileOnly)
{
- fout << m_Classes[i].m_ClassName;
- if(i < m_Classes.size()-1)
+ fout << Classes[i].m_ClassName;
+ if(i < Classes.size()-1)
{
fout << " \\";
}
@@ -195,15 +217,18 @@ void cmUnixMakefile::OutputMakefile(const char* file)
fout << "\n";
}
// Output Sub directory build rules
- if( m_SubDirectories.size() )
+ const std::vector<std::string>& SubDirectories
+ = m_Makefile->GetSubDirectories();
+
+ if( SubDirectories.size() )
{
fout << "SUBDIR_BUILD = \\\n";
- int i;
- for(i =0; i < m_SubDirectories.size(); i++)
+ unsigned int i;
+ for(i =0; i < SubDirectories.size(); i++)
{
- std::string subdir = FixDirectoryName(m_SubDirectories[i].c_str());
+ std::string subdir = FixDirectoryName(SubDirectories[i].c_str());
fout << "build_" << subdir.c_str();
- if(i == m_SubDirectories.size()-1)
+ if(i == SubDirectories.size()-1)
{
fout << " \n\n";
}
@@ -214,11 +239,11 @@ void cmUnixMakefile::OutputMakefile(const char* file)
}
fout << std::endl;
fout << "SUBDIR_CLEAN = \\\n";
- for(i =0; i < m_SubDirectories.size(); i++)
+ for(i =0; i < SubDirectories.size(); i++)
{
- std::string subdir = FixDirectoryName(m_SubDirectories[i].c_str());
+ std::string subdir = FixDirectoryName(SubDirectories[i].c_str());
fout << "clean_" << subdir.c_str();
- if(i == m_SubDirectories.size()-1)
+ if(i == SubDirectories.size()-1)
{
fout << " \n\n";
}
@@ -230,27 +255,30 @@ void cmUnixMakefile::OutputMakefile(const char* file)
fout << std::endl;
fout << "alldirs : ${SUBDIR_BUILD}\n\n";
- for(i =0; i < m_SubDirectories.size(); i++)
+ for(i =0; i < SubDirectories.size(); i++)
{
- std::string subdir = FixDirectoryName(m_SubDirectories[i].c_str());
+ std::string subdir = FixDirectoryName(SubDirectories[i].c_str());
fout << "build_" << subdir.c_str() << ":\n";
- fout << "\tcd " << m_SubDirectories[i].c_str()
+ fout << "\tcd " << SubDirectories[i].c_str()
<< "; ${MAKE} -${MAKEFLAGS} CMakeTargets.make\n";
- fout << "\tcd " << m_SubDirectories[i].c_str()
+ fout << "\tcd " << SubDirectories[i].c_str()
<< "; ${MAKE} -${MAKEFLAGS} all\n\n";
fout << "clean_" << subdir.c_str() << ": \n";
- fout << "\tcd " << m_SubDirectories[i].c_str()
+ fout << "\tcd " << SubDirectories[i].c_str()
<< "; ${MAKE} -${MAKEFLAGS} clean\n\n";
}
}
this->OutputDepends(fout);
}
-void cmUnixMakefile::OutputDependLibraries(std::ostream& fout)
+
+// output the list of libraries that the executables
+// in this makefile will depend on.
+void cmUnixMakefileGenerator::OutputDependLibraries(std::ostream& fout)
{
- std::vector<std::string>& libs = m_BuildFlags.GetLinkLibraries();
- std::vector<std::string>& libdirs = m_BuildFlags.GetLinkDirectories();
+ std::vector<std::string>& libs = m_Makefile->GetLinkLibraries();
+ std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
std::vector<std::string>::iterator dir, lib, endlibs, enddirs;
for(lib = libs.begin(); lib != libs.end(); ++lib)
{
diff --git a/Source/cmUnixMakefile.h b/Source/cmUnixMakefileGenerator.h
index 9899f70..5f3d8f6 100644
--- a/Source/cmUnixMakefile.h
+++ b/Source/cmUnixMakefileGenerator.h
@@ -17,21 +17,22 @@
* itkUnixMakefile is used generate unix makefiles.
*/
-#ifndef cmUnixMakefile_h
-#define cmUnixMakefile_h
+#ifndef cmUnixMakefileGenerator_h
+#define cmUnixMakefileGenerator_h
#include "cmMakefile.h"
+#include "cmMakefileGenerator.h"
-
-class cmUnixMakefile : public cmMakefile
+class cmUnixMakefileGenerator : public cmMakefileGenerator
{
public:
/**
* Write the makefile to the named file
*/
- void OutputMakefile(const char* file);
+ virtual void GenerateMakefile();
+ void OutputDepends(std::ostream&);
protected:
+ void OutputMakefile(const char* file);
void OutputDependLibraries(std::ostream&);
- void OutputDepends(std::ostream&);
};
#endif
diff --git a/Source/cmWin32DefinesRule.cxx b/Source/cmWin32DefinesRule.cxx
new file mode 100644
index 0000000..8927ff6
--- /dev/null
+++ b/Source/cmWin32DefinesRule.cxx
@@ -0,0 +1,28 @@
+#include "cmWin32DefinesRule.h"
+
+
+
+cmWin32DefinesRule::cmWin32DefinesRule()
+{
+#ifndef _WIN32
+ this->SetEnableOff();
+#endif
+}
+
+
+// cmWin32DefinesRule
+bool cmWin32DefinesRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 1 )
+ {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ for(std::vector<std::string>::iterator i = args.begin();
+ i != args.end(); ++i)
+ {
+ m_Makefile->AddDefineFlag((*i).c_str());
+ }
+ return true;
+}
+
diff --git a/Source/cmWin32DefinesRule.h b/Source/cmWin32DefinesRule.h
new file mode 100644
index 0000000..08518b9
--- /dev/null
+++ b/Source/cmWin32DefinesRule.h
@@ -0,0 +1,39 @@
+#ifndef cmWin32DefinesRule_h
+#define cmWin32DefinesRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmWin32DefinesRule : public cmRuleMaker
+{
+public:
+ cmWin32DefinesRule();
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmWin32DefinesRule;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+ virtual bool IsInherited() { return true; }
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "WIN32_DEFINES";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Add -D define flags to command line for win32 environments.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "Add -D define flags to command line for win32 environments.\n"
+ "WIN32_DEFINES(-DFOO -DBAR ...);";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmWin32LibrariesRule.cxx b/Source/cmWin32LibrariesRule.cxx
new file mode 100644
index 0000000..bb32110
--- /dev/null
+++ b/Source/cmWin32LibrariesRule.cxx
@@ -0,0 +1,25 @@
+#include "cmWin32LibrariesRule.h"
+cmWin32LibrariesRule::cmWin32LibrariesRule()
+{
+#ifndef _WIN32
+ this->SetEnableOff();
+#endif
+}
+
+
+// cmWin32LibrariesRule
+bool cmWin32LibrariesRule::Invoke(std::vector<std::string>& args)
+{
+ if(args.size() < 1 )
+ {
+ this->SetError("Called with incorrect number of arguments");
+ return false;
+ }
+ for(std::vector<std::string>::iterator i = args.begin();
+ i != args.end(); ++i)
+ {
+ m_Makefile->AddLinkLibrary((*i).c_str());
+ }
+ return true;
+}
+
diff --git a/Source/cmWin32LibrariesRule.h b/Source/cmWin32LibrariesRule.h
new file mode 100644
index 0000000..93277a2
--- /dev/null
+++ b/Source/cmWin32LibrariesRule.h
@@ -0,0 +1,42 @@
+#ifndef cmWin32LibrariesRule_h
+#define cmWin32LibrariesRule_h
+
+#include "cmStandardIncludes.h"
+#include "cmRuleMaker.h"
+
+
+class cmWin32LibrariesRule : public cmRuleMaker
+{
+public:
+ cmWin32LibrariesRule();
+ virtual cmRuleMaker* Clone()
+ {
+ return new cmWin32LibrariesRule ;
+ }
+ // This is called when the rule is firt encountered in
+ // the input file
+ virtual bool Invoke(std::vector<std::string>& args);
+ virtual void FinalPass() { }
+ virtual bool IsInherited() { return true; }
+
+ // This is the name used in the input file.
+ virtual const char* GetName() { return "WIN32_LIBRARIES";}
+ virtual const char* TerseDocumentaion()
+ {
+ return "Set a name for the library to be built. One argument.";
+ }
+
+ // Return full documentation for the rule
+ virtual const char* FullDocumentaion()
+ {
+ return
+ "Set the name for the library in this makefile. \n"
+ "This takes one argument.\n"
+ "LIBRARY(libraryname);\n"
+ "There can be only one library per CMakeLists.txt file.\n";
+ }
+};
+
+
+
+#endif
diff --git a/Source/cmWindowsConfigure.cxx b/Source/cmWindowsConfigure.cxx
index db9275f..17e46b2 100644
--- a/Source/cmWindowsConfigure.cxx
+++ b/Source/cmWindowsConfigure.cxx
@@ -1,9 +1,8 @@
#include "cmWindowsConfigure.h"
+#include "cmStandardIncludes.h"
#include "cmSystemTools.h"
-#include <fstream>
#include <windows.h>
-
bool cmWindowsConfigure::Configure(const char* file)
{
std::ifstream fin(file);
diff --git a/Source/cmWindowsConfigure.h b/Source/cmWindowsConfigure.h
index fa3059b..8922d97 100644
--- a/Source/cmWindowsConfigure.h
+++ b/Source/cmWindowsConfigure.h
@@ -21,7 +21,7 @@
*/
#ifndef cmWindowsConfigure_h
#define cmWindowsConfigure_h
-#include <string>
+#include "cmStandardIncludes.h"
class cmWindowsConfigure
{