cmGlobalUnixMakefileGenerator3.cxx 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator3
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmGlobalUnixMakefileGenerator3.h"
  14. #include "cmLocalUnixMakefileGenerator3.h"
  15. #include "cmMakefile.h"
  16. #include "cmake.h"
  17. #include "cmGeneratedFileStream.h"
  18. #include "cmSourceFile.h"
  19. #include "cmTarget.h"
  20. cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3()
  21. {
  22. // This type of makefile always requires unix style paths
  23. this->ForceUnixPaths = true;
  24. this->FindMakeProgramFile = "CMakeUnixFindMake.cmake";
  25. this->ToolSupportsColor = true;
  26. this->NumberOfSourceFiles = 0;
  27. this->NumberOfSourceFilesWritten = 0;
  28. #ifdef _WIN32
  29. this->UseLinkScript = false;
  30. #else
  31. this->UseLinkScript = true;
  32. #endif
  33. }
  34. void cmGlobalUnixMakefileGenerator3
  35. ::EnableLanguage(std::vector<std::string>const& languages, cmMakefile *mf)
  36. {
  37. this->cmGlobalGenerator::EnableLanguage(languages, mf);
  38. std::string path;
  39. for(std::vector<std::string>::const_iterator l = languages.begin();
  40. l != languages.end(); ++l)
  41. {
  42. if(*l == "NONE")
  43. {
  44. continue;
  45. }
  46. const char* lang = l->c_str();
  47. std::string langComp = "CMAKE_";
  48. langComp += lang;
  49. langComp += "_COMPILER";
  50. if(!mf->GetDefinition(langComp.c_str()))
  51. {
  52. cmSystemTools::Error(langComp.c_str(),
  53. " not set, after EnableLanguage");
  54. continue;
  55. }
  56. const char* name = mf->GetRequiredDefinition(langComp.c_str());
  57. if(!cmSystemTools::FileIsFullPath(name))
  58. {
  59. path = cmSystemTools::FindProgram(name);
  60. }
  61. else
  62. {
  63. path = name;
  64. }
  65. if(path.size() == 0 || !cmSystemTools::FileExists(path.c_str()))
  66. {
  67. std::string message = "your ";
  68. message += lang;
  69. message += " compiler: \"";
  70. message += name;
  71. message += "\" was not found. Please set ";
  72. message += langComp;
  73. message += " to a valid compiler path or name.";
  74. cmSystemTools::Error(message.c_str());
  75. path = name;
  76. }
  77. std::string doc = lang;
  78. doc += " compiler.";
  79. mf->AddCacheDefinition(langComp.c_str(), path.c_str(),
  80. doc.c_str(), cmCacheManager::FILEPATH);
  81. }
  82. }
  83. ///! Create a local generator appropriate to this Global Generator
  84. cmLocalGenerator *cmGlobalUnixMakefileGenerator3::CreateLocalGenerator()
  85. {
  86. cmLocalGenerator* lg = new cmLocalUnixMakefileGenerator3;
  87. lg->SetGlobalGenerator(this);
  88. return lg;
  89. }
  90. //----------------------------------------------------------------------------
  91. void cmGlobalUnixMakefileGenerator3
  92. ::GetDocumentation(cmDocumentationEntry& entry) const
  93. {
  94. entry.name = this->GetName();
  95. entry.brief = "Generates standard UNIX makefiles.";
  96. entry.full =
  97. "A hierarchy of UNIX makefiles is generated into the build tree. Any "
  98. "standard UNIX-style make program can build the project through the "
  99. "default make target. A \"make install\" target is also provided.";
  100. }
  101. //----------------------------------------------------------------------------
  102. void
  103. cmGlobalUnixMakefileGenerator3
  104. ::AddMultipleOutputPair(const char* depender, const char* dependee)
  105. {
  106. MultipleOutputPairsType::value_type p(depender, dependee);
  107. this->MultipleOutputPairs.insert(p);
  108. }
  109. //----------------------------------------------------------------------------
  110. int cmGlobalUnixMakefileGenerator3::ShouldAddProgressRule()
  111. {
  112. // add progress to 100 source files
  113. if (this->NumberOfSourceFiles &&
  114. (((this->NumberOfSourceFilesWritten + 1)*100)/this->NumberOfSourceFiles)
  115. -(this->NumberOfSourceFilesWritten*100)/this->NumberOfSourceFiles)
  116. {
  117. this->NumberOfSourceFilesWritten++;
  118. return (this->NumberOfSourceFilesWritten*100)/this->NumberOfSourceFiles;
  119. }
  120. this->NumberOfSourceFilesWritten++;
  121. return 0;
  122. }
  123. int cmGlobalUnixMakefileGenerator3::
  124. GetNumberOfCompilableSourceFilesForTarget(cmTarget &tgt)
  125. {
  126. std::map<cmStdString, int >::iterator tgtI =
  127. this->TargetSourceFileCount.find(tgt.GetName());
  128. if (tgtI != this->TargetSourceFileCount.end())
  129. {
  130. return tgtI->second;
  131. }
  132. int result = 0;
  133. if((tgt.GetType() == cmTarget::EXECUTABLE) ||
  134. (tgt.GetType() == cmTarget::STATIC_LIBRARY) ||
  135. (tgt.GetType() == cmTarget::SHARED_LIBRARY) ||
  136. (tgt.GetType() == cmTarget::MODULE_LIBRARY) )
  137. {
  138. std::vector<cmSourceFile*>& sources = tgt.GetSourceFiles();
  139. for(std::vector<cmSourceFile*>::iterator source = sources.begin();
  140. source != sources.end(); ++source)
  141. {
  142. if(!(*source)->GetPropertyAsBool("HEADER_FILE_ONLY") &&
  143. !(*source)->GetCustomCommand())
  144. {
  145. if(!this->IgnoreFile((*source)->GetSourceExtension().c_str()))
  146. {
  147. const char* lang =
  148. static_cast<cmLocalUnixMakefileGenerator3 *>
  149. (tgt.GetMakefile()->GetLocalGenerator())
  150. ->GetSourceFileLanguage(**source);
  151. if(lang)
  152. {
  153. result++;
  154. }
  155. }
  156. }
  157. }
  158. }
  159. this->TargetSourceFileCount[tgt.GetName()] = result;
  160. return result;
  161. }
  162. //----------------------------------------------------------------------------
  163. void cmGlobalUnixMakefileGenerator3::Generate()
  164. {
  165. // initialize progress
  166. this->NumberOfSourceFiles = 0;
  167. unsigned int i;
  168. for (i = 0; i < this->LocalGenerators.size(); ++i)
  169. {
  170. // for all of out targets
  171. for (cmTargets::iterator l =
  172. this->LocalGenerators[i]->GetMakefile()->GetTargets().begin();
  173. l != this->LocalGenerators[i]->GetMakefile()->GetTargets().end();
  174. l++)
  175. {
  176. this->NumberOfSourceFiles +=
  177. this->GetNumberOfCompilableSourceFilesForTarget(l->second);
  178. }
  179. }
  180. this->NumberOfSourceFilesWritten = 0;
  181. // first do superclass method
  182. this->cmGlobalGenerator::Generate();
  183. // write the main makefile
  184. this->WriteMainMakefile2();
  185. this->WriteMainCMakefile();
  186. }
  187. void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
  188. {
  189. // Open the output file. This should not be copy-if-different
  190. // because the check-build-system step compares the makefile time to
  191. // see if the build system must be regenerated.
  192. std::string makefileName =
  193. this->GetCMakeInstance()->GetHomeOutputDirectory();
  194. makefileName += cmake::GetCMakeFilesDirectory();
  195. makefileName += "/Makefile2";
  196. cmGeneratedFileStream makefileStream(makefileName.c_str());
  197. if(!makefileStream)
  198. {
  199. return;
  200. }
  201. // get a local generator for some useful methods
  202. cmLocalUnixMakefileGenerator3 *lg =
  203. static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[0]);
  204. // Write the do not edit header.
  205. lg->WriteDisclaimer(makefileStream);
  206. // Write the main entry point target. This must be the VERY first
  207. // target so that make with no arguments will run it.
  208. // Just depend on the all target to drive the build.
  209. std::vector<std::string> depends;
  210. std::vector<std::string> no_commands;
  211. depends.push_back("all");
  212. // Write the rule.
  213. lg->WriteMakeRule(makefileStream,
  214. "Default target executed when no arguments are "
  215. "given to make.",
  216. "default_target",
  217. depends,
  218. no_commands, true);
  219. depends.clear();
  220. // The all and preinstall rules might never have any dependencies
  221. // added to them.
  222. if(this->EmptyRuleHackDepends != "")
  223. {
  224. depends.push_back(this->EmptyRuleHackDepends);
  225. }
  226. // Write and empty all:
  227. lg->WriteMakeRule(makefileStream,
  228. "The main recursive all target", "all",
  229. depends, no_commands, true);
  230. // Write an empty preinstall:
  231. lg->WriteMakeRule(makefileStream,
  232. "The main recursive preinstall target", "preinstall",
  233. depends, no_commands, true);
  234. lg->WriteMakeVariables(makefileStream);
  235. // Write out the "special" stuff
  236. lg->WriteSpecialTargetsTop(makefileStream);
  237. // write the target convenience rules
  238. unsigned int i;
  239. for (i = 0; i < this->LocalGenerators.size(); ++i)
  240. {
  241. lg =
  242. static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
  243. // are any parents excluded
  244. bool exclude = false;
  245. cmLocalGenerator *lg3 = lg;
  246. while (lg3)
  247. {
  248. if (lg3->GetExcludeAll())
  249. {
  250. exclude = true;
  251. break;
  252. }
  253. lg3 = lg3->GetParent();
  254. }
  255. this->WriteConvenienceRules2(makefileStream,lg,exclude);
  256. }
  257. lg = static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[0]);
  258. lg->WriteSpecialTargetsBottom(makefileStream);
  259. }
  260. //----------------------------------------------------------------------------
  261. void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
  262. {
  263. // Open the output file. This should not be copy-if-different
  264. // because the check-build-system step compares the makefile time to
  265. // see if the build system must be regenerated.
  266. std::string cmakefileName =
  267. this->GetCMakeInstance()->GetHomeOutputDirectory();
  268. cmakefileName += cmake::GetCMakeFilesDirectory();
  269. cmakefileName += "/Makefile.cmake";
  270. cmGeneratedFileStream cmakefileStream(cmakefileName.c_str());
  271. if(!cmakefileStream)
  272. {
  273. return;
  274. }
  275. std::string makefileName =
  276. this->GetCMakeInstance()->GetHomeOutputDirectory();
  277. makefileName += "/Makefile";
  278. // get a local generator for some useful methods
  279. cmLocalUnixMakefileGenerator3 *lg =
  280. static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[0]);
  281. // Write the do not edit header.
  282. lg->WriteDisclaimer(cmakefileStream);
  283. // Save the generator name
  284. cmakefileStream
  285. << "# The generator used is:\n"
  286. << "SET(CMAKE_DEPENDS_GENERATOR \"" << this->GetName() << "\")\n\n";
  287. // for each cmMakefile get its list of dependencies
  288. std::vector<std::string> lfiles;
  289. for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
  290. {
  291. lg =
  292. static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
  293. // Get the list of files contributing to this generation step.
  294. lfiles.insert(lfiles.end(),lg->GetMakefile()->GetListFiles().begin(),
  295. lg->GetMakefile()->GetListFiles().end());
  296. }
  297. // Sort the list and remove duplicates.
  298. std::sort(lfiles.begin(), lfiles.end(), std::less<std::string>());
  299. std::vector<std::string>::iterator new_end =
  300. std::unique(lfiles.begin(),lfiles.end());
  301. lfiles.erase(new_end, lfiles.end());
  302. // reset lg to the first makefile
  303. lg = static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[0]);
  304. // Build the path to the cache file.
  305. std::string cache = this->GetCMakeInstance()->GetHomeOutputDirectory();
  306. cache += "/CMakeCache.txt";
  307. // Save the list to the cmake file.
  308. cmakefileStream
  309. << "# The top level Makefile was generated from the following files:\n"
  310. << "SET(CMAKE_MAKEFILE_DEPENDS\n"
  311. << " \""
  312. << lg->Convert(cache.c_str(),
  313. cmLocalGenerator::START_OUTPUT).c_str() << "\"\n";
  314. for(std::vector<std::string>::const_iterator i = lfiles.begin();
  315. i != lfiles.end(); ++i)
  316. {
  317. cmakefileStream
  318. << " \""
  319. << lg->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT).c_str()
  320. << "\"\n";
  321. }
  322. cmakefileStream
  323. << " )\n\n";
  324. // Build the path to the cache check file.
  325. std::string check = this->GetCMakeInstance()->GetHomeOutputDirectory();
  326. check += cmake::GetCMakeFilesDirectory();
  327. check += "/cmake.check_cache";
  328. // Set the corresponding makefile in the cmake file.
  329. cmakefileStream
  330. << "# The corresponding makefile is:\n"
  331. << "SET(CMAKE_MAKEFILE_OUTPUTS\n"
  332. << " \""
  333. << lg->Convert(makefileName.c_str(),
  334. cmLocalGenerator::START_OUTPUT).c_str() << "\"\n"
  335. << " \""
  336. << lg->Convert(check.c_str(),
  337. cmLocalGenerator::START_OUTPUT).c_str() << "\"\n";
  338. // add in all the directory information files
  339. std::string tmpStr;
  340. for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
  341. {
  342. lg =
  343. static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
  344. tmpStr = lg->GetMakefile()->GetStartOutputDirectory();
  345. tmpStr += cmake::GetCMakeFilesDirectory();
  346. tmpStr += "/CMakeDirectoryInformation.cmake";
  347. cmakefileStream << " \"" <<
  348. lg->Convert(tmpStr.c_str(),cmLocalGenerator::HOME_OUTPUT).c_str()
  349. << "\"\n";
  350. const std::vector<std::string>& outfiles =
  351. lg->GetMakefile()->GetOutputFiles();
  352. for(std::vector<std::string>::const_iterator k= outfiles.begin();
  353. k != outfiles.end(); ++k)
  354. {
  355. cmakefileStream << " \"" <<
  356. lg->Convert(k->c_str(),cmLocalGenerator::HOME_OUTPUT).c_str()
  357. << "\"\n";
  358. }
  359. }
  360. cmakefileStream << " )\n\n";
  361. this->WriteMainCMakefileLanguageRules(cmakefileStream,
  362. this->LocalGenerators);
  363. if(!this->MultipleOutputPairs.empty())
  364. {
  365. cmakefileStream
  366. << "\n"
  367. << "SET(CMAKE_MULTIPLE_OUTPUT_PAIRS\n";
  368. for(MultipleOutputPairsType::const_iterator pi =
  369. this->MultipleOutputPairs.begin();
  370. pi != this->MultipleOutputPairs.end(); ++pi)
  371. {
  372. cmakefileStream << " \"" << pi->first << "\" \""
  373. << pi->second << "\"\n";
  374. }
  375. cmakefileStream << " )\n\n";
  376. }
  377. }
  378. //----------------------------------------------------------------------------
  379. void cmGlobalUnixMakefileGenerator3::CheckMultipleOutputs(cmMakefile* mf,
  380. bool verbose)
  381. {
  382. // Get the string listing the multiple output pairs.
  383. const char* pairs_string = mf->GetDefinition("CMAKE_MULTIPLE_OUTPUT_PAIRS");
  384. if(!pairs_string)
  385. {
  386. return;
  387. }
  388. // Convert the string to a list and preserve empty entries.
  389. std::vector<std::string> pairs;
  390. cmSystemTools::ExpandListArgument(pairs_string, pairs, true);
  391. for(std::vector<std::string>::const_iterator i = pairs.begin();
  392. i != pairs.end(); ++i)
  393. {
  394. const std::string& depender = *i;
  395. if(++i != pairs.end())
  396. {
  397. const std::string& dependee = *i;
  398. // If the depender is missing then delete the dependee to make
  399. // sure both will be regenerated.
  400. if(cmSystemTools::FileExists(dependee.c_str()) &&
  401. !cmSystemTools::FileExists(depender.c_str()))
  402. {
  403. if(verbose)
  404. {
  405. cmOStringStream msg;
  406. msg << "Deleting primary custom command output \"" << dependee
  407. << "\" because another output \""
  408. << depender << "\" does not exist." << std::endl;
  409. cmSystemTools::Stdout(msg.str().c_str());
  410. }
  411. cmSystemTools::RemoveFile(dependee.c_str());
  412. }
  413. }
  414. }
  415. }
  416. void cmGlobalUnixMakefileGenerator3
  417. ::WriteMainCMakefileLanguageRules(cmGeneratedFileStream& cmakefileStream,
  418. std::vector<cmLocalGenerator *> &lGenerators
  419. )
  420. {
  421. cmLocalUnixMakefileGenerator3 *lg;
  422. // now list all the target info files
  423. cmakefileStream
  424. << "# The set of files whose dependency integrity should be checked:\n";
  425. cmakefileStream
  426. << "SET(CMAKE_DEPEND_INFO_FILES\n";
  427. for (unsigned int i = 0; i < lGenerators.size(); ++i)
  428. {
  429. lg = static_cast<cmLocalUnixMakefileGenerator3 *>(lGenerators[i]);
  430. // for all of out targets
  431. for (cmTargets::iterator l = lg->GetMakefile()->GetTargets().begin();
  432. l != lg->GetMakefile()->GetTargets().end(); l++)
  433. {
  434. if((l->second.GetType() == cmTarget::EXECUTABLE) ||
  435. (l->second.GetType() == cmTarget::STATIC_LIBRARY) ||
  436. (l->second.GetType() == cmTarget::SHARED_LIBRARY) ||
  437. (l->second.GetType() == cmTarget::MODULE_LIBRARY) )
  438. {
  439. std::string tname = lg->GetRelativeTargetDirectory(l->second);
  440. tname += "/DependInfo.cmake";
  441. cmSystemTools::ConvertToUnixSlashes(tname);
  442. cmakefileStream << " \"" << tname.c_str() << "\"\n";
  443. }
  444. }
  445. }
  446. cmakefileStream << " )\n";
  447. }
  448. //----------------------------------------------------------------------------
  449. void
  450. cmGlobalUnixMakefileGenerator3
  451. ::WriteDirectoryRule2(std::ostream& ruleFileStream,
  452. cmLocalUnixMakefileGenerator3* lg,
  453. const char* pass, bool check_all,
  454. bool check_relink)
  455. {
  456. // Get the relative path to the subdirectory from the top.
  457. std::string makeTarget = lg->GetMakefile()->GetStartOutputDirectory();
  458. makeTarget += "/";
  459. makeTarget += pass;
  460. makeTarget = lg->Convert(makeTarget.c_str(),
  461. cmLocalGenerator::HOME_OUTPUT,
  462. cmLocalGenerator::MAKEFILE);
  463. // The directory-level rule should depend on the target-level rules
  464. // for all targets in the directory.
  465. std::vector<std::string> depends;
  466. for(cmTargets::iterator l = lg->GetMakefile()->GetTargets().begin();
  467. l != lg->GetMakefile()->GetTargets().end(); ++l)
  468. {
  469. if((l->second.GetType() == cmTarget::EXECUTABLE) ||
  470. (l->second.GetType() == cmTarget::STATIC_LIBRARY) ||
  471. (l->second.GetType() == cmTarget::SHARED_LIBRARY) ||
  472. (l->second.GetType() == cmTarget::MODULE_LIBRARY) ||
  473. (l->second.GetType() == cmTarget::UTILITY))
  474. {
  475. // Add this to the list of depends rules in this directory.
  476. if((!check_all || l->second.IsInAll()) &&
  477. (!check_relink || l->second.NeedRelinkBeforeInstall()))
  478. {
  479. std::string tname = lg->GetRelativeTargetDirectory(l->second);
  480. tname += "/";
  481. tname += pass;
  482. depends.push_back(tname);
  483. }
  484. }
  485. }
  486. // The directory-level rule should depend on the directory-level
  487. // rules of the subdirectories.
  488. for(std::vector<cmLocalGenerator*>::iterator sdi =
  489. lg->GetChildren().begin(); sdi != lg->GetChildren().end(); ++sdi)
  490. {
  491. cmLocalUnixMakefileGenerator3* slg =
  492. static_cast<cmLocalUnixMakefileGenerator3*>(*sdi);
  493. std::string subdir = slg->GetMakefile()->GetStartOutputDirectory();
  494. subdir += "/";
  495. subdir += pass;
  496. subdir = slg->Convert(subdir.c_str(),
  497. cmLocalGenerator::HOME_OUTPUT,
  498. cmLocalGenerator::MAKEFILE);
  499. depends.push_back(subdir);
  500. }
  501. // Work-around for makes that drop rules that have no dependencies
  502. // or commands.
  503. if(depends.empty() && this->EmptyRuleHackDepends != "")
  504. {
  505. depends.push_back(this->EmptyRuleHackDepends);
  506. }
  507. // Write the rule.
  508. std::string doc = "Convenience name for \"";
  509. doc += pass;
  510. doc += "\" pass in the directory.";
  511. std::vector<std::string> no_commands;
  512. lg->WriteMakeRule(ruleFileStream, doc.c_str(),
  513. makeTarget.c_str(), depends, no_commands, true);
  514. }
  515. //----------------------------------------------------------------------------
  516. void
  517. cmGlobalUnixMakefileGenerator3
  518. ::WriteDirectoryRules2(std::ostream& ruleFileStream,
  519. cmLocalUnixMakefileGenerator3* lg)
  520. {
  521. // Only subdirectories need these rules.
  522. if(!lg->GetParent())
  523. {
  524. return;
  525. }
  526. // Begin the directory-level rules section.
  527. std::string dir = lg->GetMakefile()->GetStartOutputDirectory();
  528. dir = lg->Convert(dir.c_str(), cmLocalGenerator::HOME_OUTPUT,
  529. cmLocalGenerator::MAKEFILE);
  530. lg->WriteDivider(ruleFileStream);
  531. ruleFileStream
  532. << "# Directory level rules for directory "
  533. << dir << "\n\n";
  534. // Write directory-level rules for "all".
  535. this->WriteDirectoryRule2(ruleFileStream, lg, "all", true, false);
  536. // Write directory-level rules for "clean".
  537. this->WriteDirectoryRule2(ruleFileStream, lg, "clean", false, false);
  538. // Write directory-level rules for "preinstall".
  539. this->WriteDirectoryRule2(ruleFileStream, lg, "preinstall", false, true);
  540. }
  541. std::string cmGlobalUnixMakefileGenerator3
  542. ::GenerateBuildCommand(const char* makeProgram, const char *projectName,
  543. const char* additionalOptions, const char *targetName,
  544. const char* config, bool ignoreErrors, bool fast)
  545. {
  546. // Project name and config are not used yet.
  547. (void)projectName;
  548. (void)config;
  549. std::string makeCommand =
  550. cmSystemTools::ConvertToUnixOutputPath(makeProgram);
  551. // Since we have full control over the invocation of nmake, let us
  552. // make it quiet.
  553. if ( strcmp(this->GetName(), "NMake Makefiles") == 0 )
  554. {
  555. makeCommand += " /NOLOGO ";
  556. }
  557. if ( ignoreErrors )
  558. {
  559. makeCommand += " -i";
  560. }
  561. if ( additionalOptions )
  562. {
  563. makeCommand += " ";
  564. makeCommand += additionalOptions;
  565. }
  566. if ( targetName && strlen(targetName))
  567. {
  568. cmLocalUnixMakefileGenerator3 *lg;
  569. if (this->LocalGenerators.size())
  570. {
  571. lg = static_cast<cmLocalUnixMakefileGenerator3 *>
  572. (this->LocalGenerators[0]);
  573. }
  574. else
  575. {
  576. lg = static_cast<cmLocalUnixMakefileGenerator3 *>
  577. (this->CreateLocalGenerator());
  578. // set the Start directories
  579. lg->GetMakefile()->SetStartDirectory
  580. (this->CMakeInstance->GetStartDirectory());
  581. lg->GetMakefile()->SetStartOutputDirectory
  582. (this->CMakeInstance->GetStartOutputDirectory());
  583. lg->GetMakefile()->MakeStartDirectoriesCurrent();
  584. }
  585. lg->SetupPathConversions();
  586. makeCommand += " \"";
  587. std::string tname = targetName;
  588. if(fast)
  589. {
  590. tname += "/fast";
  591. }
  592. tname = lg->Convert(tname.c_str(),cmLocalGenerator::HOME_OUTPUT,
  593. cmLocalGenerator::MAKEFILE);
  594. tname = lg->ConvertToMakeTarget(tname.c_str());
  595. makeCommand += tname.c_str();
  596. makeCommand += "\"";
  597. if (!this->LocalGenerators.size())
  598. {
  599. delete lg;
  600. }
  601. }
  602. return makeCommand;
  603. }
  604. //----------------------------------------------------------------------------
  605. void
  606. cmGlobalUnixMakefileGenerator3
  607. ::WriteConvenienceRules(std::ostream& ruleFileStream,
  608. std::set<cmStdString> &emitted)
  609. {
  610. std::vector<std::string> depends;
  611. std::vector<std::string> commands;
  612. depends.push_back("cmake_check_build_system");
  613. // write the target convenience rules
  614. unsigned int i;
  615. cmLocalUnixMakefileGenerator3 *lg;
  616. for (i = 0; i < this->LocalGenerators.size(); ++i)
  617. {
  618. lg = static_cast<cmLocalUnixMakefileGenerator3 *>
  619. (this->LocalGenerators[i]);
  620. // for each target Generate the rule files for each target.
  621. cmTargets& targets = lg->GetMakefile()->GetTargets();
  622. for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
  623. {
  624. // Don't emit the same rule twice (e.g. two targets with the same
  625. // simple name)
  626. if(t->second.GetName() &&
  627. strlen(t->second.GetName()) &&
  628. emitted.insert(t->second.GetName()).second)
  629. {
  630. // Handle user targets here. Global targets are handled in
  631. // the local generator on a per-directory basis.
  632. if((t->second.GetType() == cmTarget::EXECUTABLE) ||
  633. (t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
  634. (t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
  635. (t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
  636. (t->second.GetType() == cmTarget::UTILITY))
  637. {
  638. // Add a rule to build the target by name.
  639. lg->WriteDivider(ruleFileStream);
  640. ruleFileStream
  641. << "# Target rules for targets named "
  642. << t->second.GetName() << "\n\n";
  643. // Write the rule.
  644. commands.clear();
  645. std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
  646. tmp += "Makefile2";
  647. commands.push_back(lg->GetRecursiveMakeCall
  648. (tmp.c_str(),t->second.GetName()));
  649. depends.clear();
  650. depends.push_back("cmake_check_build_system");
  651. lg->WriteMakeRule(ruleFileStream,
  652. "Build rule for target.",
  653. t->second.GetName(), depends, commands,
  654. true);
  655. // Add a fast rule to build the target
  656. std::string localName = lg->GetRelativeTargetDirectory(t->second);
  657. std::string makefileName;
  658. makefileName = localName;
  659. makefileName += "/build.make";
  660. depends.clear();
  661. commands.clear();
  662. std::string makeTargetName = localName;
  663. makeTargetName += "/build";
  664. localName = t->second.GetName();
  665. localName += "/fast";
  666. commands.push_back(lg->GetRecursiveMakeCall
  667. (makefileName.c_str(), makeTargetName.c_str()));
  668. lg->WriteMakeRule(ruleFileStream, "fast build rule for target.",
  669. localName.c_str(), depends, commands, true);
  670. }
  671. }
  672. }
  673. }
  674. }
  675. //----------------------------------------------------------------------------
  676. void
  677. cmGlobalUnixMakefileGenerator3
  678. ::WriteConvenienceRules2(std::ostream& ruleFileStream,
  679. cmLocalUnixMakefileGenerator3 *lg,
  680. bool exclude)
  681. {
  682. std::vector<std::string> depends;
  683. std::vector<std::string> commands;
  684. std::string localName;
  685. std::string makeTargetName;
  686. // write the directory level rules for this local gen
  687. this->WriteDirectoryRules2(ruleFileStream,lg);
  688. depends.push_back("cmake_check_build_system");
  689. // for each target Generate the rule files for each target.
  690. cmTargets& targets = lg->GetMakefile()->GetTargets();
  691. for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
  692. {
  693. if (t->second.GetName() && strlen(t->second.GetName()))
  694. {
  695. std::string makefileName;
  696. // Add a rule to build the target by name.
  697. localName = lg->GetRelativeTargetDirectory(t->second);
  698. makefileName = localName;
  699. makefileName += "/build.make";
  700. if (((t->second.GetType() == cmTarget::EXECUTABLE) ||
  701. (t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
  702. (t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
  703. (t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
  704. (t->second.GetType() == cmTarget::UTILITY)))
  705. {
  706. bool needRequiresStep =
  707. this->NeedRequiresStep(lg,t->second.GetName());
  708. lg->WriteDivider(ruleFileStream);
  709. ruleFileStream
  710. << "# Target rules for target "
  711. << localName << "\n\n";
  712. commands.clear();
  713. if (t->second.GetType() != cmTarget::UTILITY)
  714. {
  715. makeTargetName = localName;
  716. makeTargetName += "/depend";
  717. commands.push_back(lg->GetRecursiveMakeCall
  718. (makefileName.c_str(),makeTargetName.c_str()));
  719. // add requires if we need it for this generator
  720. if (needRequiresStep)
  721. {
  722. makeTargetName = localName;
  723. makeTargetName += "/requires";
  724. commands.push_back(lg->GetRecursiveMakeCall
  725. (makefileName.c_str(),makeTargetName.c_str()));
  726. }
  727. }
  728. makeTargetName = localName;
  729. makeTargetName += "/build";
  730. commands.push_back(lg->GetRecursiveMakeCall
  731. (makefileName.c_str(),makeTargetName.c_str()));
  732. // Write the rule.
  733. localName += "/all";
  734. depends.clear();
  735. std::string progressDir =
  736. lg->GetMakefile()->GetHomeOutputDirectory();
  737. progressDir += cmake::GetCMakeFilesDirectory();
  738. {
  739. cmOStringStream progCmd;
  740. progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
  741. // all target counts
  742. progCmd << lg->Convert(progressDir.c_str(),
  743. cmLocalGenerator::FULL,
  744. cmLocalGenerator::SHELL);
  745. progCmd << " ";
  746. std::vector<int> &progFiles = lg->ProgressFiles[t->first];
  747. for (std::vector<int>::iterator i = progFiles.begin();
  748. i != progFiles.end(); ++i)
  749. {
  750. progCmd << " " << *i;
  751. }
  752. commands.push_back(progCmd.str());
  753. }
  754. progressDir = "Building target ";
  755. progressDir += t->first;
  756. lg->AppendEcho(commands,progressDir.c_str());
  757. this->AppendGlobalTargetDepends(depends,t->second);
  758. lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
  759. localName.c_str(), depends, commands, true);
  760. // add the all/all dependency
  761. if (!exclude && t->second.IsInAll())
  762. {
  763. depends.clear();
  764. depends.push_back(localName);
  765. commands.clear();
  766. lg->WriteMakeRule(ruleFileStream, "Include target in all.",
  767. "all", depends, commands, true);
  768. }
  769. // Write the rule.
  770. commands.clear();
  771. progressDir = lg->GetMakefile()->GetHomeOutputDirectory();
  772. progressDir += cmake::GetCMakeFilesDirectory();
  773. {
  774. // TODO: Convert the total progress count to a make variable.
  775. cmOStringStream progCmd;
  776. progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start ";
  777. // # in target
  778. progCmd << lg->Convert(progressDir.c_str(),
  779. cmLocalGenerator::FULL,
  780. cmLocalGenerator::SHELL);
  781. //
  782. progCmd << " "
  783. << this->GetTargetTotalNumberOfProgressFiles(t->second);
  784. commands.push_back(progCmd.str());
  785. }
  786. std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
  787. tmp += "Makefile2";
  788. commands.push_back(lg->GetRecursiveMakeCall
  789. (tmp.c_str(),localName.c_str()));
  790. {
  791. cmOStringStream progCmd;
  792. progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
  793. progCmd << lg->Convert(progressDir.c_str(),
  794. cmLocalGenerator::FULL,
  795. cmLocalGenerator::SHELL);
  796. progCmd << " 0";
  797. commands.push_back(progCmd.str());
  798. }
  799. depends.clear();
  800. depends.push_back("cmake_check_build_system");
  801. localName = lg->GetRelativeTargetDirectory(t->second);
  802. localName += "/rule";
  803. lg->WriteMakeRule(ruleFileStream,
  804. "Build rule for subdir invocation for target.",
  805. localName.c_str(), depends, commands, true);
  806. // Add a target with the canonical name (no prefix, suffix or path).
  807. commands.clear();
  808. depends.clear();
  809. depends.push_back(localName);
  810. lg->WriteMakeRule(ruleFileStream, "Convenience name for target.",
  811. t->second.GetName(), depends, commands, true);
  812. // Add rules to prepare the target for installation.
  813. if(t->second.NeedRelinkBeforeInstall())
  814. {
  815. localName = lg->GetRelativeTargetDirectory(t->second);
  816. localName += "/preinstall";
  817. depends.clear();
  818. commands.clear();
  819. commands.push_back(lg->GetRecursiveMakeCall
  820. (makefileName.c_str(), localName.c_str()));
  821. lg->WriteMakeRule(ruleFileStream,
  822. "Pre-install relink rule for target.",
  823. localName.c_str(), depends, commands, true);
  824. depends.clear();
  825. depends.push_back(localName);
  826. commands.clear();
  827. lg->WriteMakeRule(ruleFileStream, "Prepare target for install.",
  828. "preinstall", depends, commands, true);
  829. }
  830. // add the clean rule
  831. localName = lg->GetRelativeTargetDirectory(t->second);
  832. makeTargetName = localName;
  833. makeTargetName += "/clean";
  834. depends.clear();
  835. commands.clear();
  836. commands.push_back(lg->GetRecursiveMakeCall
  837. (makefileName.c_str(), makeTargetName.c_str()));
  838. lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
  839. makeTargetName.c_str(), depends, commands, true);
  840. commands.clear();
  841. depends.push_back(makeTargetName);
  842. lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
  843. "clean", depends, commands, true);
  844. }
  845. }
  846. }
  847. }
  848. //----------------------------------------------------------------------------
  849. int cmGlobalUnixMakefileGenerator3
  850. ::GetTargetTotalNumberOfProgressFiles(cmTarget& target)
  851. {
  852. cmLocalUnixMakefileGenerator3 *lg =
  853. static_cast<cmLocalUnixMakefileGenerator3 *>
  854. (target.GetMakefile()->GetLocalGenerator());
  855. int result = static_cast<int>(lg->ProgressFiles[target.GetName()].size());
  856. std::vector<cmTarget *>& depends = this->GetTargetDepends(target);
  857. std::vector<cmTarget *>::iterator i;
  858. for (i = depends.begin(); i != depends.end(); ++i)
  859. {
  860. result += this->GetTargetTotalNumberOfProgressFiles(**i);
  861. }
  862. return result;
  863. }
  864. //----------------------------------------------------------------------------
  865. std::vector<cmTarget *>& cmGlobalUnixMakefileGenerator3
  866. ::GetTargetDepends(cmTarget& target)
  867. {
  868. // if the depends are already in the map then return
  869. std::map<cmStdString, std::vector<cmTarget *> >::iterator tgtI =
  870. this->TargetDependencies.find(target.GetName());
  871. if (tgtI != this->TargetDependencies.end())
  872. {
  873. return tgtI->second;
  874. }
  875. // A target should not depend on itself.
  876. std::set<cmStdString> emitted;
  877. emitted.insert(target.GetName());
  878. // the vector of results
  879. std::vector<cmTarget *>& result =
  880. this->TargetDependencies[target.GetName()];
  881. // Loop over all library dependencies but not for static libs
  882. if (target.GetType() != cmTarget::STATIC_LIBRARY)
  883. {
  884. const cmTarget::LinkLibraryVectorType& tlibs = target.GetLinkLibraries();
  885. for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin();
  886. lib != tlibs.end(); ++lib)
  887. {
  888. // Don't emit the same library twice for this target.
  889. if(emitted.insert(lib->first).second)
  890. {
  891. cmTarget *target2 =
  892. target.GetMakefile()->FindTarget(lib->first.c_str());
  893. // search each local generator until a match is found
  894. if (!target2)
  895. {
  896. target2 = this->FindTarget(0,lib->first.c_str());
  897. }
  898. // if a match was found then ...
  899. if (target2)
  900. {
  901. // Add this dependency.
  902. result.push_back(target2);
  903. }
  904. }
  905. }
  906. }
  907. // Loop over all utility dependencies.
  908. const std::set<cmStdString>& tutils = target.GetUtilities();
  909. for(std::set<cmStdString>::const_iterator util = tutils.begin();
  910. util != tutils.end(); ++util)
  911. {
  912. // Don't emit the same utility twice for this target.
  913. if(emitted.insert(*util).second)
  914. {
  915. cmTarget *target2 = target.GetMakefile()->FindTarget(util->c_str());
  916. // search each local generator until a match is found
  917. if (!target2)
  918. {
  919. target2 = this->FindTarget(0,util->c_str());
  920. }
  921. // if a match was found then ...
  922. if (target2)
  923. {
  924. // Add this dependency.
  925. result.push_back(target2);
  926. }
  927. }
  928. }
  929. return result;
  930. }
  931. //----------------------------------------------------------------------------
  932. void
  933. cmGlobalUnixMakefileGenerator3
  934. ::AppendGlobalTargetDepends(std::vector<std::string>& depends,
  935. cmTarget& target)
  936. {
  937. // Keep track of dependencies already listed.
  938. std::set<cmStdString> emitted;
  939. // A target should not depend on itself.
  940. emitted.insert(target.GetName());
  941. // Loop over all library dependencies but not for static libs
  942. if (target.GetType() != cmTarget::STATIC_LIBRARY)
  943. {
  944. const cmTarget::LinkLibraryVectorType& tlibs = target.GetLinkLibraries();
  945. for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin();
  946. lib != tlibs.end(); ++lib)
  947. {
  948. // Don't emit the same library twice for this target.
  949. if(emitted.insert(lib->first).second)
  950. {
  951. // Add this dependency.
  952. this->AppendAnyGlobalDepend(depends, lib->first.c_str(),
  953. emitted, target);
  954. }
  955. }
  956. }
  957. // Loop over all utility dependencies.
  958. const std::set<cmStdString>& tutils = target.GetUtilities();
  959. for(std::set<cmStdString>::const_iterator util = tutils.begin();
  960. util != tutils.end(); ++util)
  961. {
  962. // Don't emit the same utility twice for this target.
  963. if(emitted.insert(*util).second)
  964. {
  965. // Add this dependency.
  966. this->AppendAnyGlobalDepend(depends, util->c_str(), emitted, target);
  967. }
  968. }
  969. }
  970. //----------------------------------------------------------------------------
  971. void
  972. cmGlobalUnixMakefileGenerator3
  973. ::AppendAnyGlobalDepend(std::vector<std::string>& depends, const char* name,
  974. std::set<cmStdString>& emitted, cmTarget &target)
  975. {
  976. cmTarget *result;
  977. cmLocalUnixMakefileGenerator3 *lg3;
  978. // first check the same dir as the current target
  979. lg3 = static_cast<cmLocalUnixMakefileGenerator3 *>
  980. (target.GetMakefile()->GetLocalGenerator());
  981. result = target.GetMakefile()->FindTarget(name);
  982. // search each local generator until a match is found
  983. if (!result)
  984. {
  985. result = this->FindTarget(0,name);
  986. if (result)
  987. {
  988. lg3 = static_cast<cmLocalUnixMakefileGenerator3 *>
  989. (result->GetMakefile()->GetLocalGenerator());
  990. }
  991. }
  992. // if a match was found then ...
  993. if (result)
  994. {
  995. std::string tgtName = lg3->GetRelativeTargetDirectory(*result);
  996. tgtName += "/all";
  997. depends.push_back(tgtName);
  998. if(result->GetType() == cmTarget::STATIC_LIBRARY)
  999. {
  1000. const cmTarget::LinkLibraryVectorType& tlibs
  1001. = result->GetLinkLibraries();
  1002. for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin();
  1003. lib != tlibs.end(); ++lib)
  1004. {
  1005. // Don't emit the same library twice for this target.
  1006. if(emitted.insert(lib->first).second)
  1007. {
  1008. // Add this dependency.
  1009. this->AppendAnyGlobalDepend(depends, lib->first.c_str(),
  1010. emitted, *result);
  1011. }
  1012. }
  1013. }
  1014. return;
  1015. }
  1016. }
  1017. //----------------------------------------------------------------------------
  1018. void cmGlobalUnixMakefileGenerator3::WriteHelpRule
  1019. (std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3 *lg)
  1020. {
  1021. // add the help target
  1022. std::string path;
  1023. std::vector<std::string> no_depends;
  1024. std::vector<std::string> commands;
  1025. lg->AppendEcho(commands,"The following are some of the valid targets "
  1026. "for this Makefile:");
  1027. lg->AppendEcho(commands,"... all (the default if no target is provided)");
  1028. lg->AppendEcho(commands,"... clean");
  1029. lg->AppendEcho(commands,"... depend");
  1030. // Keep track of targets already listed.
  1031. std::set<cmStdString> emittedTargets;
  1032. // for each local generator
  1033. unsigned int i;
  1034. cmLocalUnixMakefileGenerator3 *lg2;
  1035. for (i = 0; i < this->LocalGenerators.size(); ++i)
  1036. {
  1037. lg2 =
  1038. static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
  1039. // for the passed in makefile or if this is the top Makefile wripte out
  1040. // the targets
  1041. if (lg2 == lg || !lg->GetParent())
  1042. {
  1043. // for each target Generate the rule files for each target.
  1044. cmTargets& targets = lg2->GetMakefile()->GetTargets();
  1045. for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
  1046. {
  1047. if((t->second.GetType() == cmTarget::EXECUTABLE) ||
  1048. (t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
  1049. (t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
  1050. (t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
  1051. (t->second.GetType() == cmTarget::GLOBAL_TARGET) ||
  1052. (t->second.GetType() == cmTarget::UTILITY))
  1053. {
  1054. if(emittedTargets.insert(t->second.GetName()).second)
  1055. {
  1056. path = "... ";
  1057. path += t->second.GetName();
  1058. lg->AppendEcho(commands,path.c_str());
  1059. }
  1060. }
  1061. }
  1062. std::map<cmStdString,std::vector<cmTarget *> > const& objs =
  1063. lg->GetLocalObjectFiles();
  1064. for(std::map<cmStdString,std::vector<cmTarget *> >::const_iterator o =
  1065. objs.begin(); o != objs.end(); ++o)
  1066. {
  1067. path = "... ";
  1068. path += o->first;
  1069. lg->AppendEcho(commands, path.c_str());
  1070. }
  1071. }
  1072. }
  1073. lg->WriteMakeRule(ruleFileStream, "Help Target",
  1074. "help:",
  1075. no_depends, commands, true);
  1076. ruleFileStream << "\n\n";
  1077. }
  1078. bool cmGlobalUnixMakefileGenerator3
  1079. ::NeedRequiresStep(cmLocalUnixMakefileGenerator3 *lg,const char *name)
  1080. {
  1081. std::map<cmStdString,cmLocalUnixMakefileGenerator3::IntegrityCheckSet>&
  1082. checkSet = lg->GetIntegrityCheckSet()[name];
  1083. for(std::map<cmStdString,
  1084. cmLocalUnixMakefileGenerator3::IntegrityCheckSet>::const_iterator
  1085. l = checkSet.begin(); l != checkSet.end(); ++l)
  1086. {
  1087. std::string name2 = "CMAKE_NEEDS_REQUIRES_STEP_";
  1088. name2 += l->first;
  1089. name2 += "_FLAG";
  1090. if(lg->GetMakefile()->GetDefinition(name2.c_str()))
  1091. {
  1092. return true;
  1093. }
  1094. }
  1095. return false;
  1096. }