ENH: Added RemoveSource(...) to complement AddSource. New command

SOURCE_FILES_REMOVE uses it and can be used to take files out of the build
This commit is contained in:
John Biddiscombe 2001-06-22 09:47:02 -04:00
parent 6bf0be8e13
commit e1e7b8adca
2 changed files with 29 additions and 3 deletions

View File

@ -413,6 +413,27 @@ void cmMakefile::AddSource(cmSourceFile& cmfile, const char *srclist)
m_Sources[srclist].push_back(cmfile); m_Sources[srclist].push_back(cmfile);
} }
struct FindSrcByName : std::binary_function<cmSourceFile, cmSourceFile, bool>
{
public:
bool operator () (const cmSourceFile &f, const cmSourceFile &test) const
{
return !stricmp(f.GetSourceName().c_str(),test.GetSourceName().c_str());
}
};
void cmMakefile::RemoveSource(cmSourceFile& cmfile,const char *srclist)
{
std::vector<cmSourceFile> &maplist = m_Sources[srclist];
std::vector<cmSourceFile>::iterator f =
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())
{
maplist.erase(f);
}
}
void cmMakefile::AddCustomCommand(const char* source, void cmMakefile::AddCustomCommand(const char* source,
const char* command, const char* command,
const char* commandArgs, const char* commandArgs,

View File

@ -232,6 +232,11 @@ public:
*/ */
void AddSource(cmSourceFile& ,const char *srcListName); void AddSource(cmSourceFile& ,const char *srcListName);
/**
* Remove a class/source file from the build.
*/
void RemoveSource(cmSourceFile& ,const char *srcListName);
/** /**
* Add a source group for consideration when adding a new source. * Add a source group for consideration when adding a new source.
*/ */