cmake/Source/CPack/cpack.cxx

482 lines
18 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2021-09-14 00:13:48 +02:00
#include <cstddef>
2022-08-04 22:12:04 +02:00
#include <functional>
2021-09-14 00:13:48 +02:00
#include <iostream>
#include <map>
#include <memory>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
2022-08-04 22:12:04 +02:00
#include <cmext/algorithm>
2017-07-20 19:35:53 +02:00
#include "cmsys/Encoding.hxx"
2017-04-14 19:02:05 +02:00
#include "cmCPackGenerator.h"
2016-07-09 11:21:54 +02:00
#include "cmCPackGeneratorFactory.h"
2016-10-30 18:24:19 +01:00
#include "cmCPackLog.h"
2022-08-04 22:12:04 +02:00
#include "cmCommandLineArgument.h"
2021-09-14 00:13:48 +02:00
#include "cmConsoleBuf.h"
2016-07-09 11:21:54 +02:00
#include "cmDocumentation.h"
2016-10-30 18:24:19 +01:00
#include "cmDocumentationEntry.h"
2019-11-11 23:01:05 +01:00
#include "cmDocumentationFormatter.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
2019-11-11 23:01:05 +01:00
#include "cmState.h"
2017-04-14 19:02:05 +02:00
#include "cmStateSnapshot.h"
2020-02-01 23:06:01 +01:00
#include "cmStringAlgorithms.h"
2016-10-30 18:24:19 +01:00
#include "cmSystemTools.h"
2021-11-20 13:41:27 +01:00
#include "cmValue.h"
2016-07-09 11:21:54 +02:00
#include "cmake.h"
2020-02-01 23:06:01 +01:00
namespace {
const char* cmDocumentationName[][2] = {
2018-01-26 17:06:56 +01:00
{ nullptr, " cpack - Packaging driver provided by CMake." },
{ nullptr, nullptr }
};
2020-02-01 23:06:01 +01:00
const char* cmDocumentationUsage[][2] = {
2018-08-09 18:06:22 +02:00
// clang-format off
{ nullptr, " cpack [options]" },
2018-01-26 17:06:56 +01:00
{ nullptr, nullptr }
2018-08-09 18:06:22 +02:00
// clang-format on
};
2020-02-01 23:06:01 +01:00
const char* cmDocumentationOptions[][2] = {
2018-08-09 18:06:22 +02:00
{ "-G <generators>", "Override/define CPACK_GENERATOR" },
2016-07-09 11:21:54 +02:00
{ "-C <Configuration>", "Specify the project configuration" },
{ "-D <var>=<value>", "Set a CPack variable." },
2018-08-09 18:06:22 +02:00
{ "--config <configFile>", "Specify the config file." },
{ "--verbose,-V", "Enable verbose output" },
2018-04-23 21:13:27 +02:00
{ "--trace", "Put underlying cmake scripts in trace mode." },
{ "--trace-expand", "Put underlying cmake scripts in expanded trace mode." },
2018-08-09 18:06:22 +02:00
{ "--debug", "Enable debug output (for CPack developers)" },
{ "-P <packageName>", "Override/define CPACK_PACKAGE_NAME" },
{ "-R <packageVersion>", "Override/define CPACK_PACKAGE_VERSION" },
{ "-B <packageDirectory>", "Override/define CPACK_PACKAGE_DIRECTORY" },
{ "--vendor <vendorName>", "Override/define CPACK_PACKAGE_VENDOR" },
2018-01-26 17:06:56 +01:00
{ nullptr, nullptr }
};
2020-02-01 23:06:01 +01:00
void cpackProgressCallback(const std::string& message, float /*unused*/)
2018-12-13 22:36:35 +01:00
{
std::cout << "-- " << message << std::endl;
}
2020-02-01 23:06:01 +01:00
} // namespace
2018-12-13 22:36:35 +01:00
// this is CPack.
2016-07-09 11:21:54 +02:00
int main(int argc, char const* const* argv)
{
2019-11-11 23:01:05 +01:00
cmSystemTools::EnsureStdPipes();
2021-09-14 00:13:48 +02:00
2017-04-14 19:02:05 +02:00
// Replace streambuf so we can output Unicode to console
2021-09-14 00:13:48 +02:00
cmConsoleBuf consoleBuf;
consoleBuf.SetUTF8Pipes();
2014-08-03 19:52:23 +02:00
cmsys::Encoding::CommandLineArguments args =
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
argc = args.argc();
argv = args.argv();
2022-08-04 22:12:04 +02:00
std::vector<std::string> inputArgs;
inputArgs.reserve(argc - 1);
cm::append(inputArgs, argv + 1, argv + argc);
2018-04-23 21:13:27 +02:00
cmSystemTools::InitializeLibUV();
2014-08-03 19:52:23 +02:00
cmSystemTools::FindCMakeResources(argv[0]);
cmCPackLog log;
2012-04-19 19:04:21 +03:00
log.SetErrorPrefix("CPack Error: ");
log.SetWarningPrefix("CPack Warning: ");
log.SetOutputPrefix("CPack: ");
log.SetVerbosePrefix("CPack Verbose: ");
2016-07-09 11:21:54 +02:00
if (cmSystemTools::GetCurrentWorkingDirectory().empty()) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
2016-07-09 11:21:54 +02:00
"Current working directory cannot be established."
<< std::endl);
2013-03-16 19:13:01 +02:00
return 1;
2016-07-09 11:21:54 +02:00
}
std::string generator;
bool help = false;
bool helpVersion = false;
std::string helpFull;
std::string helpMAN;
std::string helpHTML;
std::string cpackProjectName;
2012-08-04 10:26:08 +03:00
std::string cpackProjectDirectory;
std::string cpackBuildConfig;
std::string cpackProjectVersion;
std::string cpackProjectPatch;
std::string cpackProjectVendor;
std::string cpackConfigFile;
2022-08-04 22:12:04 +02:00
std::map<std::string, std::string> definitions;
auto const verboseLambda = [&log](const std::string&, cmake*,
cmMakefile*) -> bool {
log.SetVerbose(true);
2010-11-13 01:00:53 +02:00
cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Verbose" << std::endl);
2022-08-04 22:12:04 +02:00
return true;
};
2022-08-04 22:12:04 +02:00
auto const debugLambda = [&log](const std::string&, cmake*,
cmMakefile*) -> bool {
log.SetDebug(true);
cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Debug" << std::endl);
return true;
};
auto const traceLambda = [](const std::string&, cmake* state,
cmMakefile*) -> bool {
state->SetTrace(true);
return true;
};
auto const traceExpandLambda = [](const std::string&, cmake* state,
cmMakefile*) -> bool {
state->SetTrace(true);
state->SetTraceExpand(true);
return true;
};
using CommandArgument =
cmCommandLineArgument<bool(std::string const&, cmake*, cmMakefile*)>;
std::vector<CommandArgument> arguments = {
CommandArgument{ "--help", CommandArgument::Values::Zero,
CommandArgument::setToTrue(help) },
CommandArgument{ "--help-full", CommandArgument::Values::Zero,
CommandArgument::setToValue(helpFull) },
CommandArgument{ "--help-html", CommandArgument::Values::Zero,
CommandArgument::setToValue(helpHTML) },
CommandArgument{ "--help-man", CommandArgument::Values::Zero,
CommandArgument::setToValue(helpMAN) },
CommandArgument{ "--version", CommandArgument::Values::Zero,
CommandArgument::setToTrue(helpVersion) },
CommandArgument{ "-V", CommandArgument::Values::Zero, verboseLambda },
CommandArgument{ "--verbose", CommandArgument::Values::Zero,
verboseLambda },
CommandArgument{ "--debug", CommandArgument::Values::Zero, debugLambda },
CommandArgument{ "--config", CommandArgument::Values::One,
CommandArgument::setToValue(cpackConfigFile) },
CommandArgument{ "--trace", CommandArgument::Values::One, traceLambda },
CommandArgument{ "--trace-expand", CommandArgument::Values::One,
traceExpandLambda },
CommandArgument{ "-C", CommandArgument::Values::One,
CommandArgument::setToValue(cpackBuildConfig) },
CommandArgument{ "-G", CommandArgument::Values::One,
CommandArgument::setToValue(generator) },
CommandArgument{ "-P", CommandArgument::Values::One,
CommandArgument::setToValue(cpackProjectName) },
CommandArgument{ "-R", CommandArgument::Values::One,
CommandArgument::setToValue(cpackProjectVersion) },
CommandArgument{ "-B", CommandArgument::Values::One,
CommandArgument::setToValue(cpackProjectDirectory) },
CommandArgument{ "--patch", CommandArgument::Values::One,
CommandArgument::setToValue(cpackProjectPatch) },
CommandArgument{ "--vendor", CommandArgument::Values::One,
CommandArgument::setToValue(cpackProjectVendor) },
CommandArgument{
"-D", CommandArgument::Values::One,
[&log, &definitions](const std::string& arg, cmake*,
cmMakefile*) -> bool {
std::string value = arg;
size_t pos = value.find_first_of('=');
if (pos == std::string::npos) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Please specify CPack definitions as: KEY=VALUE"
<< std::endl);
return false;
}
std::string key = value.substr(0, pos);
value.erase(0, pos + 1);
definitions[key] = value;
cmCPack_Log(&log, cmCPackLog::LOG_DEBUG,
"Set CPack variable: " << key << " to \"" << value << "\""
<< std::endl);
return true;
} },
};
2019-11-11 23:01:05 +01:00
cmake cminst(cmake::RoleScript, cmState::CPack);
2015-08-17 11:37:30 +02:00
cminst.SetHomeDirectory("");
cminst.SetHomeOutputDirectory("");
2019-11-11 23:01:05 +01:00
cminst.SetProgressCallback(cpackProgressCallback);
2016-03-13 13:35:51 +01:00
cminst.GetCurrentSnapshot().SetDefaultDefinitions();
2015-08-17 11:37:30 +02:00
cmGlobalGenerator cmgg(&cminst);
2018-01-26 17:06:56 +01:00
cmMakefile globalMF(&cmgg, cminst.GetCurrentSnapshot());
2015-08-17 11:37:30 +02:00
#if defined(__CYGWIN__)
2018-01-26 17:06:56 +01:00
globalMF.AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
2015-08-17 11:37:30 +02:00
#endif
2022-08-04 22:12:04 +02:00
bool parsed = true;
for (std::size_t i = 0; i < inputArgs.size(); i++) {
auto const& arg = inputArgs[i];
for (auto const& m : arguments) {
if (m.matches(arg)) {
if (!m.parse(arg, i, inputArgs, &cminst, &globalMF)) {
parsed = false;
}
break;
}
}
2018-04-23 21:13:27 +02:00
}
2022-08-04 22:12:04 +02:00
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Read CPack config file: " << cpackConfigFile << std::endl);
bool cpackConfigFileSpecified = true;
2016-07-09 11:21:54 +02:00
if (cpackConfigFile.empty()) {
2020-02-01 23:06:01 +01:00
cpackConfigFile = cmStrCat(cmSystemTools::GetCurrentWorkingDirectory(),
"/CPackConfig.cmake");
cpackConfigFileSpecified = false;
2016-07-09 11:21:54 +02:00
}
cmCPackGeneratorFactory generators;
generators.SetLogger(&log);
2012-04-19 19:04:21 +03:00
cmDocumentation doc;
doc.addCPackStandardDocSections();
2012-08-04 10:26:08 +03:00
/* Were we invoked to display doc or to do some work ?
* Unlike cmake launching cpack with zero argument
* should launch cpack using "cpackConfigFile" if it exists
* in the current directory.
*/
2016-10-30 18:24:19 +01:00
help = doc.CheckOptions(argc, argv, "-G") && argc != 1;
2012-04-19 19:04:21 +03:00
// This part is used for cpack documentation lookup as well.
cminst.AddCMakePaths();
2016-07-09 11:21:54 +02:00
if (parsed && !help) {
// find out which system cpack is running on, so it can setup the search
// paths, so FIND_XXX() commands can be used in scripts
2012-02-18 12:40:36 +02:00
std::string systemFile =
2018-01-26 17:06:56 +01:00
globalMF.GetModulesFile("CMakeDetermineSystem.cmake");
2019-11-11 23:01:05 +01:00
if (!globalMF.ReadListFile(systemFile)) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
2016-07-09 11:21:54 +02:00
"Error reading CMakeDetermineSystem.cmake" << std::endl);
return 1;
2016-07-09 11:21:54 +02:00
}
2012-02-18 12:40:36 +02:00
systemFile =
2018-01-26 17:06:56 +01:00
globalMF.GetModulesFile("CMakeSystemSpecificInformation.cmake");
2019-11-11 23:01:05 +01:00
if (!globalMF.ReadListFile(systemFile)) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
2016-07-09 11:21:54 +02:00
"Error reading CMakeSystemSpecificInformation.cmake"
<< std::endl);
return 1;
2016-07-09 11:21:54 +02:00
}
2016-07-09 11:21:54 +02:00
if (!cpackBuildConfig.empty()) {
2020-02-01 23:06:01 +01:00
globalMF.AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig);
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
2018-04-23 21:13:27 +02:00
if (cmSystemTools::FileExists(cpackConfigFile)) {
2016-07-09 11:21:54 +02:00
cpackConfigFile = cmSystemTools::CollapseFullPath(cpackConfigFile);
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
2016-07-09 11:21:54 +02:00
"Read CPack configuration file: " << cpackConfigFile
<< std::endl);
2019-11-11 23:01:05 +01:00
if (!globalMF.ReadListFile(cpackConfigFile)) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
2016-07-09 11:21:54 +02:00
"Problem reading CPack config file: \""
<< cpackConfigFile << "\"" << std::endl);
return 1;
}
2016-07-09 11:21:54 +02:00
} else if (cpackConfigFileSpecified) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
2016-07-09 11:21:54 +02:00
"Cannot find CPack config file: \"" << cpackConfigFile
<< "\"" << std::endl);
return 1;
2016-07-09 11:21:54 +02:00
}
2016-07-09 11:21:54 +02:00
if (!generator.empty()) {
2020-02-01 23:06:01 +01:00
globalMF.AddDefinition("CPACK_GENERATOR", generator);
2016-07-09 11:21:54 +02:00
}
if (!cpackProjectName.empty()) {
2020-02-01 23:06:01 +01:00
globalMF.AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName);
2016-07-09 11:21:54 +02:00
}
if (!cpackProjectVersion.empty()) {
2020-02-01 23:06:01 +01:00
globalMF.AddDefinition("CPACK_PACKAGE_VERSION", cpackProjectVersion);
2016-07-09 11:21:54 +02:00
}
if (!cpackProjectVendor.empty()) {
2020-02-01 23:06:01 +01:00
globalMF.AddDefinition("CPACK_PACKAGE_VENDOR", cpackProjectVendor);
2016-07-09 11:21:54 +02:00
}
2012-08-04 10:26:08 +03:00
// if this is not empty it has been set on the command line
// go for it. Command line override values set in config file.
2016-07-09 11:21:54 +02:00
if (!cpackProjectDirectory.empty()) {
2020-02-01 23:06:01 +01:00
globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY", cpackProjectDirectory);
2016-07-09 11:21:54 +02:00
}
2012-08-04 10:26:08 +03:00
// The value has not been set on the command line
2016-07-09 11:21:54 +02:00
else {
2012-08-04 10:26:08 +03:00
// get a default value (current working directory)
2020-08-30 11:54:41 +02:00
cpackProjectDirectory = cmSystemTools::GetCurrentWorkingDirectory();
// use default value if no value has been provided by the config file
2018-01-26 17:06:56 +01:00
if (!globalMF.IsSet("CPACK_PACKAGE_DIRECTORY")) {
globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY",
2020-02-01 23:06:01 +01:00
cpackProjectDirectory);
}
2016-07-09 11:21:54 +02:00
}
2022-08-04 22:12:04 +02:00
for (auto const& cd : definitions) {
2020-02-01 23:06:01 +01:00
globalMF.AddDefinition(cd.first, cd.second);
2016-07-09 11:21:54 +02:00
}
2020-08-30 11:54:41 +02:00
// Force CPACK_PACKAGE_DIRECTORY as absolute path
2021-09-14 00:13:48 +02:00
cpackProjectDirectory =
globalMF.GetSafeDefinition("CPACK_PACKAGE_DIRECTORY");
2020-08-30 11:54:41 +02:00
cpackProjectDirectory =
cmSystemTools::CollapseFullPath(cpackProjectDirectory);
globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY", cpackProjectDirectory);
2021-11-20 13:41:27 +01:00
cmValue cpackModulesPath = globalMF.GetDefinition("CPACK_MODULE_PATH");
2016-07-09 11:21:54 +02:00
if (cpackModulesPath) {
2021-09-14 00:13:48 +02:00
globalMF.AddDefinition("CMAKE_MODULE_PATH", *cpackModulesPath);
2016-07-09 11:21:54 +02:00
}
2021-11-20 13:41:27 +01:00
cmValue genList = globalMF.GetDefinition("CPACK_GENERATOR");
2016-07-09 11:21:54 +02:00
if (!genList) {
2018-08-09 18:06:22 +02:00
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"CPack generator not specified" << std::endl);
2016-07-09 11:21:54 +02:00
} else {
2021-09-14 00:13:48 +02:00
std::vector<std::string> generatorsVector = cmExpandedList(*genList);
2018-01-26 17:06:56 +01:00
for (std::string const& gen : generatorsVector) {
cmMakefile::ScopePushPop raii(&globalMF);
cmMakefile* mf = &globalMF;
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
2016-07-09 11:21:54 +02:00
"Specified generator: " << gen << std::endl);
2021-09-14 00:13:48 +02:00
if (!mf->GetDefinition("CPACK_PACKAGE_NAME")) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
2016-07-09 11:21:54 +02:00
"CPack project name not specified" << std::endl);
2022-08-04 22:12:04 +02:00
parsed = false;
2016-07-09 11:21:54 +02:00
}
2009-10-04 10:30:41 +03:00
if (parsed &&
!(mf->GetDefinition("CPACK_PACKAGE_VERSION") ||
(mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") &&
mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR") &&
2016-07-09 11:21:54 +02:00
mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH")))) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
2016-07-09 11:21:54 +02:00
"CPack project version not specified"
<< std::endl
<< "Specify CPACK_PACKAGE_VERSION, or "
"CPACK_PACKAGE_VERSION_MAJOR, "
"CPACK_PACKAGE_VERSION_MINOR, and "
"CPACK_PACKAGE_VERSION_PATCH."
<< std::endl);
2022-08-04 22:12:04 +02:00
parsed = false;
2016-07-09 11:21:54 +02:00
}
if (parsed) {
2020-02-01 23:06:01 +01:00
std::unique_ptr<cmCPackGenerator> cpackGenerator =
generators.NewGenerator(gen);
2018-04-23 21:13:27 +02:00
if (cpackGenerator) {
2022-08-04 22:12:04 +02:00
cpackGenerator->SetTrace(cminst.GetTrace());
cpackGenerator->SetTraceExpand(cminst.GetTraceExpand());
2018-04-23 21:13:27 +02:00
} else {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
2019-11-11 23:01:05 +01:00
"Could not create CPack generator: " << gen
<< std::endl);
// Print out all the valid generators
cmDocumentation generatorDocs;
std::vector<cmDocumentationEntry> v;
for (auto const& g : generators.GetGeneratorsList()) {
cmDocumentationEntry e;
e.Name = g.first;
e.Brief = g.second;
v.push_back(std::move(e));
}
generatorDocs.SetSection("Generators", v);
std::cerr << "\n";
generatorDocs.PrintDocumentation(cmDocumentation::ListGenerators,
std::cerr);
2022-08-04 22:12:04 +02:00
parsed = false;
2016-07-09 11:21:54 +02:00
}
2018-04-23 21:13:27 +02:00
2016-07-09 11:21:54 +02:00
if (parsed && !cpackGenerator->Initialize(gen, mf)) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
2016-07-09 11:21:54 +02:00
"Cannot initialize the generator " << gen
<< std::endl);
2022-08-04 22:12:04 +02:00
parsed = false;
2016-07-09 11:21:54 +02:00
}
2016-07-09 11:21:54 +02:00
if (!mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
2018-01-26 17:06:56 +01:00
!mf->GetDefinition("CPACK_INSTALL_SCRIPT") &&
2016-07-09 11:21:54 +02:00
!mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
!mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS")) {
cmCPack_Log(
&log, cmCPackLog::LOG_ERROR,
"Please specify build tree of the project that uses CMake "
"using CPACK_INSTALL_CMAKE_PROJECTS, specify "
2018-01-26 17:06:56 +01:00
"CPACK_INSTALL_COMMANDS, CPACK_INSTALL_SCRIPT, or "
"CPACK_INSTALLED_DIRECTORIES."
2016-07-09 11:21:54 +02:00
<< std::endl);
2022-08-04 22:12:04 +02:00
parsed = false;
2016-07-09 11:21:54 +02:00
}
if (parsed) {
2021-11-20 13:41:27 +01:00
cmValue projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
2018-08-09 18:06:22 +02:00
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Use generator: " << cpackGenerator->GetNameOfClass()
<< std::endl);
2016-07-09 11:21:54 +02:00
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
2021-09-14 00:13:48 +02:00
"For project: " << *projName << std::endl);
2021-11-20 13:41:27 +01:00
cmValue projVersion = mf->GetDefinition("CPACK_PACKAGE_VERSION");
2016-07-09 11:21:54 +02:00
if (!projVersion) {
2021-11-20 13:41:27 +01:00
cmValue projVersionMajor =
2016-07-09 11:21:54 +02:00
mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
2021-11-20 13:41:27 +01:00
cmValue projVersionMinor =
2016-07-09 11:21:54 +02:00
mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
2021-11-20 13:41:27 +01:00
cmValue projVersionPatch =
2016-07-09 11:21:54 +02:00
mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
2015-04-27 22:25:09 +02:00
std::ostringstream ostr;
2021-09-14 00:13:48 +02:00
ostr << *projVersionMajor << "." << *projVersionMinor << "."
<< *projVersionPatch;
2020-02-01 23:06:01 +01:00
mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str());
2016-07-09 11:21:54 +02:00
}
int res = cpackGenerator->DoPackage();
2016-07-09 11:21:54 +02:00
if (!res) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
2021-09-14 00:13:48 +02:00
"Error when generating package: " << *projName
2016-07-09 11:21:54 +02:00
<< std::endl);
return 1;
}
}
}
}
}
2016-07-09 11:21:54 +02:00
}
2012-04-19 19:04:21 +03:00
/* In this case we are building the documentation object
* instance in order to create appropriate structure
* in order to satisfy the appropriate --help-xxx request
*/
2016-07-09 11:21:54 +02:00
if (help) {
// Construct and print requested documentation.
2012-04-19 19:04:21 +03:00
doc.SetName("cpack");
2016-07-09 11:21:54 +02:00
doc.SetSection("Name", cmDocumentationName);
doc.SetSection("Usage", cmDocumentationUsage);
doc.PrependSection("Options", cmDocumentationOptions);
std::vector<cmDocumentationEntry> v;
2018-01-26 17:06:56 +01:00
for (auto const& g : generators.GetGeneratorsList()) {
cmDocumentationEntry e;
2018-01-26 17:06:56 +01:00
e.Name = g.first;
e.Brief = g.second;
2018-04-23 21:13:27 +02:00
v.push_back(std::move(e));
2016-07-09 11:21:54 +02:00
}
doc.SetSection("Generators", v);
2016-07-09 11:21:54 +02:00
return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1;
}
2022-08-04 22:12:04 +02:00
if (cmSystemTools::GetErrorOccurredFlag()) {
return 1;
2016-07-09 11:21:54 +02:00
}
return 0;
}