major changes to support multiple libraries and source lists
This commit is contained in:
parent
7b47a5d2ef
commit
865ec96644
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/*=========================================================================
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*=========================================================================
|
||||
|
||||
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
|
|
@ -0,0 +1,33 @@
|
|||
/*=========================================================================
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*=========================================================================
|
||||
|
||||
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,12 +73,13 @@ 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:
|
||||
|
@ -86,6 +87,7 @@ 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);
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/*=========================================================================
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*=========================================================================
|
||||
|
||||
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 cmCustomCommand_h
|
||||
#define cmCustomCommand_h
|
||||
|
||||
#include "cmStandardIncludes.h"
|
||||
class cmMakefile;
|
||||
|
||||
class cmCustomCommand
|
||||
{
|
||||
public:
|
||||
cmCustomCommand(const char *src, const char *command,
|
||||
std::vector<std::string> dep,
|
||||
std::vector<std::string> out);
|
||||
cmCustomCommand(const cmCustomCommand& r);
|
||||
void ExpandVariables(const cmMakefile &);
|
||||
|
||||
std::string m_Source;
|
||||
std::string m_Command;
|
||||
std::vector<std::string> m_Depends;
|
||||
std::vector<std::string> m_Outputs;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -73,84 +73,52 @@ void cmDSPMakefile::OutputDSPFile()
|
|||
m_LibraryOptions += "/$(OUTDIR)\" ";
|
||||
}
|
||||
m_LibraryOptions += "/STACK:10000000 ";
|
||||
m_OutputLibName = m_Makefile->GetLibraryName();
|
||||
|
||||
// Create the DSP or set of DSP's for libraries and executables
|
||||
if(strlen(m_Makefile->GetLibraryName()) != 0)
|
||||
{
|
||||
const char* cacheValue
|
||||
= cmCacheManager::GetInstance()->GetCacheValue("BUILD_SHARED_LIBS");
|
||||
m_LibraryBuildType = STATIC_LIBRARY;
|
||||
if(cacheValue && strcmp(cacheValue,"0"))
|
||||
{
|
||||
this->SetBuildType(DLL);
|
||||
m_LibraryBuildType = DLL;
|
||||
}
|
||||
|
||||
// clear project names
|
||||
m_CreatedProjectNames.clear();
|
||||
|
||||
// build any targets
|
||||
const cmTargets &tgts = m_Makefile->GetTargets();
|
||||
for(cmTargets::const_iterator l = tgts.begin();
|
||||
l != tgts.end(); l++)
|
||||
{
|
||||
if (l->second.m_IsALibrary)
|
||||
{
|
||||
this->SetBuildType(m_LibraryBuildType, l->first.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
this->SetBuildType(STATIC_LIBRARY);
|
||||
}
|
||||
this->CreateSingleDSP();
|
||||
}
|
||||
// if there are executables build them
|
||||
if (m_Makefile->HasExecutables())
|
||||
{
|
||||
this->CreateExecutableDSPFiles();
|
||||
}
|
||||
}
|
||||
void cmDSPMakefile::CreateExecutableDSPFiles()
|
||||
{
|
||||
std::vector<cmClassFile>& Classes = m_Makefile->GetClasses();
|
||||
for(int i = 0; i < Classes.size(); ++i)
|
||||
{
|
||||
cmClassFile& classfile = Classes[i];
|
||||
if (classfile.m_IsExecutable)
|
||||
{
|
||||
std::string fname = m_Makefile->GetStartOutputDirectory();
|
||||
fname += "/";
|
||||
fname += classfile.m_ClassName;
|
||||
fname += ".dsp";
|
||||
std::ofstream fout(fname.c_str());
|
||||
if(!fout)
|
||||
{
|
||||
cmSystemTools::Error("Error Writing ",
|
||||
fname.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
// m_Makefile->SetLibraryName(classfile.m_ClassName.c_str());
|
||||
this->SetBuildType(EXECUTABLE);
|
||||
m_OutputLibName = classfile.m_ClassName;
|
||||
std::string pname = classfile.m_ClassName.c_str(); //m_Makefile->GetLibraryName();
|
||||
m_CreatedProjectNames.push_back(pname);
|
||||
|
||||
this->WriteDSPHeader(fout);
|
||||
this->WriteDSPBeginGroup(fout, "Source Files", "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat");
|
||||
this->WriteDSPBuildRule(fout, classfile.m_FullPath.c_str());
|
||||
this->WriteDSPEndGroup(fout);
|
||||
this->WriteDSPBuildRule(fout);
|
||||
this->WriteDSPFooter(fout);
|
||||
}
|
||||
this->SetBuildType(EXECUTABLE,l->first.c_str());
|
||||
}
|
||||
this->CreateSingleDSP(l->first.c_str(),l->second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void cmDSPMakefile::CreateSingleDSP()
|
||||
void cmDSPMakefile::CreateSingleDSP(const char *lname,
|
||||
const cmTarget &target)
|
||||
{
|
||||
std::string fname;
|
||||
fname = m_Makefile->GetStartOutputDirectory();
|
||||
fname += "/";
|
||||
fname += m_Makefile->GetLibraryName();
|
||||
fname += lname;
|
||||
fname += ".dsp";
|
||||
m_CreatedProjectNames.clear();
|
||||
std::string pname = m_Makefile->GetLibraryName();
|
||||
std::string pname = lname;
|
||||
m_CreatedProjectNames.push_back(pname);
|
||||
std::ofstream fout(fname.c_str());
|
||||
if(!fout)
|
||||
{
|
||||
cmSystemTools::Error("Error Writing ",
|
||||
fname.c_str());
|
||||
cmSystemTools::Error("Error Writing ", fname.c_str());
|
||||
}
|
||||
this->WriteDSPFile(fout);
|
||||
this->WriteDSPFile(fout,lname,target);
|
||||
}
|
||||
|
||||
void cmDSPMakefile::WriteDSPBuildRule(std::ostream& fout)
|
||||
|
@ -210,19 +178,51 @@ void cmDSPMakefile::AddDSPBuildRule(cmSourceGroup& sourceGroup)
|
|||
std::vector<std::string> depends;
|
||||
std::vector<std::string> outputs;
|
||||
outputs.push_back(dspname);
|
||||
sourceGroup.AddCustomCommand(makefileIn.c_str(), dsprule.c_str(),
|
||||
cmCustomCommand cc(makefileIn.c_str(), dsprule.c_str(),
|
||||
depends, outputs);
|
||||
sourceGroup.AddCustomCommand(cc);
|
||||
}
|
||||
|
||||
|
||||
void cmDSPMakefile::WriteDSPFile(std::ostream& fout)
|
||||
void cmDSPMakefile::WriteDSPFile(std::ostream& fout,
|
||||
const char *libName,
|
||||
const cmTarget &target)
|
||||
{
|
||||
// Write the DSP file's header.
|
||||
this->WriteDSPHeader(fout);
|
||||
this->WriteDSPHeader(fout, libName);
|
||||
|
||||
// We may be modifying the source groups temporarily, so make a copy.
|
||||
std::vector<cmSourceGroup> sourceGroups = m_Makefile->GetSourceGroups();
|
||||
|
||||
// get the classes from the source lists then add them to the groups
|
||||
std::vector<cmClassFile> classes =
|
||||
m_Makefile->GetClassesFromSourceLists(target.m_SourceLists);
|
||||
for(std::vector<cmClassFile>::iterator i = classes.begin();
|
||||
i != classes.end(); i++)
|
||||
{
|
||||
if(!i->m_HeaderFileOnly)
|
||||
{
|
||||
// Add the file to the list of sources.
|
||||
std::string source = i->m_FullPath;
|
||||
cmSourceGroup& sourceGroup = m_Makefile->FindSourceGroup(source.c_str(),
|
||||
sourceGroups);
|
||||
sourceGroup.AddSource(source.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// add any custom rules to the source groups
|
||||
for (std::vector<cmCustomCommand>::const_iterator cr =
|
||||
target.m_CustomCommands.begin();
|
||||
cr != target.m_CustomCommands.end(); ++cr)
|
||||
{
|
||||
cmSourceGroup& sourceGroup =
|
||||
m_Makefile->FindSourceGroup(cr->m_Source.c_str(),
|
||||
sourceGroups);
|
||||
cmCustomCommand cc(*cr);
|
||||
cc.ExpandVariables(*m_Makefile);
|
||||
sourceGroup.AddCustomCommand(cc);
|
||||
}
|
||||
|
||||
// Find the group in which the CMakeLists.txt source belongs, and add
|
||||
// the rule to generate this DSP file.
|
||||
for(std::vector<cmSourceGroup>::reverse_iterator sg = sourceGroups.rbegin();
|
||||
|
@ -351,9 +351,8 @@ void cmDSPMakefile::WriteDSPEndGroup(std::ostream& fout)
|
|||
|
||||
|
||||
|
||||
void cmDSPMakefile::SetBuildType(BuildType b)
|
||||
void cmDSPMakefile::SetBuildType(BuildType b, const char *libName)
|
||||
{
|
||||
m_BuildType = b;
|
||||
switch(b)
|
||||
{
|
||||
case STATIC_LIBRARY:
|
||||
|
@ -393,8 +392,7 @@ void cmDSPMakefile::SetBuildType(BuildType b)
|
|||
{
|
||||
fin.getline(buffer, 2048);
|
||||
std::string line = buffer;
|
||||
cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",
|
||||
m_Makefile->GetLibraryName());
|
||||
cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName);
|
||||
if (reg.find(line))
|
||||
{
|
||||
m_Configurations.push_back(line.substr(reg.end()));
|
||||
|
@ -402,7 +400,7 @@ void cmDSPMakefile::SetBuildType(BuildType b)
|
|||
}
|
||||
}
|
||||
|
||||
void cmDSPMakefile::WriteDSPHeader(std::ostream& fout)
|
||||
void cmDSPMakefile::WriteDSPHeader(std::ostream& fout, const char *libName)
|
||||
{
|
||||
std::ifstream fin(m_DSPHeaderTemplate.c_str());
|
||||
if(!fin)
|
||||
|
@ -419,8 +417,7 @@ void cmDSPMakefile::WriteDSPHeader(std::ostream& fout)
|
|||
m_LibraryOptions.c_str());
|
||||
cmSystemTools::ReplaceString(line, "BUILD_INCLUDES",
|
||||
m_IncludeOptions.c_str());
|
||||
cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",
|
||||
m_OutputLibName.c_str());
|
||||
cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName);
|
||||
cmSystemTools::ReplaceString(line,
|
||||
"EXTRA_DEFINES",
|
||||
m_Makefile->GetDefineFlags());
|
||||
|
@ -454,25 +451,4 @@ void cmDSPMakefile::WriteDSPBuildRule(std::ostream& fout, const char* path)
|
|||
fout << "# End Source File\n";
|
||||
}
|
||||
|
||||
bool cmDSPMakefile::NeedsDependencies(const char* dspname)
|
||||
{
|
||||
if(strcmp(m_Makefile->GetLibraryName(), dspname) == 0)
|
||||
{
|
||||
// only shared libs need depend info
|
||||
const char* cacheValue
|
||||
= cmCacheManager::GetInstance()->GetCacheValue("BUILD_SHARED_LIBS");
|
||||
if(cacheValue && strcmp(cacheValue,"0"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// must be an executable so it needs depends
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@ public:
|
|||
/**
|
||||
* Specify the type of the build: static, dll, or executable.
|
||||
*/
|
||||
void SetBuildType(BuildType);
|
||||
void SetBuildType(BuildType,const char *name);
|
||||
|
||||
BuildType GetBuildType()
|
||||
BuildType GetLibraryBuildType()
|
||||
{
|
||||
return m_BuildType;
|
||||
return m_LibraryBuildType;
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,20 +61,20 @@ public:
|
|||
{
|
||||
return m_Makefile;
|
||||
}
|
||||
bool NeedsDependencies(const char* dspname);
|
||||
|
||||
private:
|
||||
std::string m_DSPHeaderTemplate;
|
||||
std::string m_DSPFooterTemplate;
|
||||
std::vector<std::string> m_CreatedProjectNames;
|
||||
|
||||
void CreateExecutableDSPFiles();
|
||||
void CreateSingleDSP();
|
||||
void WriteDSPFile(std::ostream& fout);
|
||||
void CreateSingleDSP(const char *lname, const cmTarget &tgt);
|
||||
void WriteDSPFile(std::ostream& fout,
|
||||
const char *libName, const cmTarget &tgt);
|
||||
void WriteDSPBeginGroup(std::ostream& fout,
|
||||
const char* group,
|
||||
const char* filter);
|
||||
void WriteDSPEndGroup(std::ostream& fout);
|
||||
void WriteDSPHeader(std::ostream& fout);
|
||||
void WriteDSPHeader(std::ostream& fout, const char *libName);
|
||||
void WriteDSPBuildRule(std::ostream& fout, const char*);
|
||||
void WriteDSPBuildRule(std::ostream& fout);
|
||||
void WriteDSPFooter(std::ostream& fout);
|
||||
|
@ -86,9 +86,8 @@ private:
|
|||
|
||||
std::string m_IncludeOptions;
|
||||
std::string m_LibraryOptions;
|
||||
std::string m_OutputLibName;
|
||||
cmMakefile* m_Makefile;
|
||||
BuildType m_BuildType;
|
||||
BuildType m_LibraryBuildType;
|
||||
std::vector<std::string> m_Configurations;
|
||||
};
|
||||
|
||||
|
|
|
@ -73,84 +73,52 @@ void cmDSPMakefile::OutputDSPFile()
|
|||
m_LibraryOptions += "/$(OUTDIR)\" ";
|
||||
}
|
||||
m_LibraryOptions += "/STACK:10000000 ";
|
||||
m_OutputLibName = m_Makefile->GetLibraryName();
|
||||
|
||||
// Create the DSP or set of DSP's for libraries and executables
|
||||
if(strlen(m_Makefile->GetLibraryName()) != 0)
|
||||
{
|
||||
const char* cacheValue
|
||||
= cmCacheManager::GetInstance()->GetCacheValue("BUILD_SHARED_LIBS");
|
||||
m_LibraryBuildType = STATIC_LIBRARY;
|
||||
if(cacheValue && strcmp(cacheValue,"0"))
|
||||
{
|
||||
this->SetBuildType(DLL);
|
||||
m_LibraryBuildType = DLL;
|
||||
}
|
||||
|
||||
// clear project names
|
||||
m_CreatedProjectNames.clear();
|
||||
|
||||
// build any targets
|
||||
const cmTargets &tgts = m_Makefile->GetTargets();
|
||||
for(cmTargets::const_iterator l = tgts.begin();
|
||||
l != tgts.end(); l++)
|
||||
{
|
||||
if (l->second.m_IsALibrary)
|
||||
{
|
||||
this->SetBuildType(m_LibraryBuildType, l->first.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
this->SetBuildType(STATIC_LIBRARY);
|
||||
}
|
||||
this->CreateSingleDSP();
|
||||
}
|
||||
// if there are executables build them
|
||||
if (m_Makefile->HasExecutables())
|
||||
{
|
||||
this->CreateExecutableDSPFiles();
|
||||
}
|
||||
}
|
||||
void cmDSPMakefile::CreateExecutableDSPFiles()
|
||||
{
|
||||
std::vector<cmClassFile>& Classes = m_Makefile->GetClasses();
|
||||
for(int i = 0; i < Classes.size(); ++i)
|
||||
{
|
||||
cmClassFile& classfile = Classes[i];
|
||||
if (classfile.m_IsExecutable)
|
||||
{
|
||||
std::string fname = m_Makefile->GetStartOutputDirectory();
|
||||
fname += "/";
|
||||
fname += classfile.m_ClassName;
|
||||
fname += ".dsp";
|
||||
std::ofstream fout(fname.c_str());
|
||||
if(!fout)
|
||||
{
|
||||
cmSystemTools::Error("Error Writing ",
|
||||
fname.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
// m_Makefile->SetLibraryName(classfile.m_ClassName.c_str());
|
||||
this->SetBuildType(EXECUTABLE);
|
||||
m_OutputLibName = classfile.m_ClassName;
|
||||
std::string pname = classfile.m_ClassName.c_str(); //m_Makefile->GetLibraryName();
|
||||
m_CreatedProjectNames.push_back(pname);
|
||||
|
||||
this->WriteDSPHeader(fout);
|
||||
this->WriteDSPBeginGroup(fout, "Source Files", "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat");
|
||||
this->WriteDSPBuildRule(fout, classfile.m_FullPath.c_str());
|
||||
this->WriteDSPEndGroup(fout);
|
||||
this->WriteDSPBuildRule(fout);
|
||||
this->WriteDSPFooter(fout);
|
||||
}
|
||||
this->SetBuildType(EXECUTABLE,l->first.c_str());
|
||||
}
|
||||
this->CreateSingleDSP(l->first.c_str(),l->second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void cmDSPMakefile::CreateSingleDSP()
|
||||
void cmDSPMakefile::CreateSingleDSP(const char *lname,
|
||||
const cmTarget &target)
|
||||
{
|
||||
std::string fname;
|
||||
fname = m_Makefile->GetStartOutputDirectory();
|
||||
fname += "/";
|
||||
fname += m_Makefile->GetLibraryName();
|
||||
fname += lname;
|
||||
fname += ".dsp";
|
||||
m_CreatedProjectNames.clear();
|
||||
std::string pname = m_Makefile->GetLibraryName();
|
||||
std::string pname = lname;
|
||||
m_CreatedProjectNames.push_back(pname);
|
||||
std::ofstream fout(fname.c_str());
|
||||
if(!fout)
|
||||
{
|
||||
cmSystemTools::Error("Error Writing ",
|
||||
fname.c_str());
|
||||
cmSystemTools::Error("Error Writing ", fname.c_str());
|
||||
}
|
||||
this->WriteDSPFile(fout);
|
||||
this->WriteDSPFile(fout,lname,target);
|
||||
}
|
||||
|
||||
void cmDSPMakefile::WriteDSPBuildRule(std::ostream& fout)
|
||||
|
@ -210,19 +178,51 @@ void cmDSPMakefile::AddDSPBuildRule(cmSourceGroup& sourceGroup)
|
|||
std::vector<std::string> depends;
|
||||
std::vector<std::string> outputs;
|
||||
outputs.push_back(dspname);
|
||||
sourceGroup.AddCustomCommand(makefileIn.c_str(), dsprule.c_str(),
|
||||
cmCustomCommand cc(makefileIn.c_str(), dsprule.c_str(),
|
||||
depends, outputs);
|
||||
sourceGroup.AddCustomCommand(cc);
|
||||
}
|
||||
|
||||
|
||||
void cmDSPMakefile::WriteDSPFile(std::ostream& fout)
|
||||
void cmDSPMakefile::WriteDSPFile(std::ostream& fout,
|
||||
const char *libName,
|
||||
const cmTarget &target)
|
||||
{
|
||||
// Write the DSP file's header.
|
||||
this->WriteDSPHeader(fout);
|
||||
this->WriteDSPHeader(fout, libName);
|
||||
|
||||
// We may be modifying the source groups temporarily, so make a copy.
|
||||
std::vector<cmSourceGroup> sourceGroups = m_Makefile->GetSourceGroups();
|
||||
|
||||
// get the classes from the source lists then add them to the groups
|
||||
std::vector<cmClassFile> classes =
|
||||
m_Makefile->GetClassesFromSourceLists(target.m_SourceLists);
|
||||
for(std::vector<cmClassFile>::iterator i = classes.begin();
|
||||
i != classes.end(); i++)
|
||||
{
|
||||
if(!i->m_HeaderFileOnly)
|
||||
{
|
||||
// Add the file to the list of sources.
|
||||
std::string source = i->m_FullPath;
|
||||
cmSourceGroup& sourceGroup = m_Makefile->FindSourceGroup(source.c_str(),
|
||||
sourceGroups);
|
||||
sourceGroup.AddSource(source.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// add any custom rules to the source groups
|
||||
for (std::vector<cmCustomCommand>::const_iterator cr =
|
||||
target.m_CustomCommands.begin();
|
||||
cr != target.m_CustomCommands.end(); ++cr)
|
||||
{
|
||||
cmSourceGroup& sourceGroup =
|
||||
m_Makefile->FindSourceGroup(cr->m_Source.c_str(),
|
||||
sourceGroups);
|
||||
cmCustomCommand cc(*cr);
|
||||
cc.ExpandVariables(*m_Makefile);
|
||||
sourceGroup.AddCustomCommand(cc);
|
||||
}
|
||||
|
||||
// Find the group in which the CMakeLists.txt source belongs, and add
|
||||
// the rule to generate this DSP file.
|
||||
for(std::vector<cmSourceGroup>::reverse_iterator sg = sourceGroups.rbegin();
|
||||
|
@ -351,9 +351,8 @@ void cmDSPMakefile::WriteDSPEndGroup(std::ostream& fout)
|
|||
|
||||
|
||||
|
||||
void cmDSPMakefile::SetBuildType(BuildType b)
|
||||
void cmDSPMakefile::SetBuildType(BuildType b, const char *libName)
|
||||
{
|
||||
m_BuildType = b;
|
||||
switch(b)
|
||||
{
|
||||
case STATIC_LIBRARY:
|
||||
|
@ -393,8 +392,7 @@ void cmDSPMakefile::SetBuildType(BuildType b)
|
|||
{
|
||||
fin.getline(buffer, 2048);
|
||||
std::string line = buffer;
|
||||
cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",
|
||||
m_Makefile->GetLibraryName());
|
||||
cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName);
|
||||
if (reg.find(line))
|
||||
{
|
||||
m_Configurations.push_back(line.substr(reg.end()));
|
||||
|
@ -402,7 +400,7 @@ void cmDSPMakefile::SetBuildType(BuildType b)
|
|||
}
|
||||
}
|
||||
|
||||
void cmDSPMakefile::WriteDSPHeader(std::ostream& fout)
|
||||
void cmDSPMakefile::WriteDSPHeader(std::ostream& fout, const char *libName)
|
||||
{
|
||||
std::ifstream fin(m_DSPHeaderTemplate.c_str());
|
||||
if(!fin)
|
||||
|
@ -419,8 +417,7 @@ void cmDSPMakefile::WriteDSPHeader(std::ostream& fout)
|
|||
m_LibraryOptions.c_str());
|
||||
cmSystemTools::ReplaceString(line, "BUILD_INCLUDES",
|
||||
m_IncludeOptions.c_str());
|
||||
cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",
|
||||
m_OutputLibName.c_str());
|
||||
cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName);
|
||||
cmSystemTools::ReplaceString(line,
|
||||
"EXTRA_DEFINES",
|
||||
m_Makefile->GetDefineFlags());
|
||||
|
@ -454,25 +451,4 @@ void cmDSPMakefile::WriteDSPBuildRule(std::ostream& fout, const char* path)
|
|||
fout << "# End Source File\n";
|
||||
}
|
||||
|
||||
bool cmDSPMakefile::NeedsDependencies(const char* dspname)
|
||||
{
|
||||
if(strcmp(m_Makefile->GetLibraryName(), dspname) == 0)
|
||||
{
|
||||
// only shared libs need depend info
|
||||
const char* cacheValue
|
||||
= cmCacheManager::GetInstance()->GetCacheValue("BUILD_SHARED_LIBS");
|
||||
if(cacheValue && strcmp(cacheValue,"0"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// must be an executable so it needs depends
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@ public:
|
|||
/**
|
||||
* Specify the type of the build: static, dll, or executable.
|
||||
*/
|
||||
void SetBuildType(BuildType);
|
||||
void SetBuildType(BuildType,const char *name);
|
||||
|
||||
BuildType GetBuildType()
|
||||
BuildType GetLibraryBuildType()
|
||||
{
|
||||
return m_BuildType;
|
||||
return m_LibraryBuildType;
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,20 +61,20 @@ public:
|
|||
{
|
||||
return m_Makefile;
|
||||
}
|
||||
bool NeedsDependencies(const char* dspname);
|
||||
|
||||
private:
|
||||
std::string m_DSPHeaderTemplate;
|
||||
std::string m_DSPFooterTemplate;
|
||||
std::vector<std::string> m_CreatedProjectNames;
|
||||
|
||||
void CreateExecutableDSPFiles();
|
||||
void CreateSingleDSP();
|
||||
void WriteDSPFile(std::ostream& fout);
|
||||
void CreateSingleDSP(const char *lname, const cmTarget &tgt);
|
||||
void WriteDSPFile(std::ostream& fout,
|
||||
const char *libName, const cmTarget &tgt);
|
||||
void WriteDSPBeginGroup(std::ostream& fout,
|
||||
const char* group,
|
||||
const char* filter);
|
||||
void WriteDSPEndGroup(std::ostream& fout);
|
||||
void WriteDSPHeader(std::ostream& fout);
|
||||
void WriteDSPHeader(std::ostream& fout, const char *libName);
|
||||
void WriteDSPBuildRule(std::ostream& fout, const char*);
|
||||
void WriteDSPBuildRule(std::ostream& fout);
|
||||
void WriteDSPFooter(std::ostream& fout);
|
||||
|
@ -86,9 +86,8 @@ private:
|
|||
|
||||
std::string m_IncludeOptions;
|
||||
std::string m_LibraryOptions;
|
||||
std::string m_OutputLibName;
|
||||
cmMakefile* m_Makefile;
|
||||
BuildType m_BuildType;
|
||||
BuildType m_LibraryBuildType;
|
||||
std::vector<std::string> m_Configurations;
|
||||
};
|
||||
|
||||
|
|
|
@ -87,16 +87,19 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
|
|||
// remove the home directory and / from the source directory
|
||||
// this gives a relative path
|
||||
cmSystemTools::ReplaceString(dir, homedir.c_str(), "");
|
||||
|
||||
// Get the list of create dsp files names from the cmDSPMakefile, more
|
||||
// than one dsp could have been created per input CMakeLists.txt file
|
||||
std::vector<std::string> dspnames =
|
||||
pg->GetDSPMakefile()->GetCreatedProjectNames();
|
||||
// for each target
|
||||
std::vector<std::string> dspnames = pg->GetDSPMakefile()->GetCreatedProjectNames();
|
||||
const cmTargets &tgts = pg->GetDSPMakefile()->GetMakefile()->GetTargets();
|
||||
cmTargets::const_iterator l = tgts.begin();
|
||||
for(std::vector<std::string>::iterator si = dspnames.begin();
|
||||
si != dspnames.end(); ++si)
|
||||
l != tgts.end(); ++l, ++si)
|
||||
{
|
||||
// Write the project into the DSW file
|
||||
this->WriteProject(fout, si->c_str(), dir.c_str(),
|
||||
pg->GetDSPMakefile());
|
||||
pg->GetDSPMakefile(),l->second);
|
||||
}
|
||||
// delete the cmMakefile which also deletes the cmMSProjectGenerator
|
||||
delete mf;
|
||||
|
@ -112,7 +115,8 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
|
|||
void cmDSWMakefile::WriteProject(std::ostream& fout,
|
||||
const char* dspname,
|
||||
const char* dir,
|
||||
cmDSPMakefile* project)
|
||||
cmDSPMakefile* project,
|
||||
const cmTarget &l)
|
||||
{
|
||||
fout << "#########################################################"
|
||||
"######################\n\n";
|
||||
|
@ -126,12 +130,13 @@ void cmDSWMakefile::WriteProject(std::ostream& fout,
|
|||
std::vector<std::string>::iterator i, end;
|
||||
i = project->GetMakefile()->GetLinkLibraries().begin();
|
||||
end = project->GetMakefile()->GetLinkLibraries().end();
|
||||
if(project->NeedsDependencies(dspname))
|
||||
{
|
||||
for(;i!= end; ++i)
|
||||
{
|
||||
if(*i != dspname)
|
||||
{
|
||||
if (!l.m_IsALibrary ||
|
||||
project->GetLibraryBuildType() == cmDSPMakefile::DLL)
|
||||
{
|
||||
fout << "Begin Project Dependency\n";
|
||||
fout << "Project_Dep_Name " << *i << "\n";
|
||||
fout << "End Project Dependency\n";
|
||||
|
|
|
@ -47,7 +47,7 @@ private:
|
|||
void WriteDSWHeader(std::ostream& fout);
|
||||
void WriteProject(std::ostream& fout,
|
||||
const char* name, const char* path,
|
||||
cmDSPMakefile* project);
|
||||
cmDSPMakefile* project, const cmTarget &t);
|
||||
void WriteDSWFooter(std::ostream& fout);
|
||||
cmMakefile* m_Makefile;
|
||||
};
|
||||
|
|
|
@ -87,16 +87,19 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
|
|||
// remove the home directory and / from the source directory
|
||||
// this gives a relative path
|
||||
cmSystemTools::ReplaceString(dir, homedir.c_str(), "");
|
||||
|
||||
// Get the list of create dsp files names from the cmDSPMakefile, more
|
||||
// than one dsp could have been created per input CMakeLists.txt file
|
||||
std::vector<std::string> dspnames =
|
||||
pg->GetDSPMakefile()->GetCreatedProjectNames();
|
||||
// for each target
|
||||
std::vector<std::string> dspnames = pg->GetDSPMakefile()->GetCreatedProjectNames();
|
||||
const cmTargets &tgts = pg->GetDSPMakefile()->GetMakefile()->GetTargets();
|
||||
cmTargets::const_iterator l = tgts.begin();
|
||||
for(std::vector<std::string>::iterator si = dspnames.begin();
|
||||
si != dspnames.end(); ++si)
|
||||
l != tgts.end(); ++l, ++si)
|
||||
{
|
||||
// Write the project into the DSW file
|
||||
this->WriteProject(fout, si->c_str(), dir.c_str(),
|
||||
pg->GetDSPMakefile());
|
||||
pg->GetDSPMakefile(),l->second);
|
||||
}
|
||||
// delete the cmMakefile which also deletes the cmMSProjectGenerator
|
||||
delete mf;
|
||||
|
@ -112,7 +115,8 @@ void cmDSWMakefile::WriteDSWFile(std::ostream& fout)
|
|||
void cmDSWMakefile::WriteProject(std::ostream& fout,
|
||||
const char* dspname,
|
||||
const char* dir,
|
||||
cmDSPMakefile* project)
|
||||
cmDSPMakefile* project,
|
||||
const cmTarget &l)
|
||||
{
|
||||
fout << "#########################################################"
|
||||
"######################\n\n";
|
||||
|
@ -126,12 +130,13 @@ void cmDSWMakefile::WriteProject(std::ostream& fout,
|
|||
std::vector<std::string>::iterator i, end;
|
||||
i = project->GetMakefile()->GetLinkLibraries().begin();
|
||||
end = project->GetMakefile()->GetLinkLibraries().end();
|
||||
if(project->NeedsDependencies(dspname))
|
||||
{
|
||||
for(;i!= end; ++i)
|
||||
{
|
||||
if(*i != dspname)
|
||||
{
|
||||
if (!l.m_IsALibrary ||
|
||||
project->GetLibraryBuildType() == cmDSPMakefile::DLL)
|
||||
{
|
||||
fout << "Begin Project Dependency\n";
|
||||
fout << "Project_Dep_Name " << *i << "\n";
|
||||
fout << "End Project Dependency\n";
|
||||
|
|
|
@ -47,7 +47,7 @@ private:
|
|||
void WriteDSWHeader(std::ostream& fout);
|
||||
void WriteProject(std::ostream& fout,
|
||||
const char* name, const char* path,
|
||||
cmDSPMakefile* project);
|
||||
cmDSPMakefile* project, const cmTarget &t);
|
||||
void WriteDSWFooter(std::ostream& fout);
|
||||
cmMakefile* m_Makefile;
|
||||
};
|
||||
|
|
|
@ -55,21 +55,23 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile)
|
|||
this->AddSearchPath(j->c_str());
|
||||
}
|
||||
// Now create cmDependInformation objects for files in the directory
|
||||
int index = 0;
|
||||
std::vector<cmClassFile>::iterator i = makefile->m_Classes.begin();
|
||||
while(i != makefile->m_Classes.end())
|
||||
cmMakefile::ClassMap &Classes = m_Makefile->GetClasses();
|
||||
for(cmMakefile::ClassMap::iterator l = Classes.begin();
|
||||
l != Classes.end(); l++)
|
||||
{
|
||||
if(!(*i).m_HeaderFileOnly)
|
||||
for(std::vector<cmClassFile>::iterator i = l->second.begin();
|
||||
i != l->second.end(); ++i)
|
||||
{
|
||||
if(!i->m_HeaderFileOnly)
|
||||
{
|
||||
cmDependInformation* info = new cmDependInformation;
|
||||
info->m_FullPath = this->FullPath((*i).m_FullPath.c_str());
|
||||
info->m_FullPath = this->FullPath(i->m_FullPath.c_str());
|
||||
this->AddFileToSearchPath(info->m_FullPath.c_str());
|
||||
info->m_IncludeName = (*i).m_FullPath;
|
||||
info->m_IncludeName = i->m_FullPath;
|
||||
info->m_ClassFileIndex = i;
|
||||
m_DependInformation.push_back(info);
|
||||
info->m_ClassFileIndex = index;
|
||||
}
|
||||
++i;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,9 +101,9 @@ void cmMakeDepend::DoDepends()
|
|||
// Remove duplicate depends
|
||||
info->RemoveDuplicateIndices();
|
||||
// find the class
|
||||
if(info->m_ClassFileIndex != -1)
|
||||
if(info->m_ClassFileIndex != 0)
|
||||
{
|
||||
cmClassFile& cfile = m_Makefile->m_Classes[info->m_ClassFileIndex];
|
||||
cmClassFile& cfile = *(info->m_ClassFileIndex);
|
||||
for( std::vector<int>::iterator indx = info->m_Indices.begin();
|
||||
indx != info->m_Indices.end(); ++indx)
|
||||
{
|
||||
|
@ -126,9 +128,9 @@ void cmMakeDepend::Depend(cmDependInformation* info)
|
|||
{
|
||||
// The cmClassFile may have had hints for dependencies. Delete any that
|
||||
// exist since we can find the dependencies for real.
|
||||
if(info->m_ClassFileIndex != -1)
|
||||
if(info->m_ClassFileIndex != 0)
|
||||
{
|
||||
cmClassFile& cFile = m_Makefile->m_Classes[info->m_ClassFileIndex];
|
||||
cmClassFile& cFile = *(info->m_ClassFileIndex);
|
||||
cFile.m_Depends.erase(cFile.m_Depends.begin(), cFile.m_Depends.end());
|
||||
}
|
||||
|
||||
|
@ -140,10 +142,10 @@ void cmMakeDepend::Depend(cmDependInformation* info)
|
|||
|
||||
// The file doesn't exist. See if the cmClassFile for it has any files
|
||||
// specified as dependency hints.
|
||||
if(info->m_ClassFileIndex != -1)
|
||||
if(info->m_ClassFileIndex != 0)
|
||||
{
|
||||
// Get the cmClassFile corresponding to this.
|
||||
cmClassFile& cFile = m_Makefile->m_Classes[info->m_ClassFileIndex];
|
||||
cmClassFile& cFile = *(info->m_ClassFileIndex);
|
||||
// See if there are any hints for finding dependencies for the missing
|
||||
// file.
|
||||
if(!cFile.m_Depends.empty())
|
||||
|
|
|
@ -35,7 +35,7 @@ struct cmDependInformation
|
|||
cmDependInformation()
|
||||
{
|
||||
m_DependDone = false;
|
||||
m_ClassFileIndex = -1;
|
||||
m_ClassFileIndex = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,9 +56,9 @@ struct cmDependInformation
|
|||
|
||||
/**
|
||||
* The index into the cmMakefile::m_Classes list.
|
||||
* The index value of -1 indicates that it is not in the list.
|
||||
* The index value of 0 indicates that it is not in the list.
|
||||
*/
|
||||
int m_ClassFileIndex;
|
||||
cmClassFile *m_ClassFileIndex;
|
||||
|
||||
/**
|
||||
* This flag indicates whether dependency checking has been
|
||||
|
|
|
@ -89,9 +89,26 @@ void cmMakefile::PrintStringVector(const char* s, std::vector<std::string>& v)
|
|||
// call print on all the classes in the makefile
|
||||
void cmMakefile::Print()
|
||||
{
|
||||
// print the class lists
|
||||
std::cout << "classes:\n";
|
||||
for(unsigned int i = 0; i < m_Classes.size(); i++)
|
||||
m_Classes[i].Print();
|
||||
for(ClassMap::const_iterator l = m_Classes.begin();
|
||||
l != m_Classes.end(); l++)
|
||||
{
|
||||
std::cout << " Class list named: " << l->first << std::endl;
|
||||
for(std::vector<cmClassFile>::const_iterator i = l->second.begin();
|
||||
i != l->second.end(); i++)
|
||||
{
|
||||
i->Print();
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << " m_Targets: ";
|
||||
for (cmTargets::const_iterator l = m_Targets.begin();
|
||||
l != m_Targets.end(); l++)
|
||||
{
|
||||
std::cout << l->first << std::endl;
|
||||
}
|
||||
|
||||
std::cout << " m_CurrentOutputDirectory; " <<
|
||||
m_CurrentOutputDirectory.c_str() << std::endl;
|
||||
std::cout << " m_StartOutputDirectory; " <<
|
||||
|
@ -104,7 +121,6 @@ void cmMakefile::Print()
|
|||
m_cmStartDirectory.c_str() << std::endl;
|
||||
std::cout << " m_cmHomeDirectory; " <<
|
||||
m_cmHomeDirectory.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);
|
||||
|
@ -192,7 +208,8 @@ bool cmMakefile::ReadListFile(const char* filename)
|
|||
{
|
||||
cmSystemTools::Error(usedCommand->GetName(),
|
||||
": Error : \n",
|
||||
usedCommand->GetError());
|
||||
usedCommand->GetError(),
|
||||
m_cmCurrentDirectory.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -221,6 +238,26 @@ bool cmMakefile::ReadListFile(const char* filename)
|
|||
|
||||
|
||||
|
||||
cmClassFile *cmMakefile::GetClass(const char *srclist, const char *cname)
|
||||
{
|
||||
ClassMap::iterator sl = m_Classes.find(srclist);
|
||||
// find the src list
|
||||
if (sl == m_Classes.end())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
// find the class
|
||||
for (std::vector<cmClassFile>::iterator i = sl->second.begin();
|
||||
i != sl->second.end(); ++i)
|
||||
{
|
||||
if (i->m_ClassName == cname)
|
||||
{
|
||||
return &(*i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cmMakefile::AddCommand(cmCommand* wg)
|
||||
{
|
||||
std::string name = wg->GetName();
|
||||
|
@ -252,36 +289,34 @@ void cmMakefile::GenerateMakefile()
|
|||
m_MakefileGenerator->GenerateMakefile();
|
||||
}
|
||||
|
||||
void cmMakefile::AddClass(cmClassFile& cmfile)
|
||||
void cmMakefile::AddClass(cmClassFile& cmfile, const char *srclist)
|
||||
{
|
||||
m_Classes.push_back(cmfile);
|
||||
m_Classes[srclist].push_back(cmfile);
|
||||
}
|
||||
|
||||
if(!cmfile.m_IsExecutable && !cmfile.m_HeaderFileOnly)
|
||||
void cmMakefile::AddCustomCommand(const char* source,
|
||||
const char* command,
|
||||
const std::vector<std::string>& depends,
|
||||
const std::vector<std::string>& outputs,
|
||||
const char *target)
|
||||
{
|
||||
// Add the file to the list of sources.
|
||||
std::string source = cmfile.m_FullPath;
|
||||
cmSourceGroup& sourceGroup = this->FindSourceGroup(source.c_str());
|
||||
sourceGroup.AddSource(source.c_str());
|
||||
// find the target,
|
||||
if (m_Targets.find(target) != m_Targets.end())
|
||||
{
|
||||
cmCustomCommand cc(source,command,depends,outputs);
|
||||
m_Targets[target].m_CustomCommands.push_back(cc);
|
||||
}
|
||||
}
|
||||
|
||||
void cmMakefile::AddCustomCommand(const char* source,
|
||||
const char* command,
|
||||
const std::vector<std::string>& depends,
|
||||
const std::vector<std::string>& outputs)
|
||||
{
|
||||
cmSourceGroup& sourceGroup = this->FindSourceGroup(source);
|
||||
sourceGroup.AddCustomCommand(source, command, depends, outputs);
|
||||
}
|
||||
|
||||
void cmMakefile::AddCustomCommand(const char* source,
|
||||
const char* command,
|
||||
const std::vector<std::string>& depends,
|
||||
const char* output)
|
||||
const char* output,
|
||||
const char *target)
|
||||
{
|
||||
std::vector<std::string> outputs;
|
||||
outputs.push_back(output);
|
||||
this->AddCustomCommand(source, command, depends, outputs);
|
||||
this->AddCustomCommand(source, command, depends, outputs, target);
|
||||
}
|
||||
|
||||
void cmMakefile::AddDefineFlag(const char* flag)
|
||||
|
@ -290,24 +325,6 @@ void cmMakefile::AddDefineFlag(const char* flag)
|
|||
m_DefineFlags += flag;
|
||||
}
|
||||
|
||||
void cmMakefile::AddExecutable(cmClassFile& cf)
|
||||
{
|
||||
cf.m_IsExecutable = true;
|
||||
m_Classes.push_back(cf);
|
||||
}
|
||||
|
||||
bool cmMakefile::HasExecutables()
|
||||
{
|
||||
for(unsigned int i = 0; i < m_Classes.size(); i++)
|
||||
{
|
||||
if (m_Classes[i].m_IsExecutable)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void cmMakefile::AddUtility(const char* util)
|
||||
{
|
||||
m_Utilities.push_back(util);
|
||||
|
@ -348,11 +365,24 @@ void cmMakefile::SetProjectName(const char* p)
|
|||
m_ProjectName = p;
|
||||
}
|
||||
|
||||
void cmMakefile::SetLibraryName(const char* l)
|
||||
void cmMakefile::AddLibrary(const char* lname, const std::vector<std::string> &srcs)
|
||||
{
|
||||
m_LibraryName = l;
|
||||
cmTarget target;
|
||||
target.m_IsALibrary = 1;
|
||||
target.m_SourceLists = srcs;
|
||||
m_Targets.insert(cmTargets::value_type(lname,target));
|
||||
}
|
||||
|
||||
void cmMakefile::AddExecutable(const char *exeName,
|
||||
const std::vector<std::string> &srcs)
|
||||
{
|
||||
cmTarget target;
|
||||
target.m_IsALibrary = 0;
|
||||
target.m_SourceLists = srcs;
|
||||
m_Targets.insert(cmTargets::value_type(exeName,target));
|
||||
}
|
||||
|
||||
|
||||
void cmMakefile::AddSourceGroup(const char* name, const char* regex)
|
||||
{
|
||||
// First see if the group exists. If so, replace its regular expression.
|
||||
|
@ -491,9 +521,9 @@ int cmMakefile::DumpDocumentationToFile(const char *fileName)
|
|||
}
|
||||
|
||||
|
||||
void cmMakefile::ExpandVariablesInString(std::string& source)
|
||||
void cmMakefile::ExpandVariablesInString(std::string& source) const
|
||||
{
|
||||
for(DefinitionMap::iterator i = m_Definitions.begin();
|
||||
for(DefinitionMap::const_iterator i = m_Definitions.begin();
|
||||
i != m_Definitions.end(); ++i)
|
||||
{
|
||||
std::string variable = "${";
|
||||
|
@ -594,7 +624,9 @@ void cmMakefile::AddDefaultDefinitions()
|
|||
* non-inherited SOURCE_GROUP commands will have precedence over
|
||||
* inherited ones.
|
||||
*/
|
||||
cmSourceGroup& cmMakefile::FindSourceGroup(const char* source)
|
||||
cmSourceGroup&
|
||||
cmMakefile::FindSourceGroup(const char* source,
|
||||
std::vector<cmSourceGroup> &groups)
|
||||
{
|
||||
std::string file = source;
|
||||
std::string::size_type pos = file.rfind('/');
|
||||
|
@ -603,8 +635,8 @@ cmSourceGroup& cmMakefile::FindSourceGroup(const char* source)
|
|||
file = file.substr(pos, file.length()-pos);
|
||||
}
|
||||
|
||||
for(std::vector<cmSourceGroup>::reverse_iterator sg = m_SourceGroups.rbegin();
|
||||
sg != m_SourceGroups.rend(); ++sg)
|
||||
for(std::vector<cmSourceGroup>::reverse_iterator sg = groups.rbegin();
|
||||
sg != groups.rend(); ++sg)
|
||||
{
|
||||
if(sg->Matches(file.c_str()))
|
||||
{
|
||||
|
@ -613,5 +645,39 @@ cmSourceGroup& cmMakefile::FindSourceGroup(const char* source)
|
|||
}
|
||||
|
||||
// Shouldn't get here, but just in case, return the default group.
|
||||
return m_SourceGroups.front();
|
||||
return groups.front();
|
||||
}
|
||||
|
||||
// take srclists and put all the classes into a vector
|
||||
std::vector<cmClassFile>
|
||||
cmMakefile::GetClassesFromSourceLists(
|
||||
const std::vector<std::string> &srcLists)
|
||||
{
|
||||
std::vector<cmClassFile> result;
|
||||
|
||||
// for each src lists add the classes
|
||||
for (std::vector<std::string>::const_iterator s = srcLists.begin();
|
||||
s != srcLists.end(); ++s)
|
||||
{
|
||||
// replace any variables
|
||||
std::string temps = *s;
|
||||
this->ExpandVariablesInString(temps);
|
||||
// look for a srclist
|
||||
if (m_Classes.find(temps) != m_Classes.end())
|
||||
{
|
||||
const std::vector<cmClassFile> &clsList =
|
||||
m_Classes.find(temps)->second;
|
||||
result.insert(result.end(), clsList.begin(), clsList.end());
|
||||
}
|
||||
// if one wasn't found then assume it is a single class
|
||||
else
|
||||
{
|
||||
cmClassFile file;
|
||||
file.m_AbstractClass = false;
|
||||
file.SetName(temps.c_str(), this->GetCurrentDirectory());
|
||||
result.push_back(file);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "cmClassFile.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmSourceGroup.h"
|
||||
|
||||
#include "cmTarget.h"
|
||||
class cmCommand;
|
||||
class cmMakefileGenerator;
|
||||
|
||||
|
@ -77,12 +77,14 @@ public:
|
|||
void AddCustomCommand(const char* source,
|
||||
const char* command,
|
||||
const std::vector<std::string>& depends,
|
||||
const std::vector<std::string>& outputs);
|
||||
const std::vector<std::string>& outputs,
|
||||
const char *target);
|
||||
|
||||
void AddCustomCommand(const char* source,
|
||||
const char* command,
|
||||
const std::vector<std::string>& depends,
|
||||
const char* output);
|
||||
const char* output,
|
||||
const char* target);
|
||||
|
||||
/**
|
||||
* Add a define flag to the build.
|
||||
|
@ -92,7 +94,7 @@ public:
|
|||
/**
|
||||
* Add an executable to the build.
|
||||
*/
|
||||
void AddExecutable(cmClassFile&);
|
||||
void AddExecutable(const char *exename, const std::vector<std::string> &srcs);
|
||||
|
||||
/**
|
||||
* Add a utility on which this project depends.
|
||||
|
@ -146,12 +148,12 @@ public:
|
|||
/**
|
||||
* Set the name of the library.
|
||||
*/
|
||||
void SetLibraryName(const char*);
|
||||
void AddLibrary(const char *libname, const std::vector<std::string> &srcs);
|
||||
|
||||
/**
|
||||
* Add a class/source file to the build.
|
||||
*/
|
||||
void AddClass(cmClassFile& );
|
||||
void AddClass(cmClassFile& ,const char *srcListName);
|
||||
|
||||
/**
|
||||
* Add a source group for consideration when adding a new source.
|
||||
|
@ -269,12 +271,9 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Specify the name of the library that is built by this makefile.
|
||||
* Get the list of targets
|
||||
*/
|
||||
const char* GetLibraryName()
|
||||
{
|
||||
return m_LibraryName.c_str();
|
||||
}
|
||||
const cmTargets &GetTargets() { return m_Targets; }
|
||||
|
||||
/**
|
||||
* Get a list of the build subdirectories.
|
||||
|
@ -284,12 +283,6 @@ public:
|
|||
return m_SubDirectories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a boolean flag indicating whether the build generates
|
||||
* any executables.
|
||||
*/
|
||||
bool HasExecutables();
|
||||
|
||||
/**
|
||||
* Get a list of include directories in the build.
|
||||
*/
|
||||
|
@ -349,8 +342,16 @@ public:
|
|||
/**
|
||||
* Return a list of source files in this makefile.
|
||||
*/
|
||||
std::vector<cmClassFile>& GetClasses()
|
||||
{return m_Classes;}
|
||||
typedef std::map<std::string,std::vector<cmClassFile> > ClassMap;
|
||||
ClassMap &GetClasses() {return m_Classes;}
|
||||
cmClassFile *GetClass(const char *srclist, const char *className);
|
||||
|
||||
|
||||
/**
|
||||
* Return a list of classes in the passed source lists
|
||||
*/
|
||||
std::vector<cmClassFile> GetClassesFromSourceLists(
|
||||
const std::vector<std::string> &srcLists);
|
||||
|
||||
/**
|
||||
* Obtain a list of auxiliary source directories.
|
||||
|
@ -400,7 +401,7 @@ public:
|
|||
* entry in the m_Definitions map. Also @var@ is
|
||||
* expanded to match autoconf style expansions.
|
||||
*/
|
||||
void ExpandVariablesInString(std::string& source);
|
||||
void ExpandVariablesInString(std::string& source) const;
|
||||
|
||||
/**
|
||||
* Expand variables in the makefiles ivars such as link directories etc
|
||||
|
@ -421,6 +422,12 @@ public:
|
|||
*/
|
||||
void GenerateCacheOnly();
|
||||
|
||||
/**
|
||||
* find what source group this source is in
|
||||
*/
|
||||
cmSourceGroup& FindSourceGroup(const char* source,
|
||||
std::vector<cmSourceGroup> &groups);
|
||||
|
||||
protected:
|
||||
std::string m_Prefix;
|
||||
std::vector<std::string> m_AuxSourceDirectories; //
|
||||
|
@ -432,9 +439,12 @@ protected:
|
|||
std::string m_cmHomeDirectory;
|
||||
std::string m_HomeOutputDirectory;
|
||||
|
||||
std::string m_LibraryName; // library name
|
||||
std::string m_ProjectName; // project name
|
||||
std::vector<cmClassFile> m_Classes; // list of classes in makefile
|
||||
|
||||
// libraries, classes, and executables
|
||||
cmTargets m_Targets;
|
||||
ClassMap m_Classes;
|
||||
|
||||
std::vector<std::string> m_SubDirectories; // list of sub directories
|
||||
std::vector<std::string> m_MakeVerbatim; // lines copied from input file
|
||||
std::vector<std::string> m_IncludeDirectories;
|
||||
|
@ -454,6 +464,7 @@ protected:
|
|||
std::vector<cmCommand*> m_UsedCommands;
|
||||
cmMakefileGenerator* m_MakefileGenerator;
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
* Get the name of the parent directories CMakeLists file
|
||||
|
@ -468,7 +479,6 @@ private:
|
|||
void AddDefaultCommands();
|
||||
void AddDefaultDefinitions();
|
||||
|
||||
cmSourceGroup& FindSourceGroup(const char* source);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -23,13 +23,13 @@ bool cmSourceFilesCommand::Invoke(std::vector<std::string>& args)
|
|||
this->SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
for(std::vector<std::string>::iterator i = args.begin();
|
||||
for(std::vector<std::string>::iterator i = (args.begin() + 1);
|
||||
i != args.end(); ++i)
|
||||
{
|
||||
cmClassFile file;
|
||||
file.m_AbstractClass = false;
|
||||
file.SetName((*i).c_str(), m_Makefile->GetCurrentDirectory());
|
||||
m_Makefile->AddClass(file);
|
||||
m_Makefile->AddClass(file, args[0].c_str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
*/
|
||||
virtual const char* GetTerseDocumentation()
|
||||
{
|
||||
return "Add a list of source files.";
|
||||
return "Add a list of source files, associate them with a NAME.";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
virtual const char* GetFullDocumentation()
|
||||
{
|
||||
return
|
||||
"SOURCE_FILES(file1 file2 ...)";
|
||||
"SOURCE_FILES(NAME file1 file2 ...)";
|
||||
}
|
||||
|
||||
cmTypeMacro(cmSourceFilesCommand, cmCommand);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
// cmSourceFilesRequireCommand
|
||||
bool cmSourceFilesRequireCommand::Invoke(std::vector<std::string>& args)
|
||||
{
|
||||
if(args.size() < 3 )
|
||||
if(args.size() < 4 )
|
||||
{
|
||||
this->SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
|
@ -42,12 +42,14 @@ bool cmSourceFilesRequireCommand::Invoke(std::vector<std::string>& args)
|
|||
}
|
||||
|
||||
// Add the rest of the arguments as source files
|
||||
const char *sname = (*i).c_str();
|
||||
++i;
|
||||
for(; i != args.end(); ++i)
|
||||
{
|
||||
cmClassFile file;
|
||||
file.m_AbstractClass = false;
|
||||
file.SetName((*i).c_str(), m_Makefile->GetCurrentDirectory());
|
||||
m_Makefile->AddClass(file);
|
||||
m_Makefile->AddClass(file, sname);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -55,8 +55,8 @@ public:
|
|||
*/
|
||||
virtual const char* GetTerseDocumentation()
|
||||
{
|
||||
return "Add a list of source files if the required \n"
|
||||
"variables are set.";
|
||||
return "Add a list of source files to the source file list NAME\n"
|
||||
"if the required variables are set.";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
virtual const char* GetFullDocumentation()
|
||||
{
|
||||
return
|
||||
"SOURCE_FILES_REQUIRE(var1 var2 ... SOURCES_BEGIN file1 file2 ...)";
|
||||
"SOURCE_FILES_REQUIRE(var1 var2 ... SOURCES_BEGIN NAME file1 file2 ...)";
|
||||
}
|
||||
|
||||
cmTypeMacro(cmSourceFilesRequireCommand, cmCommand);
|
||||
|
|
|
@ -53,35 +53,32 @@ bool cmSourceGroup::Matches(const char* name)
|
|||
* If the command also already exists, the given dependencies and outputs
|
||||
* are added to it.
|
||||
*/
|
||||
void cmSourceGroup::AddCustomCommand(const char* source,
|
||||
const char* command,
|
||||
const std::vector<std::string>& depends,
|
||||
const std::vector<std::string>& outputs)
|
||||
void cmSourceGroup::AddCustomCommand(const cmCustomCommand &cmd)
|
||||
{
|
||||
CustomCommands::iterator s = m_CustomCommands.find(source);
|
||||
CustomCommands::iterator s = m_CustomCommands.find(cmd.m_Source);
|
||||
if(s == m_CustomCommands.end())
|
||||
{
|
||||
// The source was not found. Add it with this command.
|
||||
m_CustomCommands[source][command].m_Depends.insert(depends.begin(),
|
||||
depends.end());
|
||||
m_CustomCommands[source][command].m_Outputs.insert(outputs.begin(),
|
||||
outputs.end());
|
||||
m_CustomCommands[cmd.m_Source][cmd.m_Command].
|
||||
m_Depends.insert(cmd.m_Depends.begin(),cmd.m_Depends.end());
|
||||
m_CustomCommands[cmd.m_Source][cmd.m_Command].
|
||||
m_Outputs.insert(cmd.m_Outputs.begin(),cmd.m_Outputs.end());
|
||||
return;
|
||||
}
|
||||
|
||||
// The source already exists. See if the command exists.
|
||||
Commands& commands = s->second;
|
||||
Commands::iterator c = commands.find(command);
|
||||
Commands::iterator c = commands.find(cmd.m_Command);
|
||||
if(c == commands.end())
|
||||
{
|
||||
// The command did not exist. Add it.
|
||||
commands[command].m_Depends.insert(depends.begin(), depends.end());
|
||||
commands[command].m_Outputs.insert(outputs.begin(), outputs.end());
|
||||
commands[cmd.m_Command].m_Depends.insert(cmd.m_Depends.begin(), cmd.m_Depends.end());
|
||||
commands[cmd.m_Command].m_Outputs.insert(cmd.m_Outputs.begin(), cmd.m_Outputs.end());
|
||||
return;
|
||||
}
|
||||
|
||||
// The command already exists for this source. Merge the sets.
|
||||
CommandFiles& commandFiles = c->second;
|
||||
commandFiles.m_Depends.insert(depends.begin(), depends.end());
|
||||
commandFiles.m_Outputs.insert(outputs.begin(), outputs.end());
|
||||
commandFiles.m_Depends.insert(cmd.m_Depends.begin(), cmd.m_Depends.end());
|
||||
commandFiles.m_Outputs.insert(cmd.m_Outputs.begin(), cmd.m_Outputs.end());
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "cmStandardIncludes.h"
|
||||
#include "cmRegularExpression.h"
|
||||
#include "cmCustomCommand.h"
|
||||
#include <set>
|
||||
|
||||
/** \class cmSourceGroup
|
||||
|
@ -58,10 +59,7 @@ public:
|
|||
{ m_GroupRegex.compile(regex); }
|
||||
void AddSource(const char* name)
|
||||
{ m_Sources.push_back(name); }
|
||||
void AddCustomCommand(const char* source,
|
||||
const char* command,
|
||||
const std::vector<std::string>& depends,
|
||||
const std::vector<std::string>& outputs);
|
||||
void AddCustomCommand(const cmCustomCommand &cmd);
|
||||
const char* GetName() const
|
||||
{ return m_Name.c_str(); }
|
||||
const std::vector<std::string>& GetSources() const
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*=========================================================================
|
||||
|
||||
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 cmTarget_h
|
||||
#define cmTarget_h
|
||||
|
||||
#include "cmStandardIncludes.h"
|
||||
#include "cmCustomCommand.h"
|
||||
|
||||
/** \class cmTarget
|
||||
* \brief Represent a library or executable target loaded from a makefile.
|
||||
*
|
||||
* cmTarget represents a target loaded from
|
||||
* a makefile.
|
||||
*/
|
||||
class cmTarget
|
||||
{
|
||||
public:
|
||||
std::vector<cmCustomCommand> m_CustomCommands;
|
||||
bool m_IsALibrary;
|
||||
std::vector<std::string> m_SourceLists;
|
||||
};
|
||||
|
||||
typedef std::map<std::string,cmTarget> cmTargets;
|
||||
|
||||
#endif
|
|
@ -18,18 +18,7 @@
|
|||
// cmExecutableCommand
|
||||
bool cmTestsCommand::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);
|
||||
}
|
||||
// does nothing in CMake
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,49 +54,140 @@ void cmUnixMakefileGenerator::OutputMakefile(const char* file)
|
|||
return;
|
||||
}
|
||||
this->OutputMakeFlags(fout);
|
||||
this->OutputSourceToObjectList(fout);
|
||||
this->OutputVerbatim(fout);
|
||||
this->OutputExecutableRules(fout);
|
||||
this->OutputTargetRules(fout);
|
||||
this->OutputLinkLibs(fout);
|
||||
this->OutputTargets(fout);
|
||||
this->OutputSubDirectoryRules(fout);
|
||||
this->OutputObjectDepends(fout);
|
||||
this->OutputCustomRules(fout);
|
||||
}
|
||||
|
||||
// Output the LIBRARY and SRC_OBJS list based on
|
||||
// the library name and cmClassFile objects in the
|
||||
// makefile
|
||||
void cmUnixMakefileGenerator::OutputSourceToObjectList(std::ostream& fout)
|
||||
// Output the rules for any targets
|
||||
void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
|
||||
{
|
||||
std::vector<cmClassFile>& Classes = m_Makefile->GetClasses();
|
||||
if(Classes.size() == 0)
|
||||
// for each target add to the list of targets
|
||||
fout << "TARGETS = ";
|
||||
const cmTargets &tgts = m_Makefile->GetTargets();
|
||||
for(cmTargets::const_iterator l = tgts.begin();
|
||||
l != tgts.end(); l++)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Ouput Library name if there are SRC_OBJS
|
||||
if(strlen(m_Makefile->GetLibraryName()) > 0)
|
||||
if (l->second.m_IsALibrary)
|
||||
{
|
||||
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(unsigned int i = 0; i < Classes.size(); i++)
|
||||
{
|
||||
if(!Classes[i].m_AbstractClass && !Classes[i].m_HeaderFileOnly
|
||||
&& !Classes[i].m_IsExecutable)
|
||||
{
|
||||
fout << Classes[i].m_ClassName << ".o ";
|
||||
if(i == Classes.size() -1)
|
||||
{
|
||||
fout << "\n\n";
|
||||
fout << " \\\nlib" << l->first.c_str() << "${CMAKE_LIB_EXT}";
|
||||
}
|
||||
else
|
||||
{
|
||||
fout << "\\\n";
|
||||
fout << "\\\n" << l->first.c_str();
|
||||
}
|
||||
}
|
||||
fout << "\n\n";
|
||||
|
||||
// get the classes from the source lists then add them to the groups
|
||||
for(cmTargets::const_iterator l = tgts.begin();
|
||||
l != tgts.end(); l++)
|
||||
{
|
||||
std::vector<cmClassFile> classes =
|
||||
m_Makefile->GetClassesFromSourceLists(l->second.m_SourceLists);
|
||||
fout << l->first << "_SRC_OBJS = ";
|
||||
for(std::vector<cmClassFile>::iterator i = classes.begin();
|
||||
i != classes.end(); i++)
|
||||
{
|
||||
if(!i->m_HeaderFileOnly)
|
||||
{
|
||||
fout << "\\\n" << i->m_ClassName << ".o ";
|
||||
}
|
||||
}
|
||||
fout << "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Output the rules for any targets
|
||||
void cmUnixMakefileGenerator::OutputLinkLibs(std::ostream& fout)
|
||||
{
|
||||
// collect all the flags needed for linking libraries
|
||||
std::string linkLibs;
|
||||
std::vector<std::string>::iterator j;
|
||||
std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
|
||||
for(j = libdirs.begin(); j != libdirs.end(); ++j)
|
||||
{
|
||||
std::string::size_type pos = (*j).find("-L");
|
||||
if((pos == std::string::npos || pos > 0)
|
||||
&& (*j).find("${") == std::string::npos)
|
||||
{
|
||||
linkLibs += "-L";
|
||||
}
|
||||
linkLibs += *j;
|
||||
linkLibs += " ";
|
||||
}
|
||||
std::string librariesLinked;
|
||||
std::vector<std::string>& libs = m_Makefile->GetLinkLibraries();
|
||||
for(j = libs.begin(); j != libs.end(); ++j)
|
||||
{
|
||||
std::string::size_type pos = (*j).find("-l");
|
||||
if((pos == std::string::npos || pos > 0)
|
||||
&& (*j).find("${") == std::string::npos)
|
||||
{
|
||||
librariesLinked += "-l";
|
||||
}
|
||||
librariesLinked += *j;
|
||||
librariesLinked += " ";
|
||||
}
|
||||
// Add these in twice so order does not matter
|
||||
linkLibs += librariesLinked;
|
||||
linkLibs += librariesLinked;
|
||||
|
||||
std::vector<std::string>& libsUnix = m_Makefile->GetLinkLibrariesUnix();
|
||||
for(j = libsUnix.begin(); j != libsUnix.end(); ++j)
|
||||
{
|
||||
linkLibs += *j;
|
||||
linkLibs += " ";
|
||||
}
|
||||
linkLibs += " ${LOCAL_LINK_FLAGS} ";
|
||||
fout << "CMAKE_LINK_LIBS = " << linkLibs << "\n\n";
|
||||
// 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->OutputDependencies(fout);
|
||||
}
|
||||
|
||||
void cmUnixMakefileGenerator::OutputTargets(std::ostream& fout)
|
||||
{
|
||||
// for each target
|
||||
const cmTargets &tgts = m_Makefile->GetTargets();
|
||||
for(cmTargets::const_iterator l = tgts.begin();
|
||||
l != tgts.end(); l++)
|
||||
{
|
||||
if (l->second.m_IsALibrary)
|
||||
{
|
||||
fout << "#---------------------------------------------------------\n";
|
||||
fout << "# rules for a library\n";
|
||||
fout << "#\n";
|
||||
fout << "lib" << l->first << ".a: ${KIT_OBJ} ${" <<
|
||||
l->first << "_SRC_OBJS} \n";
|
||||
fout << "\t${AR} cr lib" << l->first << ".a ${KIT_OBJ} ${" <<
|
||||
l->first << "_SRC_OBJS} \n";
|
||||
fout << "\t${RANLIB} lib" << l->first << ".a\n";
|
||||
fout << std::endl;
|
||||
|
||||
fout << "lib" << l->first << "$(SHLIB_SUFFIX): ${KIT_OBJ} ${" <<
|
||||
l->first << "_SRC_OBJS} \n";
|
||||
fout << "\trm -f lib" << l->first << "$(SHLIB_SUFFIX)\n";
|
||||
fout << "\t$(CXX) ${CXX_FLAGS} ${CMAKE_SHLIB_BUILD_FLAGS} -o \\\n";
|
||||
fout << "\t lib" << l->first << "$(SHLIB_SUFFIX) \\\n";
|
||||
fout << "\t ${KIT_OBJ} ${" << l->first <<
|
||||
"_SRC_OBJS} ${SHLIB_LD_LIBS}\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
fout << l->first << ": ${" <<
|
||||
l->first << "_SRC_OBJS} ${CMAKE_DEPEND_LIBS}\n";
|
||||
fout << "\t${CXX} ${CXX_FLAGS} ${" <<
|
||||
l->first << "_SRC_OBJS} ${CMAKE_LINK_LIBS} -o "
|
||||
<< l->first << "\n\n";
|
||||
}
|
||||
}
|
||||
fout << "\n";
|
||||
}
|
||||
|
||||
|
||||
|
@ -171,7 +262,7 @@ void cmUnixMakefileGenerator::OutputMakeFlags(std::ostream& fout)
|
|||
}
|
||||
fout << m_Makefile->GetDefineFlags();
|
||||
fout << " ${LOCAL_INCLUDE_FLAGS} ";
|
||||
fout << "\n";
|
||||
fout << "\n\n";
|
||||
fout << "default_target: all\n\n";
|
||||
// see if there are files to compile in this makefile
|
||||
// These are used for both libraries and executables
|
||||
|
@ -190,92 +281,6 @@ void cmUnixMakefileGenerator::OutputVerbatim(std::ostream& fout)
|
|||
|
||||
}
|
||||
|
||||
// output executables
|
||||
void cmUnixMakefileGenerator::OutputExecutableRules(std::ostream& fout)
|
||||
{
|
||||
if(!m_Makefile->HasExecutables())
|
||||
{
|
||||
return ;
|
||||
}
|
||||
// collect all the flags needed for linking libraries
|
||||
std::string linkLibs;
|
||||
std::vector<std::string>::iterator j;
|
||||
std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
|
||||
for(j = libdirs.begin(); j != libdirs.end(); ++j)
|
||||
{
|
||||
std::string::size_type pos = (*j).find("-L");
|
||||
if((pos == std::string::npos || pos > 0)
|
||||
&& (*j).find("${") == std::string::npos)
|
||||
{
|
||||
linkLibs += "-L";
|
||||
}
|
||||
linkLibs += *j;
|
||||
linkLibs += " ";
|
||||
}
|
||||
std::string librariesLinked;
|
||||
std::vector<std::string>& libs = m_Makefile->GetLinkLibraries();
|
||||
for(j = libs.begin(); j != libs.end(); ++j)
|
||||
{
|
||||
std::string::size_type pos = (*j).find("-l");
|
||||
if((pos == std::string::npos || pos > 0)
|
||||
&& (*j).find("${") == std::string::npos)
|
||||
{
|
||||
librariesLinked += "-l";
|
||||
}
|
||||
librariesLinked += *j;
|
||||
librariesLinked += " ";
|
||||
}
|
||||
// Add these in twice so order does not matter
|
||||
linkLibs += librariesLinked;
|
||||
linkLibs += librariesLinked;
|
||||
|
||||
std::vector<std::string>& libsUnix = m_Makefile->GetLinkLibrariesUnix();
|
||||
for(j = libsUnix.begin(); j != libsUnix.end(); ++j)
|
||||
{
|
||||
linkLibs += *j;
|
||||
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->OutputDependencies(fout);
|
||||
// Now create rules for all of the executables to be built
|
||||
std::vector<cmClassFile>& Classes = m_Makefile->GetClasses();
|
||||
for(unsigned int i = 0; i < Classes.size(); i++)
|
||||
{
|
||||
if(!Classes[i].m_AbstractClass && !Classes[i].m_HeaderFileOnly
|
||||
&& Classes[i].m_IsExecutable)
|
||||
{
|
||||
std::string DotO = Classes[i].m_ClassName;
|
||||
DotO += ".o";
|
||||
fout << Classes[i].m_ClassName << ": " << DotO << " ";
|
||||
fout << "${CMAKE_DEPEND_LIBS}\n";
|
||||
fout << "\t${CXX} ${CXX_FLAGS} "
|
||||
<< DotO.c_str() << " "
|
||||
<< linkLibs.c_str()
|
||||
<< " -o $@ ""\n\n";
|
||||
}
|
||||
}
|
||||
// ouput the list of executables
|
||||
fout << "EXECUTABLES = \\\n";
|
||||
for(unsigned int i = 0; i < Classes.size(); i++)
|
||||
{
|
||||
if(!Classes[i].m_AbstractClass && !Classes[i].m_HeaderFileOnly
|
||||
&& Classes[i].m_IsExecutable)
|
||||
{
|
||||
fout << Classes[i].m_ClassName;
|
||||
if(i < Classes.size()-1)
|
||||
{
|
||||
fout << " \\";
|
||||
}
|
||||
fout << "\n";
|
||||
}
|
||||
}
|
||||
fout << "\n";
|
||||
}
|
||||
|
||||
// fix up names of directories so they can be used
|
||||
// as targets in makefiles.
|
||||
inline std::string FixDirectoryName(const char* dir)
|
||||
|
@ -365,19 +370,23 @@ void cmUnixMakefileGenerator::OutputSubDirectoryRules(std::ostream& fout)
|
|||
// by the class cmMakeDepend GenerateMakefile
|
||||
void cmUnixMakefileGenerator::OutputObjectDepends(std::ostream& fout)
|
||||
{
|
||||
std::vector<cmClassFile>& Classes = m_Makefile->GetClasses();
|
||||
for(unsigned int i = 0; i < Classes.size(); i++)
|
||||
cmMakefile::ClassMap &Classes = m_Makefile->GetClasses();
|
||||
for(cmMakefile::ClassMap::iterator l = Classes.begin();
|
||||
l != Classes.end(); l++)
|
||||
{
|
||||
if(!Classes[i].m_AbstractClass && !Classes[i].m_HeaderFileOnly)
|
||||
for(std::vector<cmClassFile>::iterator i = l->second.begin();
|
||||
i != l->second.end(); i++)
|
||||
{
|
||||
if( Classes[i].m_Depends.size())
|
||||
if(!i->m_HeaderFileOnly)
|
||||
{
|
||||
fout << Classes[i].m_ClassName << ".o : \\\n";
|
||||
if(i->m_Depends.size())
|
||||
{
|
||||
fout << i->m_ClassName << ".o : \\\n";
|
||||
for(std::vector<std::string>::iterator j =
|
||||
Classes[i].m_Depends.begin();
|
||||
j != Classes[i].m_Depends.end(); ++j)
|
||||
i->m_Depends.begin();
|
||||
j != i->m_Depends.end(); ++j)
|
||||
{
|
||||
if(j+1 == Classes[i].m_Depends.end())
|
||||
if(j+1 == i->m_Depends.end())
|
||||
{
|
||||
fout << *j << " \n";
|
||||
}
|
||||
|
@ -391,6 +400,7 @@ void cmUnixMakefileGenerator::OutputObjectDepends(std::ostream& fout)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Output each custom rule in the following format:
|
||||
|
@ -398,12 +408,33 @@ void cmUnixMakefileGenerator::OutputObjectDepends(std::ostream& fout)
|
|||
// (tab) command...
|
||||
void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout)
|
||||
{
|
||||
// We may be modifying the source groups temporarily, so make a copy.
|
||||
std::vector<cmSourceGroup> sourceGroups = m_Makefile->GetSourceGroups();
|
||||
|
||||
const cmTargets &tgts = m_Makefile->GetTargets();
|
||||
for(cmTargets::const_iterator tgt = tgts.begin();
|
||||
tgt != tgts.end(); ++tgt)
|
||||
{
|
||||
// add any custom rules to the source groups
|
||||
for (std::vector<cmCustomCommand>::const_iterator cr =
|
||||
tgt->second.m_CustomCommands.begin();
|
||||
cr != tgt->second.m_CustomCommands.end(); ++cr)
|
||||
{
|
||||
cmSourceGroup& sourceGroup =
|
||||
m_Makefile->FindSourceGroup(cr->m_Source.c_str(),
|
||||
sourceGroups);
|
||||
cmCustomCommand cc(*cr);
|
||||
cc.ExpandVariables(*m_Makefile);
|
||||
sourceGroup.AddCustomCommand(cc);
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through every source group.
|
||||
for(std::vector<cmSourceGroup>::const_iterator sg =
|
||||
m_Makefile->GetSourceGroups().begin();
|
||||
sg != m_Makefile->GetSourceGroups().end(); ++sg)
|
||||
sourceGroups.begin(); sg != sourceGroups.end(); ++sg)
|
||||
{
|
||||
const cmSourceGroup::CustomCommands& customCommands = sg->GetCustomCommands();
|
||||
const cmSourceGroup::CustomCommands& customCommands =
|
||||
sg->GetCustomCommands();
|
||||
if(customCommands.empty())
|
||||
{ continue; }
|
||||
|
||||
|
|
|
@ -44,8 +44,9 @@ protected:
|
|||
void OutputMakefile(const char* file);
|
||||
void OutputMakeFlags(std::ostream&);
|
||||
void OutputVerbatim(std::ostream&);
|
||||
void OutputSourceToObjectList(std::ostream& fout);
|
||||
void OutputExecutableRules(std::ostream&);
|
||||
void OutputTargetRules(std::ostream& fout);
|
||||
void OutputLinkLibs(std::ostream& fout);
|
||||
void OutputTargets(std::ostream&);
|
||||
void OutputSubDirectoryRules(std::ostream&);
|
||||
void OutputDependInformation(std::ostream&);
|
||||
void OutputDependencies(std::ostream&);
|
||||
|
|
|
@ -23,16 +23,21 @@ bool cmWrapExcludeFilesCommand::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_WrapExclude = true;
|
||||
break;
|
||||
if(i->m_ClassName == (*j))
|
||||
{
|
||||
i->m_WrapExclude = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
// cmWrapTclCommand
|
||||
bool cmWrapTclCommand::Invoke(std::vector<std::string>& args)
|
||||
{
|
||||
if(args.size() > 0 )
|
||||
if(args.size() < 3 )
|
||||
{
|
||||
this->SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
|
@ -44,17 +44,25 @@ bool cmWrapTclCommand::Invoke(std::vector<std::string>& args)
|
|||
}
|
||||
}
|
||||
|
||||
// get the list of classes for this library
|
||||
std::vector<cmClassFile> &classes = m_Makefile->GetClasses();
|
||||
|
||||
// add in new classes for the wrappers
|
||||
int lastClass = classes.size();
|
||||
// what is the current source dir
|
||||
std::string cdir = m_Makefile->GetCurrentDirectory();
|
||||
|
||||
for(int classNum = 0; classNum < lastClass; classNum++)
|
||||
// keep the library name
|
||||
m_LibraryName = args[0];
|
||||
m_SourceList = args[1];
|
||||
|
||||
// get the list of classes for this library
|
||||
cmMakefile::ClassMap &Classes = m_Makefile->GetClasses();
|
||||
for(std::vector<std::string>::iterator j = (args.begin() + 2);
|
||||
j != args.end(); ++j)
|
||||
{
|
||||
cmClassFile &curr = classes[classNum];
|
||||
for(cmMakefile::ClassMap::iterator l = Classes.begin();
|
||||
l != Classes.end(); l++)
|
||||
{
|
||||
for(std::vector<cmClassFile>::iterator i = l->second.begin();
|
||||
i != l->second.end(); i++)
|
||||
{
|
||||
cmClassFile &curr = *i;
|
||||
// if we should wrap the class
|
||||
if (!curr.m_WrapExclude)
|
||||
{
|
||||
|
@ -63,11 +71,16 @@ bool cmWrapTclCommand::Invoke(std::vector<std::string>& args)
|
|||
std::string newName = curr.m_ClassName + "Tcl";
|
||||
file.SetName(newName.c_str(), m_Makefile->GetCurrentOutputDirectory(),
|
||||
"cxx",false);
|
||||
m_WrapClasses.push_back(file);
|
||||
std::string hname = cdir + "/" + curr.m_ClassName + ".h";
|
||||
m_WrapHeaders.push_back(hname);
|
||||
// add starting depends
|
||||
file.m_Depends.push_back(hname);
|
||||
m_WrapClasses.push_back(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -79,35 +92,31 @@ void cmWrapTclCommand::FinalPass()
|
|||
std::string wtcl = "${WRAP_TCL_EXE}";
|
||||
std::string hints = "${WRAP_HINTS}";
|
||||
|
||||
m_Makefile->ExpandVariablesInString(wtcl);
|
||||
m_Makefile->ExpandVariablesInString(hints);
|
||||
|
||||
// Create the init file
|
||||
std::string res = m_Makefile->GetLibraryName();
|
||||
std::string res = m_LibraryName;
|
||||
res += "Init.cxx";
|
||||
this->CreateInitFile(res);
|
||||
|
||||
// add the init file
|
||||
cmClassFile cfile;
|
||||
cfile.m_AbstractClass = false;
|
||||
std::string newName = m_Makefile->GetLibraryName();
|
||||
std::string newName = m_LibraryName;
|
||||
newName += "Init";
|
||||
cfile.SetName(newName.c_str(), m_Makefile->GetCurrentOutputDirectory(),
|
||||
"cxx",false);
|
||||
m_Makefile->AddClass(cfile);
|
||||
m_Makefile->AddClass(cfile,m_SourceList.c_str());
|
||||
|
||||
// wrap all the .h files
|
||||
depends.push_back(wtcl);
|
||||
for(int classNum = 0; classNum < lastClass; classNum++)
|
||||
{
|
||||
m_Makefile->AddClass(m_WrapClasses[classNum]);
|
||||
m_Makefile->AddClass(m_WrapClasses[classNum],m_SourceList.c_str());
|
||||
std::string res = m_WrapClasses[classNum].m_ClassName + ".cxx";
|
||||
std::string cmd = wtcl + " " + m_WrapHeaders[classNum] + " "
|
||||
+ hints + (m_WrapClasses[classNum].m_AbstractClass ? " 0 " : " 1 ") + " > " + m_WrapClasses[classNum].m_ClassName + ".cxx";
|
||||
m_Makefile->AddCustomCommand(m_WrapHeaders[classNum].c_str(),
|
||||
cmd.c_str(),
|
||||
depends,
|
||||
res.c_str());
|
||||
cmd.c_str(), depends,
|
||||
res.c_str(), m_LibraryName.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -117,7 +126,7 @@ bool cmWrapTclCommand::CreateInitFile(std::string& res)
|
|||
unsigned int i;
|
||||
|
||||
/* we have to make sure that the name is the correct case */
|
||||
std::string kitName = m_Makefile->GetLibraryName();
|
||||
std::string kitName = m_LibraryName;
|
||||
if (kitName[0] > 90) kitName[0] -= 32;
|
||||
for (i = 1; i < kitName.size(); i++)
|
||||
{
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
virtual const char* GetFullDocumentation()
|
||||
{
|
||||
return
|
||||
"WRAP_TCL()";
|
||||
"WRAP_TCL(resultingLibraryName SourceListName SourceLists ...)";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,6 +74,8 @@ public:
|
|||
private:
|
||||
std::vector<cmClassFile> m_WrapClasses;
|
||||
std::vector<std::string> m_WrapHeaders;
|
||||
std::string m_LibraryName;
|
||||
std::string m_SourceList;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue