ENH: major change, the cmMakefile now contains a master list of cmSourceFile objects, the source lists reference the list via pointers, also you can now set properties on a file, like compile flags, abstract, etc.

This commit is contained in:
Bill Hoffman 2002-03-29 10:06:30 -05:00
parent 627ab62ce0
commit 8b3b49a010
31 changed files with 593 additions and 180 deletions

View File

@ -24,23 +24,29 @@ bool cmAbstractFilesCommand::InitialPass(std::vector<std::string> const& args)
this->SetError("called with incorrect number of arguments"); this->SetError("called with incorrect number of arguments");
return false; return false;
} }
bool ret = true;
std::string m = "could not find source file(s):\n";
cmMakefile::SourceMap &Classes = m_Makefile->GetSources(); cmMakefile::SourceMap &Classes = m_Makefile->GetSources();
for(std::vector<std::string>::const_iterator j = args.begin(); for(std::vector<std::string>::const_iterator j = args.begin();
j != args.end(); ++j) j != args.end(); ++j)
{ {
for(cmMakefile::SourceMap::iterator l = Classes.begin(); cmSourceFile* sf = m_Makefile->GetSource(j->c_str());
l != Classes.end(); l++) if(sf)
{ {
for(std::vector<cmSourceFile>::iterator i = l->second.begin(); sf->SetIsAnAbstractClass(true);
i != l->second.end(); i++) }
{ else
if(i->GetSourceName() == (*j)) {
{ m += *j;
i->SetIsAnAbstractClass(true); m += "\n";
} ret = false;
}
} }
} }
return true; if(!ret)
{
this->SetError(m.c_str());
}
return ret;
} }

View File

@ -161,7 +161,11 @@ OutputBuildObjectFromSource(std::ostream& fout,
} }
// Header files shouldn't have build rules. // Header files shouldn't have build rules.
if(source.IsAHeaderFileOnly()) if(source.IsAHeaderFileOnly())
{
return; return;
}
std::string comment = "Build "; std::string comment = "Build ";
std::string objectFile = std::string(shortName) + std::string objectFile = std::string(shortName) +
@ -248,14 +252,14 @@ void cmBorlandMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
command += " $(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") "; command += " $(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") ";
std::string command2 = "implib -w "; std::string command2 = "implib -w ";
command2 += libpath + " " + target; command2 += libpath + " " + target;
const std::vector<cmSourceFile>& sources = t.GetSourceFiles(); const std::vector<cmSourceFile*>& sources = t.GetSourceFiles();
for(std::vector<cmSourceFile>::const_iterator i = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
i != sources.end(); ++i) i != sources.end(); ++i)
{ {
if(i->GetSourceExtension() == "def") if((*i)->GetSourceExtension() == "def")
{ {
command += ""; command += "";
command += i->GetFullPath(); command += (*i)->GetFullPath();
} }
} }
command += "\n|\n"; command += "\n|\n";

View File

@ -46,6 +46,7 @@
#include "cmForEachCommand.cxx" #include "cmForEachCommand.cxx"
#include "cmFLTKWrapUICommand.cxx" #include "cmFLTKWrapUICommand.cxx"
#include "cmGetFilenameComponentCommand.cxx" #include "cmGetFilenameComponentCommand.cxx"
#include "cmGetSourceFilePropertyCommand.cxx"
#include "cmIfCommand.cxx" #include "cmIfCommand.cxx"
#include "cmIncludeCommand.cxx" #include "cmIncludeCommand.cxx"
#include "cmIncludeDirectoryCommand.cxx" #include "cmIncludeDirectoryCommand.cxx"
@ -64,6 +65,7 @@
#include "cmOutputRequiredFilesCommand.cxx" #include "cmOutputRequiredFilesCommand.cxx"
#include "cmProjectCommand.cxx" #include "cmProjectCommand.cxx"
#include "cmSetCommand.cxx" #include "cmSetCommand.cxx"
#include "cmSetSourceFilesPropertiesCommand.cxx"
#include "cmSiteNameCommand.cxx" #include "cmSiteNameCommand.cxx"
#include "cmSourceFilesCommand.cxx" #include "cmSourceFilesCommand.cxx"
#include "cmSourceFilesFlagsCommand.cxx" #include "cmSourceFilesFlagsCommand.cxx"
@ -113,6 +115,7 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
commands.push_back(new cmForEachCommand); commands.push_back(new cmForEachCommand);
commands.push_back(new cmFLTKWrapUICommand); commands.push_back(new cmFLTKWrapUICommand);
commands.push_back(new cmGetFilenameComponentCommand); commands.push_back(new cmGetFilenameComponentCommand);
commands.push_back(new cmGetSourceFilePropertyCommand);
commands.push_back(new cmIfCommand); commands.push_back(new cmIfCommand);
commands.push_back(new cmIncludeCommand); commands.push_back(new cmIncludeCommand);
commands.push_back(new cmIncludeDirectoryCommand); commands.push_back(new cmIncludeDirectoryCommand);
@ -131,6 +134,7 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
commands.push_back(new cmOutputRequiredFilesCommand); commands.push_back(new cmOutputRequiredFilesCommand);
commands.push_back(new cmProjectCommand); commands.push_back(new cmProjectCommand);
commands.push_back(new cmSetCommand); commands.push_back(new cmSetCommand);
commands.push_back(new cmSetSourceFilesPropertiesCommand);
commands.push_back(new cmSiteNameCommand); commands.push_back(new cmSiteNameCommand);
commands.push_back(new cmSourceFilesCommand); commands.push_back(new cmSourceFilesCommand);
commands.push_back(new cmSourceFilesFlagsCommand); commands.push_back(new cmSourceFilesFlagsCommand);

View File

@ -60,6 +60,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
"#include <ctype.h>\n" "#include <ctype.h>\n"
"#include <stdio.h>\n" "#include <stdio.h>\n"
"#include <string.h>\n" "#include <string.h>\n"
"\n" "\n"
"// Forward declare test functions\n" "// Forward declare test functions\n"
"\n"; "\n";

View File

@ -104,6 +104,18 @@ void cmDSPWriter::OutputDSPFile()
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS) && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)
&& (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0)) && (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0))
{ {
// check to see if the dsp is going into a sub-directory
std::string::size_type pos = l->first.rfind('/');
if(pos != std::string::npos)
{
std::string dir = m_Makefile->GetStartOutputDirectory();
dir += "/";
dir += l->first.substr(0, pos);
if(!cmSystemTools::MakeDirectory(dir.c_str()))
{
cmSystemTools::Error("Error creating directory ", dir.c_str());
}
}
this->CreateSingleDSP(l->first.c_str(),l->second); this->CreateSingleDSP(l->first.c_str(),l->second);
} }
} }
@ -201,15 +213,15 @@ void cmDSPWriter::WriteDSPFile(std::ostream& fout,
std::vector<cmSourceGroup> sourceGroups = m_Makefile->GetSourceGroups(); std::vector<cmSourceGroup> sourceGroups = m_Makefile->GetSourceGroups();
// get the classes from the source lists then add them to the groups // get the classes from the source lists then add them to the groups
std::vector<cmSourceFile> classes = target.GetSourceFiles(); std::vector<cmSourceFile*> classes = target.GetSourceFiles();
for(std::vector<cmSourceFile>::iterator i = classes.begin(); for(std::vector<cmSourceFile*>::iterator i = classes.begin();
i != classes.end(); i++) i != classes.end(); i++)
{ {
// Add the file to the list of sources. // Add the file to the list of sources.
std::string source = i->GetFullPath(); std::string source = (*i)->GetFullPath();
cmSourceGroup& sourceGroup = m_Makefile->FindSourceGroup(source.c_str(), cmSourceGroup& sourceGroup = m_Makefile->FindSourceGroup(source.c_str(),
sourceGroups); sourceGroups);
sourceGroup.AddSource(source.c_str(), &(*i)); sourceGroup.AddSource(source.c_str(), *i);
} }
// add any custom rules to the source groups // add any custom rules to the source groups
@ -785,25 +797,19 @@ void cmDSPWriter::WriteDSPHeader(std::ostream& fout, const char *libName,
cmSystemTools::ReplaceString(line, cmSystemTools::ReplaceString(line,
"EXTRA_DEFINES", "EXTRA_DEFINES",
m_Makefile->GetDefineFlags()); m_Makefile->GetDefineFlags());
cmSystemTools::ReplaceString(line, std::string flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELEASE");
"CMAKE_CXX_FLAGS_RELEASE", flags += " -DCMAKE_INTDIR=\\\"Release\\\"";
m_Makefile-> cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELEASE", flags.c_str());
GetDefinition("CMAKE_CXX_FLAGS_RELEASE")); flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_MINSIZEREL");
cmSystemTools::ReplaceString(line, flags += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\"";
"CMAKE_CXX_FLAGS_MINSIZEREL", cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_MINSIZEREL", flags.c_str());
m_Makefile-> flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_DEBUG");
GetDefinition("CMAKE_CXX_FLAGS_MINSIZEREL") flags += " -DCMAKE_INTDIR=\\\"Debug\\\"";
); cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_DEBUG", flags.c_str());
cmSystemTools::ReplaceString(line, flags = m_Makefile->GetDefinition("CMAKE_CXX_FLAGS_RELWITHDEBINFO");
"CMAKE_CXX_FLAGS_DEBUG", flags += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\"";
m_Makefile-> cmSystemTools::ReplaceString(line,"CMAKE_CXX_FLAGS_RELWITHDEBINFO", flags.c_str());
GetDefinition("CMAKE_CXX_FLAGS_DEBUG")); cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS",
cmSystemTools::ReplaceString(line,
"CMAKE_CXX_FLAGS_RELWITHDEBINFO",
m_Makefile->
GetDefinition("CMAKE_CXX_FLAGS_RELWITHDEBINFO"));
cmSystemTools::ReplaceString(line,
"CMAKE_CXX_FLAGS",
m_Makefile-> m_Makefile->
GetDefinition("CMAKE_CXX_FLAGS")); GetDefinition("CMAKE_CXX_FLAGS"));

View File

@ -64,10 +64,10 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args)
// where they are created have to be added to the include path // where they are created have to be added to the include path
m_Makefile->AddIncludeDirectory( outputDirectory.c_str() ); m_Makefile->AddIncludeDirectory( outputDirectory.c_str() );
for(std::vector<cmSourceFile>::iterator i = l->second.begin(); for(std::vector<cmSourceFile*>::iterator i = l->second.begin();
i != l->second.end(); i++) i != l->second.end(); i++)
{ {
cmSourceFile &curr = *i; cmSourceFile &curr = *(*i);
// if we should use the source GUI // if we should use the source GUI
// to generate .cxx and .h files // to generate .cxx and .h files
if (!curr.GetWrapExclude()) if (!curr.GetWrapExclude())
@ -139,8 +139,9 @@ void cmFLTKWrapUICommand::FinalPass()
m_Makefile->AddCustomCommand(m_WrapUserInterface[classNum].c_str(), m_Makefile->AddCustomCommand(m_WrapUserInterface[classNum].c_str(),
fluid_exe.c_str(), cxxargs, depends, fluid_exe.c_str(), cxxargs, depends,
outputs, m_Target.c_str() ); outputs, m_Target.c_str() );
cmSourceFile* sf = m_Makefile->AddSource(m_GeneratedSourcesClasses[classNum]);
m_Makefile->GetTargets()[m_Target].GetSourceFiles().push_back( m_GeneratedSourcesClasses[classNum] ); m_Makefile->GetTargets()[m_Target].GetSourceFiles().push_back( sf );
} }
} }

View File

@ -0,0 +1,55 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Insight Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmGetSourceFilePropertyCommand.h"
// cmSetSourceFilePropertyCommand
bool cmGetSourceFilePropertyCommand::InitialPass(std::vector<std::string> const&
args)
{
if(args.size() < 3 )
{
this->SetError("called with incorrect number of arguments");
return false;
}
const char* var = args[0].c_str();
const char* file = args[1].c_str();
cmSourceFile* sf = m_Makefile->GetSource(file);
if(sf)
{
if(args[2] == "ABSTRACT")
{
m_Makefile->AddDefinition(var, sf->IsAnAbstractClass());
}
if(args[2] == "WRAP_EXCLUDE")
{
m_Makefile->AddDefinition(var, sf->GetWrapExclude());
}
if(args[2] == "FLAGS")
{
m_Makefile->AddDefinition(var, sf->GetCompileFlags());
}
}
else
{
std::string m = "Could not find source file: ";
m += file;
this->SetError(m.c_str());
return false;
}
return true;
}

View File

@ -0,0 +1,66 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Insight Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmGetSourceFilePropertyCommand_h
#define cmGetSourceFilePropertyCommand_h
#include "cmStandardIncludes.h"
#include "cmCommand.h"
class cmGetSourceFilePropertyCommand : public cmCommand
{
public:
virtual cmCommand* Clone()
{
return new cmGetSourceFilePropertyCommand;
}
/**
* This is called when the command is first encountered in
* the input file.
*/
virtual bool InitialPass(std::vector<std::string> const& args);
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "GET_SOURCE_FILE_PROPERTY";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Set attributes for a specific list of files.";
}
/**
* Longer documentation.
*/
virtual const char* GetFullDocumentation()
{
return
"GET_SOURCE_FILE_PROPERTY(VAR file [ABSTRACT|WRAP_EXCLUDE|FLAGS]) "
"Get properties on a file. The syntax for the command is to list all the files you want "
"to change, and then provide the values you want to set next.";
}
cmTypeMacro(cmGetSourceFilePropertyCommand, cmCommand);
};
#endif

View File

