cpack.cxx 21 KB

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