summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2004-04-18 17:16:34 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2004-04-18 17:16:34 (GMT)
commitaf61b685839fae6af72ba4c4d42ebf39a7d1a324 (patch)
treeae8daed7bba06465eb594297e90a9cb7d0164a33
parent3da0f4940ab84d511e1073122da9be97aac160c8 (diff)
downloadCMake-af61b685839fae6af72ba4c4d42ebf39a7d1a324.zip
CMake-af61b685839fae6af72ba4c4d42ebf39a7d1a324.tar.gz
CMake-af61b685839fae6af72ba4c4d42ebf39a7d1a324.tar.bz2
ENH: Add support for adding object files and sources. This way you can use external program such as assembler or fortran to generate object files. Also star of fixing: Bug #757 - add .o file as a source file
-rw-r--r--Source/cmLocalUnixMakefileGenerator.cxx52
-rw-r--r--Source/cmSourceFile.cxx5
2 files changed, 48 insertions, 9 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator.cxx b/Source/cmLocalUnixMakefileGenerator.cxx
index a51a670..d732cbf 100644
--- a/Source/cmLocalUnixMakefileGenerator.cxx
+++ b/Source/cmLocalUnixMakefileGenerator.cxx
@@ -533,11 +533,28 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
{
std::string outExt(
this->GetOutputExtension((*i)->GetSourceExtension().c_str()));
- if(outExt.size())
+ if(outExt.size() && !(*i)->GetPropertyAsBool("EXTERNAL_OBJECT") )
{
- fout << "\\\n"
- << this->ConvertToMakeTarget(this->ConvertToRelativeOutputPath((*i)->GetSourceName().c_str()).c_str())
- << outExt.c_str() << " ";
+ fout << "\\\n";
+ fout << this->ConvertToMakeTarget(this->ConvertToRelativeOutputPath((*i)->GetSourceName().c_str()).c_str())
+ << outExt.c_str() << " ";
+ }
+ }
+ }
+ fout << "\n\n";
+ fout << this->CreateMakeVariable(l->first.c_str(), "_EXTERNAL_OBJS") << " = ";
+ for(std::vector<cmSourceFile*>::iterator i = classes.begin();
+ i != classes.end(); i++)
+ {
+ if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY") &&
+ !(*i)->GetCustomCommand())
+ {
+ std::string outExt(
+ this->GetOutputExtension((*i)->GetSourceExtension().c_str()));
+ if(outExt.size() && (*i)->GetPropertyAsBool("EXTERNAL_OBJECT") )
+ {
+ fout << "\\\n";
+ fout << this->ConvertToMakeTarget(this->ConvertToRelativeOutputPath((*i)->GetFullPath().c_str()).c_str()) << " ";
}
}
}
@@ -550,7 +567,7 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
!(*i)->GetCustomCommand())
{
std::string outExt(this->GetOutputExtension((*i)->GetSourceExtension().c_str()));
- if(outExt.size())
+ if(outExt.size() && !(*i)->GetPropertyAsBool("EXTERNAL_OBJECT") )
{
fout << "\\\n\"" << this->ConvertToMakeTarget(ConvertToRelativeOutputPath((*i)->GetSourceName().c_str()).c_str())
<< outExt.c_str() << "\" ";
@@ -558,6 +575,21 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
}
}
fout << "\n\n";
+ fout << this->CreateMakeVariable(l->first.c_str(), "_EXTERNAL_OBJS_QUOTED") << " = ";
+ for(std::vector<cmSourceFile*>::iterator i = classes.begin();
+ i != classes.end(); i++)
+ {
+ if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY") &&
+ !(*i)->GetCustomCommand())
+ {
+ std::string outExt(this->GetOutputExtension((*i)->GetSourceExtension().c_str()));
+ if(outExt.size() && (*i)->GetPropertyAsBool("EXTERNAL_OBJECT") )
+ {
+ fout << "\\\n\"" << this->ConvertToMakeTarget(ConvertToRelativeOutputPath((*i)->GetFullPath().c_str()).c_str()) << "\" ";
+ }
+ }
+ }
+ fout << "\n\n";
}
}
@@ -1115,8 +1147,8 @@ void cmLocalUnixMakefileGenerator::OutputLibraryRule(std::ostream& fout,
}
// get the objects that are used to link this library
- std::string objs = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") ";
- std::string objsQuoted = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS_QUOTED") + ") ";
+ std::string objs = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") $(" + this->CreateMakeVariable(name, "_EXTERNAL_OBJS") + ") ";
+ std::string objsQuoted = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS_QUOTED") + ") $(" + this->CreateMakeVariable(name, "_EXTERNAL_OBJS_QUOTED") + ") ";
// create a variable with the objects that this library depends on
std::string depend =
objs + " $(" + this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")";
@@ -1382,9 +1414,10 @@ void cmLocalUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout,
{
needsLocalTarget = true;
}
- std::string objs = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") ";
+ std::string objs = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") $(" + this->CreateMakeVariable(name, "_EXTERNAL_OBJS") + ") ";
std::string depend = "$(";
depend += this->CreateMakeVariable(name, "_SRC_OBJS")
+ + ") $(" + this->CreateMakeVariable(name, "_EXTERNAL_OBJS")
+ ") $(" + this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")";
std::vector<std::string> rules;
linkFlags += this->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS");
@@ -2661,6 +2694,8 @@ OutputBuildObjectFromSource(std::ostream& fout,
return;
case cmSystemTools::DEFINITION_FILE_FORMAT:
return;
+ case cmSystemTools::OBJECT_FILE_FORMAT:
+ return;
case cmSystemTools::RESOURCE_FILE_FORMAT:
{
flags = " $(INCLUDE_FLAGS) ";
@@ -2677,7 +2712,6 @@ OutputBuildObjectFromSource(std::ostream& fout,
case cmSystemTools::STATIC_LIBRARY_FILE_FORMAT:
case cmSystemTools::SHARED_LIBRARY_FILE_FORMAT:
case cmSystemTools::MODULE_FILE_FORMAT:
- case cmSystemTools::OBJECT_FILE_FORMAT:
case cmSystemTools::UNKNOWN_FILE_FORMAT:
cmSystemTools::Error("Unexpected file type ",
sourceFile.c_str());
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 1f45e92..138d5d2 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -73,6 +73,11 @@ void cmSourceFile::SetName(const char* name, const char* dir,
this->SetProperty("HEADER_FILE_ONLY","0");
}
m_FullPath = hname;
+ if ( m_SourceExtension == "obj" || m_SourceExtension == "o" ||
+ m_SourceExtension == "lo" )
+ {
+ this->SetProperty("EXTERNAL_OBJECT", "1");
+ }
return;
}