@ -64,12 +64,12 @@ void cmInstallFilesCommand::FinalPass()
// look for a srclist // look for a srclist
if (m_Makefile->GetSources().find(temps) != m_Makefile->GetSources().end()) if (m_Makefile->GetSources().find(temps) != m_Makefile->GetSources().end())
{ {
const std::vector<cmSourceFile> &clsList = const std::vector<cmSourceFile*> &clsList =
m_Makefile->GetSources().find(temps)->second; m_Makefile->GetSources().find(temps)->second;
std::vector<cmSourceFile>::const_iterator c = clsList.begin(); std::vector<cmSourceFile*>::const_iterator c = clsList.begin();
for (; c != clsList.end(); ++c) for (; c != clsList.end(); ++c)
{ {
testf = c->GetSourceName() + ext; testf = (*c)->GetSourceName() + ext;
// add to the result // add to the result
targetSourceLists.push_back(testf); targetSourceLists.push_back(testf);
} }

View File

@ -720,8 +720,10 @@ void cmMSDotNETGenerator::WriteConfiguration(std::ostream& fout,
<< "\t\t\tCharacterSet=\"2\">\n"; << "\t\t\tCharacterSet=\"2\">\n";
fout << "\t\t\t<Tool\n" fout << "\t\t\t<Tool\n"
<< "\t\t\t\tName=\"VCCLCompilerTool\"\n" << "\t\t\t\tName=\"VCCLCompilerTool\"\n"
<< "\t\t\t\tAdditionalOptions=\"" << << "\t\t\t\tAdditionalOptions=\""
m_Makefile->GetDefinition("CMAKE_CXX_FLAGS") << "\"\n"; << m_Makefile->GetDefinition("CMAKE_CXX_FLAGS")
<< " -DCMAKE_INTDIR=\\&quot;" << configName << "\\&quot;"
<< "\"\n";
fout << "\t\t\t\tAdditionalIncludeDirectories=\""; fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories(); std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
@ -891,14 +893,14 @@ void cmMSDotNETGenerator::OutputBuildTool(std::ostream& fout,
void cmMSDotNETGenerator::OutputModuleDefinitionFile(std::ostream& fout, void cmMSDotNETGenerator::OutputModuleDefinitionFile(std::ostream& fout,
const cmTarget &target) const cmTarget &target)
{ {
std::vector<cmSourceFile> const& classes = target.GetSourceFiles(); std::vector<cmSourceFile*> const& classes = target.GetSourceFiles();
for(std::vector<cmSourceFile>::const_iterator i = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); i++) i != classes.end(); i++)
{ {
if(cmSystemTools::UpperCase(i->GetSourceExtension()) == "DEF") if(cmSystemTools::UpperCase((*i)->GetSourceExtension()) == "DEF")
{ {
fout << "\t\t\t\tModuleDefinitionFile=\"" fout << "\t\t\t\tModuleDefinitionFile=\""
<< this->ConvertToXMLOutputPath(i->GetFullPath().c_str()) << this->ConvertToXMLOutputPath((*i)->GetFullPath().c_str())
<< "\"\n"; << "\"\n";
return; return;
} }
@ -1011,20 +1013,20 @@ void cmMSDotNETGenerator::WriteVCProjFile(std::ostream& fout,
std::vector<cmSourceGroup> sourceGroups = m_Makefile->GetSourceGroups(); std::vector<cmSourceGroup> sourceGroups = m_Makefile->GetSourceGroups();
// get the classes from the source lists then add them to the groups // get the classes from the source lists then add them to the groups
std::vector<cmSourceFile> const& classes = target.GetSourceFiles(); std::vector<cmSourceFile*> const& classes = target.GetSourceFiles();
for(std::vector<cmSourceFile>::const_iterator i = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); i++) i != classes.end(); i++)
{ {
// Add the file to the list of sources. // Add the file to the list of sources.
std::string source = i->GetFullPath(); std::string source = (*i)->GetFullPath();
if(cmSystemTools::UpperCase(i->GetSourceExtension()) == "DEF") if(cmSystemTools::UpperCase((*i)->GetSourceExtension()) == "DEF")
{ {
m_ModuleDefinitionFile = i->GetFullPath(); m_ModuleDefinitionFile = (*i)->GetFullPath();
} }
cmSourceGroup& sourceGroup = m_Makefile->FindSourceGroup(source.c_str(), cmSourceGroup& sourceGroup = m_Makefile->FindSourceGroup(source.c_str(),
sourceGroups); sourceGroups);
sourceGroup.AddSource(source.c_str(), &(*i)); sourceGroup.AddSource(source.c_str(), *i);
} }
// add any custom rules to the source groups // add any custom rules to the source groups

View File

@ -147,10 +147,10 @@ void cmMakeDepend::GenerateDependInformation(cmDependInformation* info)
cmMakefile::SourceMap::iterator l; cmMakefile::SourceMap::iterator l;
for (l= srcmap.begin() ; l!=srcmap.end() ; l++) for (l= srcmap.begin() ; l!=srcmap.end() ; l++)
{ {
for(std::vector<cmSourceFile>::iterator i = l->second.begin(); for(std::vector<cmSourceFile*>::iterator i = l->second.begin();
i != l->second.end(); i++) i != l->second.end(); i++)
{ {
if (i->GetFullPath() == path) if ((*i)->GetFullPath() == path)
{ {
found=true; found=true;
} }
@ -164,7 +164,7 @@ void cmMakeDepend::GenerateDependInformation(cmDependInformation* info)
std::string incpath = *t; std::string incpath = *t;
incpath = incpath + "/"; incpath = incpath + "/";
incpath = incpath + path; incpath = incpath + path;
if (i->GetFullPath() == incpath) if ((*i)->GetFullPath() == incpath)
{ {
// set the path to the guessed path // set the path to the guessed path
info->m_FullPath = incpath; info->m_FullPath = incpath;
@ -272,16 +272,16 @@ void cmMakeDepend::GenerateMakefileDependencies()
for(cmTargets::const_iterator l = tgts.begin(); for(cmTargets::const_iterator l = tgts.begin();
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
const std::vector<cmSourceFile> &classes = l->second.GetSourceFiles(); const std::vector<cmSourceFile*> &classes = l->second.GetSourceFiles();
for(std::vector<cmSourceFile>::const_iterator i = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); ++i) i != classes.end(); ++i)
{ {
if(!i->GetIsAHeaderFileOnly()) if(!(*i)->GetIsAHeaderFileOnly())
{ {
cmDependInformation* info = cmDependInformation* info =
this->GetDependInformation(i->GetFullPath().c_str()); this->GetDependInformation((*i)->GetFullPath().c_str());
this->AddFileToSearchPath(info->m_FullPath.c_str()); this->AddFileToSearchPath(info->m_FullPath.c_str());
info->m_cmSourceFile = &*i; info->m_cmSourceFile = *i;
this->GenerateDependInformation(info); this->GenerateDependInformation(info);
} }
} }

View File

@ -104,6 +104,11 @@ void cmMakefile::AddDefaultCommands()
cmMakefile::~cmMakefile() cmMakefile::~cmMakefile()
{ {
for(std::vector<cmSourceFile*>::iterator i = m_SourceFiles.begin();
i != m_SourceFiles.end(); ++i)
{
delete *i;
}
for(unsigned int i=0; i < m_UsedCommands.size(); i++) for(unsigned int i=0; i < m_UsedCommands.size(); i++)
{ {
delete m_UsedCommands[i]; delete m_UsedCommands[i];
@ -153,10 +158,10 @@ void cmMakefile::Print() const
l != m_Sources.end(); l++) l != m_Sources.end(); l++)
{ {
std::cout << " Class list named: " << l->first << std::endl; std::cout << " Class list named: " << l->first << std::endl;
for(std::vector<cmSourceFile>::const_iterator i = l->second.begin(); for(std::vector<cmSourceFile*>::const_iterator i = l->second.begin();
i != l->second.end(); i++) i != l->second.end(); i++)
{ {
i->Print(); (*i)->Print();
} }
} }
@ -361,12 +366,12 @@ cmSourceFile *cmMakefile::GetSource(const char *srclist, const char *cname)
return 0; return 0;
} }
// find the class // find the class
for (std::vector<cmSourceFile>::iterator i = sl->second.begin(); for (std::vector<cmSourceFile*>::iterator i = sl->second.begin();
i != sl->second.end(); ++i) i != sl->second.end(); ++i)
{ {
if (i->GetSourceName() == cname) if ((*i)->GetSourceName() == cname)
{ {
return &(*i); return *i;
} }
} }
return 0; return 0;
@ -423,24 +428,23 @@ void cmMakefile::GenerateMakefile()
void cmMakefile::AddSource(cmSourceFile& cmfile, const char *srclist) void cmMakefile::AddSource(cmSourceFile& cmfile, const char *srclist)
{ {
m_Sources[srclist].push_back(cmfile); m_Sources[srclist].push_back(this->AddSource(cmfile));
} }
struct FindSrcByName : std::binary_function<cmSourceFile, cmSourceFile, bool> struct FindSrcByName : std::binary_function<cmSourceFile*, cmSourceFile*, bool>
{ {
public: public:
bool operator () (const cmSourceFile &f, const cmSourceFile &test) const bool operator () (const cmSourceFile *f, const cmSourceFile *test) const
{ {
return !strcmp(f.GetSourceName().c_str(),test.GetSourceName().c_str()); return (f->GetSourceName() == test->GetSourceName());
} }
}; };
void cmMakefile::RemoveSource(cmSourceFile& cmfile,const char *srclist) void cmMakefile::RemoveSource(cmSourceFile& cmfile,const char *srclist)
{ {
std::vector<cmSourceFile> &maplist = m_Sources[srclist]; std::vector<cmSourceFile*> &maplist = m_Sources[srclist];
std::vector<cmSourceFile>::iterator f = std::vector<cmSourceFile*>::iterator f =
std::find_if(maplist.begin(), maplist.end(), std::bind2nd(FindSrcByName(),cmfile)); std::find_if(maplist.begin(), maplist.end(), std::bind2nd(FindSrcByName(),&cmfile));
// std::vector<cmSourceFile>::iterator f = find_if(maplist.begin(), maplist.end(), matches(srclist);
if (f!=maplist.end()) if (f!=maplist.end())
{ {
maplist.erase(f); maplist.erase(f);
@ -1288,3 +1292,33 @@ cmData* cmMakefile::LookupData(const char* name) const
} }
} }
cmSourceFile* cmMakefile::GetSource(const char* sourceName)
{
for(std::vector<cmSourceFile*>::iterator i = m_SourceFiles.begin();
i != m_SourceFiles.end(); ++i)
{
if((*i)->GetSourceName() == sourceName
|| (*i)->GetSourceName()+"."+(*i)->GetSourceExtension() == sourceName)
{
return *i;
}
}
return 0;
}
cmSourceFile* cmMakefile::AddSource(cmSourceFile const&sf)
{
// check to see if it exists
cmSourceFile* ret = this->GetSource(sf.GetSourceName().c_str());
if(ret && ret->GetSourceExtension() == sf.GetSourceExtension())
{
return ret;
}
ret = new cmSourceFile(sf);
m_SourceFiles.push_back(ret);
return ret;
}

View File

@ -401,10 +401,17 @@ public:
/** /**
* Return a list of source files in this makefile. * Return a list of source files in this makefile.
*/ */
typedef std::map<cmStdString,std::vector<cmSourceFile> > SourceMap; typedef std::map<cmStdString,std::vector<cmSourceFile*> > SourceMap;
const SourceMap &GetSources() const {return m_Sources;} const SourceMap &GetSources() const {return m_Sources;}
SourceMap &GetSources() {return m_Sources;} SourceMap &GetSources() {return m_Sources;}
cmSourceFile *GetSource(const char *srclist, const char *sourceName); cmSourceFile* GetSource(const char *srclist, const char *sourceName);
/** Get a cmSourceFile pointer for a given source name, if the name is
* not found, then a null pointer is returned.
*/
cmSourceFile* GetSource(const char* sourceName);
///! Add a new cmSourceFile to the list of sources for this makefile.
cmSourceFile* AddSource(cmSourceFile const&);
/** /**
* Obtain a list of auxiliary source directories. * Obtain a list of auxiliary source directories.
@ -533,6 +540,8 @@ protected:
// libraries, classes, and executables // libraries, classes, and executables
cmTargets m_Targets; cmTargets m_Targets;
SourceMap m_Sources; SourceMap m_Sources;
std::vector<cmSourceFile*> m_SourceFiles;
std::vector<std::string> m_SubDirectories; // list of sub directories std::vector<std::string> m_SubDirectories; // list of sub directories
struct StringSet : public std::set<cmStdString> struct StringSet : public std::set<cmStdString>

View File

@ -445,14 +445,14 @@ void cmNMakeMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
command += linklibs.str(); command += linklibs.str();
delete [] linklibs.str(); delete [] linklibs.str();
const std::vector<cmSourceFile>& sources = t.GetSourceFiles(); const std::vector<cmSourceFile*>& sources = t.GetSourceFiles();
for(std::vector<cmSourceFile>::const_iterator i = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
i != sources.end(); ++i) i != sources.end(); ++i)
{ {
if(i->GetSourceExtension() == "def") if((*i)->GetSourceExtension() == "def")
{ {
command += "/DEF:"; command += "/DEF:";
command += i->GetFullPath(); command += (*i)->GetFullPath();
} }
} }

View File

@ -60,10 +60,10 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args)
this->SetError("bad source list passed to QTWrapCPPCommand"); this->SetError("bad source list passed to QTWrapCPPCommand");
return false; return false;
} }
for(std::vector<cmSourceFile>::iterator i = l->second.begin(); for(std::vector<cmSourceFile*>::iterator i = l->second.begin();
i != l->second.end(); i++) i != l->second.end(); i++)
{ {
cmSourceFile &curr = *i; cmSourceFile &curr = *(*i);
// if we should wrap the class // if we should wrap the class
if (!curr.GetWrapExclude()) if (!curr.GetWrapExclude())
{ {

View File

@ -61,10 +61,10 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args)
this->SetError("bad source list passed to QTWrapUICommand"); this->SetError("bad source list passed to QTWrapUICommand");
return false; return false;
} }
for(std::vector<cmSourceFile>::iterator i = l->second.begin(); for(std::vector<cmSourceFile*>::iterator i = l->second.begin();
i != l->second.end(); i++) i != l->second.end(); i++)
{ {
cmSourceFile &curr = *i; cmSourceFile &curr = *(*i);
// if we should wrap the class // if we should wrap the class
if (!curr.GetWrapExclude()) if (!curr.GetWrapExclude())
{ {

View File

@ -0,0 +1,136 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Insight Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmSetSourceFilesPropertiesCommand.h"
// cmSetSourceFilesPropertiesCommand
bool cmSetSourceFilesPropertiesCommand::InitialPass(std::vector<std::string> const&
args)
{
if(args.size() < 2 )
{
this->SetError("called with incorrect number of arguments");
return false;
}
std::vector<std::string>::const_iterator j;
// first collect up all the flags that need to be set on the file
bool abstract = false;
bool wrap_exclude = false;
bool generated = false;
std::string flags;
for(j= args.begin(); j != args.end();++j)
{
if(*j == "ABSTRACT")
{
abstract = true;
}
else if(*j == "WRAP_EXCLUDE")
{
wrap_exclude = true;
}
else if(*j == "GENERATED")
{
generated = true;
}
else if(*j == "FLAGS")
{
++j;
if(j == args.end())
{
this->SetError("called with incorrect number of arguments FLAGS with no flags");
return false;
}
flags = *j;
}
}
// now loop over all the files
for(j = args.begin(); j != args.end(); ++j)
{
// at the sign of the first property exit the loop
if(*j == "ABSTRACT" || *j == "WRAP_EXCLUDE" || *j == "FLAGS")
{
break;
}
// if the file is already in the makefile just set properites on it
cmSourceFile* sf = m_Makefile->GetSource(j->c_str());
if(sf)
{
if(flags.size())
{
sf->SetCompileFlags(flags.c_str());
}
sf->SetIsAnAbstractClass(abstract);
sf->SetWrapExclude(wrap_exclude);
}
// if file is not already in the makefile, then add it
else
{
std::string newfile = *j;
cmSourceFile file;
std::string path = cmSystemTools::GetFilenamePath(newfile);
// set the flags
file.SetIsAnAbstractClass(abstract);
file.SetWrapExclude(wrap_exclude);
if(flags.size())
{
file.SetCompileFlags(flags.c_str());
}
if(generated)
{
std::string ext = cmSystemTools::GetFilenameExtension(newfile);
std::string name_no_ext = cmSystemTools::GetFilenameName(newfile.c_str());
name_no_ext = name_no_ext.substr(0, name_no_ext.length()-ext.length());
if ( ext.length() && ext[0] == '.' )
{
ext = ext.substr(1);
}
if((path.size() && path[0] == '/') ||
(path.size() > 1 && path[1] == ':'))
{
file.SetName(name_no_ext.c_str(), path.c_str(), ext.c_str(), false);
}
else
{
file.SetName(name_no_ext.c_str(), m_Makefile->GetCurrentOutputDirectory(),
ext.c_str(), false);
}
}
else
{
// if this is a full path then
if((path.size() && path[0] == '/') ||
(path.size() > 1 && path[1] == ':'))
{
file.SetName(cmSystemTools::GetFilenameName(newfile.c_str()).c_str(),
path.c_str(),
m_Makefile->GetSourceExtensions(),
m_Makefile->GetHeaderExtensions());
}
else
{
file.SetName(newfile.c_str(), m_Makefile->GetCurrentDirectory(),
m_Makefile->GetSourceExtensions(),
m_Makefile->GetHeaderExtensions());
}
}
// add the source file to the makefile
m_Makefile->AddSource(file);
}
}
return true;
}

View File

@ -0,0 +1,66 @@
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Insight Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmSetSourceFilesPropertiesCommand_h
#define cmSetSourceFilesPropertiesCommand_h
#include "cmStandardIncludes.h"
#include "cmCommand.h"
class cmSetSourceFilesPropertiesCommand : public cmCommand
{
public:
virtual cmCommand* Clone()
{
return new cmSetSourceFilesPropertiesCommand;
}
/**
* This is called when the command is first encountered in
* the input file.
*/
virtual bool InitialPass(std::vector<std::string> const& args);
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "SET_SOURCE_FILES_PROPERTIES";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Set attributes for a specific list of files.";
}
/**
* Longer documentation.
*/
virtual const char* GetFullDocumentation()
{
return
"SET_SOURCE_FILES_PROPERTIES(flags file1 file2 [ABSTRACT|WRAP_EXCLUDE|GENERATED|FLAGS] [flags]) "
"Set properties on a file. The syntax for the command is to list all the files you want "
"to change, and then provide the values you want to set next.";
}
cmTypeMacro(cmSetSourceFilesPropertiesCommand, cmCommand);
};
#endif

View File

@ -151,19 +151,22 @@ void cmSourceFile::Print() const
{ {
if(m_AbstractClass) if(m_AbstractClass)
{ {
std::cout << "Abstract "; std::cerr << "Abstract ";
} }
else else
{ {
std::cout << "Concrete "; std::cerr << "Concrete ";
} }
if(m_HeaderFileOnly) if(m_HeaderFileOnly)
{ {
std::cout << "Header file "; std::cerr << "Header file ";
} }
else else
{ {
std::cout << "CXX file "; std::cerr << "CXX file ";
} }
std::cout << m_SourceName << std::endl; std::cerr << "m_CompileFlags: " << m_CompileFlags << "\n";
std::cerr << "m_FullPath: " << m_FullPath << "\n";
std::cerr << "m_SourceName: " << m_SourceName << std::endl;
std::cerr << "m_SourceExtension: " << m_SourceExtension << "\n";
} }

View File

@ -40,6 +40,14 @@ bool cmSourceFilesCommand::InitialPass(std::vector<std::string> const& args)
generated = 1; generated = 1;
continue; continue;
} }
cmSourceFile* sf = m_Makefile->GetSource(copy.c_str());
if(sf)
{
// if the source file is already in the makefile,
// then add the pointer to the source list without creating a cmSourceFile
m_Makefile->GetSources()[name].push_back(sf);
continue;
}
cmSourceFile file; cmSourceFile file;
file.SetIsAnAbstractClass(false); file.SetIsAnAbstractClass(false);
std::string path = cmSystemTools::GetFilenamePath(copy); std::string path = cmSystemTools::GetFilenamePath(copy);

View File

@ -25,23 +25,23 @@ bool cmSourceFilesFlagsCommand::InitialPass(std::vector<std::string> const&
this->SetError("called with incorrect number of arguments"); this->SetError("called with incorrect number of arguments");
return false; return false;
} }
cmMakefile::SourceMap &Classes = m_Makefile->GetSources();
std::vector<std::string>::const_iterator j = args.begin(); std::vector<std::string>::const_iterator j = args.begin();
std::string flags = *j; std::string flags = *j;
++j; ++j;
for(;j != args.end(); ++j) for(;j != args.end(); ++j)
{ {
for(cmMakefile::SourceMap::iterator l = Classes.begin(); cmSourceFile* sf = m_Makefile->GetSource(j->c_str());
l != Classes.end(); l++) if(sf)
{ {
for(std::vector<cmSourceFile>::iterator i = l->second.begin(); sf->SetCompileFlags(flags.c_str());
i != l->second.end(); i++) }
{ else
if(i->GetSourceName() == (*j) || i->GetSourceName()+"."+i->GetSourceExtension() == (*j)) {
{ std::string m = "could not find source file ";
i->SetCompileFlags(flags.c_str()); m += *j;
} this->SetError(m.c_str());
} return false;
} }
} }
return true; return true;

View File

@ -17,7 +17,7 @@
#include "cmTarget.h" #include "cmTarget.h"
#include "cmMakefile.h" #include "cmMakefile.h"
void cmTarget::GenerateSourceFilesFromSourceLists(const cmMakefile &mf) void cmTarget::GenerateSourceFilesFromSourceLists( cmMakefile &mf)
{ {
// this is only done for non install targets // this is only done for non install targets
if ((this->m_TargetType == cmTarget::INSTALL_FILES) if ((this->m_TargetType == cmTarget::INSTALL_FILES)
@ -36,7 +36,7 @@ void cmTarget::GenerateSourceFilesFromSourceLists(const cmMakefile &mf)
// look for a srclist // look for a srclist
if (mf.GetSources().find(temps) != mf.GetSources().end()) if (mf.GetSources().find(temps) != mf.GetSources().end())
{ {
const std::vector<cmSourceFile> &clsList = const std::vector<cmSourceFile*> &clsList =
mf.GetSources().find(temps)->second; mf.GetSources().find(temps)->second;
// if we ahave a limited build list, use it // if we ahave a limited build list, use it
m_SourceFiles.insert(m_SourceFiles.end(), m_SourceFiles.insert(m_SourceFiles.end(),
@ -51,7 +51,7 @@ void cmTarget::GenerateSourceFilesFromSourceLists(const cmMakefile &mf)
file.SetName(temps.c_str(), mf.GetCurrentDirectory(), file.SetName(temps.c_str(), mf.GetCurrentDirectory(),
mf.GetSourceExtensions(), mf.GetSourceExtensions(),
mf.GetHeaderExtensions()); mf.GetHeaderExtensions());
m_SourceFiles.push_back(file); m_SourceFiles.push_back(mf.AddSource(file));
} }
} }

View File

@ -67,9 +67,9 @@ public:
/** /**
* Get the list of the source files used by this target * Get the list of the source files used by this target
*/ */
const std::vector<cmSourceFile> &GetSourceFiles() const const std::vector<cmSourceFile*> &GetSourceFiles() const
{return m_SourceFiles;} {return m_SourceFiles;}
std::vector<cmSourceFile> &GetSourceFiles() {return m_SourceFiles;} std::vector<cmSourceFile*> &GetSourceFiles() {return m_SourceFiles;}
/** /**
* Get the list of the source files used by this target * Get the list of the source files used by this target
@ -95,7 +95,7 @@ public:
* Generate the SourceFilesList from the SourceLists. This should only be * Generate the SourceFilesList from the SourceLists. This should only be
* done once to be safe. * done once to be safe.
*/ */
void GenerateSourceFilesFromSourceLists(const cmMakefile &mf); void GenerateSourceFilesFromSourceLists(cmMakefile &mf);
/** Add a utility on which this project depends. A utility is an executable /** Add a utility on which this project depends. A utility is an executable
* name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE * name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE
@ -109,7 +109,7 @@ private:
std::vector<cmCustomCommand> m_CustomCommands; std::vector<cmCustomCommand> m_CustomCommands;
std::vector<std::string> m_SourceLists; std::vector<std::string> m_SourceLists;
TargetType m_TargetType; TargetType m_TargetType;
std::vector<cmSourceFile> m_SourceFiles; std::vector<cmSourceFile*> m_SourceFiles;
LinkLibraries m_LinkLibraries; LinkLibraries m_LinkLibraries;
bool m_InAll; bool m_InAll;
std::string m_InstallPath; std::string m_InstallPath;

View File

@ -110,18 +110,18 @@ void cmUnixMakefileGenerator::ProcessDepends(const cmMakeDepend &md)
cmTargets &tgts = m_Makefile->GetTargets(); cmTargets &tgts = m_Makefile->GetTargets();
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
{ {
std::vector<cmSourceFile> &classes = l->second.GetSourceFiles(); std::vector<cmSourceFile*> &classes = l->second.GetSourceFiles();
for(std::vector<cmSourceFile>::iterator i = classes.begin(); for(std::vector<cmSourceFile*>::iterator i = classes.begin();
i != classes.end(); ++i) i != classes.end(); ++i)
{ {
if(!i->GetIsAHeaderFileOnly()) if(!(*i)->GetIsAHeaderFileOnly())
{ {
// get the depends // get the depends
const cmDependInformation *info = const cmDependInformation *info =
md.GetDependInformationForSourceFile(*i); md.GetDependInformationForSourceFile(*(*i));
// Delete any hints from the source file's dependencies. // Delete any hints from the source file's dependencies.
i->GetDepends().erase(i->GetDepends().begin(), i->GetDepends().end()); (*i)->GetDepends().erase((*i)->GetDepends().begin(), (*i)->GetDepends().end());
// Now add the real dependencies for the file. // Now add the real dependencies for the file.
if (info) if (info)
@ -134,7 +134,7 @@ void cmUnixMakefileGenerator::ProcessDepends(const cmMakeDepend &md)
// not found. // not found.
if((*d)->m_FullPath != "") if((*d)->m_FullPath != "")
{ {
i->GetDepends().push_back((*d)->m_FullPath); (*i)->GetDepends().push_back((*d)->m_FullPath);
} }
} }
} }
@ -359,34 +359,34 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
for(cmTargets::const_iterator l = tgts.begin(); for(cmTargets::const_iterator l = tgts.begin();
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
std::vector<cmSourceFile> classes = l->second.GetSourceFiles(); std::vector<cmSourceFile*> classes = l->second.GetSourceFiles();
if (classes.begin() != classes.end()) if (classes.begin() != classes.end())
{ {
fout << this->CreateMakeVariable(l->first.c_str(), "_SRC_OBJS") << " = "; fout << this->CreateMakeVariable(l->first.c_str(), "_SRC_OBJS") << " = ";
for(std::vector<cmSourceFile>::iterator i = classes.begin(); for(std::vector<cmSourceFile*>::iterator i = classes.begin();
i != classes.end(); i++) i != classes.end(); i++)
{ {
if(!i->IsAHeaderFileOnly()) if(!(*i)->IsAHeaderFileOnly())
{ {
std::string outExt(this->GetOutputExtension(i->GetSourceExtension().c_str())); std::string outExt(this->GetOutputExtension((*i)->GetSourceExtension().c_str()));
if(outExt.size()) if(outExt.size())
{ {
fout << "\\\n" << this->ConvertToOutputPath(i->GetSourceName().c_str()) fout << "\\\n" << this->ConvertToOutputPath((*i)->GetSourceName().c_str())
<< outExt.c_str() << " "; << outExt.c_str() << " ";
} }
} }
} }
fout << "\n\n"; fout << "\n\n";
fout << this->CreateMakeVariable(l->first.c_str(), "_SRC_OBJS_QUOTED") << " = "; fout << this->CreateMakeVariable(l->first.c_str(), "_SRC_OBJS_QUOTED") << " = ";
for(std::vector<cmSourceFile>::iterator i = classes.begin(); for(std::vector<cmSourceFile*>::iterator i = classes.begin();
i != classes.end(); i++) i != classes.end(); i++)
{ {
if(!i->IsAHeaderFileOnly()) if(!(*i)->IsAHeaderFileOnly())
{ {
std::string outExt(this->GetOutputExtension(i->GetSourceExtension().c_str())); std::string outExt(this->GetOutputExtension((*i)->GetSourceExtension().c_str()));
if(outExt.size()) if(outExt.size())
{ {
fout << "\\\n\"" << this->ConvertToOutputPath(i->GetSourceName().c_str()) fout << "\\\n\"" << this->ConvertToOutputPath((*i)->GetSourceName().c_str())
<< outExt.c_str() << "\" "; << outExt.c_str() << "\" ";
} }
} }
@ -398,7 +398,7 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
for(cmTargets::const_iterator l = tgts.begin(); for(cmTargets::const_iterator l = tgts.begin();
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
std::vector<cmSourceFile> classes = l->second.GetSourceFiles(); std::vector<cmSourceFile*> classes = l->second.GetSourceFiles();
if (classes.begin() != classes.end()) if (classes.begin() != classes.end())
{ {
fout << "$(" << this->CreateMakeVariable(l->first.c_str(), "_SRC_OBJS") fout << "$(" << this->CreateMakeVariable(l->first.c_str(), "_SRC_OBJS")
@ -1224,19 +1224,19 @@ bool cmUnixMakefileGenerator::OutputObjectDepends(std::ostream& fout)
target != targets.end(); ++target) target != targets.end(); ++target)
{ {
// Iterate over every source for this target. // Iterate over every source for this target.
const std::vector<cmSourceFile>& sources = target->second.GetSourceFiles(); const std::vector<cmSourceFile*>& sources = target->second.GetSourceFiles();
for(std::vector<cmSourceFile>::const_iterator source = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
source != sources.end(); ++source) source != sources.end(); ++source)
{ {
if(!source->IsAHeaderFileOnly()) if(!(*source)->IsAHeaderFileOnly())
{ {
if(!source->GetDepends().empty()) if(!(*source)->GetDepends().empty())
{ {
fout << source->GetSourceName() << m_ObjectFileExtension << " :"; fout << (*source)->GetSourceName() << m_ObjectFileExtension << " :";
// Iterate through all the dependencies for this source. // Iterate through all the dependencies for this source.
for(std::vector<std::string>::const_iterator dep = for(std::vector<std::string>::const_iterator dep =
source->GetDepends().begin(); (*source)->GetDepends().begin();
dep != source->GetDepends().end(); ++dep) dep != (*source)->GetDepends().end(); ++dep)
{ {
fout << " \\\n" fout << " \\\n"
<< this->ConvertToOutputPath(dep->c_str()); << this->ConvertToOutputPath(dep->c_str());
@ -1274,17 +1274,17 @@ void cmUnixMakefileGenerator::OutputCheckDepends(std::ostream& fout)
target != targets.end(); ++target) target != targets.end(); ++target)
{ {
// Iterate over every source for this target. // Iterate over every source for this target.
const std::vector<cmSourceFile>& sources = target->second.GetSourceFiles(); const std::vector<cmSourceFile*>& sources = target->second.GetSourceFiles();
for(std::vector<cmSourceFile>::const_iterator source = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
source != sources.end(); ++source) source != sources.end(); ++source)
{ {
if(!source->IsAHeaderFileOnly()) if(!(*source)->IsAHeaderFileOnly())
{ {
if(!source->GetDepends().empty()) if(!(*source)->GetDepends().empty())
{ {
for(std::vector<std::string>::const_iterator dep = for(std::vector<std::string>::const_iterator dep =
source->GetDepends().begin(); (*source)->GetDepends().begin();
dep != source->GetDepends().end(); ++dep) dep != (*source)->GetDepends().end(); ++dep)
{ {
std::string dependfile = std::string dependfile =
this->ConvertToOutputPath(dep->c_str()); this->ConvertToOutputPath(dep->c_str());
@ -1702,14 +1702,14 @@ void cmUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
target != targets.end(); ++target) target != targets.end(); ++target)
{ {
// Iterate over every source for this target. // Iterate over every source for this target.
const std::vector<cmSourceFile>& sources = target->second.GetSourceFiles(); const std::vector<cmSourceFile*>& sources = target->second.GetSourceFiles();
for(std::vector<cmSourceFile>::const_iterator source = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
source != sources.end(); ++source) source != sources.end(); ++source)
{ {
if(!source->IsAHeaderFileOnly()) if(!(*source)->IsAHeaderFileOnly())
{ {
allsources += " \\\n"; allsources += " \\\n";
allsources += source->GetFullPath(); allsources += (*source)->GetFullPath();
} }
} }
} }
@ -1810,7 +1810,9 @@ OutputBuildObjectFromSource(std::ostream& fout,
{ {
// Header files shouldn't have build rules. // Header files shouldn't have build rules.
if(source.IsAHeaderFileOnly()) if(source.IsAHeaderFileOnly())
{
return; return;
}
std::string comment = "Build "; std::string comment = "Build ";
std::string objectFile = std::string(shortName) + m_ObjectFileExtension; std::string objectFile = std::string(shortName) + m_ObjectFileExtension;
@ -1877,11 +1879,11 @@ void cmUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fout)
exportsDef = "-D"+target->first+"_EXPORTS "; exportsDef = "-D"+target->first+"_EXPORTS ";
} }
// Iterate over every source for this target. // Iterate over every source for this target.
const std::vector<cmSourceFile>& sources = target->second.GetSourceFiles(); const std::vector<cmSourceFile*>& sources = target->second.GetSourceFiles();
for(std::vector<cmSourceFile>::const_iterator source = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
source != sources.end(); ++source) source != sources.end(); ++source)
{ {
if(!source->IsAHeaderFileOnly()) if(!(*source)->IsAHeaderFileOnly())
{ {
std::string shortName; std::string shortName;
std::string sourceName; std::string sourceName;
@ -1889,18 +1891,18 @@ void cmUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fout)
// directory, we want to use the relative path for the // directory, we want to use the relative path for the
// filename of the object file. Otherwise, we will use just // filename of the object file. Otherwise, we will use just
// the filename portion. // the filename portion.
if((cmSystemTools::GetFilenamePath(source->GetFullPath()).find(m_Makefile->GetCurrentDirectory()) == 0) if((cmSystemTools::GetFilenamePath((*source)->GetFullPath()).find(m_Makefile->GetCurrentDirectory()) == 0)
|| (cmSystemTools::GetFilenamePath(source->GetFullPath()).find(m_Makefile-> || (cmSystemTools::GetFilenamePath((*source)->GetFullPath()).find(m_Makefile->
GetCurrentOutputDirectory()) == 0)) GetCurrentOutputDirectory()) == 0))
{ {
sourceName = source->GetSourceName()+"."+source->GetSourceExtension(); sourceName = (*source)->GetSourceName()+"."+(*source)->GetSourceExtension();
shortName = source->GetSourceName(); shortName = (*source)->GetSourceName();
// The path may be relative. See if a directory needs to be // The path may be relative. See if a directory needs to be
// created for the output file. This is a ugly, and perhaps // created for the output file. This is a ugly, and perhaps
// should be moved elsewhere. // should be moved elsewhere.
std::string relPath = std::string relPath =
cmSystemTools::GetFilenamePath(source->GetSourceName()); cmSystemTools::GetFilenamePath((*source)->GetSourceName());
if(relPath != "") if(relPath != "")
{ {
std::string outPath = m_Makefile->GetCurrentOutputDirectory(); std::string outPath = m_Makefile->GetCurrentOutputDirectory();
@ -1910,22 +1912,22 @@ void cmUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fout)
} }
else else
{ {
sourceName = source->GetFullPath(); sourceName = (*source)->GetFullPath();
shortName = cmSystemTools::GetFilenameName(source->GetSourceName()); shortName = cmSystemTools::GetFilenameName((*source)->GetSourceName());
} }
std::string shortNameWithExt = shortName + std::string shortNameWithExt = shortName +
source->GetSourceExtension(); (*source)->GetSourceExtension();
// Only output a rule for each .o once. // Only output a rule for each .o once.
if(rules.find(shortNameWithExt) == rules.end()) if(rules.find(shortNameWithExt) == rules.end())
{ {
if(source->GetCompileFlags()) if((*source)->GetCompileFlags())
{ {
exportsDef += source->GetCompileFlags(); exportsDef += (*source)->GetCompileFlags();
exportsDef += " "; exportsDef += " ";
} }
this->OutputBuildObjectFromSource(fout, this->OutputBuildObjectFromSource(fout,
shortName.c_str(), shortName.c_str(),
*source, *(*source),
exportsDef.c_str(), exportsDef.c_str(),
shared); shared);
rules.insert(shortNameWithExt); rules.insert(shortNameWithExt);

View File

@ -121,20 +121,20 @@ cmVTKMakeInstantiatorCommand
return false; return false;
} }
std::vector<cmSourceFile>& srcList = srcListIter->second; std::vector<cmSourceFile*>& srcList = srcListIter->second;
// Collect the names of the classes. // Collect the names of the classes.
for(std::vector<cmSourceFile>::iterator src = srcList.begin(); for(std::vector<cmSourceFile*>::iterator src = srcList.begin();
src != srcList.end();++src) src != srcList.end();++src)
{ {
// Wrap-excluded and abstract classes do not have a New() method. // Wrap-excluded and abstract classes do not have a New() method.
// vtkIndent and vtkTimeStamp are special cases and are not // vtkIndent and vtkTimeStamp are special cases and are not
// vtkObject subclasses. // vtkObject subclasses.
if(!src->GetWrapExclude() && !src->GetIsAnAbstractClass() if(!(*src)->GetWrapExclude() && !(*src)->GetIsAnAbstractClass()
&& (src->GetSourceName() != "vtkIndent") && ((*src)->GetSourceName() != "vtkIndent")
&& (src->GetSourceName() != "vtkTimeStamp")) && ((*src)->GetSourceName() != "vtkTimeStamp"))
{ {
m_Classes.push_back(src->GetSourceName()); m_Classes.push_back((*src)->GetSourceName());
} }
} }
} }

View File

@ -50,10 +50,10 @@ bool cmVTKWrapJavaCommand::InitialPass(std::vector<std::string> const& args)
this->SetError("bad source list passed to VTKWrapJavaCommand"); this->SetError("bad source list passed to VTKWrapJavaCommand");
return false; return false;
} }
for(std::vector<cmSourceFile>::iterator i = l->second.begin(); for(std::vector<cmSourceFile*>::iterator i = l->second.begin();
i != l->second.end(); i++) i != l->second.end(); i++)
{ {
cmSourceFile &curr = *i; cmSourceFile &curr = *(*i);
// if we should wrap the class // if we should wrap the class
if (!curr.GetWrapExclude()) if (!curr.GetWrapExclude())
{ {

View File

@ -51,10 +51,10 @@ bool cmVTKWrapPythonCommand::InitialPass(std::vector<std::string> const& args)
this->SetError("bad source list passed to VTKWrapPythonCommand"); this->SetError("bad source list passed to VTKWrapPythonCommand");
return false; return false;
} }
for(std::vector<cmSourceFile>::iterator i = l->second.begin(); for(std::vector<cmSourceFile*>::iterator i = l->second.begin();
i != l->second.end(); i++) i != l->second.end(); i++)
{ {
cmSourceFile &curr = *i; cmSourceFile &curr = *(*i);
// if we should wrap the class // if we should wrap the class
if (!curr.GetWrapExclude()) if (!curr.GetWrapExclude())
{ {

View File

@ -82,10 +82,10 @@ bool cmVTKWrapTclCommand::InitialPass(std::vector<std::string> const& args)
this->SetError("bad source list passed to VTKWrapTclCommand"); this->SetError("bad source list passed to VTKWrapTclCommand");
return false; return false;
} }
for(std::vector<cmSourceFile>::iterator i = l->second.begin(); for(std::vector<cmSourceFile*>::iterator i = l->second.begin();
i != l->second.end(); i++) i != l->second.end(); i++)
{ {
cmSourceFile &curr = *i; cmSourceFile &curr = *(*i);
// if we should wrap the class // if we should wrap the class
if (!curr.GetWrapExclude()) if (!curr.GetWrapExclude())
{ {

View File

@ -32,12 +32,12 @@ bool cmWrapExcludeFilesCommand::InitialPass(std::vector<std::string> const& args
for(cmMakefile::SourceMap::iterator l = Classes.begin(); for(cmMakefile::SourceMap::iterator l = Classes.begin();
l != Classes.end(); l++) l != Classes.end(); l++)
{ {
for(std::vector<cmSourceFile>::iterator i = l->second.begin(); for(std::vector<cmSourceFile*>::iterator i = l->second.begin();
i != l->second.end(); i++) i != l->second.end(); i++)
{ {
if(i->GetSourceName() == (*j)) if((*i)->GetSourceName() == (*j))
{ {
i->SetWrapExclude(true); (*i)->SetWrapExclude(true);
} }
} }
} }

View File

@ -16,6 +16,7 @@
=========================================================================*/ =========================================================================*/
#include "cmaketest.h" #include "cmaketest.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmRegularExpression.h"
#include "cmake.h" #include "cmake.h"
#include "cmListFileCache.h" #include "cmListFileCache.h"
#include "cmMakefileGenerator.h" #include "cmMakefileGenerator.h"
@ -24,13 +25,14 @@
#endif #endif
// this is a test driver program for cmake. // this is a test driver program for cmake.
int main (int argc, char *argv[]) int main (int argc, char **argv)
{ {
if (argc < 4) if (argc < 4)
{ {
std::cerr << "Usage: " << argv[0] << " test-src-dir test-bin-dir test-executable\n"; std::cerr << "Usage: " << argv[0] << " test-src-dir test-bin-dir test-executable\n";
return 1; return 1;
} }
// does the directory exist ? // does the directory exist ?
if (!cmSystemTools::FileIsDirectory(argv[2])) if (!cmSystemTools::FileIsDirectory(argv[2]))
{ {
@ -140,7 +142,11 @@ int main (int argc, char *argv[])
makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str()); makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str());
std::string lowerCaseCommand = makeCommand; std::string lowerCaseCommand = makeCommand;
cmSystemTools::LowerCase(lowerCaseCommand); cmSystemTools::LowerCase(lowerCaseCommand);
std::string dartMakeCommand = DART_MAKECOMMAND;
std::string buildtype = "Debug";
#ifdef CMAKE_INTDIR
buildtype = CMAKE_INTDIR;
#endif
// if msdev is the make program then do the following // if msdev is the make program then do the following
// MSDEV 6.0 // MSDEV 6.0
if(lowerCaseCommand.find("msdev") != std::string::npos) if(lowerCaseCommand.find("msdev") != std::string::npos)
@ -162,7 +168,8 @@ int main (int argc, char *argv[])
#endif #endif
makeCommand += " "; makeCommand += " ";
makeCommand += projectName; makeCommand += projectName;
makeCommand += ".dsw /MAKE \"ALL_BUILD - Debug\" /REBUILD"; makeCommand += ".dsw /MAKE \"ALL_BUILD - ";
makeCommand += buildtype + "\" /REBUILD";
} }
// MSDEV 7.0 .NET // MSDEV 7.0 .NET
else if (lowerCaseCommand.find("devenv") != std::string::npos) else if (lowerCaseCommand.find("devenv") != std::string::npos)
@ -181,7 +188,8 @@ int main (int argc, char *argv[])
#endif #endif
makeCommand += " "; makeCommand += " ";
makeCommand += projectName; makeCommand += projectName;
makeCommand += ".sln /rebuild Debug /project ALL_BUILD"; makeCommand += ".sln /rebuild ";
makeCommand += buildtype + " /project ALL_BUILD";
} }
// command line make program // command line make program
else else
@ -228,7 +236,7 @@ int main (int argc, char *argv[])
fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
} }
// try the Debug extension // try the Debug extension
tryPath = "Debug/"; tryPath = buildtype + "/";
tryPath += cmSystemTools::GetFilenameName(executableName); tryPath += cmSystemTools::GetFilenameName(executableName);
if(cmSystemTools::FileExists(tryPath.c_str())) if(cmSystemTools::FileExists(tryPath.c_str()))
{ {
@ -248,7 +256,8 @@ int main (int argc, char *argv[])
fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); fullPath = cmSystemTools::CollapseFullPath(tryPath.c_str());
} }
tryPath = executableDirectory; tryPath = executableDirectory;
tryPath += "/Debug/"; tryPath += "/";
tryPath += buildtype + "/";
tryPath += executableName; tryPath += executableName;
tryPath += cmSystemTools::GetExecutableExtension(); tryPath += cmSystemTools::GetExecutableExtension();
if(cmSystemTools::FileExists(tryPath.c_str())) if(cmSystemTools::FileExists(tryPath.c_str()))

View File

@ -1,3 +1,4 @@
#define CMAKE_COMMAND "${CMAKE_COMMAND}" #define CMAKE_COMMAND "${CMAKE_COMMAND}"
#define MAKEPROGRAM "${MAKEPROGRAM}" #define MAKEPROGRAM "${MAKEPROGRAM}"
#define CMAKE_GENERATOR "${CMAKE_GENERATOR}" #define CMAKE_GENERATOR "${CMAKE_GENERATOR}"
#define DART_MAKECOMMAND "${MAKECOMMAND}"