Commit 865ec966 authored by Ken Martin's avatar Ken Martin

major changes to support multiple libraries and source lists

parent 7b47a5d2
......@@ -6,7 +6,7 @@
#
#------------------------------------------------------------------------------
#
all: CMakeTargets.make ${LOCAL_BUILD_TARGETS} ${BUILD_LIB_FILE} ${EXECUTABLES} ${SUBDIR_BUILD} ${CMAKE}
all: CMakeTargets.make ${LOCAL_BUILD_TARGETS} ${TARGETS} ${SUBDIR_BUILD} ${CMAKE}
#------------------------------------------------------------------------------
......@@ -30,19 +30,6 @@ rebuild_cache: ${CMAKE_CONFIG_DIR}/CMakeCache.txt
${CMAKE_CONFIG_DIR}/CMakeCache.txt:
${CMAKE} ${topdir}/CMakeLists.txt -MakeCache -S${topdir} -O${CMAKE_CONFIG_DIR} -H${topdir} -B${CMAKE_CONFIG_DIR}
#------------------------------------------------------------------------------
# rules for the normal library
#
lib${LIBRARY}.a: ${SRC_OBJ} ${KIT_OBJ}
${AR} cr lib${LIBRARY}.a ${KIT_OBJ}
${RANLIB} lib$(LIBRARY).a
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}
@echo "Installing ${BUILD_LIB_FILE}"
......
......@@ -97,6 +97,10 @@ SOURCE=.\cmCommands.cxx
# End Source File
# Begin Source File
SOURCE=.\cmCustomCommand.cxx
# End Source File
# Begin Source File
SOURCE=.\cmDirectory.cxx
# End Source File
# Begin Source File
......
......@@ -68,7 +68,8 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /W3 /Gm /GR /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
......
......@@ -22,6 +22,7 @@ cmSystemTools.o \
cmDirectory.o \
cmUnixMakefileGenerator.o \
cmCommands.o \
cmCustomCommand.o \
cmCacheManager.o \
cmSourceGroup.o
......@@ -36,6 +37,7 @@ cmAuxSourceDirectoryCommand.o : $(DEPENDS)
cmRegularExpression.o : $(DEPENDS)
cmClassFile.o : $(DEPENDS)
cmDirectory.o : $(DEPENDS)
cmCustomCommand.o : $(DEPENDS)
cmUnixMakefileGenerator.o : $(DEPENDS)
cmCommands.o : $(DEPENDS)
cmCacheManager.o : $(DEPENDS)
......
......@@ -23,16 +23,20 @@ bool cmAbstractFilesCommand::Invoke(std::vector<std::string>& args)
this->SetError("called with incorrect number of arguments");
return false;
}
cmMakefile::ClassMap &Classes = m_Makefile->GetClasses();
for(std::vector<std::string>::iterator j = args.begin();
j != args.end(); ++j)
{
std::vector<cmClassFile>& Classes = m_Makefile->GetClasses();
for(unsigned int i = 0; i < Classes.size(); i++)
for(cmMakefile::ClassMap::iterator l = Classes.begin();
l != Classes.end(); l++)
{
if(Classes[i].m_ClassName == (*j))
for(std::vector<cmClassFile>::iterator i = l->second.begin();
i != l->second.end(); i++)
{
Classes[i].m_AbstractClass = true;
break;
if(i->m_ClassName == (*j))
{
i->m_AbstractClass = true;
}
}
}
}
......
/*=========================================================================
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.
=========================================================================*/
#include "cmAddExecutableCommand.h"
// cmExecutableCommand
bool cmAddExecutableCommand::Invoke(std::vector<std::string>& args)
{
if(args.size() < 2 )
{
this->SetError("called with incorrect number of arguments");
return false;
}
std::vector<std::string>::iterator s = args.begin();
std::vector<std::string> srclists(++s, args.end());
m_Makefile->AddExecutable(args[0].c_str(),srclists);
return true;
}
/*=========================================================================
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.
=========================================================================*/
#ifndef cmExecutablesCommand_h
#define cmExecutablesCommand_h
#include "cmStandardIncludes.h"
#include "cmCommand.h"
/** \class cmExecutablesCommand
* \brief Defines a list of executables to build.
*
* cmExecutablesCommand defines a list of executable (i.e., test)
* programs to create.
*/
class cmAddExecutableCommand : public cmCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmAddExecutableCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool Invoke(std::vector<std::string>& args);
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "ADD_EXECUTABLE";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Add an executable to the project that uses the specified srclists";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
"ADD_EXECUTABLE(exename srclist srclist srclist ...)";
}
cmTypeMacro(cmAddExecutableCommand, cmCommand);
};
#endif
/*=========================================================================
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.
=========================================================================*/
#include "cmAddLibraryCommand.h"
// cmLibraryCommand
bool cmAddLibraryCommand::Invoke(std::vector<std::string>& args)
{
if(args.size() < 2 )
{
this->SetError("called with incorrect number of arguments");
return false;
}
std::vector<std::string>::iterator s = args.begin();
std::vector<std::string> srclists(++s, args.end());
m_Makefile->AddLibrary(args[0].c_str(),srclists);
return true;
}
/*=========================================================================
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.
=========================================================================*/
#ifndef cmLibrarysCommand_h
#define cmLibrarysCommand_h
#include "cmStandardIncludes.h"
#include "cmCommand.h"
/** \class cmLibrarysCommand
* \brief Defines a list of executables to build.
*
* cmLibrarysCommand defines a list of executable (i.e., test)
* programs to create.
*/
class cmAddLibraryCommand : public cmCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmAddLibraryCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool Invoke(std::vector<std::string>& args);
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "ADD_LIBRARY";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Add an library to the project that uses the specified srclists";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
"ADD_LIBRARY(libname srclist srclist srclist ...)";
}
cmTypeMacro(cmAddLibraryCommand, cmCommand);
};
#endif
......@@ -19,9 +19,9 @@
// cmAuxSourceDirectoryCommand
bool cmAuxSourceDirectoryCommand::Invoke(std::vector<std::string>& args)
{
if(args.size() < 1 || args.size() > 1)
if(args.size() < 2 || args.size() > 2)
{
this->SetError("PROJECT called with incorrect number of arguments");
this->SetError("called with incorrect number of arguments");
return false;
}
......@@ -52,7 +52,7 @@ bool cmAuxSourceDirectoryCommand::Invoke(std::vector<std::string>& args)
cmClassFile cmfile;
cmfile.SetName(fullname.c_str(), m_Makefile->GetCurrentDirectory());
cmfile.m_AbstractClass = false;
m_Makefile->AddClass(cmfile);
m_Makefile->AddClass(cmfile,args[1].c_str());
}
}
}
......
......@@ -56,7 +56,7 @@ public:
virtual const char* GetTerseDocumentation()
{
return "Add all the source files found in the specified\n"
"directory to the build.";
"directory to the build as source list NAME.";
}
/**
......@@ -65,7 +65,7 @@ public:
virtual const char* GetFullDocumentation()
{
return
"AUX_SOURCE_DIRECTORY(dir)";
"AUX_SOURCE_DIRECTORY(dir srcListName)";
}
cmTypeMacro(cmAuxSourceDirectoryCommand, cmCommand);
......
......@@ -78,40 +78,5 @@ void cmCableCommand::SetupCableData()
// command as its owner.
pathName += "/cable_config.xml";
m_CableData = new cmCableData(this, pathName);
// We must add a custom rule to cause the cable_config.xml to be re-built
// when it is removed. Rebuilding it means re-running CMake.
std::string cMakeLists = m_Makefile->GetStartDirectory();
cMakeLists += "/";
cMakeLists += "CMakeLists.txt";
std::string command;
#if defined(_WIN32) && !defined(__CYGWIN__)
command = "\"";
command += m_Makefile->GetHomeDirectory();
command += "/CMake/Source/CMakeSetupCMD\" \"";
command += cMakeLists;
command += "\" -DSP";
#else
command = "\"";
command += m_Makefile->GetHomeOutputDirectory();
command += "/CMake/Source/CMakeBuildTargets\" \"";
command += cMakeLists;
command += "\"";
#endif
command += " -H\"";
command += m_Makefile->GetHomeDirectory();
command += "\" -S\"";
command += m_Makefile->GetStartDirectory();
command += "\" -O\"";
command += m_Makefile->GetStartOutputDirectory();
command += "\" -B\"";
command += m_Makefile->GetHomeOutputDirectory();
command += "\"";
std::vector<std::string> depends;
m_Makefile->AddCustomCommand(cMakeLists.c_str(),
command.c_str(),
depends,
"cable_config.xml");
}
......@@ -29,8 +29,7 @@ cmCableData::cmCableData(const cmCableCommand* owner,
m_OutputFile(configurationFile.c_str()),
m_Indentation(0),
m_Package(NULL),
m_PackageNamespaceDepth(0),
m_PackageClassIndex(-1)
m_PackageNamespaceDepth(0)
{
this->InitializeOutputFile();
}
......
......@@ -71,8 +71,7 @@ public:
void BeginPackage(cmCablePackageCommand*);
void EndPackage();
void SetPackageClassIndex(int index) { m_PackageClassIndex = index; }
int GetPackageClassIndex() const { return m_PackageClassIndex; }
cmCablePackageCommand *GetCurrentPackage() { return m_Package; }
private:
/**
......@@ -110,13 +109,6 @@ private:
* This must be the level when the package is ended.
*/
unsigned int m_PackageNamespaceDepth;
/**
* During the final pass, this maintains the index into a cmMakefile's
* m_Classes corresponding to the cmClassFile for this package's generated
* file.
*/
int m_PackageClassIndex;
};
std::ostream& operator<<(std::ostream&, const cmCableData::Indentation&);
......
......@@ -36,17 +36,58 @@ cmCablePackageCommand::~cmCablePackageCommand()
// cmCablePackageCommand
bool cmCablePackageCommand::Invoke(std::vector<std::string>& args)
{
if(args.size() != 1)
if(args.size() != 2)
{
this->SetError("called with incorrect number of arguments");
return false;
}
// setup this once. Really this should probably be moved somewhere else
// at some point.
{
// We must add a custom rule to cause the cable_config.xml to be re-built
// when it is removed. Rebuilding it means re-running CMake.
std::string cMakeLists = m_Makefile->GetStartDirectory();
cMakeLists += "/";
cMakeLists += "CMakeLists.txt";
std::string command;
#if defined(_WIN32) && !defined(__CYGWIN__)
command = "\"";
command += m_Makefile->GetHomeDirectory();
command += "/CMake/Source/CMakeSetupCMD\" \"";
command += cMakeLists;
command += "\" -DSP";
#else
command = "\"";
command += m_Makefile->GetHomeOutputDirectory();
command += "/CMake/Source/CMakeBuildTargets\" \"";
command += cMakeLists;
command += "\"";
#endif
command += " -H\"";
command += m_Makefile->GetHomeDirectory();
command += "\" -S\"";
command += m_Makefile->GetStartDirectory();
command += "\" -O\"";
command += m_Makefile->GetStartOutputDirectory();
command += "\" -B\"";
command += m_Makefile->GetHomeOutputDirectory();
command += "\"";
std::vector<std::string> depends;
m_Makefile->AddCustomCommand(cMakeLists.c_str(),
command.c_str(),
depends,
"cable_config.xml", args[1].c_str());
}
// This command needs to access the Cable data.
this->SetupCableData();
// The argument is the package name.
m_PackageName = args[0];
m_TargetName = args[1];
// Ask the cable data to begin the package. This may call another
// cmCablePackageCommand's WritePackageFooter(). This will call
......@@ -72,7 +113,7 @@ bool cmCablePackageCommand::Invoke(std::vector<std::string>& args)
m_Makefile->AddCustomCommand("cable_config.xml",
command.c_str(),
depends,
outputs);
outputs, m_TargetName.c_str());
return true;
}
......@@ -87,9 +128,7 @@ void cmCablePackageCommand::FinalPass()
file.m_AbstractClass = false;
file.m_HeaderFileOnly = false;
file.SetName(fileName.c_str(), filePath.c_str(), "cxx", false);
m_CableData->SetPackageClassIndex(m_Makefile->GetClasses().size());
m_Makefile->AddClass(file);
m_Makefile->AddClass(file, m_PackageName.c_str());
}
......
......@@ -73,19 +73,21 @@ public:
virtual const char* GetFullDocumentation()
{
return
"CABLE_PACKAGE(package_name)\n"
"CABLE_PACKAGE(package_name target)\n"
"Close current package (if any), and open a new package definition.";
}
void WritePackageHeader() const;
void WritePackageFooter() const;
const char *GetPackageName() {return m_PackageName.c_str();}
cmTypeMacro(cmCablePackageCommand, cmCableCommand);
private:
/**
* The name of the package.
*/
std::string m_PackageName;
std::string m_TargetName;
};
......
......@@ -20,19 +20,23 @@ void cmCableSourceFilesCommand::FinalPass()
{
// Get the index of the current package's cmClassFile.
// If it doesn't exist, ignore this command.
int index = m_CableData->GetPackageClassIndex();
if(index < 0)
cmCablePackageCommand *cablePackage = m_CableData->GetCurrentPackage();
std::string fileName = "Cxx/";
fileName += cablePackage->GetPackageName();
fileName += "_cxx";
cmClassFile *ci = m_Makefile->GetClass(cablePackage->GetPackageName(),
fileName.c_str());
if(ci == 0)
{ return; }
// The package's file has not yet been generated yet. The dependency
// finder will need hints. Add one for each source file.
cmClassFile& cFile = m_Makefile->GetClasses()[index];
for(Entries::const_iterator f = m_Entries.begin();
f != m_Entries.end(); ++f)
{
std::string header = *f+".h";
cFile.m_Depends.push_back(header);
ci->m_Depends.push_back(header);
}
}
......
......@@ -103,19 +103,23 @@ void cmClassFile::SetName(const char* name, const char* dir, const char *ext,
return;
}
void cmClassFile::Print()
void cmClassFile::Print() const
{
if(m_AbstractClass)
{
std::cout << "Abstract ";
}
else
{
std::cout << "Concrete ";
}
if(m_HeaderFileOnly)
{
std::cout << "Header file ";
}
else
{
std::cout << "CXX file ";
if(m_IsExecutable)
std::cout << "Executable ";
else
std::cout << "Non Executable ";
}
std::cout << m_ClassName << std::endl;
}
......@@ -35,7 +35,6 @@ public:
{
m_AbstractClass = false;
m_HeaderFileOnly = false;
m_IsExecutable = false;
m_WrapExclude = false;
}
......@@ -57,7 +56,7 @@ public:
/**
* Print the structure to std::cout.
*/
void Print();
void Print() const;
/**
* Indicate whether the class is abstract (non-instantiable).
......@@ -74,11 +73,6 @@ public:
*/
bool m_HeaderFileOnly;
/**
* Indicate whether this class is an executable file
*/
bool m_IsExecutable;
/**
* The full path to the file.
*/
......
......@@ -4,14 +4,14 @@
// like to have CMake to build CMake.
#include "cmCommands.h"
#include "cmAbstractFilesCommand.cxx"
#include "cmAddExecutableCommand.cxx"
#include "cmAddLibraryCommand.cxx"
#include "cmAddTargetCommand.cxx"
#include "cmAuxSourceDirectoryCommand.cxx"
#include "cmExecutablesCommand.cxx"
#include "cmFindIncludeCommand.cxx"
#include "cmFindLibraryCommand.cxx"
#include "cmFindProgramCommand.cxx"
#include "cmIncludeDirectoryCommand.cxx"
#include "cmLibraryCommand.cxx"
#include "cmLinkDirectoriesCommand.cxx"
#include "cmLinkLibrariesCommand.cxx"
#include "cmProjectCommand.cxx"
......@@ -47,14 +47,14 @@
void GetPredefinedCommands(std::list<cmCommand*>& commands)
{
commands.push_back(new cmAbstractFilesCommand);
commands.push_back(new cmAddExecutableCommand);
commands.push_back(new cmAddLibraryCommand);
commands.push_back(new cmAddTargetCommand);
commands.push_back(new cmAuxSourceDirectoryCommand);
commands.push_back(new cmExecutablesCommand);
commands.push_back(new cmFindIncludeCommand);
commands.push_back(new cmFindLibraryCommand);
commands.push_back(new cmFindProgramCommand);
commands.push_back(new cmIncludeDirectoryCommand);
commands.push_back(new cmLibraryCommand);
commands.push_back(new cmLinkDirectoriesCommand);
commands.push_back(new cmLinkLibrariesCommand);
commands.push_back(new cmProjectCommand);
......
/*=========================================================================
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.
=========================================================================*/
#include "cmCustomCommand.h"
#include "cmMakefile.h"
/**
* The constructor
*/
cmCustomCommand::cmCustomCommand(const char *src, const char *command,
std::vector<std::string> dep,
std::vector<std::string> out):
m_Source(src),
m_Command(command),
m_Depends(dep),
m_Outputs(out)
{
}
/**
* Copy constructor.
*/
cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
m_Source(r.m_Source),
m_Command(r.m_Command),
m_Depends(r.m_Depends),
m_Outputs(r.m_Outputs)
{
}
void cmCustomCommand::ExpandVariables(const cmMakefile &mf)
{
mf.ExpandVariablesInString(m_Source);
mf.ExpandVariablesInString(m_Command);
for (std::vector<std::string>::iterator i = m_Depends.begin();
i != m_Depends.end(); ++i)
{
mf.ExpandVariablesInString(*i);
}
for (std::vector<std::string>::iterator i = m_Outputs.begin();
i != m_Outputs.end(); ++i)
{
mf.ExpandVariablesInString(*i);
}
}
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$