Build object library targets in Makefiles
Treat OBJECT libraries as STATIC libraries but leave out the archive step. The object files will be left behind for reference by other targets later.
This commit is contained in:
parent
b87d7a60a0
commit
3aa741acb6
|
@ -411,6 +411,7 @@ void cmGlobalUnixMakefileGenerator3
|
|||
(l->second.GetType() == cmTarget::STATIC_LIBRARY) ||
|
||||
(l->second.GetType() == cmTarget::SHARED_LIBRARY) ||
|
||||
(l->second.GetType() == cmTarget::MODULE_LIBRARY) ||
|
||||
(l->second.GetType() == cmTarget::OBJECT_LIBRARY) ||
|
||||
(l->second.GetType() == cmTarget::UTILITY))
|
||||
{
|
||||
std::string tname = lg->GetRelativeTargetDirectory(l->second);
|
||||
|
@ -446,6 +447,7 @@ cmGlobalUnixMakefileGenerator3
|
|||
(l->second.GetType() == cmTarget::STATIC_LIBRARY) ||
|
||||
(l->second.GetType() == cmTarget::SHARED_LIBRARY) ||
|
||||
(l->second.GetType() == cmTarget::MODULE_LIBRARY) ||
|
||||
(l->second.GetType() == cmTarget::OBJECT_LIBRARY) ||
|
||||
(l->second.GetType() == cmTarget::UTILITY))
|
||||
{
|
||||
// Add this to the list of depends rules in this directory.
|
||||
|
@ -620,6 +622,7 @@ cmGlobalUnixMakefileGenerator3
|
|||
(t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
|
||||
(t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
|
||||
(t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
|
||||
(t->second.GetType() == cmTarget::OBJECT_LIBRARY) ||
|
||||
(t->second.GetType() == cmTarget::UTILITY)))
|
||||
{
|
||||
// Add a rule to build the target by name.
|
||||
|
@ -706,6 +709,7 @@ cmGlobalUnixMakefileGenerator3
|
|||
|| (t->second.GetType() == cmTarget::STATIC_LIBRARY)
|
||||
|| (t->second.GetType() == cmTarget::SHARED_LIBRARY)
|
||||
|| (t->second.GetType() == cmTarget::MODULE_LIBRARY)
|
||||
|| (t->second.GetType() == cmTarget::OBJECT_LIBRARY)
|
||||
|| (t->second.GetType() == cmTarget::UTILITY)))
|
||||
{
|
||||
std::string makefileName;
|
||||
|
@ -1015,6 +1019,7 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule
|
|||
(t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
|
||||
(t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
|
||||
(t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
|
||||
(t->second.GetType() == cmTarget::OBJECT_LIBRARY) ||
|
||||
(t->second.GetType() == cmTarget::GLOBAL_TARGET) ||
|
||||
(t->second.GetType() == cmTarget::UTILITY))
|
||||
{
|
||||
|
|
|
@ -358,6 +358,7 @@ void cmLocalUnixMakefileGenerator3
|
|||
(t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
|
||||
(t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
|
||||
(t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
|
||||
(t->second.GetType() == cmTarget::OBJECT_LIBRARY) ||
|
||||
(t->second.GetType() == cmTarget::UTILITY))
|
||||
{
|
||||
emitted.insert(t->second.GetName());
|
||||
|
|
|
@ -101,6 +101,9 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
|
|||
this->WriteModuleLibraryRules(true);
|
||||
}
|
||||
break;
|
||||
case cmTarget::OBJECT_LIBRARY:
|
||||
this->WriteObjectLibraryRules();
|
||||
break;
|
||||
default:
|
||||
// If language is not known, this is an error.
|
||||
cmSystemTools::Error("Unknown Library Type");
|
||||
|
@ -121,6 +124,29 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
|
|||
this->CloseFileStreams();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
|
||||
{
|
||||
std::vector<std::string> commands;
|
||||
std::vector<std::string> depends;
|
||||
|
||||
// Add post-build rules.
|
||||
this->LocalGenerator->
|
||||
AppendCustomCommands(commands, this->Target->GetPostBuildCommands(),
|
||||
this->Target);
|
||||
|
||||
// Depend on the object files.
|
||||
this->AppendObjectDepends(depends);
|
||||
|
||||
// Write the rule.
|
||||
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
|
||||
this->Target->GetName(),
|
||||
depends, commands, true);
|
||||
|
||||
// Write the main driver rule to build everything in this target.
|
||||
this->WriteTargetDriverRule(this->Target->GetName(), false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
virtual void WriteRuleFiles();
|
||||
|
||||
protected:
|
||||
void WriteObjectLibraryRules();
|
||||
void WriteStaticLibraryRules();
|
||||
void WriteSharedLibraryRules(bool relink);
|
||||
void WriteModuleLibraryRules(bool relink);
|
||||
|
|
|
@ -65,6 +65,7 @@ cmMakefileTargetGenerator::New(cmTarget *tgt)
|
|||
case cmTarget::STATIC_LIBRARY:
|
||||
case cmTarget::SHARED_LIBRARY:
|
||||
case cmTarget::MODULE_LIBRARY:
|
||||
case cmTarget::OBJECT_LIBRARY:
|
||||
result = new cmMakefileLibraryTargetGenerator(tgt);
|
||||
break;
|
||||
case cmTarget::UTILITY:
|
||||
|
@ -1596,7 +1597,7 @@ void cmMakefileTargetGenerator
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmMakefileTargetGenerator
|
||||
::AppendLinkDepends(std::vector<std::string>& depends)
|
||||
::AppendObjectDepends(std::vector<std::string>& depends)
|
||||
{
|
||||
// Add dependencies on the compiled object files.
|
||||
std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath();
|
||||
|
@ -1609,19 +1610,6 @@ void cmMakefileTargetGenerator
|
|||
depends.push_back(objTarget);
|
||||
}
|
||||
|
||||
// Add dependencies on targets that must be built first.
|
||||
this->AppendTargetDepends(depends);
|
||||
|
||||
// Add a dependency on the rule file itself.
|
||||
this->LocalGenerator->AppendRuleDepend(depends,
|
||||
this->BuildFileNameFull.c_str());
|
||||
|
||||
// Add a dependency on the link definitions file, if any.
|
||||
if(!this->GeneratorTarget->ModuleDefinitionFile.empty())
|
||||
{
|
||||
depends.push_back(this->GeneratorTarget->ModuleDefinitionFile);
|
||||
}
|
||||
|
||||
// Add dependencies on the external object files.
|
||||
for(std::vector<std::string>::const_iterator obj
|
||||
= this->ExternalObjects.begin();
|
||||
|
@ -1630,6 +1618,26 @@ void cmMakefileTargetGenerator
|
|||
depends.push_back(*obj);
|
||||
}
|
||||
|
||||
// Add a dependency on the rule file itself.
|
||||
this->LocalGenerator->AppendRuleDepend(depends,
|
||||
this->BuildFileNameFull.c_str());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmMakefileTargetGenerator
|
||||
::AppendLinkDepends(std::vector<std::string>& depends)
|
||||
{
|
||||
this->AppendObjectDepends(depends);
|
||||
|
||||
// Add dependencies on targets that must be built first.
|
||||
this->AppendTargetDepends(depends);
|
||||
|
||||
// Add a dependency on the link definitions file, if any.
|
||||
if(!this->GeneratorTarget->ModuleDefinitionFile.empty())
|
||||
{
|
||||
depends.push_back(this->GeneratorTarget->ModuleDefinitionFile);
|
||||
}
|
||||
|
||||
// Add user-specified dependencies.
|
||||
if(const char* linkDepends =
|
||||
this->Target->GetProperty("LINK_DEPENDS"))
|
||||
|
|
|
@ -118,6 +118,9 @@ protected:
|
|||
// append intertarget dependencies
|
||||
void AppendTargetDepends(std::vector<std::string>& depends);
|
||||
|
||||
// Append object file dependencies.
|
||||
void AppendObjectDepends(std::vector<std::string>& depends);
|
||||
|
||||
// Append link rule dependencies (objects, etc.).
|
||||
void AppendLinkDepends(std::vector<std::string>& depends);
|
||||
|
||||
|
|
Loading…
Reference in New Issue