summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2003-06-05 18:40:25 (GMT)
committerKen Martin <ken.martin@kitware.com>2003-06-05 18:40:25 (GMT)
commit703242071f022b211253c68e434ec20e0c58e637 (patch)
tree2db84d24d340300c61f0b0b8de8bf2941a944e34 /Source
parentd5d0f17e5cb4eea7af9940daefbf8d55df964456 (diff)
downloadCMake-703242071f022b211253c68e434ec20e0c58e637.zip
CMake-703242071f022b211253c68e434ec20e0c58e637.tar.gz
CMake-703242071f022b211253c68e434ec20e0c58e637.tar.bz2
more crazt changes source files now must match with full path
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx6
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx6
-rw-r--r--Source/cmMakefile.cxx82
-rw-r--r--Source/cmTarget.cxx14
4 files changed, 69 insertions, 39 deletions
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index 5aa9e47..055ac3a 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -281,7 +281,11 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
name += ".";
name += outsf->GetSourceExtension();
}
- srcFilesToProcess.push(name);
+ std::string temp =
+ cmSystemTools::GetFilenamePath(outsf->GetFullPath());
+ temp += "/";
+ temp += name;
+ srcFilesToProcess.push(temp);
}
// add its dependencies to the list to check
unsigned int i;
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 5e4b5cd..56b3e91 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -705,7 +705,11 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
name += ".";
name += outsf->GetSourceExtension();
}
- srcFilesToProcess.push(name);
+ std::string temp =
+ cmSystemTools::GetFilenamePath(outsf->GetFullPath());
+ temp += "/";
+ temp += name;
+ srcFilesToProcess.push(temp);
}
// add its dependencies to the list to check
unsigned int i;
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index a9db9a6..0aacb35 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1625,7 +1625,25 @@ cmData* cmMakefile::LookupData(const char* name) const
cmSourceFile* cmMakefile::GetSource(const char* sourceName) const
{
- std::string s = cmSystemTools::GetFilenameName(sourceName);
+ // if the source is provided with a full path use it, otherwise
+ // by default it is in the current source dir
+ std::string path = cmSystemTools::GetFilenamePath(sourceName);
+ std::string s = sourceName;
+ if (path.empty())
+ {
+ s = this->GetCurrentDirectory();
+ s += "/";
+ s += cmSystemTools::GetFilenameName(sourceName);
+ path = this->GetCurrentDirectory();
+ }
+ std::string sname =
+ cmSystemTools::GetFilenameWithoutLastExtension(s);
+
+ /* unfortunately old CMakeList files sometimes use sources with providing
+ * their extensions. If this is the case then we must
+ */
+
+ // compute the extension
std::string ext;
ext = cmSystemTools::GetFilenameLastExtension(s);
s = s.substr(0, s.length()-ext.length());
@@ -1633,15 +1651,15 @@ cmSourceFile* cmMakefile::GetSource(const char* sourceName) const
{
ext = ext.substr(1);
}
+
for(std::vector<cmSourceFile*>::const_iterator i = m_SourceFiles.begin();
i != m_SourceFiles.end(); ++i)
{
- if ((*i)->GetSourceName() == s)
+ if (cmSystemTools::GetFilenamePath((*i)->GetFullPath()) == path &&
+ (*i)->GetSourceName() == sname &&
+ (ext.size() == 0 || (ext == (*i)->GetSourceExtension())))
{
- if ((ext.size() == 0 || (ext == (*i)->GetSourceExtension())))
- {
- return *i;
- }
+ return *i;
}
}
return 0;
@@ -1650,58 +1668,48 @@ cmSourceFile* cmMakefile::GetSource(const char* sourceName) const
cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName,
bool generated)
{
+ // make it a full path first
+ std::string path = cmSystemTools::GetFilenamePath(sourceName);
+ std::string src = sourceName;
+ if (path.empty())
+ {
+ src = this->GetCurrentDirectory();
+ src += "/";
+ src += cmSystemTools::GetFilenameName(sourceName);
+ }
+
// check to see if it exists
- cmSourceFile* ret = this->GetSource(sourceName);
+ cmSourceFile* ret = this->GetSource(src.c_str());
if (ret)
{
return ret;
}
// we must create one
- std::string newfile = sourceName;
cmSourceFile file;
- std::string path = cmSystemTools::GetFilenamePath(newfile);
+ path = cmSystemTools::GetFilenamePath(src);
if(generated)
{
- std::string ext = cmSystemTools::GetFilenameLastExtension(newfile);
- std::string name_no_ext = cmSystemTools::GetFilenameName(newfile.c_str());
+ std::string ext = cmSystemTools::GetFilenameLastExtension(src);
+ std::string name_no_ext = cmSystemTools::GetFilenameName(src.c_str());
name_no_ext = name_no_ext.substr(0, name_no_ext.length()-ext.length());
if ( ext.length() && ext[0] == '.' )
{
ext = ext.substr(1);
}
- if((path.size() && path[0] == '/') ||
- (path.size() > 1 && path[1] == ':'))
- {
- file.SetName(name_no_ext.c_str(), path.c_str(), ext.c_str(), false);
- }
- else
- {
- file.SetName(name_no_ext.c_str(), this->GetCurrentOutputDirectory(),
- ext.c_str(), false);
- }
+ file.SetName(name_no_ext.c_str(), path.c_str(), ext.c_str(), false);
}
else
{
- // if this is a full path then
- if((path.size() && path[0] == '/') ||
- (path.size() > 1 && path[1] == ':'))
- {
- file.SetName(cmSystemTools::GetFilenameName(newfile.c_str()).c_str(),
- path.c_str(),
- this->GetSourceExtensions(),
- this->GetHeaderExtensions());
- }
- else
- {
- file.SetName(newfile.c_str(), this->GetCurrentDirectory(),
- this->GetSourceExtensions(),
- this->GetHeaderExtensions());
- }
+ file.SetName(cmSystemTools::GetFilenameName(src.c_str()).c_str(),
+ path.c_str(),
+ this->GetSourceExtensions(),
+ this->GetHeaderExtensions());
}
// add the source file to the makefile
this->AddSource(file);
- ret = this->GetSource(sourceName);
+ src = file.GetFullPath();
+ ret = this->GetSource(src.c_str());
if (!ret)
{
cmSystemTools::Error(
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 9706ba8..4cb4bb8 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -54,12 +54,26 @@ void cmTarget::GenerateSourceFilesFromSourceLists( cmMakefile &mf)
mf.ExpandVariablesInString(temps);
// Next if one wasn't found then assume it is a single class
+ // check to see if it is an existing source file
if (!done && mf.GetSource(temps.c_str()))
{
m_SourceFiles.push_back(mf.GetSource(temps.c_str()));
done = 1;
}
+ // check to see if it is an existing source file in the output directory
+ if (!done && cmSystemTools::GetFilenamePath(temps).empty())
+ {
+ std::string testName = mf.GetCurrentOutputDirectory();
+ testName += "/";
+ testName += temps;
+ if (mf.GetSource(testName.c_str()))
+ {
+ m_SourceFiles.push_back(mf.GetSource(testName.c_str()));
+ done = 1;
+ }
+ }
+
// if it wasn't a source file listed with the makefile
// see if it is a variable. This is for old CMake 1.2 compatability
// where a source list would be passed into here, by making it