cmake.cxx 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  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 "cmake.h"
  14. #include "time.h"
  15. #include "cmCacheManager.h"
  16. #include "cmMakefile.h"
  17. #include "cmLocalGenerator.h"
  18. #include "cmCommands.h"
  19. #include "cmCommand.h"
  20. #include "cmVariableWatch.h"
  21. // include the generator
  22. #if defined(_WIN32) && !defined(__CYGWIN__)
  23. #include "cmGlobalVisualStudio6Generator.h"
  24. #include "cmGlobalVisualStudio7Generator.h"
  25. #include "cmGlobalVisualStudio71Generator.h"
  26. #include "cmGlobalBorlandMakefileGenerator.h"
  27. #include "cmGlobalNMakeMakefileGenerator.h"
  28. #include "cmWin32ProcessExecution.h"
  29. #else
  30. #include "cmGlobalUnixMakefileGenerator.h"
  31. #endif
  32. #include <stdio.h>
  33. #include <stdlib.h> // required for atoi
  34. #ifdef __APPLE__
  35. #include <sys/types.h>
  36. #include <sys/time.h>
  37. #include <sys/resource.h>
  38. #if defined(CMAKE_BUILD_WITH_CMAKE)
  39. #include "cmGlobalCodeWarriorGenerator.h"
  40. #endif
  41. #endif
  42. void cmNeedBackwardsCompatibility(const std::string& variable,
  43. int access_type, void* )
  44. {
  45. if (access_type == cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS)
  46. {
  47. std::string message = "An attempt was made to access a variable: ";
  48. message += variable;
  49. message += " that has not been defined. Some variables were always defined by CMake in versions prior to 1.6. To fix this you might need to set the cache value of CMAKE_BACKWARDS_COMPATIBILITY to 1.4 or less. If you are writing a CMakeList file, (or have already set CMAKE_BACKWARDS_COMPATABILITY to 1.4 or less) then you probably need to include a CMake module to test for the feature this variable defines.";
  50. cmSystemTools::Error(message.c_str());
  51. }
  52. }
  53. cmake::cmake()
  54. {
  55. #ifdef __APPLE__
  56. struct rlimit rlp;
  57. if(!getrlimit(RLIMIT_STACK, &rlp))
  58. {
  59. if(rlp.rlim_cur != rlp.rlim_max)
  60. {
  61. rlp.rlim_cur = rlp.rlim_max;
  62. setrlimit(RLIMIT_STACK, &rlp);
  63. }
  64. }
  65. #endif
  66. // If MAKEFLAGS are given in the environment, remove the environment
  67. // variable. This will prevent try-compile from succeeding when it
  68. // should fail (if "-i" is an option). We cannot simply test
  69. // whether "-i" is given and remove it because some make programs
  70. // encode the MAKEFLAGS variable in a strange way.
  71. if(getenv("MAKEFLAGS"))
  72. {
  73. static char makeflags[] = "MAKEFLAGS=";
  74. putenv(makeflags);
  75. }
  76. m_Local = false;
  77. m_Verbose = false;
  78. m_InTryCompile = false;
  79. m_CacheManager = new cmCacheManager;
  80. m_GlobalGenerator = 0;
  81. m_ProgressCallback = 0;
  82. m_ProgressCallbackClientData = 0;
  83. m_VariableWatch = new cmVariableWatch;
  84. this->AddDefaultGenerators();
  85. this->AddDefaultCommands();
  86. m_VariableWatch->AddWatch("CMAKE_WORDS_BIGENDIAN",
  87. cmNeedBackwardsCompatibility);
  88. m_VariableWatch->AddWatch("CMAKE_SIZEOF_INT",
  89. cmNeedBackwardsCompatibility);
  90. m_VariableWatch->AddWatch("CMAKE_X_LIBS",
  91. cmNeedBackwardsCompatibility);
  92. }
  93. cmake::~cmake()
  94. {
  95. delete m_CacheManager;
  96. if (m_GlobalGenerator)
  97. {
  98. delete m_GlobalGenerator;
  99. m_GlobalGenerator = 0;
  100. }
  101. for(RegisteredCommandsMap::iterator j = m_Commands.begin();
  102. j != m_Commands.end(); ++j)
  103. {
  104. delete (*j).second;
  105. }
  106. delete m_VariableWatch;
  107. }
  108. bool cmake::CommandExists(const char* name) const
  109. {
  110. return (m_Commands.find(name) != m_Commands.end());
  111. }
  112. cmCommand *cmake::GetCommand(const char *name)
  113. {
  114. cmCommand* rm = 0;
  115. RegisteredCommandsMap::iterator pos = m_Commands.find(name);
  116. if (pos != m_Commands.end())
  117. {
  118. rm = (*pos).second;
  119. }
  120. return rm;
  121. }
  122. void cmake::AddCommand(cmCommand* wg)
  123. {
  124. std::string name = wg->GetName();
  125. // if the command already exists, free the old one
  126. RegisteredCommandsMap::iterator pos = m_Commands.find(name);
  127. if (pos != m_Commands.end())
  128. {
  129. delete pos->second;
  130. m_Commands.erase(pos);
  131. }
  132. m_Commands.insert( RegisteredCommandsMap::value_type(name, wg));
  133. }
  134. void cmake::Usage(const char* program)
  135. {
  136. cmOStringStream errorStream;
  137. errorStream << "cmake version " << cmMakefile::GetMajorVersion()
  138. << "." << cmMakefile::GetMinorVersion() << "\n";
  139. errorStream << "Usage: " << program << " [srcdir] [options]\n"
  140. << "Where cmake is run from the directory where you want the object files written. If srcdir is not specified, the current directory is used for both source and object files.\n";
  141. errorStream << "Options are:\n";
  142. errorStream << "\n-i (puts cmake in wizard mode, not available for ccmake)\n";
  143. errorStream << "\n-DVAR:TYPE=VALUE (create a cache file entry)\n";
  144. errorStream << "\n-Cpath_to_initial_cache (a cmake list file that is used to pre-load the cache with values.)\n";
  145. errorStream << "\n[-GgeneratorName] (where generator name can be one of these: ";
  146. std::vector<std::string> names;
  147. this->GetRegisteredGenerators(names);
  148. for(std::vector<std::string>::iterator i =names.begin();
  149. i != names.end(); ++i)
  150. {
  151. errorStream << "\"" << i->c_str() << "\" ";
  152. }
  153. errorStream << ")\n";
  154. cmSystemTools::Error(errorStream.str().c_str());
  155. }
  156. // Parse the args
  157. void cmake::SetCacheArgs(const std::vector<std::string>& args)
  158. {
  159. for(unsigned int i=1; i < args.size(); ++i)
  160. {
  161. std::string arg = args[i];
  162. if(arg.find("-D",0) == 0)
  163. {
  164. std::string entry = arg.substr(2);
  165. std::string var, value;
  166. cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
  167. if(cmCacheManager::ParseEntry(entry.c_str(), var, value, type) ||
  168. cmCacheManager::ParseEntry(entry.c_str(), var, value))
  169. {
  170. this->m_CacheManager->AddCacheEntry(var.c_str(), value.c_str(),
  171. "No help, variable specified on the command line.",
  172. type);
  173. }
  174. else
  175. {
  176. std::cerr << "Parse error in command line argument: " << arg << "\n"
  177. << "Should be: VAR:type=value\n";
  178. }
  179. }
  180. else if(arg.find("-C",0) == 0)
  181. {
  182. std::string path = arg.substr(2);
  183. std::cerr << "loading initial cache file " << path.c_str() << "\n";
  184. this->ReadListFile(path.c_str());
  185. }
  186. }
  187. }
  188. void cmake::ReadListFile(const char *path)
  189. {
  190. // if a generator was not yet created, temporarily create one
  191. cmGlobalGenerator *gg = this->GetGlobalGenerator();
  192. bool created = false;
  193. // if a generator was not specified use a generic one
  194. if (!gg)
  195. {
  196. gg = new cmGlobalGenerator;
  197. gg->SetCMakeInstance(this);
  198. created = true;
  199. }
  200. // read in the list file to fill the cache
  201. if(path)
  202. {
  203. cmLocalGenerator *lg = gg->CreateLocalGenerator();
  204. lg->SetGlobalGenerator(gg);
  205. if (!lg->GetMakefile()->ReadListFile(0, path))
  206. {
  207. std::cerr << "Error in reading cmake initial cache file:"
  208. << path << "\n";
  209. }
  210. }
  211. // free generic one if generated
  212. if (created)
  213. {
  214. delete gg;
  215. }
  216. }
  217. // Parse the args
  218. void cmake::SetArgs(const std::vector<std::string>& args)
  219. {
  220. m_Local = false;
  221. bool directoriesSet = false;
  222. for(unsigned int i=1; i < args.size(); ++i)
  223. {
  224. std::string arg = args[i];
  225. if(arg.find("-H",0) == 0)
  226. {
  227. directoriesSet = true;
  228. std::string path = arg.substr(2);
  229. this->SetHomeDirectory(path.c_str());
  230. }
  231. else if(arg.find("-S",0) == 0)
  232. {
  233. directoriesSet = true;
  234. m_Local = true;
  235. std::string path = arg.substr(2);
  236. this->SetStartDirectory(path.c_str());
  237. }
  238. else if(arg.find("-O",0) == 0)
  239. {
  240. directoriesSet = true;
  241. std::string path = arg.substr(2);
  242. this->SetStartOutputDirectory(path.c_str());
  243. }
  244. else if(arg.find("-B",0) == 0)
  245. {
  246. directoriesSet = true;
  247. std::string path = arg.substr(2);
  248. this->SetHomeOutputDirectory(path.c_str());
  249. }
  250. else if(arg.find("-V",0) == 0)
  251. {
  252. m_Verbose = true;
  253. }
  254. else if(arg.find("-D",0) == 0)
  255. {
  256. // skip for now
  257. }
  258. else if(arg.find("-C",0) == 0)
  259. {
  260. // skip for now
  261. }
  262. else if(arg.find("-G",0) == 0)
  263. {
  264. std::string value = arg.substr(2);
  265. cmGlobalGenerator* gen =
  266. this->CreateGlobalGenerator(value.c_str());
  267. if(!gen)
  268. {
  269. cmSystemTools::Error("Could not create named generator ",
  270. value.c_str());
  271. }
  272. else
  273. {
  274. this->SetGlobalGenerator(gen);
  275. }
  276. }
  277. // no option assume it is the path to the source
  278. else
  279. {
  280. directoriesSet = true;
  281. this->SetDirectoriesFromFile(arg.c_str());
  282. }
  283. }
  284. if(!directoriesSet)
  285. {
  286. this->SetHomeOutputDirectory
  287. (cmSystemTools::GetCurrentWorkingDirectory().c_str());
  288. this->SetStartOutputDirectory
  289. (cmSystemTools::GetCurrentWorkingDirectory().c_str());
  290. this->SetHomeDirectory
  291. (cmSystemTools::GetCurrentWorkingDirectory().c_str());
  292. this->SetStartDirectory
  293. (cmSystemTools::GetCurrentWorkingDirectory().c_str());
  294. }
  295. if (!m_Local)
  296. {
  297. this->SetStartDirectory(this->GetHomeDirectory());
  298. this->SetStartOutputDirectory(this->GetHomeOutputDirectory());
  299. }
  300. }
  301. //----------------------------------------------------------------------------
  302. void cmake::SetDirectoriesFromFile(const char* arg)
  303. {
  304. // Check if the argument refers to a CMakeCache.txt or
  305. // CMakeLists.txt file.
  306. std::string listPath;
  307. std::string cachePath;
  308. bool argIsFile = false;
  309. if(cmSystemTools::FileIsDirectory(arg))
  310. {
  311. std::string path = cmSystemTools::CollapseFullPath(arg);
  312. cmSystemTools::ConvertToUnixSlashes(path);
  313. std::string cacheFile = path;
  314. cacheFile += "/CMakeCache.txt";
  315. std::string listFile = path;
  316. listFile += "/CMakeLists.txt";
  317. if(cmSystemTools::FileExists(cacheFile.c_str()))
  318. {
  319. cachePath = path;
  320. }
  321. if(cmSystemTools::FileExists(listFile.c_str()))
  322. {
  323. listPath = path;
  324. }
  325. }
  326. else if(cmSystemTools::FileExists(arg))
  327. {
  328. argIsFile = true;
  329. std::string fullPath = cmSystemTools::CollapseFullPath(arg);
  330. std::string name = cmSystemTools::GetFilenameName(fullPath.c_str());
  331. name = cmSystemTools::LowerCase(name);
  332. if(name == "cmakecache.txt")
  333. {
  334. cachePath = cmSystemTools::GetFilenamePath(fullPath.c_str());
  335. }
  336. else if(name == "cmakelists.txt")
  337. {
  338. listPath = cmSystemTools::GetFilenamePath(fullPath.c_str());
  339. }
  340. }
  341. // If there is a CMakeCache.txt file, use its settings.
  342. if(cachePath.length() > 0)
  343. {
  344. cmCacheManager* cachem = this->GetCacheManager();
  345. cmCacheManager::CacheIterator it = cachem->NewIterator();
  346. if(cachem->LoadCache(cachePath.c_str()) && it.Find("CMAKE_HOME_DIRECTORY"))
  347. {
  348. this->SetHomeOutputDirectory(cachePath.c_str());
  349. this->SetStartOutputDirectory(cachePath.c_str());
  350. this->SetHomeDirectory(it.GetValue());
  351. this->SetStartDirectory(it.GetValue());
  352. return;
  353. }
  354. }
  355. // If there is a CMakeLists.txt file, use it as the source tree.
  356. if(listPath.length() > 0)
  357. {
  358. this->SetHomeDirectory(listPath.c_str());
  359. this->SetStartDirectory(listPath.c_str());
  360. if(argIsFile)
  361. {
  362. // Source CMakeLists.txt file given. It was probably dropped
  363. // onto the executable in a GUI. Default to an in-source build.
  364. this->SetHomeOutputDirectory(listPath.c_str());
  365. this->SetStartOutputDirectory(listPath.c_str());
  366. }
  367. else
  368. {
  369. // Source directory given on command line. Use current working
  370. // directory as build tree.
  371. std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
  372. this->SetHomeOutputDirectory(cwd.c_str());
  373. this->SetStartOutputDirectory(cwd.c_str());
  374. }
  375. return;
  376. }
  377. // We didn't find a CMakeLists.txt or CMakeCache.txt file from the
  378. // argument. Assume it is the path to the source tree, and use the
  379. // current working directory as the build tree.
  380. std::string full = cmSystemTools::CollapseFullPath(arg);
  381. std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
  382. this->SetHomeDirectory(full.c_str());
  383. this->SetStartDirectory(full.c_str());
  384. this->SetHomeOutputDirectory(cwd.c_str());
  385. this->SetStartOutputDirectory(cwd.c_str());
  386. }
  387. // at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the cache
  388. int cmake::AddCMakePaths(const char *arg0)
  389. {
  390. // Find our own executable.
  391. std::vector<cmStdString> failures;
  392. std::string cMakeSelf = arg0;
  393. cmSystemTools::ConvertToUnixSlashes(cMakeSelf);
  394. failures.push_back(cMakeSelf);
  395. cMakeSelf = cmSystemTools::FindProgram(cMakeSelf.c_str());
  396. if(!cmSystemTools::FileExists(cMakeSelf.c_str()))
  397. {
  398. #ifdef CMAKE_BUILD_DIR
  399. std::string intdir = ".";
  400. #ifdef CMAKE_INTDIR
  401. intdir = CMAKE_INTDIR;
  402. #endif
  403. cMakeSelf = CMAKE_BUILD_DIR;
  404. cMakeSelf += "/bin/";
  405. cMakeSelf += intdir;
  406. cMakeSelf += "/cmake";
  407. cMakeSelf += cmSystemTools::GetExecutableExtension();
  408. #endif
  409. }
  410. #ifdef CMAKE_PREFIX
  411. if(!cmSystemTools::FileExists(cMakeSelf.c_str()))
  412. {
  413. failures.push_back(cMakeSelf);
  414. cMakeSelf = CMAKE_PREFIX "/bin/cmake";
  415. }
  416. #endif
  417. if(!cmSystemTools::FileExists(cMakeSelf.c_str()))
  418. {
  419. failures.push_back(cMakeSelf);
  420. cmOStringStream msg;
  421. msg << "CMAKE can not find the command line program cmake.\n";
  422. msg << " argv[0] = \"" << arg0 << "\"\n";
  423. msg << " Attempted paths:\n";
  424. std::vector<cmStdString>::iterator i;
  425. for(i=failures.begin(); i != failures.end(); ++i)
  426. {
  427. msg << " \"" << i->c_str() << "\"\n";
  428. }
  429. cmSystemTools::Error(msg.str().c_str());
  430. return 0;
  431. }
  432. // Save the value in the cache
  433. this->m_CacheManager->AddCacheEntry
  434. ("CMAKE_COMMAND",cMakeSelf.c_str(), "Path to CMake executable.",
  435. cmCacheManager::INTERNAL);
  436. // Find and save the command to edit the cache
  437. std::string editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) +
  438. "/ccmake" + cmSystemTools::GetFilenameExtension(cMakeSelf);
  439. if( !cmSystemTools::FileExists(editCacheCommand.c_str()))
  440. {
  441. editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) +
  442. "/CMakeSetup" + cmSystemTools::GetFilenameExtension(cMakeSelf);
  443. }
  444. if(cmSystemTools::FileExists(editCacheCommand.c_str()))
  445. {
  446. this->m_CacheManager->AddCacheEntry
  447. ("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(),
  448. "Path to cache edit program executable.", cmCacheManager::INTERNAL);
  449. }
  450. // do CMAKE_ROOT, look for the environment variable first
  451. std::string cMakeRoot;
  452. std::string modules;
  453. if (getenv("CMAKE_ROOT"))
  454. {
  455. cMakeRoot = getenv("CMAKE_ROOT");
  456. modules = cMakeRoot + "/Modules/CMakeDefaultMakeRuleVariables.cmake";
  457. }
  458. if(!cmSystemTools::FileExists(modules.c_str()))
  459. {
  460. // next try exe/..
  461. cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str());
  462. std::string::size_type slashPos = cMakeRoot.rfind("/");
  463. if(slashPos != std::string::npos)
  464. {
  465. cMakeRoot = cMakeRoot.substr(0, slashPos);
  466. }
  467. // is there no Modules direcory there?
  468. modules = cMakeRoot + "/Modules/CMakeDefaultMakeRuleVariables.cmake";
  469. }
  470. if (!cmSystemTools::FileExists(modules.c_str()))
  471. {
  472. // try exe/../share/cmake
  473. cMakeRoot += CMAKE_DATA_DIR;
  474. modules = cMakeRoot + "/Modules/CMakeDefaultMakeRuleVariables.cmake";
  475. }
  476. #ifdef CMAKE_ROOT_DIR
  477. if (!cmSystemTools::FileExists(modules.c_str()))
  478. {
  479. // try compiled in root directory
  480. cMakeRoot = CMAKE_ROOT_DIR;
  481. modules = cMakeRoot + "/Modules/CMakeDefaultMakeRuleVariables.cmake";
  482. }
  483. #endif
  484. #ifdef CMAKE_PREFIX
  485. if (!cmSystemTools::FileExists(modules.c_str()))
  486. {
  487. // try compiled in install prefix
  488. cMakeRoot = CMAKE_PREFIX CMAKE_DATA_DIR;
  489. modules = cMakeRoot + "/Modules/CMakeDefaultMakeRuleVariables.cmake";
  490. }
  491. #endif
  492. if (!cmSystemTools::FileExists(modules.c_str()))
  493. {
  494. // try
  495. cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str());
  496. cMakeRoot += CMAKE_DATA_DIR;
  497. modules = cMakeRoot + "/Modules/CMakeDefaultMakeRuleVariables.cmake";
  498. }
  499. if(!cmSystemTools::FileExists(modules.c_str()))
  500. {
  501. // next try exe
  502. cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str());
  503. // is there no Modules direcory there?
  504. modules = cMakeRoot + "/Modules/CMakeDefaultMakeRuleVariables.cmake";
  505. }
  506. if (!cmSystemTools::FileExists(modules.c_str()))
  507. {
  508. // couldn't find modules
  509. cmSystemTools::Error("Could not find CMAKE_ROOT !!!\n",
  510. "Modules directory not in directory:\n",
  511. modules.c_str());
  512. return 0;
  513. }
  514. this->m_CacheManager->AddCacheEntry
  515. ("CMAKE_ROOT", cMakeRoot.c_str(),
  516. "Path to CMake installation.", cmCacheManager::INTERNAL);
  517. #ifdef _WIN32
  518. std::string comspec = "cmw9xcom.exe";
  519. cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str());
  520. #endif
  521. return 1;
  522. }
  523. void CMakeCommandUsage(const char* program)
  524. {
  525. cmOStringStream errorStream;
  526. errorStream
  527. << "cmake version " << cmMakefile::GetMajorVersion()
  528. << "." << cmMakefile::GetMinorVersion() << "\n";
  529. errorStream
  530. << "Usage: " << program << " -E [command] [arguments ...]\n"
  531. << "Available commands: \n"
  532. << " chdir dir cmd [args]... - run command in a given directory\n"
  533. << " copy file destination - copy file to destination (either file or directory)\n"
  534. << " copy_if_different in-file out-file - copy file if input has changed\n"
  535. << " echo [string]... - displays arguments as text\n"
  536. << " remove file1 file2 ... - remove the file(s)\n"
  537. << " time command [args] ... - run command and return elapsed time\n";
  538. #if defined(_WIN32) && !defined(__CYGWIN__)
  539. errorStream
  540. << " write_regv key value - write registry value\n"
  541. << " delete_regv key - delete registry value\n"
  542. << " comspec - on windows 9x use this for RunCommand\n";
  543. #endif
  544. cmSystemTools::Error(errorStream.str().c_str());
  545. }
  546. int cmake::CMakeCommand(std::vector<std::string>& args)
  547. {
  548. if (args.size() > 1)
  549. {
  550. // Copy file
  551. if (args[1] == "copy" && args.size() == 4)
  552. {
  553. cmSystemTools::cmCopyFile(args[2].c_str(), args[3].c_str());
  554. return cmSystemTools::GetErrorOccuredFlag();
  555. }
  556. // Copy file if different.
  557. if (args[1] == "copy_if_different" && args.size() == 4)
  558. {
  559. cmSystemTools::CopyFileIfDifferent(args[2].c_str(), args[3].c_str());
  560. return cmSystemTools::GetErrorOccuredFlag();
  561. }
  562. // Echo string
  563. else if (args[1] == "echo" )
  564. {
  565. unsigned int cc;
  566. for ( cc = 2; cc < args.size(); cc ++ )
  567. {
  568. std::cout << args[cc] << " ";
  569. }
  570. std::cout << std::endl;
  571. return 0;
  572. }
  573. // Remove file
  574. else if (args[1] == "remove" && args.size() > 2)
  575. {
  576. for (std::string::size_type cc = 2; cc < args.size(); cc ++)
  577. {
  578. if(args[cc] != "-f")
  579. {
  580. if(args[cc] == "\\-f")
  581. {
  582. args[cc] = "-f";
  583. }
  584. cmSystemTools::RemoveFile(args[cc].c_str());
  585. }
  586. }
  587. return 0;
  588. }
  589. // Clock command
  590. else if (args[1] == "time" && args.size() > 2)
  591. {
  592. std::string command = args[2];
  593. std::string output;
  594. for (std::string::size_type cc = 3; cc < args.size(); cc ++)
  595. {
  596. command += " ";
  597. command += args[cc];
  598. }
  599. clock_t clock_start, clock_finish;
  600. time_t time_start, time_finish;
  601. time(&time_start);
  602. clock_start = clock();
  603. cmSystemTools::RunSingleCommand(command.c_str());
  604. clock_finish = clock();
  605. time(&time_finish);
  606. double clocks_per_sec = (double)CLOCKS_PER_SEC;
  607. std::cout << "Elapsed time: "
  608. << (long)(time_finish - time_start) << " s. (time)"
  609. << ", "
  610. << (double)(clock_finish - clock_start) / clocks_per_sec
  611. << " s. (clock)"
  612. << "\n";
  613. return 0;
  614. }
  615. // Clock command
  616. else if (args[1] == "chdir" && args.size() >= 4)
  617. {
  618. std::string directory = args[2];
  619. std::string command = args[3];
  620. std::string output;
  621. for (std::string::size_type cc = 4; cc < args.size(); cc ++)
  622. {
  623. command += " ";
  624. command += args[cc];
  625. }
  626. int retval = 0;
  627. int timeout = 0;
  628. if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, &retval,
  629. directory.c_str(), true, timeout) )
  630. {
  631. return retval;
  632. }
  633. return 1;
  634. }
  635. #if defined(_WIN32) && !defined(__CYGWIN__)
  636. // Write registry value
  637. else if (args[1] == "write_regv" && args.size() > 3)
  638. {
  639. return cmSystemTools::WriteRegistryValue(args[2].c_str(),
  640. args[3].c_str()) ? 0 : 1;
  641. }
  642. // Delete registry value
  643. else if (args[1] == "delete_regv" && args.size() > 2)
  644. {
  645. return cmSystemTools::DeleteRegistryValue(args[2].c_str()) ? 0 : 1;
  646. }
  647. // Remove file
  648. else if (args[1] == "comspec" && args.size() > 2)
  649. {
  650. unsigned int cc;
  651. std::string command = args[2];
  652. for ( cc = 3; cc < args.size(); cc ++ )
  653. {
  654. command += " " + args[cc];
  655. }
  656. return cmWin32ProcessExecution::Windows9xHack(command.c_str());
  657. }
  658. #endif
  659. }
  660. ::CMakeCommandUsage(args[0].c_str());
  661. return 1;
  662. }
  663. void cmake::GetRegisteredGenerators(std::vector<std::string>& names)
  664. {
  665. for(RegisteredGeneratorsMap::const_iterator i = m_Generators.begin();
  666. i != m_Generators.end(); ++i)
  667. {
  668. names.push_back(i->first);
  669. }
  670. }
  671. cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name)
  672. {
  673. RegisteredGeneratorsMap::const_iterator i = m_Generators.find(name);
  674. if(i != m_Generators.end())
  675. {
  676. cmGlobalGenerator* generator = (i->second)();
  677. generator->SetCMakeInstance(this);
  678. return generator;
  679. }
  680. else
  681. {
  682. return 0;
  683. }
  684. }
  685. void cmake::SetHomeDirectory(const char* dir)
  686. {
  687. m_cmHomeDirectory = dir;
  688. cmSystemTools::ConvertToUnixSlashes(m_cmHomeDirectory);
  689. }
  690. void cmake::SetHomeOutputDirectory(const char* lib)
  691. {
  692. m_HomeOutputDirectory = lib;
  693. cmSystemTools::ConvertToUnixSlashes(m_HomeOutputDirectory);
  694. }
  695. void cmake::SetGlobalGenerator(cmGlobalGenerator *gg)
  696. {
  697. // delete the old generator
  698. if (m_GlobalGenerator)
  699. {
  700. delete m_GlobalGenerator;
  701. // restore the original environment variables CXX and CC
  702. // Restor CC
  703. static char envCC[5000];
  704. std::string env = "CC=";
  705. if(m_CCEnvironment)
  706. {
  707. env += m_CCEnvironment;
  708. }
  709. std::string::size_type size = env.size();
  710. if(size > 4999)
  711. {
  712. size = 4999;
  713. }
  714. strncpy(envCC, env.c_str(), size);
  715. envCC[4999] = 0;
  716. putenv(envCC);
  717. // Restore CXX
  718. static char envCXX[5000];
  719. env = "CXX=";
  720. if(m_CXXEnvironment)
  721. {
  722. env += m_CXXEnvironment;
  723. }
  724. size = env.size();
  725. if(size > 4999)
  726. {
  727. size = 4999;
  728. }
  729. strncpy(envCXX, env.c_str(), size);
  730. envCXX[4999] = 0;
  731. putenv(envCXX);
  732. }
  733. // set the new
  734. m_GlobalGenerator = gg;
  735. // Save the environment variables CXX and CC
  736. m_CXXEnvironment = getenv("CXX");
  737. m_CCEnvironment = getenv("CC");
  738. // set the cmake instance just to be sure
  739. gg->SetCMakeInstance(this);
  740. }
  741. int cmake::DoPreConfigureChecks()
  742. {
  743. // Make sure the Start directory contains a CMakeLists.txt file.
  744. std::string srcList = this->GetHomeDirectory();
  745. srcList += "/CMakeLists.txt";
  746. if(!cmSystemTools::FileExists(srcList.c_str()))
  747. {
  748. cmSystemTools::Error(
  749. "The source directory does not appear to contain CMakeLists.txt.\n"
  750. "Specify --help for usage, or press the help button on the CMake GUI.");
  751. return -2;
  752. }
  753. // do a sanity check on some values
  754. if(m_CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY"))
  755. {
  756. std::string cacheStart =
  757. m_CacheManager->GetCacheValue("CMAKE_HOME_DIRECTORY");
  758. cacheStart += "/CMakeLists.txt";
  759. std::string currentStart = this->GetHomeDirectory();
  760. currentStart += "/CMakeLists.txt";
  761. if(!cmSystemTools::SameFile(cacheStart.c_str(), currentStart.c_str()))
  762. {
  763. std::string message = "The source \"";
  764. message += currentStart;
  765. message += "\" does not match the source \"";
  766. message += cacheStart;
  767. message += "\" used to generate cache. ";
  768. message += "Re-run cmake with a different source directory.";
  769. cmSystemTools::Error(message.c_str());
  770. return -2;
  771. }
  772. }
  773. else
  774. {
  775. return 0;
  776. }
  777. return 1;
  778. }
  779. int cmake::Configure()
  780. {
  781. int res = this->DoPreConfigureChecks();
  782. if ( res < 0 )
  783. {
  784. return -2;
  785. }
  786. if ( !res )
  787. {
  788. m_CacheManager->AddCacheEntry("CMAKE_HOME_DIRECTORY",
  789. this->GetHomeDirectory(),
  790. "Start directory with the top level CMakeLists.txt file for this project",
  791. cmCacheManager::INTERNAL);
  792. }
  793. // set the default BACKWARDS compatibility to the current version
  794. if(!m_CacheManager->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))
  795. {
  796. char ver[256];
  797. sprintf(ver,"%i.%i",cmMakefile::GetMajorVersion(),
  798. cmMakefile::GetMinorVersion());
  799. this->m_CacheManager->AddCacheEntry
  800. ("CMAKE_BACKWARDS_COMPATIBILITY",ver,
  801. "For backwards compatibility, what version of CMake commands and syntax should this version of CMake allow.",
  802. cmCacheManager::STRING);
  803. }
  804. // no generator specified on the command line
  805. if(!m_GlobalGenerator)
  806. {
  807. const char* genName = m_CacheManager->GetCacheValue("CMAKE_GENERATOR");
  808. if(genName)
  809. {
  810. m_GlobalGenerator = this->CreateGlobalGenerator(genName);
  811. }
  812. else
  813. {
  814. #if defined(__BORLANDC__) && defined(_WIN32)
  815. this->SetGlobalGenerator(new cmGlobalBorlandMakefileGenerator);
  816. #elif defined(_WIN32) && !defined(__CYGWIN__)
  817. this->SetGlobalGenerator(new cmGlobalVisualStudio6Generator);
  818. #else
  819. this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator);
  820. #endif
  821. }
  822. if(!m_GlobalGenerator)
  823. {
  824. cmSystemTools::Error("Could not create generator");
  825. return -1;
  826. }
  827. }
  828. const char* genName = m_CacheManager->GetCacheValue("CMAKE_GENERATOR");
  829. if(genName)
  830. {
  831. if(strcmp(m_GlobalGenerator->GetName(), genName) != 0)
  832. {
  833. std::string message = "Error: generator : ";
  834. message += m_GlobalGenerator->GetName();
  835. message += "\nDoes not match the generator used previously: ";
  836. message += genName;
  837. message +=
  838. "\nEither remove the CMakeCache.txt file or choose a different"
  839. " binary directory.";
  840. cmSystemTools::Error(message.c_str());
  841. return -2;
  842. }
  843. }
  844. if(!m_CacheManager->GetCacheValue("CMAKE_GENERATOR"))
  845. {
  846. m_CacheManager->AddCacheEntry("CMAKE_GENERATOR", m_GlobalGenerator->GetName(),
  847. "Name of generator.",
  848. cmCacheManager::INTERNAL);
  849. }
  850. // reset any system configuration information, except for when we are
  851. // InTryCompile. With TryCompile the system info is taken from the parent's
  852. // info to save time
  853. if (!m_InTryCompile)
  854. {
  855. m_GlobalGenerator->ClearEnabledLanguages();
  856. }
  857. // actually do the configure
  858. m_GlobalGenerator->Configure();
  859. // Before saving the cache
  860. // if the project did not define one of the entries below, add them now
  861. // so users can edit the values in the cache:
  862. // LIBRARY_OUTPUT_PATH
  863. // EXECUTABLE_OUTPUT_PATH
  864. if(!m_CacheManager->GetCacheValue("LIBRARY_OUTPUT_PATH"))
  865. {
  866. m_CacheManager->AddCacheEntry("LIBRARY_OUTPUT_PATH", "",
  867. "Single output directory for building all libraries.",
  868. cmCacheManager::PATH);
  869. }
  870. if(!m_CacheManager->GetCacheValue("EXECUTABLE_OUTPUT_PATH"))
  871. {
  872. m_CacheManager->AddCacheEntry("EXECUTABLE_OUTPUT_PATH", "",
  873. "Single output directory for building all executables.",
  874. cmCacheManager::PATH);
  875. }
  876. if(cmSystemTools::GetFatalErrorOccured() &&
  877. (!this->m_CacheManager->GetCacheValue("CMAKE_MAKE_PROGRAM") ||
  878. cmSystemTools::IsOff(this->m_CacheManager->GetCacheValue("CMAKE_MAKE_PROGRAM"))))
  879. {
  880. // We must have a bad generator selection. Wipe the cache entry so the
  881. // user can select another.
  882. m_CacheManager->RemoveCacheEntry("CMAKE_GENERATOR");
  883. }
  884. this->m_CacheManager->SaveCache(this->GetHomeOutputDirectory());
  885. if(cmSystemTools::GetErrorOccuredFlag())
  886. {
  887. return -1;
  888. }
  889. return 0;
  890. }
  891. bool cmake::CacheVersionMatches()
  892. {
  893. const char* majv = m_CacheManager->GetCacheValue("CMAKE_CACHE_MAJOR_VERSION");
  894. const char* minv = m_CacheManager->GetCacheValue("CMAKE_CACHE_MINOR_VERSION");
  895. const char* relv = m_CacheManager->GetCacheValue("CMAKE_CACHE_RELEASE_VERSION");
  896. bool cacheSameCMake = false;
  897. if(majv &&
  898. atoi(majv) == static_cast<int>(cmMakefile::GetMajorVersion())
  899. && minv &&
  900. atoi(minv) == static_cast<int>(cmMakefile::GetMinorVersion())
  901. && relv && (strcmp(relv, cmMakefile::GetReleaseVersion()) == 0))
  902. {
  903. cacheSameCMake = true;
  904. }
  905. return cacheSameCMake;
  906. }
  907. // handle a command line invocation
  908. int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
  909. {
  910. // Process the arguments
  911. this->SetArgs(args);
  912. // set the cmake command
  913. m_CMakeCommand = args[0];
  914. // load the cache
  915. if(this->LoadCache() < 0)
  916. {
  917. cmSystemTools::Error("Error executing cmake::LoadCache(). Aborting.\n");
  918. return -1;
  919. }
  920. // Add any cache args
  921. this->SetCacheArgs(args);
  922. std::string systemFile = this->GetHomeOutputDirectory();
  923. systemFile += "/CMakeSystem.cmake";
  924. if ( noconfigure )
  925. {
  926. return 0;
  927. }
  928. int ret = 0;
  929. // if not local or the cmake version has changed since the last run
  930. // of cmake, or CMakeSystem.cmake file is not in the root binary
  931. // directory, run a global generate
  932. if(!m_Local || !this->CacheVersionMatches() ||
  933. !cmSystemTools::FileExists(systemFile.c_str()) )
  934. {
  935. // If we are doing global generate, we better set start and start
  936. // output directory to the root of the project.
  937. std::string oldstartdir = this->GetStartDirectory();
  938. std::string oldstartoutputdir = this->GetStartOutputDirectory();
  939. this->SetStartDirectory(this->GetHomeDirectory());
  940. this->SetStartOutputDirectory(this->GetHomeOutputDirectory());
  941. bool saveLocalFlag = m_Local;
  942. m_Local = false;
  943. ret = this->Configure();
  944. if (ret)
  945. {
  946. return ret;
  947. }
  948. ret = this->Generate();
  949. if(ret)
  950. {
  951. return ret;
  952. }
  953. m_Local = saveLocalFlag;
  954. this->SetStartDirectory(oldstartdir.c_str());
  955. this->SetStartOutputDirectory(oldstartoutputdir.c_str());
  956. }
  957. // if we are local do the local thing
  958. if (m_Local)
  959. {
  960. ret = this->LocalGenerate();
  961. }
  962. return ret;
  963. }
  964. int cmake::Generate()
  965. {
  966. m_GlobalGenerator->Generate();
  967. if(cmSystemTools::GetErrorOccuredFlag())
  968. {
  969. return -1;
  970. }
  971. return 0;
  972. }
  973. int cmake::LocalGenerate()
  974. {
  975. // Read in the cache
  976. m_CacheManager->LoadCache(this->GetHomeOutputDirectory());
  977. // create the generator based on the cache if it isn't already there
  978. const char* genName = m_CacheManager->GetCacheValue("CMAKE_GENERATOR");
  979. if(genName)
  980. {
  981. m_GlobalGenerator = this->CreateGlobalGenerator(genName);
  982. }
  983. else
  984. {
  985. cmSystemTools::Error("Could local Generate called without the GENERATOR being specified in the CMakeCache");
  986. return -1;
  987. }
  988. // do the local generate
  989. m_GlobalGenerator->LocalGenerate();
  990. if(cmSystemTools::GetErrorOccuredFlag())
  991. {
  992. return -1;
  993. }
  994. return 0;
  995. }
  996. unsigned int cmake::GetMajorVersion()
  997. {
  998. return cmMakefile::GetMajorVersion();
  999. }
  1000. unsigned int cmake::GetMinorVersion()
  1001. {
  1002. return cmMakefile::GetMinorVersion();
  1003. }
  1004. const char *cmake::GetReleaseVersion()
  1005. {
  1006. return cmMakefile::GetReleaseVersion();
  1007. }
  1008. void cmake::AddCacheEntry(const char* key, const char* value,
  1009. const char* helpString,
  1010. int type)
  1011. {
  1012. m_CacheManager->AddCacheEntry(key, value,
  1013. helpString,
  1014. cmCacheManager::CacheEntryType(type));
  1015. }
  1016. const char* cmake::GetCacheDefinition(const char* name) const
  1017. {
  1018. return m_CacheManager->GetCacheValue(name);
  1019. }
  1020. int cmake::DumpDocumentationToFile(std::ostream& f)
  1021. {
  1022. // Loop over all registered commands and print out documentation
  1023. const char *name;
  1024. const char *terse;
  1025. const char *full;
  1026. char tmp[1024];
  1027. sprintf(tmp,"Version %d.%d", cmake::GetMajorVersion(),
  1028. cmake::GetMinorVersion());
  1029. f << "<html>\n";
  1030. f << "<h1>Documentation for commands of CMake " << tmp << "</h1>\n";
  1031. f << "<ul>\n";
  1032. for(RegisteredCommandsMap::iterator j = m_Commands.begin();
  1033. j != m_Commands.end(); ++j)
  1034. {
  1035. name = (*j).second->GetName();
  1036. terse = (*j).second->GetTerseDocumentation();
  1037. full = (*j).second->GetFullDocumentation();
  1038. f << "<li><b>" << name << "</b> - " << terse << std::endl
  1039. << "<br><i>Usage:</i> " << full << "</li>" << std::endl << std::endl;
  1040. }
  1041. f << "</ul></html>\n";
  1042. return 1;
  1043. }
  1044. void cmake::AddDefaultCommands()
  1045. {
  1046. std::list<cmCommand*> commands;
  1047. GetPredefinedCommands(commands);
  1048. for(std::list<cmCommand*>::iterator i = commands.begin();
  1049. i != commands.end(); ++i)
  1050. {
  1051. this->AddCommand(*i);
  1052. }
  1053. }
  1054. void cmake::AddDefaultGenerators()
  1055. {
  1056. #if defined(_WIN32) && !defined(__CYGWIN__)
  1057. m_Generators[cmGlobalVisualStudio6Generator::GetActualName()] =
  1058. &cmGlobalVisualStudio6Generator::New;
  1059. m_Generators[cmGlobalVisualStudio7Generator::GetActualName()] =
  1060. &cmGlobalVisualStudio7Generator::New;
  1061. m_Generators[cmGlobalVisualStudio71Generator::GetActualName()] =
  1062. &cmGlobalVisualStudio71Generator::New;
  1063. m_Generators[cmGlobalBorlandMakefileGenerator::GetActualName()] =
  1064. &cmGlobalBorlandMakefileGenerator::New;
  1065. m_Generators[cmGlobalNMakeMakefileGenerator::GetActualName()] =
  1066. &cmGlobalNMakeMakefileGenerator::New;
  1067. #else
  1068. # if defined(__APPLE__) && defined(CMAKE_BUILD_WITH_CMAKE)
  1069. m_Generators[cmGlobalCodeWarriorGenerator::GetActualName()] =
  1070. &cmGlobalCodeWarriorGenerator::New;
  1071. # endif
  1072. m_Generators[cmGlobalUnixMakefileGenerator::GetActualName()] =
  1073. &cmGlobalUnixMakefileGenerator::New;
  1074. #endif
  1075. }
  1076. int cmake::LoadCache()
  1077. {
  1078. m_CacheManager->LoadCache(this->GetHomeOutputDirectory());
  1079. if (m_CMakeCommand.size() < 2)
  1080. {
  1081. cmSystemTools::Error("cmake command was not specified prior to loading the cache in cmake.cxx");
  1082. return -1;
  1083. }
  1084. // setup CMAKE_ROOT and CMAKE_COMMAND
  1085. if(!this->AddCMakePaths(m_CMakeCommand.c_str()))
  1086. {
  1087. return -3;
  1088. }
  1089. // set the default BACKWARDS compatibility to the current version
  1090. if(!m_CacheManager->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))
  1091. {
  1092. char ver[256];
  1093. sprintf(ver,"%i.%i",cmMakefile::GetMajorVersion(),
  1094. cmMakefile::GetMinorVersion());
  1095. this->m_CacheManager->AddCacheEntry
  1096. ("CMAKE_BACKWARDS_COMPATIBILITY",ver,
  1097. "For backwards compatibility, what version of CMake commands and syntax should this version of CMake allow.",
  1098. cmCacheManager::STRING);
  1099. }
  1100. return 0;
  1101. }
  1102. void cmake::SetProgressCallback(ProgressCallback f, void *cd)
  1103. {
  1104. m_ProgressCallback = f;
  1105. m_ProgressCallbackClientData = cd;
  1106. }
  1107. void cmake::UpdateProgress(const char *msg, float prog)
  1108. {
  1109. if(m_ProgressCallback && !m_InTryCompile)
  1110. {
  1111. (*m_ProgressCallback)(msg, prog, m_ProgressCallbackClientData);
  1112. return;
  1113. }
  1114. }
  1115. void cmake::GetCommandDocumentation(std::vector<cmDocumentationEntry>& v) const
  1116. {
  1117. for(RegisteredCommandsMap::const_iterator j = m_Commands.begin();
  1118. j != m_Commands.end(); ++j)
  1119. {
  1120. cmDocumentationEntry e =
  1121. {
  1122. (*j).second->GetName(),
  1123. (*j).second->GetTerseDocumentation(),
  1124. (*j).second->GetFullDocumentation()
  1125. };
  1126. v.push_back(e);
  1127. }
  1128. cmDocumentationEntry empty = {0,0,0};
  1129. v.push_back(empty);
  1130. }
  1131. void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v)
  1132. {
  1133. for(RegisteredGeneratorsMap::const_iterator i = m_Generators.begin();
  1134. i != m_Generators.end(); ++i)
  1135. {
  1136. cmDocumentationEntry e;
  1137. cmGlobalGenerator* generator = (i->second)();
  1138. generator->GetDocumentation(e);
  1139. delete generator;
  1140. v.push_back(e);
  1141. }
  1142. cmDocumentationEntry empty = {0,0,0};
  1143. v.push_back(empty);
  1144. }