From 323dc3a89aeadbff9651234b41983f5aabb60d98 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 5 May 2006 11:46:20 -0400 Subject: [PATCH] ENH: Added information about target needing a source file when one cannot be found. --- Source/cmSourceFile.cxx | 29 +++++++++++++++++------------ Source/cmSourceFile.h | 5 +++-- Source/cmTarget.cxx | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 303ff78cc..7ab15baef 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -23,9 +23,10 @@ // The class must be found in dir and end in name.cxx, name.txx, // name.c or it will be considered a header file only class // and not included in the build process -void cmSourceFile::SetName(const char* name, const char* dir, +bool cmSourceFile::SetName(const char* name, const char* dir, const std::vector& sourceExts, - const std::vector& headerExts) + const std::vector& headerExts, + const char* target) { this->SetProperty("HEADER_FILE_ONLY","1"); @@ -79,7 +80,7 @@ void cmSourceFile::SetName(const char* name, const char* dir, { this->SetProperty("EXTERNAL_OBJECT", "1"); } - return; + return true; } // Next, try the various source extensions @@ -94,7 +95,7 @@ void cmSourceFile::SetName(const char* name, const char* dir, this->SourceExtension = *ext; this->SetProperty("HEADER_FILE_ONLY","0"); this->FullPath = hname; - return; + return true; } } @@ -109,25 +110,29 @@ void cmSourceFile::SetName(const char* name, const char* dir, { this->SourceExtension = *ext; this->FullPath = hname; - return; + return true; } } - std::string errorMsg = "\n\nTried"; + cmOStringStream e; + e << "Cannot find source file \"" << pathname << "\""; + if(target) + { + e << " for target \"" << target << "\""; + } + e << "\n\nTried extensions"; for( std::vector::const_iterator ext = sourceExts.begin(); ext != sourceExts.end(); ++ext ) { - errorMsg += " ."; - errorMsg += *ext; + e << " ." << *ext; } for( std::vector::const_iterator ext = headerExts.begin(); ext != headerExts.end(); ++ext ) { - errorMsg += " ."; - errorMsg += *ext; + e << " ." << *ext; } - cmSystemTools::Error("can not find file ", pathname.c_str(), - errorMsg.c_str()); + cmSystemTools::Error(e.str().c_str()); + return false; } void cmSourceFile::SetName(const char* name, const char* dir, const char *ext, diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 656d5f0e4..3f81ea73e 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -46,9 +46,10 @@ public: * in. The various extensions provided are tried on the name * (e.g., cxx, cpp) in the directory to find the actual file. */ - void SetName(const char* name, const char* dir, + bool SetName(const char* name, const char* dir, const std::vector& sourceExts, - const std::vector& headerExts); + const std::vector& headerExts, + const char* target = 0); /** * Get the list of the custom commands for this source file diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index efa20f827..f0132e340 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -299,7 +299,7 @@ void cmTarget::GenerateSourceFilesFromSourceLists( cmMakefile &mf) file.SetProperty("ABSTRACT","0"); file.SetName(temps.c_str(), mf.GetCurrentDirectory(), mf.GetSourceExtensions(), - mf.GetHeaderExtensions()); + mf.GetHeaderExtensions(), this->Name.c_str()); this->SourceFiles.push_back(mf.AddSource(file)); } }