Skip to content
Snippets Groups Projects
Commit 70c65ea0 authored by Ken Martin's avatar Ken Martin
Browse files

bug fix for finding source files

parent 590460aa
No related branches found
No related tags found
No related merge requests found
......@@ -1710,11 +1710,13 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName,
// make it a full path first
std::string src = sourceName;
bool relative = !cmSystemTools::FileIsFullPath(sourceName);
std::string srcTreeFile = this->GetCurrentDirectory();
srcTreeFile += "/";
srcTreeFile += sourceName;
if(relative)
{
src = this->GetCurrentDirectory();
src += "/";
src += sourceName;
src = srcTreeFile;
}
// 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
// maybe we made a bad call on assuming it was in the src tree
std::string buildTreeFile = this->GetCurrentOutputDirectory();
buildTreeFile += "/";
buildTreeFile += sourceName;
if (relative)
{
src = this->GetCurrentOutputDirectory();
src += "/";
src += sourceName;
}
ret = this->GetSource(src.c_str());
if (ret)
{
return ret;
src = buildTreeFile;
ret = this->GetSource(src.c_str());
if (ret)
{
return ret;
}
// if it has not been marked generated check to see if it exists in the
// 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
if(relative)
{
src = this->GetCurrentDirectory();
src += "/";
src += sourceName;
}
// we must create one
cmSourceFile file;
std::string path = cmSystemTools::GetFilenamePath(src);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment