summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2000-09-27 19:01:19 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2000-09-27 19:01:19 (GMT)
commit74c1345333b456eb34480c987bc186ef2af3c536 (patch)
tree0c0751e4bfef94831377d7f5e20202b27cd06de9
parent1e3ba0f1d72873233193ce69614fd4bd880e8fc5 (diff)
downloadCMake-74c1345333b456eb34480c987bc186ef2af3c536.zip
CMake-74c1345333b456eb34480c987bc186ef2af3c536.tar.gz
CMake-74c1345333b456eb34480c987bc186ef2af3c536.tar.bz2
ENH: change ME to LIBRARY and added PROJECT, also remove ITK stuff and replaced with CMake
-rw-r--r--CMakeMaster.make.in4
-rw-r--r--CMakeRules.make.in16
-rw-r--r--CMakeVariables.make.in11
-rw-r--r--README8
-rw-r--r--Source/cmDSWMakefile.cxx21
-rw-r--r--Source/cmDSWMakefile.h3
-rw-r--r--Source/cmDSWWriter.cxx21
-rw-r--r--Source/cmDSWWriter.h3
-rw-r--r--Source/cmMakefile.cxx27
-rw-r--r--Source/cmMakefile.h15
-rw-r--r--Source/cmSystemTools.cxx45
-rw-r--r--Source/cmSystemTools.h11
-rw-r--r--Source/cmUnixMakefile.cxx39
-rw-r--r--Source/cmUnixMakefile.h1
14 files changed, 176 insertions, 49 deletions
diff --git a/CMakeMaster.make.in b/CMakeMaster.make.in
index 8d477c9..404b73a 100644
--- a/CMakeMaster.make.in
+++ b/CMakeMaster.make.in
@@ -1,4 +1,8 @@
#------------------------------------------------------------------------------
+# move this from CMakeVariables.make.in so that depends can be done in CMakeTargets.make
+CMAKE_LIB_EXT = @CMAKE_LIB_EXT@
+
+#------------------------------------------------------------------------------
# Include generated rules
@MAKEINCLUDE@ @MAKEQUOTE@CMakeTargets.make@MAKEQUOTE@
diff --git a/CMakeRules.make.in b/CMakeRules.make.in
index 307b9f6..bfecbf3 100644
--- a/CMakeRules.make.in
+++ b/CMakeRules.make.in
@@ -1,4 +1,4 @@
-# include simple rules for building .o files from source files
+# rules for building .o files from source files
@MAKEINCLUDE@ @MAKEQUOTE@@CMAKE_CONFIG_DIR@/CMake/CMakeSimpleRules.make@MAKEQUOTE@
#
@@ -26,15 +26,15 @@ CMakeTargets.make: ${CMAKE} ${srcdir}/CMakeLists.txt
#------------------------------------------------------------------------------
# rules for the normal library
#
-lib${ME}.a: ${SRC_OBJ} ${KIT_OBJ}
- ${AR} cr lib${ME}.a ${KIT_OBJ}
- ${RANLIB} lib$(ME).a
+lib${LIBRARY}.a: ${SRC_OBJ} ${KIT_OBJ}
+ ${AR} cr lib${LIBRARY}.a ${KIT_OBJ}
+ ${RANLIB} lib$(LIBRARY).a
-lib$(ME)$(SHLIB_SUFFIX): ${KIT_OBJ}
- rm -f lib$(ME)$(SHLIB_SUFFIX)
- $(CXX) ${CXX_FLAGS} ${ITK_SHLIB_BUILD_FLAGS} -o \
- lib$(ME)$(SHLIB_SUFFIX) \
+lib$(LIBRARY)$(SHLIB_SUFFIX): ${KIT_OBJ}
+ rm -f lib$(LIBRARY)$(SHLIB_SUFFIX)
+ $(CXX) ${CXX_FLAGS} ${CMAKE_SHLIB_BUILD_FLAGS} -o \
+ lib$(LIBRARY)$(SHLIB_SUFFIX) \
${KIT_OBJ} ${SHLIB_LD_LIBS}
install: ${BUILD_LIB_FILE}
diff --git a/CMakeVariables.make.in b/CMakeVariables.make.in
index 1e8246b..b9aa899 100644
--- a/CMakeVariables.make.in
+++ b/CMakeVariables.make.in
@@ -43,10 +43,10 @@ SHELL = /bin/sh
RANLIB = @RANLIB@
CC = @CC@
-CFLAGS = @ITK_SHLIB_CFLAGS@ @ANSI_CFLAGS@
+CFLAGS = @CMAKE_SHLIB_CFLAGS@ @ANSI_CFLAGS@
CXX = @CXX@
-CXXFLAGS = @ITK_SHLIB_CFLAGS@ @EXTRA_GCC_FLAG@ @ITK_TEMPLATE_FLAGS@
+CXXFLAGS = @CMAKE_SHLIB_CFLAGS@ @EXTRA_GCC_FLAG@ @CMAKE_TEMPLATE_FLAGS@
@@ -84,10 +84,9 @@ USE_LOCAL_JAVA = @USE_LOCAL_JAVA@
TOOLKIT_DEPENDS = @TOOLKIT_DEPENDS@
-ITK_TCL_SHLIB_TARGET = @ITK_TCL_SHLIB_TARGET@
-ITK_SHLIB_BUILD_FLAGS = @ITK_SHLIB_BUILD_FLAGS@
-ITK_SHLIB_LINK_FLAGS = @ITK_SHLIB_LINK_FLAGS@
-ITK_LIB_EXT = @ITK_LIB_EXT@
+CMAKE_TCL_SHLIB_TARGET = @CMAKE_TCL_SHLIB_TARGET@
+CMAKE_SHLIB_BUILD_FLAGS = @CMAKE_SHLIB_BUILD_FLAGS@
+CMAKE_SHLIB_LINK_FLAGS = @CMAKE_SHLIB_LINK_FLAGS@
DL_LIBS = @DL_LIBS@
SHLIB_LD_LIBS = @SHLIB_LD_LIBS@
SHLIB_SUFFIX = @SHLIB_SUFFIX@
diff --git a/README b/README
index bc70780..64dbbe9 100644
--- a/README
+++ b/README
@@ -68,13 +68,13 @@ make
TODO:
-
+FEATURES:
Add include and directories to the build on windows.
For unix just add them to the CMakeLocal.make.in
-
Add a --with idea, sets a #define in the config.h file
+CLEANUP:
Change ME to LIBRARY, and add PROJECT=
-
-
+Remove the rest of the ITK_* stuff
+move the libs used from the top into the testing...
diff --git a/Source/cmDSWMakefile.cxx b/Source/cmDSWMakefile.cxx
index 5ce7b2c..3ee71f9 100644
--- a/Source/cmDSWMakefile.cxx
+++ b/Source/cmDSWMakefile.cxx
@@ -33,7 +33,7 @@ void cmDSWMakefile::OutputDSWFile()
std::string fname;
fname = m_OutputDirectory;
fname += "/";
- fname += this->m_LibraryName;
+ fname += this->m_ProjectName;
fname += ".dsw";
std::cerr << "writting dsw file " << fname.c_str() << std::endl;
std::ofstream fout(fname.c_str());
@@ -149,7 +149,7 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
si != dspnames.end(); ++si)
{
// Write the project into the DSW file
- this->WriteProject(fout, si->c_str(), dir.c_str());
+ this->WriteProject(fout, si->c_str(), dir.c_str(), *k);
}
// delete the cmDSPMakefile object once done with it to avoid
// leaks
@@ -162,7 +162,8 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
void cmDSWMakefile::WriteProject(std::ostream& fout,
const char* dspname,
- const char* dir)
+ const char* dir,
+ cmMakefile* project)
{
fout << "###############################################################################\n\n";
fout << "Project: \"" << dspname << "\"="
@@ -170,7 +171,19 @@ void cmDSWMakefile::WriteProject(std::ostream& fout,
fout << "Package=<5>\n{{{\n}}}\n\n";
fout << "Package=<4>\n";
fout << "{{{\n";
- // insert Begin Project Dependency Project_Dep_Name project stuff here
+ if(project->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();
+ for(;i!= end; ++i)
+ {
+ fout << "Begin Project Dependency\n";
+ fout << "Project_Dep_Name " << *i << "\n";
+ fout << "End Project Dependency\n";
+ }
+ }
fout << "}}}\n\n";
}
diff --git a/Source/cmDSWMakefile.h b/Source/cmDSWMakefile.h
index 6c3fc9e..4a2fbf9 100644
--- a/Source/cmDSWMakefile.h
+++ b/Source/cmDSWMakefile.h
@@ -37,7 +37,8 @@ private:
void WriteDSWFile(std::ostream& fout);
void WriteDSWHeader(std::ostream& fout);
void WriteProject(std::ostream& fout,
- const char* name, const char* path);
+ const char* name, const char* path,
+ cmMakefile* project);
void WriteDSWFooter(std::ostream& fout);
};
diff --git a/Source/cmDSWWriter.cxx b/Source/cmDSWWriter.cxx
index 5ce7b2c..3ee71f9 100644
--- a/Source/cmDSWWriter.cxx
+++ b/Source/cmDSWWriter.cxx
@@ -33,7 +33,7 @@ void cmDSWMakefile::OutputDSWFile()
std::string fname;
fname = m_OutputDirectory;
fname += "/";
- fname += this->m_LibraryName;
+ fname += this->m_ProjectName;
fname += ".dsw";
std::cerr << "writting dsw file " << fname.c_str() << std::endl;
std::ofstream fout(fname.c_str());
@@ -149,7 +149,7 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
si != dspnames.end(); ++si)
{
// Write the project into the DSW file
- this->WriteProject(fout, si->c_str(), dir.c_str());
+ this->WriteProject(fout, si->c_str(), dir.c_str(), *k);
}
// delete the cmDSPMakefile object once done with it to avoid
// leaks
@@ -162,7 +162,8 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
void cmDSWMakefile::WriteProject(std::ostream& fout,
const char* dspname,
- const char* dir)
+ const char* dir,
+ cmMakefile* project)
{
fout << "###############################################################################\n\n";
fout << "Project: \"" << dspname << "\"="
@@ -170,7 +171,19 @@ void cmDSWMakefile::WriteProject(std::ostream& fout,
fout << "Package=<5>\n{{{\n}}}\n\n";
fout << "Package=<4>\n";
fout << "{{{\n";
- // insert Begin Project Dependency Project_Dep_Name project stuff here
+ if(project->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();
+ for(;i!= end; ++i)
+ {
+ fout << "Begin Project Dependency\n";
+ fout << "Project_Dep_Name " << *i << "\n";
+ fout << "End Project Dependency\n";
+ }
+ }
fout << "}}}\n\n";
}
diff --git a/Source/cmDSWWriter.h b/Source/cmDSWWriter.h
index 6c3fc9e..4a2fbf9 100644
--- a/Source/cmDSWWriter.h
+++ b/Source/cmDSWWriter.h
@@ -37,7 +37,8 @@ private:
void WriteDSWFile(std::ostream& fout);
void WriteDSWHeader(std::ostream& fout);
void WriteProject(std::ostream& fout,
- const char* name, const char* path);
+ const char* name, const char* path,
+ cmMakefile* project);
void WriteDSWFooter(std::ostream& fout);
};
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 1b6538c..49ee42f 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -109,24 +109,17 @@ bool cmMakefile::ReadMakefile(const char* filename)
}
}
}
- else if(line.find("ME") != std::string::npos)
+ else if(line.find("LIBRARY") != std::string::npos)
{
- size_t mestart = line.find("ME");
- size_t start = line.find("=");
- if(start != std::string::npos && start > mestart )
- {
- start++;
- while(line[start] == ' ' && start < line.size())
- {
- start++;
- }
- size_t end = line.size()-1;
- while(line[end] == ' ' && end > start)
- {
- end--;
- }
- this->SetLibraryName(line.substr(start, end).c_str());
- }
+ 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;
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 3396dd5..6541cff 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -64,6 +64,15 @@ public:
{
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();
+ }
// Set the name of the library that is built by this makefile
void SetOutputDirectory(const char* lib)
@@ -93,6 +102,11 @@ public:
return m_SubDirectories;
}
+ bool HasExecutables()
+ {
+ return m_Executables;
+ }
+
private:
void ReadTemplateInstanceDirectory(std::string&);
void ReadClasses(std::ifstream& fin, bool t);
@@ -107,6 +121,7 @@ protected:
std::string m_cmHomeDirectory; // Home directory for source
std::string m_cmCurrentDirectory; // current directory in source
std::string m_LibraryName; // library name
+ std::string m_ProjectName; // project 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; // lines copied from input file
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index b8a44c9..aa80d51 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1,6 +1,7 @@
#include "cmSystemTools.h"
#include "errno.h"
#include <sys/stat.h>
+#include "cmRegularExpression.h"
#ifdef _MSC_VER
#include <windows.h>
@@ -125,7 +126,7 @@ void cmSystemTools::ReadList(std::vector<std::string>& stringList,
bool done = false;
while ( !done )
{
- fin.getline(inbuffer, 2047 );
+ fin.getline(inbuffer, sizeof(inbuffer) );
std::string inname = inbuffer;
if(inname.find('\\') == std::string::npos)
{
@@ -154,3 +155,45 @@ void cmSystemTools::ConvertToUnixSlashes(std::string& path)
path = path.substr(0, path.size()-1);
}
}
+
+
+int cmSystemTools::Grep(const char* dir, const char* file, const char* expression)
+{
+ std::string path = dir;
+ path += "/";
+ path += file;
+ std::ifstream fin(path.c_str());
+ char buffer[2056];
+ int count = 0;
+ cmRegularExpression reg(expression);
+ while(fin)
+ {
+ fin.getline(buffer, sizeof(buffer));
+ count += reg.find(buffer);
+ }
+ return count;
+}
+
+std::string cmSystemTools::ExtractVariable(const char* variable,
+ const char* l)
+{
+ std::string line = l;
+ size_t varstart = line.find(variable);
+ size_t start = line.find("=");
+ if(start != std::string::npos && start > varstart )
+ {
+ start++;
+ while(line[start] == ' ' && start < line.size())
+ {
+ start++;
+ }
+ size_t end = line.size()-1;
+ while(line[end] == ' ' && end > start)
+ {
+ end--;
+ }
+ return line.substr(start, end).c_str();
+ }
+ return std::string("");
+}
+
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index d4745f4..ec80573 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -56,6 +56,17 @@ public:
*/
static bool FileExists(const char* filename);
/**
+ * Return the number of times expression occurs in file in dir
+ */
+ static int Grep(const char* dir, const char* file, const char* expression);
+
+ /**
+ * Extract the right hand side of an asignment varibale = value
+ */
+ static std::string ExtractVariable(const char* varible,
+ const char* line);
+
+ /**
* 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
diff --git a/Source/cmUnixMakefile.cxx b/Source/cmUnixMakefile.cxx
index 8a21295..11964b4 100644
--- a/Source/cmUnixMakefile.cxx
+++ b/Source/cmUnixMakefile.cxx
@@ -101,8 +101,8 @@ void cmUnixMakefile::OutputMakefile(const char* file)
// Ouput Library name if there are SRC_OBJS
if(strlen(this->GetLibraryName()) > 0)
{
- fout << "ME = " << this->GetLibraryName() << "\n\n";
- fout << "BUILD_LIB_FILE = lib${ME}${ITK_LIB_EXT}\n\n";
+ fout << "LIBRARY = " << this->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";
@@ -157,6 +157,11 @@ void cmUnixMakefile::OutputMakefile(const char* file)
linkLibs += " ";
}
linkLibs += " ${LOCAL_LINK_FLAGS} ";
+ // create and output a varible in the makefile that
+ // each executable will depend on. This will have all the
+ // libraries that the executable uses
+ 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++)
{
@@ -164,7 +169,9 @@ 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 << m_Classes[i].m_ClassName << ": " << DotO << " ";
+ fout << "${CMAKE_DEPEND_LIBS}\n";
fout << "\t${CXX} ${CXX_FLAGS} "
<< DotO.c_str() << " "
<< linkLibs.c_str()
@@ -239,3 +246,29 @@ void cmUnixMakefile::OutputMakefile(const char* file)
}
this->OutputDepends(fout);
}
+
+void cmUnixMakefile::OutputDependLibraries(std::ostream& fout)
+{
+ std::vector<std::string>& libs = m_BuildFlags.GetLinkLibraries();
+ std::vector<std::string>& libdirs = m_BuildFlags.GetLinkDirectories();
+ std::vector<std::string>::iterator dir, lib, endlibs, enddirs;
+ for(lib = libs.begin(); lib != libs.end(); ++lib)
+ {
+ bool found = false;
+ for(dir = libdirs.begin(); dir != libdirs.end() && !found; ++dir)
+ {
+ std::string expression = "LIBRARY.*=.*";
+ expression += lib->c_str();
+ if(cmSystemTools::Grep(dir->c_str(), "CMakeTargets.make", expression.c_str()))
+ {
+ std::string libpath = *dir;
+ libpath += "/lib";
+ libpath += *lib;
+ libpath += "${CMAKE_LIB_EXT}";
+ fout << libpath << " ";
+ found = true;
+ }
+ }
+ }
+ fout << "\n";
+}
diff --git a/Source/cmUnixMakefile.h b/Source/cmUnixMakefile.h
index 220a07d..9899f70 100644
--- a/Source/cmUnixMakefile.h
+++ b/Source/cmUnixMakefile.h
@@ -30,6 +30,7 @@ public:
*/
void OutputMakefile(const char* file);
protected:
+ void OutputDependLibraries(std::ostream&);
void OutputDepends(std::ostream&);
};