BUG: Avoid full paths and spaces when constructing object file names.

This commit is contained in:
Brad King 2006-03-14 10:14:52 -05:00
parent 6018c27993
commit c332ff41f1
1 changed files with 11 additions and 0 deletions

View File

@ -929,9 +929,20 @@ cmLocalUnixMakefileGenerator3::CreateSafeUniqueObjectFileName(const char* sin)
// Start with the original name. // Start with the original name.
std::string ssin = sin; std::string ssin = sin;
// Avoid full paths by removing leading slashes.
std::string::size_type pos = 0;
for(;pos < ssin.size() && ssin[pos] == '/'; ++pos);
ssin = ssin.substr(pos);
// Avoid full paths by removing colons.
cmSystemTools::ReplaceString(ssin, ":", "_");
// Avoid relative paths that go up the tree. // Avoid relative paths that go up the tree.
cmSystemTools::ReplaceString(ssin, "../", "__/"); cmSystemTools::ReplaceString(ssin, "../", "__/");
// Avoid spaces.
cmSystemTools::ReplaceString(ssin, " ", "_");
// Mangle the name if necessary. // Mangle the name if necessary.
if(m_Makefile->IsOn("CMAKE_MANGLE_OBJECT_FILE_NAMES")) if(m_Makefile->IsOn("CMAKE_MANGLE_OBJECT_FILE_NAMES"))
{ {