cpack.cxx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  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. //----------------------------------------------------------------------------
  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. std::string cpackBuildConfig;
  191. std::string cpackProjectVersion;
  192. std::string cpackProjectPatch;
  193. std::string cpackProjectVendor;
  194. std::string cpackConfigFile;
  195. cpackDefinitions definitions;
  196. definitions.Log = &log;
  197. cpackConfigFile = "";
  198. cmsys::CommandLineArguments arg;
  199. arg.Initialize(argc, argv);
  200. typedef cmsys::CommandLineArguments argT;
  201. // Help arguments
  202. arg.AddArgument("--help", argT::NO_ARGUMENT, &help, "CPack help");
  203. arg.AddArgument("--help-full", argT::SPACE_ARGUMENT, &helpFull,
  204. "CPack help");
  205. arg.AddArgument("--help-html", argT::SPACE_ARGUMENT, &helpHTML,
  206. "CPack help");
  207. arg.AddArgument("--help-man", argT::SPACE_ARGUMENT, &helpMAN, "CPack help");
  208. arg.AddArgument("--version", argT::NO_ARGUMENT, &helpVersion, "CPack help");
  209. arg.AddArgument("-V", argT::NO_ARGUMENT, &verbose, "CPack verbose");
  210. arg.AddArgument("--verbose", argT::NO_ARGUMENT, &verbose, "-V");
  211. arg.AddArgument("--debug", argT::NO_ARGUMENT, &debug, "-V");
  212. arg.AddArgument("--config", argT::SPACE_ARGUMENT, &cpackConfigFile,
  213. "CPack configuration file");
  214. arg.AddArgument("-C", argT::SPACE_ARGUMENT, &cpackBuildConfig,
  215. "CPack build configuration");
  216. arg.AddArgument("-G", argT::SPACE_ARGUMENT,
  217. &generator, "CPack generator");
  218. arg.AddArgument("-P", argT::SPACE_ARGUMENT,
  219. &cpackProjectName, "CPack project name");
  220. arg.AddArgument("-R", argT::SPACE_ARGUMENT,
  221. &cpackProjectVersion, "CPack project version");
  222. arg.AddArgument("-B", argT::SPACE_ARGUMENT,
  223. &cpackProjectDirectory, "CPack project directory");
  224. arg.AddArgument("--patch", argT::SPACE_ARGUMENT,
  225. &cpackProjectPatch, "CPack project patch");
  226. arg.AddArgument("--vendor", argT::SPACE_ARGUMENT,
  227. &cpackProjectVendor, "CPack project vendor");
  228. arg.AddCallback("-D", argT::SPACE_ARGUMENT,
  229. cpackDefinitionArgument, &definitions, "CPack Definitions");
  230. arg.SetUnknownArgumentCallback(cpackUnknownArgument);
  231. // Parse command line
  232. int parsed = arg.Parse();
  233. // Setup logging
  234. if ( verbose )
  235. {
  236. log.SetVerbose(verbose);
  237. cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Verbose" << std::endl);
  238. }
  239. if ( debug )
  240. {
  241. log.SetDebug(debug);
  242. cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Debug" << std::endl);
  243. }
  244. cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
  245. "Read CPack config file: " << cpackConfigFile.c_str() << std::endl);
  246. cmake cminst;
  247. cminst.RemoveUnscriptableCommands();
  248. cmGlobalGenerator cmgg;
  249. cmgg.SetCMakeInstance(&cminst);
  250. cmsys::auto_ptr<cmLocalGenerator> cmlg(cmgg.CreateLocalGenerator());
  251. cmMakefile* globalMF = cmlg->GetMakefile();
  252. bool cpackConfigFileSpecified = true;
  253. if ( cpackConfigFile.empty() )
  254. {
  255. cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory();
  256. cpackConfigFile += "/CPackConfig.cmake";
  257. cpackConfigFileSpecified = false;
  258. }
  259. cmCPackGeneratorFactory generators;
  260. generators.SetLogger(&log);
  261. cmCPackGenerator* cpackGenerator = 0;
  262. cmDocumentation doc;
  263. doc.addCPackStandardDocSections();
  264. /* Were we invoked to display doc or to do some work ?
  265. * Unlike cmake launching cpack with zero argument
  266. * should launch cpack using "cpackConfigFile" if it exists
  267. * in the current directory.
  268. */
  269. if((doc.CheckOptions(argc, argv,"-G") || nocwd) && !(argc==1))
  270. {
  271. help = true;
  272. }
  273. else
  274. {
  275. help = false;
  276. }
  277. // This part is used for cpack documentation lookup as well.
  278. cminst.AddCMakePaths();
  279. if ( parsed && !help )
  280. {
  281. // find out which system cpack is running on, so it can setup the search
  282. // paths, so FIND_XXX() commands can be used in scripts
  283. std::string systemFile =
  284. globalMF->GetModulesFile("CMakeDetermineSystem.cmake");
  285. if (!globalMF->ReadListFile(0, systemFile.c_str()))
  286. {
  287. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  288. "Error reading CMakeDetermineSystem.cmake" << std::endl);
  289. return 1;
  290. }
  291. systemFile =
  292. globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake");
  293. if (!globalMF->ReadListFile(0, systemFile.c_str()))
  294. {
  295. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  296. "Error reading CMakeSystemSpecificInformation.cmake" << std::endl);
  297. return 1;
  298. }
  299. if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) )
  300. {
  301. cpackConfigFile =
  302. cmSystemTools::CollapseFullPath(cpackConfigFile.c_str());
  303. cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
  304. "Read CPack configuration file: " << cpackConfigFile.c_str()
  305. << std::endl);
  306. if ( !globalMF->ReadListFile(0, cpackConfigFile.c_str()) )
  307. {
  308. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  309. "Problem reading CPack config file: \""
  310. << cpackConfigFile.c_str() << "\"" << std::endl);
  311. return 1;
  312. }
  313. }
  314. else if ( cpackConfigFileSpecified )
  315. {
  316. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  317. "Cannot find CPack config file: \"" << cpackConfigFile.c_str()
  318. << "\"" << std::endl);
  319. return 1;
  320. }
  321. if ( !generator.empty() )
  322. {
  323. globalMF->AddDefinition("CPACK_GENERATOR", generator.c_str());
  324. }
  325. if ( !cpackProjectName.empty() )
  326. {
  327. globalMF->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str());
  328. }
  329. if ( !cpackProjectVersion.empty() )
  330. {
  331. globalMF->AddDefinition("CPACK_PACKAGE_VERSION",
  332. cpackProjectVersion.c_str());
  333. }
  334. if ( !cpackProjectVendor.empty() )
  335. {
  336. globalMF->AddDefinition("CPACK_PACKAGE_VENDOR",
  337. cpackProjectVendor.c_str());
  338. }
  339. // if this is not empty it has been set on the command line
  340. // go for it. Command line override values set in config file.
  341. if ( !cpackProjectDirectory.empty() )
  342. {
  343. globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
  344. cpackProjectDirectory.c_str());
  345. }
  346. // The value has not been set on the command line
  347. else
  348. {
  349. // get a default value (current working directory)
  350. cpackProjectDirectory = cmsys::SystemTools::GetCurrentWorkingDirectory();
  351. // use default value iff no value has been provided by the config file
  352. if (!globalMF->IsSet("CPACK_PACKAGE_DIRECTORY"))
  353. {
  354. globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
  355. cpackProjectDirectory.c_str());
  356. }
  357. }
  358. if ( !cpackBuildConfig.empty() )
  359. {
  360. globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
  361. }
  362. cpackDefinitions::MapType::iterator cdit;
  363. for ( cdit = definitions.Map.begin();
  364. cdit != definitions.Map.end();
  365. ++cdit )
  366. {
  367. globalMF->AddDefinition(cdit->first.c_str(), cdit->second.c_str());
  368. }
  369. const char* cpackModulesPath =
  370. globalMF->GetDefinition("CPACK_MODULE_PATH");
  371. if ( cpackModulesPath )
  372. {
  373. globalMF->AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath);
  374. }
  375. const char* genList = globalMF->GetDefinition("CPACK_GENERATOR");
  376. if ( !genList )
  377. {
  378. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  379. "CPack generator not specified" << std::endl);
  380. parsed = 0;
  381. }
  382. else
  383. {
  384. std::vector<std::string> generatorsVector;
  385. cmSystemTools::ExpandListArgument(genList,
  386. generatorsVector);
  387. std::vector<std::string>::iterator it;
  388. for ( it = generatorsVector.begin();
  389. it != generatorsVector.end();
  390. ++it )
  391. {
  392. const char* gen = it->c_str();
  393. cmMakefile newMF(*globalMF);
  394. cmMakefile* mf = &newMF;
  395. cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
  396. "Specified generator: " << gen << std::endl);
  397. if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") )
  398. {
  399. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  400. "CPack project name not specified" << std::endl);
  401. parsed = 0;
  402. }
  403. if (parsed &&
  404. !(mf->GetDefinition("CPACK_PACKAGE_VERSION") ||
  405. (mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") &&
  406. mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR") &&
  407. mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH"))))
  408. {
  409. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  410. "CPack project version not specified" << std::endl
  411. << "Specify CPACK_PACKAGE_VERSION, or "
  412. "CPACK_PACKAGE_VERSION_MAJOR, "
  413. "CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH."
  414. << std::endl);
  415. parsed = 0;
  416. }
  417. if ( parsed )
  418. {
  419. cpackGenerator = generators.NewGenerator(gen);
  420. if ( !cpackGenerator )
  421. {
  422. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  423. "Cannot initialize CPack generator: "
  424. << gen << std::endl);
  425. parsed = 0;
  426. }
  427. if ( parsed && !cpackGenerator->Initialize(gen, mf) )
  428. {
  429. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  430. "Cannot initialize the generator " << gen << std::endl);
  431. parsed = 0;
  432. }
  433. if ( !mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
  434. !mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
  435. !mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS") )
  436. {
  437. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  438. "Please specify build tree of the project that uses CMake "
  439. "using CPACK_INSTALL_CMAKE_PROJECTS, specify "
  440. "CPACK_INSTALL_COMMANDS, or specify "
  441. "CPACK_INSTALLED_DIRECTORIES."
  442. << std::endl);
  443. parsed = 0;
  444. }
  445. if ( parsed )
  446. {
  447. #ifdef _WIN32
  448. std::string comspec = "cmw9xcom.exe";
  449. cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str());
  450. #endif
  451. const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
  452. cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: "
  453. << cpackGenerator->GetNameOfClass() << std::endl);
  454. cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: "
  455. << projName << std::endl);
  456. const char* projVersion =
  457. mf->GetDefinition("CPACK_PACKAGE_VERSION");
  458. if ( !projVersion )
  459. {
  460. const char* projVersionMajor
  461. = mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
  462. const char* projVersionMinor
  463. = mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
  464. const char* projVersionPatch
  465. = mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
  466. cmOStringStream ostr;
  467. ostr << projVersionMajor << "." << projVersionMinor << "."
  468. << projVersionPatch;
  469. mf->AddDefinition("CPACK_PACKAGE_VERSION",
  470. ostr.str().c_str());
  471. }
  472. int res = cpackGenerator->DoPackage();
  473. if ( !res )
  474. {
  475. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  476. "Error when generating package: " << projName << std::endl);
  477. return 1;
  478. }
  479. }
  480. }
  481. }
  482. }
  483. }
  484. /* In this case we are building the documentation object
  485. * instance in order to create appropriate structure
  486. * in order to satisfy the appropriate --help-xxx request
  487. */
  488. if ( help )
  489. {
  490. // Construct and print requested documentation.
  491. doc.SetName("cpack");
  492. doc.SetSection("Name",cmDocumentationName);
  493. doc.SetSection("Usage",cmDocumentationUsage);
  494. doc.SetSection("Description",cmDocumentationDescription);
  495. doc.PrependSection("Options",cmDocumentationOptions);
  496. // statically (in C++ code) defined variables
  497. cmCPackDocumentVariables::DefineVariables(&cminst);
  498. std::vector<cmDocumentationEntry> commands;
  499. std::string docedFile;
  500. std::string docPath;
  501. cmDocumentation::documentedModulesList_t docedModList;
  502. docedFile = globalMF->GetModulesFile("CPack.cmake");
  503. if (docedFile.length()!=0)
  504. {
  505. docPath = cmSystemTools::GetFilenamePath(docedFile.c_str());
  506. doc.getDocumentedModulesListInDir(docPath,"CPack*.cmake",docedModList);
  507. }
  508. // parse the files for documentation.
  509. cmDocumentation::documentedModulesList_t::iterator docedIt;
  510. for (docedIt = docedModList.begin();
  511. docedIt!= docedModList.end(); ++docedIt)
  512. {
  513. doc.GetStructuredDocFromFile(
  514. (docedIt->first).c_str(),
  515. commands,&cminst);
  516. }
  517. std::map<std::string,cmDocumentationSection *> propDocs;
  518. cminst.GetPropertiesDocumentation(propDocs);
  519. doc.SetSections(propDocs);
  520. cminst.GetCommandDocumentation(commands,true,false);
  521. // statically (in C++ code) defined macros/commands
  522. cmCPackDocumentMacros::GetMacrosDocumentation(commands);
  523. doc.SetSection("Commands",commands);
  524. std::vector<cmDocumentationEntry> v;
  525. cmCPackGeneratorFactory::DescriptionsMap::const_iterator generatorIt;
  526. for( generatorIt = generators.GetGeneratorsList().begin();
  527. generatorIt != generators.GetGeneratorsList().end();
  528. ++ generatorIt )
  529. {
  530. cmDocumentationEntry e;
  531. e.Name = generatorIt->first.c_str();
  532. e.Brief = generatorIt->second.c_str();
  533. e.Full = "";
  534. v.push_back(e);
  535. }
  536. doc.SetSection("Generators",v);
  537. doc.SetSeeAlsoList(cmDocumentationSeeAlso);
  538. #undef cout
  539. return doc.PrintRequestedDocumentation(std::cout)? 0:1;
  540. #define cout no_cout_use_cmCPack_Log
  541. }
  542. if (cmSystemTools::GetErrorOccuredFlag())
  543. {
  544. return 1;
  545. }
  546. return 0;
  547. }