cpack.cxx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  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. 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. // This part is used for cpack documentation lookup as well.
  275. cminst.AddCMakePaths();
  276. if ( parsed && !help )
  277. {
  278. // find out which system cpack is running on, so it can setup the search
  279. // paths, so FIND_XXX() commands can be used in scripts
  280. std::string systemFile =
  281. globalMF->GetModulesFile("CMakeDetermineSystem.cmake");
  282. if (!globalMF->ReadListFile(0, systemFile.c_str()))
  283. {
  284. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  285. "Error reading CMakeDetermineSystem.cmake" << std::endl);
  286. return 1;
  287. }
  288. systemFile =
  289. globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake");
  290. if (!globalMF->ReadListFile(0, systemFile.c_str()))
  291. {
  292. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  293. "Error reading CMakeSystemSpecificInformation.cmake" << std::endl);
  294. return 1;
  295. }
  296. if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) )
  297. {
  298. cpackConfigFile =
  299. cmSystemTools::CollapseFullPath(cpackConfigFile.c_str());
  300. cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
  301. "Read CPack configuration file: " << cpackConfigFile.c_str()
  302. << std::endl);
  303. if ( !globalMF->ReadListFile(0, cpackConfigFile.c_str()) )
  304. {
  305. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  306. "Problem reading CPack config file: \""
  307. << cpackConfigFile.c_str() << "\"" << std::endl);
  308. return 1;
  309. }
  310. }
  311. else if ( cpackConfigFileSpecified )
  312. {
  313. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  314. "Cannot find CPack config file: \"" << cpackConfigFile.c_str()
  315. << "\"" << std::endl);
  316. return 1;
  317. }
  318. if ( !generator.empty() )
  319. {
  320. globalMF->AddDefinition("CPACK_GENERATOR", generator.c_str());
  321. }
  322. if ( !cpackProjectName.empty() )
  323. {
  324. globalMF->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str());
  325. }
  326. if ( !cpackProjectVersion.empty() )
  327. {
  328. globalMF->AddDefinition("CPACK_PACKAGE_VERSION",
  329. cpackProjectVersion.c_str());
  330. }
  331. if ( !cpackProjectVendor.empty() )
  332. {
  333. globalMF->AddDefinition("CPACK_PACKAGE_VENDOR",
  334. cpackProjectVendor.c_str());
  335. }
  336. // if this is not empty it has been set on the command line
  337. // go for it. Command line override values set in config file.
  338. if ( !cpackProjectDirectory.empty() )
  339. {
  340. globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
  341. cpackProjectDirectory.c_str());
  342. }
  343. // The value has not been set on the command line
  344. else
  345. {
  346. // get a default value (current working directory)
  347. cpackProjectDirectory = cmsys::SystemTools::GetCurrentWorkingDirectory();
  348. // use default value iff no value has been provided by the config file
  349. if (!globalMF->IsSet("CPACK_PACKAGE_DIRECTORY"))
  350. {
  351. globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
  352. cpackProjectDirectory.c_str());
  353. }
  354. }
  355. if ( !cpackBuildConfig.empty() )
  356. {
  357. globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
  358. }
  359. cpackDefinitions::MapType::iterator cdit;
  360. for ( cdit = definitions.Map.begin();
  361. cdit != definitions.Map.end();
  362. ++cdit )
  363. {
  364. globalMF->AddDefinition(cdit->first.c_str(), cdit->second.c_str());
  365. }
  366. const char* cpackModulesPath =
  367. globalMF->GetDefinition("CPACK_MODULE_PATH");
  368. if ( cpackModulesPath )
  369. {
  370. globalMF->AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath);
  371. }
  372. const char* genList = globalMF->GetDefinition("CPACK_GENERATOR");
  373. if ( !genList )
  374. {
  375. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  376. "CPack generator not specified" << std::endl);
  377. parsed = 0;
  378. }
  379. else
  380. {
  381. std::vector<std::string> generatorsVector;
  382. cmSystemTools::ExpandListArgument(genList,
  383. generatorsVector);
  384. std::vector<std::string>::iterator it;
  385. for ( it = generatorsVector.begin();
  386. it != generatorsVector.end();
  387. ++it )
  388. {
  389. const char* gen = it->c_str();
  390. cmMakefile newMF(*globalMF);
  391. cmMakefile* mf = &newMF;
  392. cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
  393. "Specified generator: " << gen << std::endl);
  394. if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") )
  395. {
  396. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  397. "CPack project name not specified" << std::endl);
  398. parsed = 0;
  399. }
  400. if (parsed &&
  401. !(mf->GetDefinition("CPACK_PACKAGE_VERSION") ||
  402. (mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") &&
  403. mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR") &&
  404. mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH"))))
  405. {
  406. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  407. "CPack project version not specified" << std::endl
  408. << "Specify CPACK_PACKAGE_VERSION, or "
  409. "CPACK_PACKAGE_VERSION_MAJOR, "
  410. "CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH."
  411. << std::endl);
  412. parsed = 0;
  413. }
  414. if ( parsed )
  415. {
  416. cpackGenerator = generators.NewGenerator(gen);
  417. if ( !cpackGenerator )
  418. {
  419. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  420. "Cannot initialize CPack generator: "
  421. << gen << std::endl);
  422. parsed = 0;
  423. }
  424. if ( parsed && !cpackGenerator->Initialize(gen, mf) )
  425. {
  426. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  427. "Cannot initialize the generator " << gen << std::endl);
  428. parsed = 0;
  429. }
  430. if ( !mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
  431. !mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
  432. !mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS") )
  433. {
  434. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  435. "Please specify build tree of the project that uses CMake "
  436. "using CPACK_INSTALL_CMAKE_PROJECTS, specify "
  437. "CPACK_INSTALL_COMMANDS, or specify "
  438. "CPACK_INSTALLED_DIRECTORIES."
  439. << std::endl);
  440. parsed = 0;
  441. }
  442. if ( parsed )
  443. {
  444. #ifdef _WIN32
  445. std::string comspec = "cmw9xcom.exe";
  446. cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str());
  447. #endif
  448. const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
  449. cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: "
  450. << cpackGenerator->GetNameOfClass() << std::endl);
  451. cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: "
  452. << projName << std::endl);
  453. const char* projVersion =
  454. mf->GetDefinition("CPACK_PACKAGE_VERSION");
  455. if ( !projVersion )
  456. {
  457. const char* projVersionMajor
  458. = mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
  459. const char* projVersionMinor
  460. = mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
  461. const char* projVersionPatch
  462. = mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
  463. cmOStringStream ostr;
  464. ostr << projVersionMajor << "." << projVersionMinor << "."
  465. << projVersionPatch;
  466. mf->AddDefinition("CPACK_PACKAGE_VERSION",
  467. ostr.str().c_str());
  468. }
  469. int res = cpackGenerator->DoPackage();
  470. if ( !res )
  471. {
  472. cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
  473. "Error when generating package: " << projName << std::endl);
  474. return 1;
  475. }
  476. }
  477. }
  478. }
  479. }
  480. }
  481. /* In this case we are building the documentation object
  482. * instance in order to create appropriate structure
  483. * in order to satisfy the appropriate --help-xxx request
  484. */
  485. if ( help )
  486. {
  487. // Construct and print requested documentation.
  488. doc.SetName("cpack");
  489. doc.SetSection("Name",cmDocumentationName);
  490. doc.SetSection("Usage",cmDocumentationUsage);
  491. doc.SetSection("Description",cmDocumentationDescription);
  492. doc.PrependSection("Options",cmDocumentationOptions);
  493. // statically (in C++ code) defined variables
  494. cmCPackDocumentVariables::DefineVariables(&cminst);
  495. std::vector<cmDocumentationEntry> commands;
  496. std::string docedFile;
  497. std::string docPath;
  498. cmDocumentation::documentedModulesList_t docedModList;
  499. docedFile = globalMF->GetModulesFile("CPack.cmake");
  500. if (docedFile.length()!=0)
  501. {
  502. docPath = cmSystemTools::GetFilenamePath(docedFile.c_str());
  503. doc.getDocumentedModulesListInDir(docPath,"CPack*.cmake",docedModList);
  504. }
  505. // parse the files for documentation.
  506. cmDocumentation::documentedModulesList_t::iterator docedIt;
  507. for (docedIt = docedModList.begin();
  508. docedIt!= docedModList.end(); ++docedIt)
  509. {
  510. doc.GetStructuredDocFromFile(
  511. (docedIt->first).c_str(),
  512. commands,&cminst);
  513. }
  514. std::map<std::string,cmDocumentationSection *> propDocs;
  515. cminst.GetPropertiesDocumentation(propDocs);
  516. doc.SetSections(propDocs);
  517. cminst.GetCommandDocumentation(commands,true,false);
  518. // statically (in C++ code) defined macros/commands
  519. cmCPackDocumentMacros::GetMacrosDocumentation(commands);
  520. doc.SetSection("Commands",commands);
  521. std::vector<cmDocumentationEntry> v;
  522. cmCPackGeneratorFactory::DescriptionsMap::const_iterator generatorIt;
  523. for( generatorIt = generators.GetGeneratorsList().begin();
  524. generatorIt != generators.GetGeneratorsList().end();
  525. ++ generatorIt )
  526. {
  527. cmDocumentationEntry e;
  528. e.Name = generatorIt->first.c_str();
  529. e.Brief = generatorIt->second.c_str();
  530. e.Full = "";
  531. v.push_back(e);
  532. }
  533. doc.SetSection("Generators",v);
  534. doc.SetSeeAlsoList(cmDocumentationSeeAlso);
  535. #undef cout
  536. return doc.PrintRequestedDocumentation(std::cout)? 0:1;
  537. #define cout no_cout_use_cmCPack_Log
  538. }
  539. if (cmSystemTools::GetErrorOccuredFlag())
  540. {
  541. return 1;
  542. }
  543. return 0;
  544. }