From e1e7b8adcafed947de7845b82420634d3b302268 Mon Sep 17 00:00:00 2001 From: John Biddiscombe Date: Fri, 22 Jun 2001 09:47:02 -0400 Subject: [PATCH] ENH: Added RemoveSource(...) to complement AddSource. New command SOURCE_FILES_REMOVE uses it and can be used to take files out of the build --- Source/cmMakefile.cxx | 27 ++++++++++++++++++++++++--- Source/cmMakefile.h | 5 +++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index eedeb4557..acd18c803 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -164,17 +164,17 @@ void cmMakefile::Print() const { // print the class lists std::cout << "classes:\n"; - for(SourceMap::const_iterator l = m_Sources.begin(); + for(SourceMap::const_iterator l = m_Sources.begin(); l != m_Sources.end(); l++) { std::cout << " Class list named: " << l->first << std::endl; - for(std::vector::const_iterator i = l->second.begin(); + for(std::vector::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++) @@ -413,6 +413,27 @@ void cmMakefile::AddSource(cmSourceFile& cmfile, const char *srclist) m_Sources[srclist].push_back(cmfile); } +struct FindSrcByName : std::binary_function +{ + 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 &maplist = m_Sources[srclist]; + std::vector::iterator f = + std::find_if(maplist.begin(), maplist.end(), std::bind2nd(FindSrcByName(),cmfile)); +// std::vector::iterator f = find_if(maplist.begin(), maplist.end(), matches(srclist); + if (f!=maplist.end()) + { + maplist.erase(f); + } +} + void cmMakefile::AddCustomCommand(const char* source, const char* command, const char* commandArgs, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index bce13acc9..d430f0422 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -232,6 +232,11 @@ public: */ 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. */