bug fix for finding source files

This commit is contained in:
Ken Martin 2003-06-19 14:27:39 -04:00
parent 590460aaae
commit 70c65ea016

View File

@ -1710,11 +1710,13 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName,
// make it a full path first // make it a full path first
std::string src = sourceName; std::string src = sourceName;
bool relative = !cmSystemTools::FileIsFullPath(sourceName); bool relative = !cmSystemTools::FileIsFullPath(sourceName);
std::string srcTreeFile = this->GetCurrentDirectory();
srcTreeFile += "/";
srcTreeFile += sourceName;
if(relative) if(relative)
{ {
src = this->GetCurrentDirectory(); src = srcTreeFile;
src += "/";
src += sourceName;
} }
// check to see if it exists // check to see if it exists
@ -1726,24 +1728,51 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName,
// OK a source file object doesn't exist for the source // OK a source file object doesn't exist for the source
// maybe we made a bad call on assuming it was in the src tree // maybe we made a bad call on assuming it was in the src tree
std::string buildTreeFile = this->GetCurrentOutputDirectory();
buildTreeFile += "/";
buildTreeFile += sourceName;
if (relative) if (relative)
{ {
src = this->GetCurrentOutputDirectory(); src = buildTreeFile;
src += "/"; ret = this->GetSource(src.c_str());
src += sourceName; if (ret)
} {
ret = this->GetSource(src.c_str()); return ret;
if (ret) }
{ // if it has not been marked generated check to see if it exists in the
return ret; // src tree
if(!generated)
{
// see if the file is in the source tree, otherwise assume it
// is in the binary tree
if (cmSystemTools::FileExists(srcTreeFile.c_str()) &&
!cmSystemTools::FileIsDirectory(srcTreeFile.c_str()))
{
src = srcTreeFile;
}
else
{
if ( cmSystemTools::GetFilenameLastExtension(srcTreeFile.c_str()).size() == 0)
{
if (cmSystemTools::DoesFileExistWithExtensions(
srcTreeFile.c_str(), this->GetSourceExtensions()))
{
src = srcTreeFile;
}
else if (cmSystemTools::DoesFileExistWithExtensions(
srcTreeFile.c_str(), this->GetHeaderExtensions()))
{
src = srcTreeFile;
}
}
}
}
} }
// a cmSourceFile instance does not exist yet so we must create one
// go back to looking in the source directory for it // go back to looking in the source directory for it
if(relative)
{
src = this->GetCurrentDirectory();
src += "/";
src += sourceName;
}
// we must create one // we must create one
cmSourceFile file; cmSourceFile file;
std::string path = cmSystemTools::GetFilenamePath(src); std::string path = cmSystemTools::GetFilenamePath(src);