diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2012-02-19 21:38:10 (GMT) |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2012-02-19 23:20:03 (GMT) |
commit | a1a30340a2eb0174f9f6911ee1e2cf4a36eaac96 (patch) | |
tree | cc1903a317419d0fc35505bee3e50647ffe67ba1 | |
parent | 21997cea4d8694077e8bcf9ba4cbd3d96a3f163c (diff) | |
download | CMake-a1a30340a2eb0174f9f6911ee1e2cf4a36eaac96.zip CMake-a1a30340a2eb0174f9f6911ee1e2cf4a36eaac96.tar.gz CMake-a1a30340a2eb0174f9f6911ee1e2cf4a36eaac96.tar.bz2 |
Ninja: Import library support for Windows
-rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 1 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 21 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 13 |
3 files changed, 18 insertions, 17 deletions
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 687dbb8..ea03cbb 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -31,6 +31,7 @@ cmLocalNinjaGenerator::cmLocalNinjaGenerator() #ifdef _WIN32 this->WindowsShell = true; #endif + this->TargetImplib = "$TARGET_IMPLIB"; } //---------------------------------------------------------------------------- diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 66714e9..9294a01 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -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()); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 1a8d13d..8a563b6 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -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; } |