From 771bdb7ef84b99f29b87c5424a78daf1d49c9dc7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 12 May 2008 17:43:45 -0400 Subject: BUG: Make sure all source files are found before generating. - Previously this was done implicitly by the check for a target link language which checked all source full paths. - The recent change to support computing a link language without finding all the source files skipped the implicit check. - This change adds an explicit check to find all source files. --- Source/cmGlobalGenerator.cxx | 34 ++++++++++++++++++++++++++++++++++ Source/cmGlobalGenerator.h | 2 ++ Source/cmTarget.cxx | 15 +++++++++++++++ Source/cmTarget.h | 5 +++++ 4 files changed, 56 insertions(+) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b589332..dce60ff 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -764,6 +764,12 @@ void cmGlobalGenerator::Generate() return; } + // Check that all targets are valid. + if(!this->CheckTargets()) + { + return; + } + // For each existing cmLocalGenerator unsigned int i; @@ -850,6 +856,34 @@ void cmGlobalGenerator::Generate() this->CMakeInstance->UpdateProgress("Generating done", -1); } +//---------------------------------------------------------------------------- +bool cmGlobalGenerator::CheckTargets() +{ + // Make sure all targets can find their source files. + for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) + { + cmTargets& targets = + this->LocalGenerators[i]->GetMakefile()->GetTargets(); + for(cmTargets::iterator ti = targets.begin(); + ti != targets.end(); ++ti) + { + cmTarget& target = ti->second; + if(target.GetType() == cmTarget::EXECUTABLE || + target.GetType() == cmTarget::STATIC_LIBRARY || + target.GetType() == cmTarget::SHARED_LIBRARY || + target.GetType() == cmTarget::MODULE_LIBRARY || + target.GetType() == cmTarget::UTILITY) + { + if(!target.FindSourceFiles()) + { + return false; + } + } + } + } + return true; +} + void cmGlobalGenerator::CheckLocalGenerators() { std::map notFoundMap; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 8ea408e..7991a33 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -260,6 +260,8 @@ protected: virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS(); + bool CheckTargets(); + // Fill the ProjectMap, this must be called after LocalGenerators // has been populated. void FillProjectMap(); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1bf3061..70ba7ea 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1006,6 +1006,21 @@ void cmTarget::TraceDependencies(const char* vsProjectFile) } //---------------------------------------------------------------------------- +bool cmTarget::FindSourceFiles() +{ + for(std::vector::const_iterator + si = this->SourceFiles.begin(); + si != this->SourceFiles.end(); ++si) + { + if((*si)->GetFullPath().empty()) + { + return false; + } + } + return true; +} + +//---------------------------------------------------------------------------- void cmTarget::AddSources(std::vector const& srcs) { for(std::vector::const_iterator i = srcs.begin(); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 2bb0f00..af94876 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -271,6 +271,11 @@ public: */ void TraceDependencies(const char* vsProjectFile); + /** + * Make sure the full path to all source files is known. + */ + bool FindSourceFiles(); + ///! Return the prefered linker language for this target const char* GetLinkerLanguage(cmGlobalGenerator*); -- cgit v0.12