summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2007-06-18 15:59:23 (GMT)
committerBrad King <brad.king@kitware.com>2007-06-18 15:59:23 (GMT)
commit35936433e11728397dcdb2beab615674bfa79ec7 (patch)
tree8222a4daea955055c852d6db058421a570a8f6b2 /Source/cmLocalGenerator.cxx
parentef81ac50e5d6e981088c00e822fde538d9da9e37 (diff)
downloadCMake-35936433e11728397dcdb2beab615674bfa79ec7.zip
CMake-35936433e11728397dcdb2beab615674bfa79ec7.tar.gz
CMake-35936433e11728397dcdb2beab615674bfa79ec7.tar.bz2
ENH: Merging changes from branch CMake-SourceFile2-b between tags
CMake-SourceFile2-bp and CMake-SourceFile2-b-mp1 to trunk. This commit is surrounded by tags CMake-SourceFile2-b-mp1-pre and CMake-SourceFile2-b-mp1-post on the trunk. The changes re-implement cmSourceFile and the use of it to allow instances to be created much earlier. The use of cmSourceFileLocation allows locating a source file referenced by a user to be much simpler and more robust. The two SetName methods are no longer needed so some duplicate code has been removed. The strange "SourceName" stuff is gone. Code that created cmSourceFile instances on the stack and then sent them to cmMakefile::AddSource has been simplified and converted to getting cmSourceFile instances from cmMakefile. The CPluginAPI has preserved the old API through a compatibility interface. Source lists are gone. Targets now get real instances of cmSourceFile right away instead of storing a list of strings until the final pass. TraceVSDependencies has been re-written to avoid the use of SourceName. It is now called TraceDependencies since it is not just for VS. It is now implemented with a helper object which makes the code simpler.
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r--Source/cmLocalGenerator.cxx66
1 files changed, 26 insertions, 40 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 8f2bcca..222e608 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -147,12 +147,12 @@ void cmLocalGenerator::TraceDependencies()
// so don't build a projectfile for it
if (strncmp(t->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0)
{
- std::string projectFilename;
+ const char* projectFilename = 0;
if (this->IsMakefileGenerator == false) // only use of this variable
{
- projectFilename=t->second.GetName();
+ projectFilename = t->second.GetName();
}
- t->second.TraceVSDependencies(projectFilename, this->Makefile);
+ t->second.TraceDependencies(projectFilename);
}
}
}
@@ -625,18 +625,21 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
std::vector<cmSourceFile*> const& classes = target.GetSourceFiles();
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); ++i)
- {
- if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY") &&
- !(*i)->GetCustomCommand())
+ {
+ cmSourceFile* sf = *i;
+ if(!sf->GetCustomCommand() &&
+ !sf->GetPropertyAsBool("HEADER_FILE_ONLY") &&
+ !sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
{
- std::string outExt =
- this->GlobalGenerator->GetLanguageOutputExtensionFromExtension(
- (*i)->GetSourceExtension().c_str());
- if(outExt.size() && !(*i)->GetPropertyAsBool("EXTERNAL_OBJECT") )
+ std::string::size_type dir_len = 0;
+ dir_len += strlen(this->Makefile->GetCurrentOutputDirectory());
+ dir_len += 1;
+ std::string obj = this->GetObjectFileNameWithoutTarget(*sf, dir_len);
+ if(!obj.empty())
{
std::string ofname = this->Makefile->GetCurrentOutputDirectory();
ofname += "/";
- ofname += (*i)->GetSourceName() + outExt;
+ ofname += obj;
objVector.push_back(ofname);
this->AddCustomCommandToCreateObject(ofname.c_str(),
llang, *(*i), target);
@@ -1358,11 +1361,12 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
i != sources.end(); ++i)
{
- if((*i)->GetSourceExtension() == "def")
+ cmSourceFile* sf = *i;
+ if(sf->GetExtension() == "def")
{
linkFlags +=
this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
- linkFlags += this->Convert((*i)->GetFullPath().c_str(),
+ linkFlags += this->Convert(sf->GetFullPath().c_str(),
START_OUTPUT, SHELL);
linkFlags += " ";
}
@@ -2672,23 +2676,18 @@ cmLocalGenerator
// 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.GetPropertyAsBool("KEEP_EXTENSION"))
{
- if ( !source.GetSourceExtension().empty() )
+ // Remove the original extension.
+ std::string::size_type dot_pos = objectName.rfind(".");
+ if(dot_pos != std::string::npos)
{
- objectName += "." + source.GetSourceExtension();
+ objectName = objectName.substr(0, dot_pos);
}
- }
- else
- {
+
+ // Store the new extension.
objectName +=
- this->GlobalGenerator->GetLanguageOutputExtensionFromExtension(
- source.GetSourceExtension().c_str());
+ this->GlobalGenerator->GetLanguageOutputExtension(source);
}
// Convert to a safe name.
@@ -2700,15 +2699,7 @@ const char*
cmLocalGenerator
::GetSourceFileLanguage(const cmSourceFile& source)
{
- // Check for an explicitly assigned language.
- if(const char* lang = source.GetProperty("LANGUAGE"))
- {
- return lang;
- }
-
- // Infer the language from the source file extension.
- return (this->GlobalGenerator
- ->GetLanguageFromExtension(source.GetSourceExtension().c_str()));
+ return source.GetLanguage();
}
//----------------------------------------------------------------------------
@@ -2784,8 +2775,3 @@ cmLocalGenerator::GetTargetObjectFileDirectories(cmTarget* ,
cmSystemTools::Error("GetTargetObjectFileDirectories"
" called on cmLocalGenerator");
}
-
-std::string cmLocalGenerator::GetSourceObjectName(cmSourceFile& sf)
-{
- return sf.GetSourceName();
-}