cmGlobalUnixMakefileGenerator3.cxx 41 KB

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