cmake.cxx 36 KB

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