diff options
author | Brad King <brad.king@kitware.com> | 2006-07-11 15:41:38 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-07-11 15:41:38 (GMT) |
commit | 9bf5af6e32570195b06df594c1cb07f8c7a6a83e (patch) | |
tree | ad72b8722793ae974c26b9b2138547f3cab62aae /Source/cmLocalUnixMakefileGenerator3.cxx | |
parent | c05b8fb993a4e92fded0d735a66063bb8b265630 (diff) | |
download | CMake-9bf5af6e32570195b06df594c1cb07f8c7a6a83e.zip CMake-9bf5af6e32570195b06df594c1cb07f8c7a6a83e.tar.gz CMake-9bf5af6e32570195b06df594c1cb07f8c7a6a83e.tar.bz2 |
ENH: Moved unique object file name computation from cmLocalUnixMakefileGenerator3 up to cmLocalGenerator for use by all generators. Created cmLocalVisualStudioGenerator as superclass for all VS generators. Implemented on-demand unique object file name computation for VS 7 generator to avoid slow compiles when all sources are in subdirectories.
Diffstat (limited to 'Source/cmLocalUnixMakefileGenerator3.cxx')
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 118 |
1 files changed, 4 insertions, 114 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index dca1669..2252c16 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1062,75 +1062,6 @@ std::string cmLocalUnixMakefileGenerator3 } //---------------------------------------------------------------------------- -std::string& -cmLocalUnixMakefileGenerator3::CreateSafeUniqueObjectFileName(const char* sin) -{ - // Look for an existing mapped name for this object file. - std::map<cmStdString,cmStdString>::iterator it = - this->UniqueObjectNamesMap.find(sin); - - // If no entry exists create one. - if(it == this->UniqueObjectNamesMap.end()) - { - // Start with the original name. - 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. - cmSystemTools::ReplaceString(ssin, "../", "__/"); - - // Avoid spaces. - cmSystemTools::ReplaceString(ssin, " ", "_"); - - // Mangle the name if necessary. - if(this->Makefile->IsOn("CMAKE_MANGLE_OBJECT_FILE_NAMES")) - { - bool done; - int cc = 0; - char rpstr[100]; - sprintf(rpstr, "_p_"); - cmSystemTools::ReplaceString(ssin, "+", rpstr); - std::string sssin = sin; - do - { - done = true; - for ( it = this->UniqueObjectNamesMap.begin(); - it != this->UniqueObjectNamesMap.end(); - ++ it ) - { - if ( it->second == ssin ) - { - done = false; - } - } - if ( done ) - { - break; - } - sssin = ssin; - cmSystemTools::ReplaceString(ssin, "_p_", rpstr); - sprintf(rpstr, "_p%d_", cc++); - } - while ( !done ); - } - - // Insert the newly mapped object file name. - std::map<cmStdString, cmStdString>::value_type e(sin, ssin); - it = this->UniqueObjectNamesMap.insert(e).first; - } - - // Return the map entry. - return it->second; -} - -//---------------------------------------------------------------------------- std::string cmLocalUnixMakefileGenerator3 ::CreateMakeVariable(const char* sin, const char* s2in) @@ -1707,50 +1638,13 @@ cmLocalUnixMakefileGenerator3 const cmSourceFile& source, std::string* nameWithoutTargetDir) { - // If the source file is located below the current binary directory - // then use that relative path for the object file name. - std::string objectName = this->Convert(source.GetFullPath().c_str(), - START_OUTPUT); - if(cmSystemTools::FileIsFullPath(objectName.c_str()) || - objectName.empty() || objectName[0] == '.') - { - // If the source file is located below the current source - // directory then use that relative path for the object file name. - // Otherwise just use the relative path from the current binary - // directory. - std::string relFromSource = this->Convert(source.GetFullPath().c_str(), - START); - if(!cmSystemTools::FileIsFullPath(relFromSource.c_str()) && - !relFromSource.empty() && relFromSource[0] != '.') - { - objectName = relFromSource; - } - } - - // Replace the original source file extension with the object file - // extension. - std::string::size_type dot_pos = objectName.rfind("."); - if(dot_pos != std::string::npos) - { - objectName = objectName.substr(0, dot_pos); - } - if ( source.GetPropertyAsBool("KEEP_EXTENSION") ) - { - if ( !source.GetSourceExtension().empty() ) - { - objectName += "." + source.GetSourceExtension(); - } - } - else + // Get the object file name independent of target. + std::string objectName = this->GetObjectFileNameWithoutTarget(source); + if(nameWithoutTargetDir) { - objectName += - this->GlobalGenerator->GetLanguageOutputExtensionFromExtension( - source.GetSourceExtension().c_str()); + *nameWithoutTargetDir = objectName; } - // Convert to a safe name. - objectName = this->CreateSafeUniqueObjectFileName(objectName.c_str()); - // Prepend the target directory. std::string obj; const char* fileTargetDirectory = @@ -1788,10 +1682,6 @@ cmLocalUnixMakefileGenerator3 } obj += "/"; obj += objectName; - if(nameWithoutTargetDir) - { - *nameWithoutTargetDir = objectName; - } return obj; } |