summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2000-08-30 17:35:41 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2000-08-30 17:35:41 (GMT)
commit077c31484e216a72c73370c05fcf970ce5269085 (patch)
tree214109143e01d98fd406264be9f80a5bffdaff17
parent1f42f521cea8b953f4ad7ef5ca0d4c6d49c42a88 (diff)
downloadCMake-077c31484e216a72c73370c05fcf970ce5269085.zip
CMake-077c31484e216a72c73370c05fcf970ce5269085.tar.gz
CMake-077c31484e216a72c73370c05fcf970ce5269085.tar.bz2
ENH: move from tools and create working CMake program
-rw-r--r--CMakeRules.make.in8
-rw-r--r--CMakeVariables.make.in2
-rw-r--r--README12
-rw-r--r--Source/CMakeSetupCMD.dsp12
-rw-r--r--Source/MFCDialog/CMakeSetup.dsp54
-rw-r--r--Source/MFCDialog/CMakeSetupDialog.cpp6
-rw-r--r--Source/Makefile.in5
-rw-r--r--Source/cmClassFile.cxx5
-rw-r--r--Source/cmDSPMakefile.cxx61
-rw-r--r--Source/cmDSPWriter.cxx61
-rw-r--r--Source/cmDSWMakefile.cxx4
-rw-r--r--Source/cmDSWWriter.cxx4
-rw-r--r--Source/cmMakefile.cxx73
-rw-r--r--Source/cmMakefile.h2
-rw-r--r--Source/cmUnixMakefile.cxx24
15 files changed, 222 insertions, 111 deletions
diff --git a/CMakeRules.make.in b/CMakeRules.make.in
index e65c16e..5a9f445 100644
--- a/CMakeRules.make.in
+++ b/CMakeRules.make.in
@@ -15,7 +15,7 @@
#
#------------------------------------------------------------------------------
#
-all: ${OBJ_SUB_DIRS} ${EXECUTABLES} ${SUBDIR_BUILD} ${ITK_LIB_FILE} ${LOCAL_BUILD_TARGETS}
+all: ${OBJ_SUB_DIRS} ${EXECUTABLES} ${SUBDIR_BUILD} ${BUILD_LIB_FILE} ${LOCAL_BUILD_TARGETS}
#------------------------------------------------------------------------------
@@ -46,6 +46,6 @@ lib$(ME)$(SHLIB_SUFFIX): ${KIT_OBJ}
lib$(ME)$(SHLIB_SUFFIX) \
${KIT_OBJ} ${SHLIB_LD_LIBS}
-install: ${ITK_LIB_FILE}
- @echo "Installing ${ITK_LIB_FILE}"
- ${INSTALL} -m 755 $(ITK_LIB_FILE) $(LIB_INSTALL_DIR)/$(ITK_LIB_FILE)
+install: ${BUILD_LIB_FILE}
+ @echo "Installing ${BUILD_LIB_FILE}"
+ ${INSTALL} -m 755 $(BUILD_LIB_FILE) $(LIB_INSTALL_DIR)/$(BUILD_LIB_FILE)
diff --git a/CMakeVariables.make.in b/CMakeVariables.make.in
index 61a8363..1b47d00 100644
--- a/CMakeVariables.make.in
+++ b/CMakeVariables.make.in
@@ -105,5 +105,5 @@ CC_FLAGS = ${CPPFLAGS} ${LOCAL_CFLAGS} ${CFLAGS}
# set up the path to the rulesgen program
CMAKE = @CMAKE_OBJ_DIR@/CMake/Source/CMakeBuildTargets
-
+KIT_OBJ = ${SRC_OBJ}
BUILD_LIB_FILE = lib${ME}${ITK_LIB_EXT}
diff --git a/README b/README
index ff43133..736e273 100644
--- a/README
+++ b/README
@@ -13,6 +13,18 @@ Unix
configure -> run on unix to configure for build
CMakeBuildTargets -> Unix program to read CMakeLists.txt and generate CMakeTargets.make
+
+CMakeLists.txt:
+WIN32_CLASSES =
+UNIX_CLASSES =
+ABSTRACT_CLASSES =
+SUBDIRS =
+EXECUTABLES =
+ME =
+BEGIN MAKE VERBATIM
+... # copy stuff into CMakeTargets.make directly
+END MAKE VERBATIM
+TEMPLATE_INSTANCE_DIR =
TODO:
Fix cmUnixMakefile.cxx and cmDSPMakefile.cxx
to read libraries and -I stuff from a config file
diff --git a/Source/CMakeSetupCMD.dsp b/Source/CMakeSetupCMD.dsp
index 3efa9a1..9af6147 100644
--- a/Source/CMakeSetupCMD.dsp
+++ b/Source/CMakeSetupCMD.dsp
@@ -91,10 +91,18 @@ LINK32=link.exe
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
+SOURCE=.\CMakeSetupCMD.cxx
+# End Source File
+# Begin Source File
+
SOURCE=.\cmClassFile.cxx
# End Source File
# Begin Source File
+SOURCE=.\cmDirectory.cxx
+# End Source File
+# Begin Source File
+
SOURCE=.\cmDSPBuilder.cxx
# End Source File
# Begin Source File
@@ -129,10 +137,6 @@ SOURCE=.\cmRegularExpression.cxx
SOURCE=.\cmSystemTools.cxx
# End Source File
-# Begin Source File
-
-SOURCE=.\CMakeSetupCMD.cxx
-# End Source File
# End Group
# Begin Group "Header Files"
diff --git a/Source/MFCDialog/CMakeSetup.dsp b/Source/MFCDialog/CMakeSetup.dsp
index 6ab7031..9864a7c 100644
--- a/Source/MFCDialog/CMakeSetup.dsp
+++ b/Source/MFCDialog/CMakeSetup.dsp
@@ -92,10 +92,26 @@ LINK32=link.exe
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
+SOURCE=.\CMakeSetup.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\CMakeSetup.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\CMakeSetupDialog.cpp
+# End Source File
+# Begin Source File
+
SOURCE=..\cmClassFile.cxx
# End Source File
# Begin Source File
+SOURCE=..\cmDirectory.cxx
+# End Source File
+# Begin Source File
+
SOURCE=..\cmDSPBuilder.cxx
# End Source File
# Begin Source File
@@ -132,33 +148,33 @@ SOURCE=..\cmSystemTools.cxx
# End Source File
# Begin Source File
-SOURCE=..\itkVC60Configure.cxx
+SOURCE=..\cmWindowsConfigure.cxx
# End Source File
# Begin Source File
-SOURCE=..\cmWindowsConfigure.cxx
+SOURCE=..\itkVC60Configure.cxx
# End Source File
# Begin Source File
-SOURCE=.\CMakeSetup.cpp
+SOURCE=.\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
-SOURCE=.\CMakeSetup.rc
+SOURCE=..\CMakeSetup.h
# End Source File
# Begin Source File
-SOURCE=.\CMakeSetupDialog.cpp
+SOURCE=.\CMakeSetup.h
# End Source File
# Begin Source File
-SOURCE=.\StdAfx.cpp
-# ADD CPP /Yc"stdafx.h"
+SOURCE=.\CMakeSetupDialog.h
# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\cmClassFile.h
@@ -189,22 +205,10 @@ SOURCE=..\cmMakefile.h
# End Source File
# Begin Source File
-SOURCE=..\CMakeSetup.h
-# End Source File
-# Begin Source File
-
SOURCE=..\cmRegularExpression.h
# End Source File
# Begin Source File
-SOURCE=.\CMakeSetup.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\CMakeSetupDialog.h
-# End Source File
-# Begin Source File
-
SOURCE=.\Resource.h
# End Source File
# Begin Source File
@@ -221,11 +225,11 @@ SOURCE=.\res\CMakeSetup.ico
# End Source File
# Begin Source File
-SOURCE=.\res\CMakeSetupDialog.rc2
+SOURCE=.\res\CMakeSetupDialog.ico
# End Source File
# Begin Source File
-SOURCE=.\res\CMakeSetupDialog.ico
+SOURCE=.\res\CMakeSetupDialog.rc2
# End Source File
# End Group
# Begin Source File
diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp
index 13513b29..32b8027 100644
--- a/Source/MFCDialog/CMakeSetupDialog.cpp
+++ b/Source/MFCDialog/CMakeSetupDialog.cpp
@@ -235,13 +235,13 @@ void CMakeSetupDialog::OnOK()
cmDSWBuilder builder;
// Set the ITK home directory
builder.SetHomeDirectory(m_WhereSource);
- // Set the Makefile.in file
+ // Set the CMakeLists.txt file
CString makefileIn = m_WhereSource;
- makefileIn += "/Makefile.in";
+ makefileIn += "/CMakeLists.txt";
builder.SetInputMakefilePath(makefileIn);
// Set the output directory
builder.SetOutputDirectory(m_WhereBuild);
- // set the directory which contains the Makefile.in
+ // set the directory which contains the CMakeLists.txt
builder.SetMakefileDirectory(m_WhereSource);
// Create the master DSW file and all children dsp files for ITK
builder.CreateDSWFile();
diff --git a/Source/Makefile.in b/Source/Makefile.in
index 0466192..ecd0171 100644
--- a/Source/Makefile.in
+++ b/Source/Makefile.in
@@ -12,12 +12,15 @@ CMAKE =
OBJS = \
cmClassFile.o \
+cmDirectory.o \
cmMakefile.o \
cmUnixMakefile.o \
cmMakeDepend.o \
cmRegularExpression.o \
-CMakeBuildTargets.o
+CMakeBuildTargets.o
+
+cmDirectory.o : cmDirectory.h cmDirectory.cxx
cmClassFile.o : cmClassFile.h cmClassFile.cxx
cmMakefile.o : cmMakefile.h cmMakefile.cxx cmClassFile.h
cmUnixMakefile.o : cmUnixMakefile.h cmUnixMakefile.cxx cmMakefile.h cmClassFile.h
diff --git a/Source/cmClassFile.cxx b/Source/cmClassFile.cxx
index 7893df6..f953bbb 100644
--- a/Source/cmClassFile.cxx
+++ b/Source/cmClassFile.cxx
@@ -38,11 +38,12 @@ void cmClassFile::SetName(const char* name, const char* dir)
std::string hname = pathname;
hname += ".cxx";
if(cmFileExists(hname.c_str()))
- {
+ {
m_HeaderFileOnly = false;
m_FullPath = hname;
return;
- }
+ }
+
hname = pathname;
hname += ".c";
if(cmFileExists(hname.c_str()))
diff --git a/Source/cmDSPMakefile.cxx b/Source/cmDSPMakefile.cxx
index 430f3ac..ab17add 100644
--- a/Source/cmDSPMakefile.cxx
+++ b/Source/cmDSPMakefile.cxx
@@ -4,6 +4,13 @@
#include <fstream>
#include <windows.h>
+static void Die(const char* message)
+{
+ MessageBox(0, message, 0, MB_OK);
+ exit(-1);
+}
+
+
void cmDSPMakefile::OutputDSPFile()
{
m_IncludeOptions = "/STACK:10000000 ";
@@ -36,8 +43,9 @@ void cmDSPMakefile::OutputDSPFile()
{
if(!cmSystemTools::MakeDirectory(m_OutputDirectory.c_str()))
{
- MessageBox(0, "Error creating directory ", 0, MB_OK);
- MessageBox(0, m_OutputDirectory.c_str(), 0, MB_OK);
+ std::string message = "Error creating directory ";
+ message += m_OutputDirectory;
+ Die(message.c_str());
}
}
@@ -45,22 +53,19 @@ void cmDSPMakefile::OutputDSPFile()
{
if(this->m_LibraryName == "")
{
- std::cerr << "No library name in Makefile.in dsp not created" << std::endl;
+ // if no library silently give up
return;
}
- std::cerr << "building library " << this->m_LibraryName.c_str() << std::endl;
this->SetBuildType(STATIC_LIBRARY);
this->CreateSingleDSP();
}
else
{
- std::cerr << "Build Executables " << std::endl;
this->CreateExecutableDSPFiles();
}
}
void cmDSPMakefile::CreateExecutableDSPFiles()
{
- std::cerr << "Create executables for ";
for(int i = 0; i < m_Classes.size(); ++i)
{
cmClassFile& classfile = m_Classes[i];
@@ -71,9 +76,9 @@ void cmDSPMakefile::CreateExecutableDSPFiles()
std::ofstream fout(fname.c_str());
if(!fout)
{
- MessageBox(0, "Error writing ", 0, MB_OK);
- MessageBox(0, fname.c_str(), 0, MB_OK);
- std::cerr << "Error can not open " << fname.c_str() << " for write" << std::endl;
+ std::string message = "Error Writing ";
+ message += fname;
+ Die(message.c_str());
}
else
{
@@ -97,8 +102,6 @@ void cmDSPMakefile::CreateExecutableDSPFiles()
void cmDSPMakefile::CreateSingleDSP()
{
std::string fname;
- std::cerr << "writting dsp file " << m_cmCurrentDirectory.c_str()
- << std::endl;
fname = m_OutputDirectory;
fname += "/";
fname += this->m_LibraryName;
@@ -106,15 +109,13 @@ void cmDSPMakefile::CreateSingleDSP()
m_CreatedProjectNames.clear();
std::string pname = m_LibraryName;
m_CreatedProjectNames.push_back(pname);
- std::cerr << "writting dsp file " << fname.c_str() << std::endl;
std::ofstream fout(fname.c_str());
if(!fout)
{
- MessageBox(0, "Error writing ", 0, MB_OK);
- MessageBox(0, fname.c_str(), 0, MB_OK);
- std::cerr << "Error can not open " << fname.c_str() << " for write" << std::endl;
- return;
- }
+ std::string message = "Error Writing ";
+ message += fname;
+ Die(message.c_str());
+ }
this->WriteDSPFile(fout);
}
@@ -125,7 +126,7 @@ void cmDSPMakefile::WriteDSPBuildRule(std::ostream& fout)
#undef GetCurrentDirectory
std::string makefileIn = this->GetCurrentDirectory();
makefileIn += "/";
- makefileIn += "Makefile.in";
+ makefileIn += "CMakeLists.txt";
std::string dsprule = GetHomeDirectory();
dsprule += "/CMake/pcbuilderCMD ";
dsprule += makefileIn;
@@ -191,21 +192,21 @@ void cmDSPMakefile::SetBuildType(BuildType b)
{
case STATIC_LIBRARY:
m_DSPHeaderTemplate = m_cmHomeDirectory;
- m_DSPHeaderTemplate += "/CMake/staticLibHeader.dsptemplate";
+ m_DSPHeaderTemplate += "/CMake/Source/staticLibHeader.dsptemplate";
m_DSPFooterTemplate = m_cmHomeDirectory;
- m_DSPFooterTemplate += "/CMake/staticLibFooter.dsptemplate";
+ m_DSPFooterTemplate += "/CMake/Source/staticLibFooter.dsptemplate";
break;
case DLL:
m_DSPHeaderTemplate = m_cmHomeDirectory;
- m_DSPHeaderTemplate += "/CMake/DLLHeader.dsptemplate";
+ m_DSPHeaderTemplate += "/CMake/Source/DLLHeader.dsptemplate";
m_DSPFooterTemplate = m_cmHomeDirectory;
- m_DSPFooterTemplate += "/CMake/DLLFooter.dsptemplate";
+ m_DSPFooterTemplate += "/CMake/Source/DLLFooter.dsptemplate";
break;
case EXECUTABLE:
m_DSPHeaderTemplate = m_cmHomeDirectory;
- m_DSPHeaderTemplate += "/CMake/EXEHeader.dsptemplate";
+ m_DSPHeaderTemplate += "/CMake/Source/EXEHeader.dsptemplate";
m_DSPFooterTemplate = m_cmHomeDirectory;
- m_DSPFooterTemplate += "/CMake/EXEFooter.dsptemplate";
+ m_DSPFooterTemplate += "/CMake/Source/EXEFooter.dsptemplate";
break;
}
}
@@ -216,9 +217,9 @@ void cmDSPMakefile::WriteDSPHeader(std::ostream& fout)
std::ifstream fin(m_DSPHeaderTemplate.c_str());
if(!fin)
{
- std::cerr << "failed to open " << m_DSPHeaderTemplate.c_str()
- << " for read" << std::endl;
- return;
+ std::string message = "Error Reading ";
+ message += m_DSPHeaderTemplate;
+ Die(message.c_str());
}
char buffer[2048];
while(fin)
@@ -245,9 +246,9 @@ void cmDSPMakefile::WriteDSPFooter(std::ostream& fout)
std::ifstream fin(m_DSPFooterTemplate.c_str());
if(!fin)
{
- std::cerr << "can not open " << m_DSPFooterTemplate.c_str() <<
- " for read" << std::endl;
- return;
+ std::string message = "Error Reading ";
+ message += m_DSPFooterTemplate;
+ Die(message.c_str());
}
char buffer[2048];
while(fin)
diff --git a/Source/cmDSPWriter.cxx b/Source/cmDSPWriter.cxx
index 430f3ac..ab17add 100644
--- a/Source/cmDSPWriter.cxx
+++ b/Source/cmDSPWriter.cxx
@@ -4,6 +4,13 @@
#include <fstream>
#include <windows.h>
+static void Die(const char* message)
+{
+ MessageBox(0, message, 0, MB_OK);
+ exit(-1);
+}
+
+
void cmDSPMakefile::OutputDSPFile()
{
m_IncludeOptions = "/STACK:10000000 ";
@@ -36,8 +43,9 @@ void cmDSPMakefile::OutputDSPFile()
{
if(!cmSystemTools::MakeDirectory(m_OutputDirectory.c_str()))
{
- MessageBox(0, "Error creating directory ", 0, MB_OK);
- MessageBox(0, m_OutputDirectory.c_str(), 0, MB_OK);
+ std::string message = "Error creating directory ";
+ message += m_OutputDirectory;
+ Die(message.c_str());
}
}
@@ -45,22 +53,19 @@ void cmDSPMakefile::OutputDSPFile()
{
if(this->m_LibraryName == "")
{
- std::cerr << "No library name in Makefile.in dsp not created" << std::endl;
+ // if no library silently give up
return;
}
- std::cerr << "building library " << this->m_LibraryName.c_str() << std::endl;
this->SetBuildType(STATIC_LIBRARY);
this->CreateSingleDSP();
}
else
{
- std::cerr << "Build Executables " << std::endl;
this->CreateExecutableDSPFiles();
}
}
void cmDSPMakefile::CreateExecutableDSPFiles()
{
- std::cerr << "Create executables for ";
for(int i = 0; i < m_Classes.size(); ++i)
{
cmClassFile& classfile = m_Classes[i];
@@ -71,9 +76,9 @@ void cmDSPMakefile::CreateExecutableDSPFiles()
std::ofstream fout(fname.c_str());
if(!fout)
{
- MessageBox(0, "Error writing ", 0, MB_OK);
- MessageBox(0, fname.c_str(), 0, MB_OK);
- std::cerr << "Error can not open " << fname.c_str() << " for write" << std::endl;
+ std::string message = "Error Writing ";
+ message += fname;
+ Die(message.c_str());
}
else
{
@@ -97,8 +102,6 @@ void cmDSPMakefile::CreateExecutableDSPFiles()
void cmDSPMakefile::CreateSingleDSP()
{
std::string fname;
- std::cerr << "writting dsp file " << m_cmCurrentDirectory.c_str()
- << std::endl;
fname = m_OutputDirectory;
fname += "/";
fname += this->m_LibraryName;
@@ -106,15 +109,13 @@ void cmDSPMakefile::CreateSingleDSP()
m_CreatedProjectNames.clear();
std::string pname = m_LibraryName;
m_CreatedProjectNames.push_back(pname);
- std::cerr << "writting dsp file " << fname.c_str() << std::endl;
std::ofstream fout(fname.c_str());
if(!fout)
{
- MessageBox(0, "Error writing ", 0, MB_OK);
- MessageBox(0, fname.c_str(), 0, MB_OK);
- std::cerr << "Error can not open " << fname.c_str() << " for write" << std::endl;
- return;
- }
+ std::string message = "Error Writing ";
+ message += fname;
+ Die(message.c_str());
+ }
this->WriteDSPFile(fout);
}
@@ -125,7 +126,7 @@ void cmDSPMakefile::WriteDSPBuildRule(std::ostream& fout)
#undef GetCurrentDirectory
std::string makefileIn = this->GetCurrentDirectory();
makefileIn += "/";
- makefileIn += "Makefile.in";
+ makefileIn += "CMakeLists.txt";
std::string dsprule = GetHomeDirectory();
dsprule += "/CMake/pcbuilderCMD ";
dsprule += makefileIn;
@@ -191,21 +192,21 @@ void cmDSPMakefile::SetBuildType(BuildType b)
{
case STATIC_LIBRARY:
m_DSPHeaderTemplate = m_cmHomeDirectory;
- m_DSPHeaderTemplate += "/CMake/staticLibHeader.dsptemplate";
+ m_DSPHeaderTemplate += "/CMake/Source/staticLibHeader.dsptemplate";
m_DSPFooterTemplate = m_cmHomeDirectory;
- m_DSPFooterTemplate += "/CMake/staticLibFooter.dsptemplate";
+ m_DSPFooterTemplate += "/CMake/Source/staticLibFooter.dsptemplate";
break;
case DLL:
m_DSPHeaderTemplate = m_cmHomeDirectory;
- m_DSPHeaderTemplate += "/CMake/DLLHeader.dsptemplate";
+ m_DSPHeaderTemplate += "/CMake/Source/DLLHeader.dsptemplate";
m_DSPFooterTemplate = m_cmHomeDirectory;
- m_DSPFooterTemplate += "/CMake/DLLFooter.dsptemplate";
+ m_DSPFooterTemplate += "/CMake/Source/DLLFooter.dsptemplate";
break;
case EXECUTABLE:
m_DSPHeaderTemplate = m_cmHomeDirectory;
- m_DSPHeaderTemplate += "/CMake/EXEHeader.dsptemplate";
+ m_DSPHeaderTemplate += "/CMake/Source/EXEHeader.dsptemplate";
m_DSPFooterTemplate = m_cmHomeDirectory;
- m_DSPFooterTemplate += "/CMake/EXEFooter.dsptemplate";
+ m_DSPFooterTemplate += "/CMake/Source/EXEFooter.dsptemplate";
break;
}
}
@@ -216,9 +217,9 @@ void cmDSPMakefile::WriteDSPHeader(std::ostream& fout)
std::ifstream fin(m_DSPHeaderTemplate.c_str());
if(!fin)
{
- std::cerr << "failed to open " << m_DSPHeaderTemplate.c_str()
- << " for read" << std::endl;
- return;
+ std::string message = "Error Reading ";
+ message += m_DSPHeaderTemplate;
+ Die(message.c_str());
}
char buffer[2048];
while(fin)
@@ -245,9 +246,9 @@ void cmDSPMakefile::WriteDSPFooter(std::ostream& fout)
std::ifstream fin(m_DSPFooterTemplate.c_str());
if(!fin)
{
- std::cerr << "can not open " << m_DSPFooterTemplate.c_str() <<
- " for read" << std::endl;
- return;
+ std::string message = "Error Reading ";
+ message += m_DSPFooterTemplate;
+ Die(message.c_str());
}
char buffer[2048];
while(fin)
diff --git a/Source/cmDSWMakefile.cxx b/Source/cmDSWMakefile.cxx
index ae72f4b..60d09f5 100644
--- a/Source/cmDSWMakefile.cxx
+++ b/Source/cmDSWMakefile.cxx
@@ -62,7 +62,7 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
std::cerr << "Create dsp for " << (*si).c_str() << std::endl;
if(dspname == "")
{
- std::cerr << "Project name not found in " << dir << "/Makefile.in" << std::endl;
+ std::cerr << "Project name not found in " << dir << "/CMakeLists.txt" << std::endl;
std::cerr << "Skipping Project " << std::endl;
}
else
@@ -91,7 +91,7 @@ std::vector<std::string> cmDSWMakefile::CreateDSPFile(const char* subdir)
outdir += subdir;
dsp.SetOutputDirectory(outdir.c_str());
currentDir += "/";
- currentDir += "Makefile.in";
+ currentDir += "CMakeLists.txt";
dsp.SetInputMakefilePath(currentDir.c_str());
dsp.CreateDSPFile();
return dsp.GetCreatedProjectNames();
diff --git a/Source/cmDSWWriter.cxx b/Source/cmDSWWriter.cxx
index ae72f4b..60d09f5 100644
--- a/Source/cmDSWWriter.cxx
+++ b/Source/cmDSWWriter.cxx
@@ -62,7 +62,7 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
std::cerr << "Create dsp for " << (*si).c_str() << std::endl;
if(dspname == "")
{
- std::cerr << "Project name not found in " << dir << "/Makefile.in" << std::endl;
+ std::cerr << "Project name not found in " << dir << "/CMakeLists.txt" << std::endl;
std::cerr << "Skipping Project " << std::endl;
}
else
@@ -91,7 +91,7 @@ std::vector<std::string> cmDSWMakefile::CreateDSPFile(const char* subdir)
outdir += subdir;
dsp.SetOutputDirectory(outdir.c_str());
currentDir += "/";
- currentDir += "Makefile.in";
+ currentDir += "CMakeLists.txt";
dsp.SetInputMakefilePath(currentDir.c_str());
dsp.CreateDSPFile();
return dsp.GetCreatedProjectNames();
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 9f9955c..38792a5 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -3,13 +3,14 @@
#endif
#include "cmMakefile.h"
#include "cmClassFile.h"
+#include "cmDirectory.h"
#include <fstream>
#include <iostream>
// remove extra spaces and the "\" character from the name
-// of the class as it is in the Makefile.in
+// of the class as it is in the CMakeLists.txt
inline std::string CleanUpName(const char* name)
{
std::string className = name;
@@ -50,7 +51,7 @@ void cmMakefile::Print()
m_Classes[i].Print();
}
-// Parse the given Makefile.in file into a list of classes.
+// Parse the given CMakeLists.txt file into a list of classes.
bool cmMakefile::ReadMakefile(const char* filename)
{
@@ -97,6 +98,10 @@ bool cmMakefile::ReadMakefile(const char* filename)
this->ReadClasses(fin, true);
}
}
+ else if(line.find("TEMPLATE_INSTANCE_DIRECTORY") != std::string::npos)
+ {
+ this->ReadTemplateInstanceDirectory(line);
+ }
else if(line.find("SUBDIRS") != std::string::npos)
{
if(line.find("\\") != std::string::npos)
@@ -112,6 +117,23 @@ bool cmMakefile::ReadMakefile(const char* filename)
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)
+ {
+ fin.getline(inbuffer, 2047);
+ m_MakeVerbatim.push_back(inbuffer);
+ if((m_MakeVerbatim.end()-1)->find("END MAKE VERBATIM")
+ != std::string::npos )
+ {
+ done = true;
+ *(m_MakeVerbatim.end()-1) = "# End CMakeLists VERBATIM\n\n";
+ }
+ }
+ }
else if(line.find("ME") != std::string::npos)
{
size_t mestart = line.find("ME");
@@ -183,6 +205,52 @@ void cmMakefile::ReadClasses(std::ifstream& fin,
}
+void cmMakefile::ReadTemplateInstanceDirectory(std::string& line)
+{
+ std::string::size_type start = line.find("=");
+ if(start != std::string::npos)
+ {
+ std::string dirname = line.substr(start+1, line.size());
+ dirname = CleanUpName(dirname.c_str());
+ std::string tdir = this->GetCurrentDirectory();
+ tdir += "/";
+ tdir += dirname;
+ // 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 = dirname;
+ 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 << "Error can not open template instance directory "
+ << dirname.c_str() << std::endl;
+ }
+ }
+}
+
+
+
// Read a list of subdirectories from the stream
void cmMakefile::ReadSubdirs(std::ifstream& fin)
{
@@ -206,3 +274,4 @@ void cmMakefile::ReadSubdirs(std::ifstream& fin)
m_SubDirectories.push_back(dir);
}
}
+
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 35781b4..d570de4 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -84,6 +84,7 @@ public:
}
private:
+ void ReadTemplateInstanceDirectory(std::string&);
void ReadSubdirs(std::ifstream& fin);
void ReadClasses(std::ifstream& fin, bool t);
friend class cmMakeDepend; // make depend needs direct access
@@ -98,6 +99,7 @@ protected:
std::string m_LibraryName; // library name
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; // list of sub directories
};
diff --git a/Source/cmUnixMakefile.cxx b/Source/cmUnixMakefile.cxx
index 4a14599..4628e9e 100644
--- a/Source/cmUnixMakefile.cxx
+++ b/Source/cmUnixMakefile.cxx
@@ -82,6 +82,13 @@ void cmUnixMakefile::OutputMakefile(const char* file)
}
fout << "\n";
}
+ fout << "ME = " << this->GetLibraryName() << "\n\n";
+ for(int i =0; i < m_MakeVerbatim.size(); i++)
+ {
+ fout << m_MakeVerbatim[i] << "\n";
+ }
+ fout << "\n\n";
+
if( m_Executables )
{
for(int i = 0; i < m_Classes.size(); i++)
@@ -91,10 +98,19 @@ void cmUnixMakefile::OutputMakefile(const char* file)
std::string DotO = m_Classes[i].m_ClassName;
DotO += ".o";
fout << m_Classes[i].m_ClassName << ": " << DotO << "\n";
- fout << "\t ${CXX} ${CXX_FLAGS} " << DotO.c_str() << " -o $@ -L${ITK_OBJ}/Code/Common -lITKCommon \\\n"
- << "\t-L${ITK_OBJ}/Code/Insight3DParty/vxl -lITKNumerics -lm ${DL_LIBS}\n\n";
+ fout << "\t ${CXX} ${CXX_FLAGS} " << DotO.c_str() << " -o $@ -L${CMAKE_OBJ_DIR}/Code/Common -lITKCommon \\\n"
+ << "\t-L${CMAKE_OBJ_DIR}/Code/Insight3DParty/vxl -lITKNumerics -lm ${DL_LIBS}\n\n";
}
}
+ fout << "EXECUTABLES = \\\n";
+ for(int i = 0; i < m_Classes.size(); i++)
+ {
+ if(!m_Classes[i].m_AbstractClass && !m_Classes[i].m_HeaderFileOnly)
+ {
+ fout << m_Classes[i].m_ClassName << " \\\n";
+ }
+ }
+ fout << "\n";
}
if( m_SubDirectories.size() )
@@ -135,9 +151,7 @@ void cmUnixMakefile::OutputMakefile(const char* file)
for(i =0; i < m_SubDirectories.size(); i++)
{
std::string subdir = FixDirectoryName(m_SubDirectories[i].c_str());
- fout << "build_" << subdir.c_str() << ": targets.make\n";
- fout << "\tcd " << m_SubDirectories[i].c_str()
- << "; ${MAKE} -${MAKEFLAGS} targets.make\n";
+ fout << "build_" << subdir.c_str() << ":\n";
fout << "\tcd " << m_SubDirectories[i].c_str()
<< "; ${MAKE} -${MAKEFLAGS} all\n\n";