cmNinjaNormalTargetGenerator.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2011 Peter Collingbourne <[email protected]>
  4. Copyright 2011 Nicolas Despres <[email protected]>
  5. Distributed under the OSI-approved BSD License (the "License");
  6. see accompanying file Copyright.txt for details.
  7. This software is distributed WITHOUT ANY WARRANTY; without even the
  8. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. See the License for more information.
  10. ============================================================================*/
  11. #include "cmNinjaNormalTargetGenerator.h"
  12. #include "cmLocalNinjaGenerator.h"
  13. #include "cmGlobalNinjaGenerator.h"
  14. #include "cmSourceFile.h"
  15. #include "cmGeneratedFileStream.h"
  16. #include "cmMakefile.h"
  17. #include <assert.h>
  18. #include <algorithm>
  19. #ifndef _WIN32
  20. #include <unistd.h>
  21. #endif
  22. cmNinjaNormalTargetGenerator::
  23. cmNinjaNormalTargetGenerator(cmTarget* target)
  24. : cmNinjaTargetGenerator(target)
  25. , TargetNameOut()
  26. , TargetNameSO()
  27. , TargetNameReal()
  28. , TargetNameImport()
  29. , TargetNamePDB()
  30. {
  31. this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName());
  32. if (target->GetType() == cmTarget::EXECUTABLE)
  33. target->GetExecutableNames(this->TargetNameOut,
  34. this->TargetNameReal,
  35. this->TargetNameImport,
  36. this->TargetNamePDB,
  37. GetLocalGenerator()->GetConfigName());
  38. else
  39. target->GetLibraryNames(this->TargetNameOut,
  40. this->TargetNameSO,
  41. this->TargetNameReal,
  42. this->TargetNameImport,
  43. this->TargetNamePDB,
  44. GetLocalGenerator()->GetConfigName());
  45. if(target->GetType() != cmTarget::OBJECT_LIBRARY)
  46. {
  47. // on Windows the output dir is already needed at compile time
  48. // ensure the directory exists (OutDir test)
  49. EnsureDirectoryExists(target->GetDirectory(this->GetConfigName()));
  50. }
  51. }
  52. cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator()
  53. {
  54. }
  55. void cmNinjaNormalTargetGenerator::Generate()
  56. {
  57. if (!this->TargetLinkLanguage) {
  58. cmSystemTools::Error("CMake can not determine linker language for target:",
  59. this->GetTarget()->GetName());
  60. return;
  61. }
  62. // Write the rules for each language.
  63. this->WriteLanguagesRules();
  64. // Write the build statements
  65. this->WriteObjectBuildStatements();
  66. if(this->GetTarget()->GetType() == cmTarget::OBJECT_LIBRARY)
  67. {
  68. this->WriteObjectLibStatement();
  69. }
  70. else
  71. {
  72. this->WriteLinkRule(false); // write rule without rspfile support
  73. this->WriteLinkRule(true); // write rule with rspfile support
  74. this->WriteLinkStatement();
  75. }
  76. }
  77. void cmNinjaNormalTargetGenerator::WriteLanguagesRules()
  78. {
  79. #ifdef NINJA_GEN_VERBOSE_FILES
  80. cmGlobalNinjaGenerator::WriteDivider(this->GetRulesFileStream());
  81. this->GetRulesFileStream()
  82. << "# Rules for each languages for "
  83. << cmTarget::GetTargetTypeName(this->GetTarget()->GetType())
  84. << " target "
  85. << this->GetTargetName()
  86. << "\n\n";
  87. #endif
  88. std::set<cmStdString> languages;
  89. this->GetTarget()->GetLanguages(languages);
  90. for(std::set<cmStdString>::const_iterator l = languages.begin();
  91. l != languages.end();
  92. ++l)
  93. this->WriteLanguageRules(*l);
  94. }
  95. const char *cmNinjaNormalTargetGenerator::GetVisibleTypeName() const
  96. {
  97. switch (this->GetTarget()->GetType()) {
  98. case cmTarget::STATIC_LIBRARY:
  99. return "static library";
  100. case cmTarget::SHARED_LIBRARY:
  101. return "shared library";
  102. case cmTarget::MODULE_LIBRARY:
  103. return "shared module";
  104. case cmTarget::EXECUTABLE:
  105. return "executable";
  106. default:
  107. return 0;
  108. }
  109. }
  110. std::string
  111. cmNinjaNormalTargetGenerator
  112. ::LanguageLinkerRule() const
  113. {
  114. return std::string(this->TargetLinkLanguage)
  115. + "_"
  116. + cmTarget::GetTargetTypeName(this->GetTarget()->GetType())
  117. + "_LINKER";
  118. }
  119. void
  120. cmNinjaNormalTargetGenerator
  121. ::WriteLinkRule(bool useResponseFile)
  122. {
  123. cmTarget::TargetType targetType = this->GetTarget()->GetType();
  124. std::string ruleName = this->LanguageLinkerRule();
  125. if (useResponseFile)
  126. ruleName += "_RSPFILE";
  127. // Select whether to use a response file for objects.
  128. std::string rspfile;
  129. std::string rspcontent;
  130. if (!this->GetGlobalGenerator()->HasRule(ruleName)) {
  131. cmLocalGenerator::RuleVariables vars;
  132. vars.RuleLauncher = "RULE_LAUNCH_LINK";
  133. vars.CMTarget = this->GetTarget();
  134. vars.Language = this->TargetLinkLanguage;
  135. std::string responseFlag;
  136. if (!useResponseFile) {
  137. vars.Objects = "$in";
  138. vars.LinkLibraries = "$LINK_LIBRARIES";
  139. } else {
  140. // handle response file
  141. std::string cmakeLinkVar = std::string("CMAKE_") +
  142. this->TargetLinkLanguage + "_RESPONSE_FILE_LINK_FLAG";
  143. const char * flag = GetMakefile()->GetDefinition(cmakeLinkVar.c_str());
  144. if(flag) {
  145. responseFlag = flag;
  146. } else {
  147. responseFlag = "@";
  148. }
  149. rspfile = "$out.rsp";
  150. responseFlag += rspfile;
  151. rspcontent = "$in $LINK_LIBRARIES";
  152. vars.Objects = responseFlag.c_str();
  153. vars.LinkLibraries = "";
  154. }
  155. vars.ObjectDir = "$OBJECT_DIR";
  156. vars.Target = "$out";
  157. vars.SONameFlag = "$SONAME_FLAG";
  158. vars.TargetSOName = "$SONAME";
  159. vars.TargetInstallNameDir = "$INSTALLNAME_DIR";
  160. vars.TargetPDB = "$TARGET_PDB";
  161. // Setup the target version.
  162. std::string targetVersionMajor;
  163. std::string targetVersionMinor;
  164. {
  165. cmOStringStream majorStream;
  166. cmOStringStream minorStream;
  167. int major;
  168. int minor;
  169. this->GetTarget()->GetTargetVersion(major, minor);
  170. majorStream << major;
  171. minorStream << minor;
  172. targetVersionMajor = majorStream.str();
  173. targetVersionMinor = minorStream.str();
  174. }
  175. vars.TargetVersionMajor = targetVersionMajor.c_str();
  176. vars.TargetVersionMinor = targetVersionMinor.c_str();
  177. vars.Flags = "$FLAGS";
  178. vars.LinkFlags = "$LINK_FLAGS";
  179. std::string langFlags;
  180. if (targetType != cmTarget::EXECUTABLE) {
  181. this->GetLocalGenerator()->AddLanguageFlags(langFlags,
  182. this->TargetLinkLanguage,
  183. this->GetConfigName());
  184. langFlags += " $ARCH_FLAGS";
  185. vars.LanguageCompileFlags = langFlags.c_str();
  186. }
  187. // Rule for linking library/executable.
  188. std::vector<std::string> linkCmds = this->ComputeLinkCmd();
  189. for(std::vector<std::string>::iterator i = linkCmds.begin();
  190. i != linkCmds.end();
  191. ++i)
  192. {
  193. this->GetLocalGenerator()->ExpandRuleVariables(*i, vars);
  194. }
  195. linkCmds.insert(linkCmds.begin(), "$PRE_LINK");
  196. linkCmds.push_back("$POST_BUILD");
  197. std::string linkCmd =
  198. this->GetLocalGenerator()->BuildCommandLine(linkCmds);
  199. // Write the linker rule with response file if needed.
  200. cmOStringStream comment;
  201. comment << "Rule for linking " << this->TargetLinkLanguage << " "
  202. << this->GetVisibleTypeName() << ".";
  203. cmOStringStream description;
  204. description << "Linking " << this->TargetLinkLanguage << " "
  205. << this->GetVisibleTypeName() << " $out";
  206. this->GetGlobalGenerator()->AddRule(ruleName,
  207. linkCmd,
  208. description.str(),
  209. comment.str(),
  210. /*depfile*/ "",
  211. rspfile,
  212. rspcontent);
  213. }
  214. if (this->TargetNameOut != this->TargetNameReal) {
  215. std::string cmakeCommand =
  216. this->GetLocalGenerator()->ConvertToOutputFormat(
  217. this->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"),
  218. cmLocalGenerator::SHELL);
  219. if (targetType == cmTarget::EXECUTABLE)
  220. this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_EXECUTABLE",
  221. cmakeCommand +
  222. " -E cmake_symlink_executable"
  223. " $in $out && $POST_BUILD",
  224. "Creating executable symlink $out",
  225. "Rule for creating executable symlink.");
  226. else
  227. this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY",
  228. cmakeCommand +
  229. " -E cmake_symlink_library"
  230. " $in $SONAME $out && $POST_BUILD",
  231. "Creating library symlink $out",
  232. "Rule for creating library symlink.");
  233. }
  234. }
  235. std::vector<std::string>
  236. cmNinjaNormalTargetGenerator
  237. ::ComputeLinkCmd()
  238. {
  239. std::vector<std::string> linkCmds;
  240. cmTarget::TargetType targetType = this->GetTarget()->GetType();
  241. switch (targetType) {
  242. case cmTarget::STATIC_LIBRARY: {
  243. // Check if you have a non archive way to create the static library.
  244. {
  245. std::string linkCmdVar = "CMAKE_";
  246. linkCmdVar += this->TargetLinkLanguage;
  247. linkCmdVar += "_CREATE_STATIC_LIBRARY";
  248. if (const char *linkCmd =
  249. this->GetMakefile()->GetDefinition(linkCmdVar.c_str()))
  250. {
  251. cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
  252. return linkCmds;
  253. }
  254. }
  255. // We have archive link commands set. First, delete the existing archive.
  256. std::string cmakeCommand =
  257. this->GetLocalGenerator()->ConvertToOutputFormat(
  258. this->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"),
  259. cmLocalGenerator::SHELL);
  260. linkCmds.push_back(cmakeCommand + " -E remove $out");
  261. // TODO: Use ARCHIVE_APPEND for archives over a certain size.
  262. {
  263. std::string linkCmdVar = "CMAKE_";
  264. linkCmdVar += this->TargetLinkLanguage;
  265. linkCmdVar += "_ARCHIVE_CREATE";
  266. const char *linkCmd =
  267. this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str());
  268. cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
  269. }
  270. {
  271. std::string linkCmdVar = "CMAKE_";
  272. linkCmdVar += this->TargetLinkLanguage;
  273. linkCmdVar += "_ARCHIVE_FINISH";
  274. const char *linkCmd =
  275. this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str());
  276. cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
  277. }
  278. return linkCmds;
  279. }
  280. case cmTarget::SHARED_LIBRARY:
  281. case cmTarget::MODULE_LIBRARY:
  282. case cmTarget::EXECUTABLE: {
  283. std::string linkCmdVar = "CMAKE_";
  284. linkCmdVar += this->TargetLinkLanguage;
  285. switch (targetType) {
  286. case cmTarget::SHARED_LIBRARY:
  287. linkCmdVar += "_CREATE_SHARED_LIBRARY";
  288. break;
  289. case cmTarget::MODULE_LIBRARY:
  290. linkCmdVar += "_CREATE_SHARED_MODULE";
  291. break;
  292. case cmTarget::EXECUTABLE:
  293. linkCmdVar += "_LINK_EXECUTABLE";
  294. break;
  295. default:
  296. assert(0 && "Unexpected target type");
  297. }
  298. const char *linkCmd =
  299. this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str());
  300. cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
  301. return linkCmds;
  302. }
  303. default:
  304. assert(0 && "Unexpected target type");
  305. }
  306. return std::vector<std::string>();
  307. }
  308. void cmNinjaNormalTargetGenerator::WriteLinkStatement()
  309. {
  310. cmTarget::TargetType targetType = this->GetTarget()->GetType();
  311. // Write comments.
  312. cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream());
  313. this->GetBuildFileStream()
  314. << "# Link build statements for "
  315. << cmTarget::GetTargetTypeName(targetType)
  316. << " target "
  317. << this->GetTargetName()
  318. << "\n\n";
  319. cmNinjaDeps emptyDeps;
  320. cmNinjaVars vars;
  321. std::string targetOutput = ConvertToNinjaPath(
  322. this->GetTarget()->GetFullPath(this->GetConfigName()).c_str());
  323. std::string targetOutputReal = ConvertToNinjaPath(
  324. this->GetTarget()->GetFullPath(this->GetConfigName(),
  325. /*implib=*/false,
  326. /*realpath=*/true).c_str());
  327. std::string targetOutputImplib = ConvertToNinjaPath(
  328. this->GetTarget()->GetFullPath(this->GetConfigName(),
  329. /*implib=*/true).c_str());
  330. // Compute the comment.
  331. cmOStringStream comment;
  332. comment << "Link the " << this->GetVisibleTypeName() << " "
  333. << targetOutputReal;
  334. // Compute outputs.
  335. cmNinjaDeps outputs;
  336. outputs.push_back(targetOutputReal);
  337. // Compute specific libraries to link with.
  338. cmNinjaDeps explicitDeps = this->GetObjects();
  339. cmNinjaDeps implicitDeps = this->ComputeLinkDeps();
  340. this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"],
  341. vars["FLAGS"],
  342. vars["LINK_FLAGS"],
  343. *this->GetTarget());
  344. this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]);
  345. // Compute architecture specific link flags. Yes, these go into a different
  346. // variable for executables, probably due to a mistake made when duplicating
  347. // code between the Makefile executable and library generators.
  348. std::string flags = (targetType == cmTarget::EXECUTABLE
  349. ? vars["FLAGS"]
  350. : vars["ARCH_FLAGS"]);
  351. this->GetLocalGenerator()->AddArchitectureFlags(flags,
  352. this->GetTarget(),
  353. this->TargetLinkLanguage,
  354. this->GetConfigName());
  355. if (targetType == cmTarget::EXECUTABLE) {
  356. vars["FLAGS"] = flags;
  357. } else {
  358. vars["ARCH_FLAGS"] = flags;
  359. }
  360. if (this->GetTarget()->HasSOName(this->GetConfigName())) {
  361. vars["SONAME_FLAG"] =
  362. this->GetMakefile()->GetSONameFlag(this->TargetLinkLanguage);
  363. vars["SONAME"] = this->TargetNameSO;
  364. if (targetType == cmTarget::SHARED_LIBRARY) {
  365. std::string install_name_dir = this->GetTarget()
  366. ->GetInstallNameDirForBuildTree(this->GetConfigName());
  367. if (!install_name_dir.empty()) {
  368. vars["INSTALLNAME_DIR"] =
  369. this->GetLocalGenerator()->Convert(install_name_dir.c_str(),
  370. cmLocalGenerator::NONE,
  371. cmLocalGenerator::SHELL, false);
  372. }
  373. }
  374. }
  375. std::string path;
  376. if (!this->TargetNameImport.empty()) {
  377. path = this->GetLocalGenerator()->ConvertToOutputFormat(
  378. targetOutputImplib.c_str(), cmLocalGenerator::SHELL);
  379. vars["TARGET_IMPLIB"] = path;
  380. EnsureParentDirectoryExists(path);
  381. }
  382. // TODO move to GetTargetPDB
  383. cmMakefile* mf = this->GetMakefile();
  384. if (mf->GetDefinition("MSVC_C_ARCHITECTURE_ID") ||
  385. mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID"))
  386. {
  387. path = this->GetTargetPDB();
  388. vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
  389. ConvertToNinjaPath(path.c_str()).c_str(),
  390. cmLocalGenerator::SHELL);
  391. EnsureParentDirectoryExists(path);
  392. }
  393. if (mf->IsOn("CMAKE_COMPILER_IS_MINGW"))
  394. {
  395. path = GetTarget()->GetSupportDirectory();
  396. vars["OBJECT_DIR"] = ConvertToNinjaPath(path.c_str());
  397. EnsureDirectoryExists(path);
  398. // ar.exe can't handle backslashes in rsp files (implictly used by gcc)
  399. std::string& linkLibraries = vars["LINK_LIBRARIES"];
  400. std::replace(linkLibraries.begin(), linkLibraries.end(), '\\', '/');
  401. }
  402. std::vector<cmCustomCommand> *cmdLists[3] = {
  403. &this->GetTarget()->GetPreBuildCommands(),
  404. &this->GetTarget()->GetPreLinkCommands(),
  405. &this->GetTarget()->GetPostBuildCommands()
  406. };
  407. std::vector<std::string> preLinkCmdLines, postBuildCmdLines;
  408. std::vector<std::string> *cmdLineLists[3] = {
  409. &preLinkCmdLines,
  410. &preLinkCmdLines,
  411. &postBuildCmdLines
  412. };
  413. for (unsigned i = 0; i != 3; ++i) {
  414. for (std::vector<cmCustomCommand>::const_iterator
  415. ci = cmdLists[i]->begin();
  416. ci != cmdLists[i]->end(); ++ci) {
  417. this->GetLocalGenerator()->AppendCustomCommandLines(&*ci,
  418. *cmdLineLists[i]);
  419. }
  420. }
  421. // If we have any PRE_LINK commands, we need to go back to HOME_OUTPUT for
  422. // the link commands.
  423. if (!preLinkCmdLines.empty()) {
  424. path = this->GetLocalGenerator()->ConvertToOutputFormat(
  425. this->GetMakefile()->GetHomeOutputDirectory(),
  426. cmLocalGenerator::SHELL);
  427. preLinkCmdLines.push_back("cd " + path);
  428. }
  429. vars["PRE_LINK"] =
  430. this->GetLocalGenerator()->BuildCommandLine(preLinkCmdLines);
  431. std::string postBuildCmdLine =
  432. this->GetLocalGenerator()->BuildCommandLine(postBuildCmdLines);
  433. cmNinjaVars symlinkVars;
  434. if (targetOutput == targetOutputReal) {
  435. vars["POST_BUILD"] = postBuildCmdLine;
  436. } else {
  437. vars["POST_BUILD"] = ":";
  438. symlinkVars["POST_BUILD"] = postBuildCmdLine;
  439. }
  440. int linkRuleLength = this->GetGlobalGenerator()->
  441. GetRuleCmdLength(this->LanguageLinkerRule());
  442. #ifdef _WIN32
  443. int commandLineLengthLimit = 8000 - linkRuleLength;
  444. #elif defined(__linux) || defined(__APPLE__)
  445. // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac
  446. int commandLineLengthLimit = ((int)sysconf(_SC_ARG_MAX))
  447. - linkRuleLength - 1000;
  448. #else
  449. int commandLineLengthLimit = -1;
  450. #endif
  451. // Write the build statement for this target.
  452. cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(),
  453. comment.str(),
  454. this->LanguageLinkerRule(),
  455. outputs,
  456. explicitDeps,
  457. implicitDeps,
  458. emptyDeps,
  459. vars,
  460. commandLineLengthLimit);
  461. if (targetOutput != targetOutputReal) {
  462. if (targetType == cmTarget::EXECUTABLE) {
  463. cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(),
  464. "Create executable symlink " + targetOutput,
  465. "CMAKE_SYMLINK_EXECUTABLE",
  466. cmNinjaDeps(1, targetOutput),
  467. cmNinjaDeps(1, targetOutputReal),
  468. emptyDeps,
  469. emptyDeps,
  470. symlinkVars);
  471. } else {
  472. cmNinjaDeps symlinks;
  473. const std::string soName = this->GetTargetFilePath(this->TargetNameSO);
  474. // If one link has to be created.
  475. if (targetOutputReal == soName || targetOutput == soName) {
  476. symlinkVars["SONAME"] = soName;
  477. } else {
  478. symlinkVars["SONAME"] = "";
  479. symlinks.push_back(soName);
  480. }
  481. symlinks.push_back(targetOutput);
  482. cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(),
  483. "Create library symlink " + targetOutput,
  484. "CMAKE_SYMLINK_LIBRARY",
  485. symlinks,
  486. cmNinjaDeps(1, targetOutputReal),
  487. emptyDeps,
  488. emptyDeps,
  489. symlinkVars);
  490. }
  491. }
  492. if (!this->TargetNameImport.empty()) {
  493. // Since using multiple outputs would mess up the $out variable, use an
  494. // alias for the import library.
  495. cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(),
  496. "Alias for import library.",
  497. cmNinjaDeps(1, targetOutputImplib),
  498. cmNinjaDeps(1, targetOutputReal));
  499. }
  500. // Add aliases for the file name and the target name.
  501. this->GetGlobalGenerator()->AddTargetAlias(this->TargetNameOut,
  502. this->GetTarget());
  503. this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
  504. this->GetTarget());
  505. }
  506. //----------------------------------------------------------------------------
  507. void cmNinjaNormalTargetGenerator::WriteObjectLibStatement()
  508. {
  509. // Write a phony output that depends on all object files.
  510. cmNinjaDeps outputs;
  511. this->GetLocalGenerator()->AppendTargetOutputs(this->GetTarget(), outputs);
  512. cmNinjaDeps depends = this->GetObjects();
  513. cmGlobalNinjaGenerator::WritePhonyBuild(this->GetBuildFileStream(),
  514. "Object library "
  515. + this->GetTargetName(),
  516. outputs,
  517. depends);
  518. // Add aliases for the target name.
  519. this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
  520. this->GetTarget());
  521. }