cpack.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmSystemTools.h"
  11. // Need these for documentation support.
  12. #include "cmake.h"
  13. #include "cmDocumentation.h"
  14. #include "cmCPackDocumentVariables.h"
  15. #include "cmCPackDocumentMacros.h"
  16. #include "cmCPackGeneratorFactory.h"
  17. #include "cmCPackGenerator.h"
  18. #include "cmake.h"
  19. #include "cmGlobalGenerator.h"
  20. #include "cmLocalGenerator.h"
  21. #include "cmMakefile.h"
  22. #include "cmCPackLog.h"
  23. #include <cmsys/CommandLineArguments.hxx>
  24. #include <cmsys/SystemTools.hxx>
  25. #include <memory> // auto_ptr
  26. //----------------------------------------------------------------------------
  27. static const char * cmDocumentationName[][3] =
  28. {
  29. {0,
  30. " cpack - Packaging driver provided by CMake.", 0},
  31. {0,0,0}
  32. };
  33. //----------------------------------------------------------------------------
  34. static const char * cmDocumentationUsage[][3] =
  35. {
  36. {0,
  37. " cpack -G <generator> [options]",
  38. 0},
  39. {0,0,0}
  40. };
  41. //----------------------------------------------------------------------------
  42. static const char * cmDocumentationDescription[][3] =
  43. {
  44. {0,
  45. "The \"cpack\" executable is the CMake packaging program. "
  46. "CMake-generated build trees created for projects that use "
  47. "the INSTALL_* commands have packaging support. "
  48. "This program will generate the package.", 0},
  49. CMAKE_STANDARD_INTRODUCTION,
  50. {0,0,0}
  51. };
  52. //----------------------------------------------------------------------------
  53. static const char * cmDocumentationOptions[][3] =
  54. {
  55. {"-G <generator>", "Use the specified generator to generate package.",
  56. "CPack may support multiple native packaging systems on certain "
  57. "platforms. A generator is responsible for generating input files for "
  58. "particular system and invoking that systems. Possible generator names "
  59. "are specified in the Generators section." },
  60. {"-C <Configuration>", "Specify the project configuration",
  61. "This option specifies the configuration that the project was build "
  62. "with, for example 'Debug', 'Release'." },
  63. {"-D <var>=<value>", "Set a CPack variable.", \
  64. "Set a variable that can be used by the generator."}, \
  65. {"--config <config file>", "Specify the config file.",
  66. "Specify the config file to use to create the package. By default "
  67. "CPackConfig.cmake in the current directory will be used." },
  68. {"--verbose,-V","enable verbose output","Run cpack with verbose output."},
  69. {"--debug","enable debug output (for CPack developers)",
  70. "Run cpack with debug output (for CPack developers)."},
  71. {"-P <package name>","override/define CPACK_PACKAGE_NAME",
  72. "If the package name is not specified on cpack commmand line then"
  73. "CPack.cmake defines it as CMAKE_PROJECT_NAME"},
  74. {"-R <package version>","override/define CPACK_PACKAGE_VERSION",
  75. "If version is not specified on cpack command line then"
  76. "CPack.cmake defines it from CPACK_PACKAGE_VERSION_[MAJOR|MINOR|PATCH]"
  77. "look into CPack.cmake for detail"},
  78. {"-B <package directory>","override/define CPACK_PACKAGE_DIRECTORY",
  79. "The directory where CPack will be doing its packaging work."
  80. "The resulting package will be found there. Inside this directory"
  81. "CPack creates '_CPack_Packages' sub-directory which is the"
  82. "CPack temporary directory."},
  83. {"--vendor <vendor name>","override/define CPACK_PACKAGE_VENDOR",
  84. "If vendor is not specified on cpack command line "
  85. "(or inside CMakeLists.txt) then"
  86. "CPack.cmake defines it with a default value"},
  87. {"--help-command cmd [file]", "Print help for a single command and exit.",
  88. "Full documentation specific to the given command is displayed. "
  89. "If a file is specified, the documentation is written into and the output "
  90. "format is determined depending on the filename suffix. Supported are man "
  91. "page, HTML, DocBook and plain text."},
  92. {"--help-command-list [file]", "List available commands and exit.",
  93. "The list contains all commands for which help may be obtained by using "
  94. "the --help-command argument followed by a command name. "
  95. "If a file is specified, the documentation is written into and the output "
  96. "format is determined depending on the filename suffix. Supported are man "
  97. "page, HTML, DocBook and plain text."},
  98. {"--help-commands [file]", "Print help for all commands and exit.",
  99. "Full documentation specific for all current command is displayed."
  100. "If a file is specified, the documentation is written into and the output "
  101. "format is determined depending on the filename suffix. Supported are man "
  102. "page, HTML, DocBook and plain text."},
  103. {"--help-variable var [file]",
  104. "Print help for a single variable and exit.",
  105. "Full documentation specific to the given variable is displayed."
  106. "If a file is specified, the documentation is written into and the output "
  107. "format is determined depending on the filename suffix. Supported are man "
  108. "page, HTML, DocBook and plain text."},
  109. {"--help-variable-list [file]", "List documented variables and exit.",
  110. "The list contains all variables for which help may be obtained by using "
  111. "the --help-variable argument followed by a variable name. If a file is "
  112. "specified, the help is written into it."
  113. "If a file is specified, the documentation is written into and the output "
  114. "format is determined depending on the filename suffix. Supported are man "
  115. "page, HTML, DocBook and plain text."},
  116. {"--help-variables [file]", "Print help for all variables and exit.",
  117. "Full documentation for all variables is displayed."
  118. "If a file is specified, the documentation is written into and the output "
  119. "format is determined depending on the filename suffix. Supported are man "
  120. "page, HTML, DocBook and plain text."},
  121. {0,0,0}
  122. };
  123. //----------------------------------------------------------------------------
  124. static const char * cmDocumentationSeeAlso[][3] =
  125. {
  126. {0, "cmake", 0},
  127. {0, "ccmake", 0},
  128. {0, 0, 0}
  129. };
  130. //----------------------------------------------------------------------------
  131. int cpackUnknownArgument(const char*, void*)
  132. {
  133. return 1;
  134. }
  135. //----------------------------------------------------------------------------
  136. struct cpackDefinitions
  137. {
  138. typedef std::map<cmStdString, cmStdString> MapType;
  139. MapType Map;
  140. cmCPackLog *Log;
  141. };
  142. //----------------------------------------------------------------------------
  143. int cpackDefinitionArgument(const char* argument, const char* cValue,
  144. void* call_data)
  145. {
  146. (void)argument;
  147. cpackDefinitions* def = static_cast<cpackDefinitions*>(call_data);
  148. std::string value = cValue;
  149. size_t pos = value.find_first_of("=");
  150. if ( pos == std::string::npos )
  151. {
  152. cmCPack_Log(def->Log, cmCPackLog::LOG_ERROR,
  153. "Please specify CPack definitions as: KEY=VALUE" << std::endl);
  154. return 0;
  155. }
  156. std::string key = value.substr(0, pos);
  157. value = value.c_str() + pos + 1;
  158. def->Map[key] = value;
  159. cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: "
  160. << key.c_str() << " to \"" << value.c_str() << "\"" << std::endl);
  161. return 1;
  162. }
  163. //----------------------------------------------------------------------------
  164. // this is CPack.
  165. int main (int argc, char *argv[])
  166. {
  167. cmSystemTools::FindExecutableDirectory(argv[0]);
  168. cmCPackLog log;
  169. int nocwd = 0;
  170. log.SetErrorPrefix("CPack Error: ");
  171. log.SetWarningPrefix("CPack Warning: ");
  172. log.SetOutputPrefix("CPack: ");
  173. log.SetVerbosePrefix("CPack Verbose: ");
  174. cmSystemTools::EnableMSVCDebugHook();
  175. if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 )
  176. {
  177. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  178. "Current working directory cannot be established." << std::endl);
  179. nocwd = 1;
  180. }
  181. std::string generator;
  182. bool help = false;
  183. bool helpVersion = false;
  184. bool verbose = false;
  185. bool debug = false;
  186. std::string helpFull;
  187. std::string helpMAN;
  188. std::string helpHTML;
  189. std::string cpackProjectName;
  190. std::string cpackProjectDirectory
  191. = cmsys::SystemTools::GetCurrentWorkingDirectory();
  192. std::string cpackBuildConfig;
  193. std::string cpackProjectVersion;
  194. std::string cpackProjectPatch;
  195. std::string cpackProjectVendor;
  196. std::string cpackConfigFile;
  197. cpackDefinitions definitions;
  198. definitions.Log = &log;
  199. cpackConfigFile = "";
  200. cmsys::CommandLineArguments arg;
  201. arg.Initialize(argc, argv);
  202. typedef cmsys::CommandLineArguments argT;
  203. // Help arguments
  204. arg.AddArgument("--help", argT::NO_ARGUMENT, &help, "CPack help");
  205. arg.AddArgument("--help-full", argT::SPACE_ARGUMENT, &helpFull,
  206. "CPack help");
  207. arg.AddArgument("--help-html", argT::SPACE_ARGUMENT, &helpHTML,
  208. "CPack help");
  209. arg.AddArgument("--help-man", argT::SPACE_ARGUMENT, &helpMAN, "CPack help");
  210. arg.AddArgument("--version", argT::NO_ARGUMENT, &helpVersion, "CPack help");
  211. arg.AddArgument("-V", argT::NO_ARGUMENT, &verbose, "CPack verbose");
  212. arg.AddArgument("--verbose", argT::NO_ARGUMENT, &verbose, "-V");
  213. arg.AddArgument("--debug", argT::NO_ARGUMENT, &debug, "-V");
  214. arg.AddArgument("--config", argT::SPACE_ARGUMENT, &cpackConfigFile,
  215. "CPack configuration file");
  216. arg.AddArgument("-C", argT::SPACE_ARGUMENT, &cpackBuildConfig,
  217. "CPack build configuration");
  218. arg.AddArgument("-G", argT::SPACE_ARGUMENT,
  219. &generator, "CPack generator");
  220. arg.AddArgument("-P", argT::SPACE_ARGUMENT,
  221. &cpackProjectName, "CPack project name");
  222. arg.AddArgument("-R", argT::SPACE_ARGUMENT,
  223. &cpackProjectVersion, "CPack project version");
  224. arg.AddArgument("-B", argT::SPACE_ARGUMENT,
  225. &cpackProjectDirectory, "CPack project directory");
  226. arg.AddArgument("--patch", argT::SPACE_ARGUMENT,
  227. &cpackProjectPatch, "CPack project patch");
  228. arg.AddArgument("--vendor", argT::SPACE_ARGUMENT,
  229. &cpackProjectVendor, "CPack project vendor");
  230. arg.AddCallback("-D", argT::SPACE_ARGUMENT,
  231. cpackDefinitionArgument, &definitions, "CPack Definitions");
  232. arg.SetUnknownArgumentCallback(cpackUnknownArgument);
  233. // Parse command line
  234. int parsed = arg.Parse();
  235. // Setup logging
  236. if ( verbose )
  237. {
  238. log.SetVerbose(verbose);
  239. cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Verbose" << std::endl);
  240. }
  241. if ( debug )
  242. {
  243. log.SetDebug(debug);
  244. cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Debug" << std::endl);
  245. }
  246. cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
  247. "Read CPack config file: " << cpackConfigFile.c_str() << std::endl);
  248. cmake cminst;
  249. cminst.RemoveUnscriptableCommands();
  250. cmGlobalGenerator cmgg;
  251. cmgg.SetCMakeInstance(&cminst);
  252. std::auto_ptr<cmLocalGenerator> cmlg(cmgg.CreateLocalGenerator());
  253. cmMakefile* globalMF = cmlg->GetMakefile();
  254. bool cpackConfigFileSpecified = true;
  255. if ( cpackConfigFile.empty() )
  256. {
  257. cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory();
  258. cpackConfigFile += "/CPackConfig.cmake";
  259. cpackConfigFileSpecified = false;
  260. }
  261. cmCPackGeneratorFactory generators;
  262. generators.SetLogger(&log);
  263. cmCPackGenerator* cpackGenerator = 0;
  264. cmDocumentation doc;
  265. doc.addCPackStandardDocSections();
  266. /* Were we invoked to display doc or to do some work ? */
  267. if(doc.CheckOptions(argc, argv,"-G") || nocwd)
  268. {
  269. help = true;
  270. }
  271. else
  272. {
  273. help = false;
  274. }
  275. // This part is used for cpack documentation lookup as well.
  276. cminst.AddCMakePaths();
  277. if ( parsed && !help )
  278. {
  279. // find out which system cpack is running on, so it can setup the search
  280. // paths, so FIND_XXX() commands can be used in scripts
  281. std::string systemFile =
  282. globalMF->GetModulesFile("CMakeDetermineSystem.cmake");
  283. if (!globalMF->ReadListFile(0, systemFile.c_str()))
  284. {
  285. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  286. "Error reading CMakeDetermineSystem.cmake" << std::endl);
  287. return 1;
  288. }
  289. systemFile =
  290. globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake");
  291. if (!globalMF->ReadListFile(0, systemFile.c_str()))
  292. {
  293. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  294. "Error reading CMakeSystemSpecificInformation.cmake" << std::endl);
  295. return 1;
  296. }
  297. if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) )
  298. {
  299. cpackConfigFile =
  300. cmSystemTools::CollapseFullPath(cpackConfigFile.c_str());
  301. cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
  302. "Read CPack configuration file: " << cpackConfigFile.c_str()
  303. << std::endl);
  304. if ( !globalMF->ReadListFile(0, cpackConfigFile.c_str()) )
  305. {
  306. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  307. "Problem reading CPack config file: \""
  308. << cpackConfigFile.c_str() << "\"" << std::endl);
  309. return 1;
  310. }
  311. }
  312. else if ( cpackConfigFileSpecified )
  313. {
  314. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  315. "Cannot find CPack config file: \"" << cpackConfigFile.c_str()
  316. << "\"" << std::endl);
  317. return 1;
  318. }
  319. if ( !generator.empty() )
  320. {
  321. globalMF->AddDefinition("CPACK_GENERATOR", generator.c_str());
  322. }
  323. if ( !cpackProjectName.empty() )
  324. {
  325. globalMF->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str());
  326. }
  327. if ( !cpackProjectVersion.empty() )
  328. {
  329. globalMF->AddDefinition("CPACK_PACKAGE_VERSION",
  330. cpackProjectVersion.c_str());
  331. }
  332. if ( !cpackProjectVendor.empty() )
  333. {
  334. globalMF->AddDefinition("CPACK_PACKAGE_VENDOR",
  335. cpackProjectVendor.c_str());
  336. }
  337. if ( !cpackProjectDirectory.empty() )
  338. {
  339. globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
  340. cpackProjectDirectory.c_str());
  341. }
  342. if ( !cpackBuildConfig.empty() )
  343. {
  344. globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
  345. }
  346. cpackDefinitions::MapType::iterator cdit;
  347. for ( cdit = definitions.Map.begin();
  348. cdit != definitions.Map.end();
  349. ++cdit )
  350. {
  351. globalMF->AddDefinition(cdit->first.c_str(), cdit->second.c_str());
  352. }
  353. const char* cpackModulesPath =
  354. globalMF->GetDefinition("CPACK_MODULE_PATH");
  355. if ( cpackModulesPath )
  356. {
  357. globalMF->AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath);
  358. }
  359. const char* genList = globalMF->GetDefinition("CPACK_GENERATOR");
  360. if ( !genList )
  361. {
  362. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  363. "CPack generator not specified" << std::endl);
  364. parsed = 0;
  365. }
  366. else
  367. {
  368. std::vector<std::string> generatorsVector;
  369. cmSystemTools::ExpandListArgument(genList,
  370. generatorsVector);
  371. std::vector<std::string>::iterator it;
  372. for ( it = generatorsVector.begin();
  373. it != generatorsVector.end();
  374. ++it )
  375. {
  376. const char* gen = it->c_str();
  377. cmMakefile newMF(*globalMF);
  378. cmMakefile* mf = &newMF;
  379. cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
  380. "Specified generator: " << gen << std::endl);
  381. if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") )
  382. {
  383. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  384. "CPack project name not specified" << std::endl);
  385. parsed = 0;
  386. }
  387. if (parsed &&
  388. !(mf->GetDefinition("CPACK_PACKAGE_VERSION") ||
  389. (mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") &&
  390. mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR") &&
  391. mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH"))))
  392. {
  393. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  394. "CPack project version not specified" << std::endl
  395. << "Specify CPACK_PACKAGE_VERSION, or "
  396. "CPACK_PACKAGE_VERSION_MAJOR, "
  397. "CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH."
  398. << std::endl);
  399. parsed = 0;
  400. }
  401. if ( parsed )
  402. {
  403. cpackGenerator = generators.NewGenerator(gen);
  404. if ( !cpackGenerator )
  405. {
  406. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  407. "Cannot initialize CPack generator: "
  408. << gen << std::endl);
  409. parsed = 0;
  410. }
  411. if ( parsed && !cpackGenerator->Initialize(gen, mf) )
  412. {
  413. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  414. "Cannot initialize the generator " << gen << std::endl);
  415. parsed = 0;
  416. }
  417. if ( !mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
  418. !mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
  419. !mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS") )
  420. {
  421. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  422. "Please specify build tree of the project that uses CMake "
  423. "using CPACK_INSTALL_CMAKE_PROJECTS, specify "
  424. "CPACK_INSTALL_COMMANDS, or specify "
  425. "CPACK_INSTALLED_DIRECTORIES."
  426. << std::endl);
  427. parsed = 0;
  428. }
  429. if ( parsed )
  430. {
  431. #ifdef _WIN32
  432. std::string comspec = "cmw9xcom.exe";
  433. cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str());
  434. #endif
  435. const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
  436. cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: "
  437. << cpackGenerator->GetNameOfClass() << std::endl);
  438. cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: "
  439. << projName << std::endl);
  440. const char* projVersion =
  441. mf->GetDefinition("CPACK_PACKAGE_VERSION");
  442. if ( !projVersion )
  443. {
  444. const char* projVersionMajor
  445. = mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
  446. const char* projVersionMinor
  447. = mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
  448. const char* projVersionPatch
  449. = mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
  450. cmOStringStream ostr;
  451. ostr << projVersionMajor << "." << projVersionMinor << "."
  452. << projVersionPatch;
  453. mf->AddDefinition("CPACK_PACKAGE_VERSION",
  454. ostr.str().c_str());
  455. }
  456. int res = cpackGenerator->DoPackage();
  457. if ( !res )
  458. {
  459. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  460. "Error when generating package: " << projName << std::endl);
  461. return 1;
  462. }
  463. }
  464. }
  465. }
  466. }
  467. }
  468. /* In this case we are building the documentation object
  469. * instance in order to create appropriate structure
  470. * in order to satisfy the appropriate --help-xxx request
  471. */
  472. if ( help )
  473. {
  474. // Construct and print requested documentation.
  475. doc.SetName("cpack");
  476. doc.SetSection("Name",cmDocumentationName);
  477. doc.SetSection("Usage",cmDocumentationUsage);
  478. doc.SetSection("Description",cmDocumentationDescription);
  479. doc.PrependSection("Options",cmDocumentationOptions);
  480. // statically (in C++ code) defined variables
  481. cmCPackDocumentVariables::DefineVariables(&cminst);
  482. std::vector<cmDocumentationEntry> commands;
  483. std::string docedFile;
  484. std::string docPath;
  485. cmDocumentation::documentedModulesList_t docedModList;
  486. docedFile = globalMF->GetModulesFile("CPack.cmake");
  487. if (docedFile.length()!=0)
  488. {
  489. docPath = cmSystemTools::GetFilenamePath(docedFile.c_str());
  490. doc.getDocumentedModulesListInDir(docPath,"CPack*.cmake",docedModList);
  491. }
  492. // parse the files for documentation.
  493. cmDocumentation::documentedModulesList_t::iterator docedIt;
  494. for (docedIt = docedModList.begin();
  495. docedIt!= docedModList.end(); ++docedIt)
  496. {
  497. doc.GetStructuredDocFromFile(
  498. (docedIt->first).c_str(),
  499. commands,&cminst);
  500. }
  501. std::map<std::string,cmDocumentationSection *> propDocs;
  502. cminst.GetPropertiesDocumentation(propDocs);
  503. doc.SetSections(propDocs);
  504. cminst.GetCommandDocumentation(commands,true,false);
  505. // statically (in C++ code) defined macros/commands
  506. cmCPackDocumentMacros::GetMacrosDocumentation(commands);
  507. doc.SetSection("Commands",commands);
  508. std::vector<cmDocumentationEntry> v;
  509. cmCPackGeneratorFactory::DescriptionsMap::const_iterator generatorIt;
  510. for( generatorIt = generators.GetGeneratorsList().begin();
  511. generatorIt != generators.GetGeneratorsList().end();
  512. ++ generatorIt )
  513. {
  514. cmDocumentationEntry e;
  515. e.Name = generatorIt->first.c_str();
  516. e.Brief = generatorIt->second.c_str();
  517. e.Full = "";
  518. v.push_back(e);
  519. }
  520. doc.SetSection("Generators",v);
  521. doc.SetSeeAlsoList(cmDocumentationSeeAlso);
  522. #undef cout
  523. return doc.PrintRequestedDocumentation(std::cout)? 0:1;
  524. #define cout no_cout_use_cmCPack_Log
  525. }
  526. if (cmSystemTools::GetErrorOccuredFlag())
  527. {
  528. return 1;
  529. }
  530. return 0;
  531. }