diff options
author | Ken Martin <ken.martin@kitware.com> | 2004-12-03 14:05:07 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2004-12-03 14:05:07 (GMT) |
commit | b1c5f1a7ba343178628dee6217d0059efa691522 (patch) | |
tree | 078dca9d6c19af42f623cfccc9c51ce1ec5af70f /Source/cmMakefile.cxx | |
parent | 82ec50f83fb787de800b40ef6c25bb4916eb316a (diff) | |
download | CMake-b1c5f1a7ba343178628dee6217d0059efa691522.zip CMake-b1c5f1a7ba343178628dee6217d0059efa691522.tar.gz CMake-b1c5f1a7ba343178628dee6217d0059efa691522.tar.bz2 |
ENH: fix for relative paths
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3187c4b..c6c8541 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1884,7 +1884,8 @@ cmSourceFile* cmMakefile::GetSource(const char* sourceName) const for(std::vector<cmSourceFile*>::const_iterator i = m_SourceFiles.begin(); i != m_SourceFiles.end(); ++i) { - if ((*i)->GetSourceName() == sname && + if (cmSystemTools::GetFilenameWithoutLastExtension((*i)->GetFullPath()) + == sname && cmSystemTools::GetFilenamePath((*i)->GetFullPath()) == path && (ext.size() == 0 || (ext == (*i)->GetSourceExtension()))) { @@ -2000,10 +2001,30 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName, } else { - file.SetName(cmSystemTools::GetFilenameName(src.c_str()).c_str(), - path.c_str(), - this->GetSourceExtensions(), - this->GetHeaderExtensions()); + std::string relPath = cmSystemTools::GetFilenamePath(sourceName); + if (relative && relPath.size()) + { + // we need to keep the relative part of the filename + std::string fullPathLessRel = path; + std::string::size_type pos = fullPathLessRel.rfind(relPath); + if (pos == std::string::npos) + { + cmSystemTools::Error( + "CMake failed to properly look up relative cmSourceFile: ", + sourceName); + } + fullPathLessRel.erase(pos-1); + file.SetName(sourceName, fullPathLessRel.c_str(), + this->GetSourceExtensions(), + this->GetHeaderExtensions()); + } + else + { + 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); |