Ninja: Import library support for Windows
This commit is contained in:
parent
21997cea4d
commit
a1a30340a2
|
@ -31,6 +31,7 @@ cmLocalNinjaGenerator::cmLocalNinjaGenerator()
|
|||
#ifdef _WIN32
|
||||
this->WindowsShell = true;
|
||||
#endif
|
||||
this->TargetImplib = "$TARGET_IMPLIB";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
@ -172,10 +172,6 @@ cmNinjaNormalTargetGenerator
|
|||
i != linkCmds.end();
|
||||
++i)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// TODO TARGET_IMPLIB is empty
|
||||
cmSystemTools::ReplaceString(*i, "/implib:", "");
|
||||
#endif
|
||||
this->GetLocalGenerator()->ExpandRuleVariables(*i, vars);
|
||||
}
|
||||
linkCmds.insert(linkCmds.begin(), "$PRE_LINK");
|
||||
|
@ -314,6 +310,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
|||
this->GetTarget()->GetFullPath(this->GetConfigName(),
|
||||
/*implib=*/false,
|
||||
/*realpath=*/true).c_str());
|
||||
std::string targetOutputImplib = ConvertToNinjaPath(
|
||||
this->GetTarget()->GetFullPath(this->GetConfigName(),
|
||||
/*implib=*/true).c_str());
|
||||
|
||||
// Compute the comment.
|
||||
std::ostringstream comment;
|
||||
|
@ -357,6 +356,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
|||
}
|
||||
}
|
||||
|
||||
if (!this->TargetNameImport.empty()) {
|
||||
vars["TARGET_IMPLIB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
|
||||
targetOutputImplib.c_str(), cmLocalGenerator::SHELL);
|
||||
}
|
||||
|
||||
std::vector<cmCustomCommand> *cmdLists[3] = {
|
||||
&this->GetTarget()->GetPreBuildCommands(),
|
||||
&this->GetTarget()->GetPreLinkCommands(),
|
||||
|
@ -434,6 +438,15 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
|||
}
|
||||
}
|
||||
|
||||
if (!this->TargetNameImport.empty()) {
|
||||
// Since using multiple outputs would mess up the $out variable, use an
|
||||
// alias for the import library.
|
||||
cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(),
|
||||
"Alias for import library.",
|
||||
cmNinjaDeps(1, targetOutputImplib),
|
||||
cmNinjaDeps(1, targetOutputReal));
|
||||
}
|
||||
|
||||
// Add aliases for the file name and the target name.
|
||||
this->GetGlobalGenerator()->AddTargetAlias(this->TargetNameOut,
|
||||
this->GetTarget());
|
||||
|
|
|
@ -223,22 +223,9 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
|
|||
if(!cli)
|
||||
return cmNinjaDeps();
|
||||
|
||||
|
||||
#ifndef _WIN32
|
||||
const std::vector<std::string> &deps = cli->GetDepends();
|
||||
cmNinjaDeps result(deps.size());
|
||||
std::transform(deps.begin(), deps.end(), result.begin(), MapToNinjaPath());
|
||||
#else
|
||||
// TODO The ninja generator misses a lot on Windows.
|
||||
// This hack avoids a problem when a Dll is build:
|
||||
// It builds the .dll but uses the .lib which is then unknown to ninja.
|
||||
cmNinjaDeps result;
|
||||
for(unsigned i = 0; i < cli->GetItems().size(); ++i) {
|
||||
if( cli->GetItems()[i].Target ) {
|
||||
result.push_back( cli->GetItems()[i].Target->GetName() );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue