2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2006-01-02 07:21:05 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2006-01-02 07:21:05 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2006-01-02 07:21:05 +03:00
|
|
|
#include "cmSystemTools.h"
|
|
|
|
|
|
|
|
// Need these for documentation support.
|
2007-11-06 00:55:45 +03:00
|
|
|
#include "cmCPackGenerator.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmCPackGeneratorFactory.h"
|
|
|
|
#include "cmDocumentation.h"
|
2006-01-03 01:28:20 +03:00
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmMakefile.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmake.h"
|
|
|
|
#include "cmake.h"
|
2006-01-02 07:21:05 +03:00
|
|
|
|
2006-01-03 00:14:21 +03:00
|
|
|
#include "cmCPackLog.h"
|
|
|
|
|
2006-01-02 07:21:05 +03:00
|
|
|
#include <cmsys/CommandLineArguments.hxx>
|
2013-12-19 01:38:56 +04:00
|
|
|
#include <cmsys/Encoding.hxx>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <cmsys/SystemTools.hxx>
|
2006-01-02 07:21:05 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static const char* cmDocumentationName[][2] = {
|
|
|
|
{ 0, " cpack - Packaging driver provided by CMake." },
|
|
|
|
{ 0, 0 }
|
2006-01-02 07:21:05 +03:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static const char* cmDocumentationUsage[][2] = {
|
|
|
|
{ 0, " cpack -G <generator> [options]" },
|
|
|
|
{ 0, 0 }
|
2006-01-02 07:21:05 +03:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static const char* cmDocumentationOptions[][2] = {
|
|
|
|
{ "-G <generator>", "Use the specified generator to generate package." },
|
|
|
|
{ "-C <Configuration>", "Specify the project configuration" },
|
|
|
|
{ "-D <var>=<value>", "Set a CPack variable." },
|
|
|
|
{ "--config <config file>", "Specify the config file." },
|
|
|
|
{ "--verbose,-V", "enable verbose output" },
|
|
|
|
{ "--debug", "enable debug output (for CPack developers)" },
|
|
|
|
{ "-P <package name>", "override/define CPACK_PACKAGE_NAME" },
|
|
|
|
{ "-R <package version>", "override/define CPACK_PACKAGE_VERSION" },
|
|
|
|
{ "-B <package directory>", "override/define CPACK_PACKAGE_DIRECTORY" },
|
|
|
|
{ "--vendor <vendor name>", "override/define CPACK_PACKAGE_VENDOR" },
|
|
|
|
{ 0, 0 }
|
2006-01-02 07:21:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
int cpackUnknownArgument(const char*, void*)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-01-03 00:14:21 +03:00
|
|
|
struct cpackDefinitions
|
|
|
|
{
|
2014-02-10 09:21:34 +04:00
|
|
|
typedef std::map<std::string, std::string> MapType;
|
2006-03-10 21:06:26 +03:00
|
|
|
MapType Map;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLog* Log;
|
2006-01-03 00:14:21 +03:00
|
|
|
};
|
2006-01-02 07:21:05 +03:00
|
|
|
|
2006-03-10 21:06:26 +03:00
|
|
|
int cpackDefinitionArgument(const char* argument, const char* cValue,
|
2016-05-16 17:34:04 +03:00
|
|
|
void* call_data)
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
|
|
|
(void)argument;
|
2006-01-03 00:14:21 +03:00
|
|
|
cpackDefinitions* def = static_cast<cpackDefinitions*>(call_data);
|
2006-01-02 07:21:05 +03:00
|
|
|
std::string value = cValue;
|
2016-05-24 22:24:10 +03:00
|
|
|
size_t pos = value.find_first_of('=');
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pos == std::string::npos) {
|
2006-03-10 21:06:26 +03:00
|
|
|
cmCPack_Log(def->Log, cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Please specify CPack definitions as: KEY=VALUE" << std::endl);
|
2006-01-02 07:21:05 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-02 07:21:05 +03:00
|
|
|
std::string key = value.substr(0, pos);
|
|
|
|
value = value.c_str() + pos + 1;
|
2006-03-10 21:06:26 +03:00
|
|
|
def->Map[key] = value;
|
|
|
|
cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< key << " to \"" << value << "\"" << std::endl);
|
2006-01-02 07:21:05 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this is CPack.
|
2016-05-16 17:34:04 +03:00
|
|
|
int main(int argc, char const* const* argv)
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2013-12-19 01:38:56 +04:00
|
|
|
cmsys::Encoding::CommandLineArguments args =
|
|
|
|
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
|
|
|
|
argc = args.argc();
|
|
|
|
argv = args.argv();
|
|
|
|
|
2013-11-08 00:30:59 +04:00
|
|
|
cmSystemTools::FindCMakeResources(argv[0]);
|
2006-01-03 00:14:21 +03:00
|
|
|
cmCPackLog log;
|
2011-11-14 01:44:53 +04:00
|
|
|
|
2006-01-03 00:14:21 +03:00
|
|
|
log.SetErrorPrefix("CPack Error: ");
|
|
|
|
log.SetWarningPrefix("CPack Warning: ");
|
|
|
|
log.SetOutputPrefix("CPack: ");
|
2006-01-03 01:28:20 +03:00
|
|
|
log.SetVerbosePrefix("CPack Verbose: ");
|
2006-01-03 00:14:21 +03:00
|
|
|
|
2006-01-02 07:21:05 +03:00
|
|
|
cmSystemTools::EnableMSVCDebugHook();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetCurrentWorkingDirectory().empty()) {
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Current working directory cannot be established."
|
|
|
|
<< std::endl);
|
2013-02-07 17:53:50 +04:00
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-02 07:21:05 +03:00
|
|
|
|
|
|
|
std::string generator;
|
|
|
|
bool help = false;
|
|
|
|
bool helpVersion = false;
|
2006-01-03 00:14:21 +03:00
|
|
|
bool verbose = false;
|
|
|
|
bool debug = false;
|
2006-01-02 07:21:05 +03:00
|
|
|
std::string helpFull;
|
|
|
|
std::string helpMAN;
|
|
|
|
std::string helpHTML;
|
|
|
|
|
|
|
|
std::string cpackProjectName;
|
2012-07-05 01:08:32 +04:00
|
|
|
std::string cpackProjectDirectory;
|
2006-01-02 07:21:05 +03:00
|
|
|
std::string cpackBuildConfig;
|
|
|
|
std::string cpackProjectVersion;
|
|
|
|
std::string cpackProjectPatch;
|
|
|
|
std::string cpackProjectVendor;
|
2006-01-03 00:14:21 +03:00
|
|
|
std::string cpackConfigFile;
|
|
|
|
|
|
|
|
cpackDefinitions definitions;
|
2006-03-10 21:06:26 +03:00
|
|
|
definitions.Log = &log;
|
2006-01-03 00:14:21 +03:00
|
|
|
|
2006-01-03 01:28:20 +03:00
|
|
|
cpackConfigFile = "";
|
2006-01-02 07:21:05 +03:00
|
|
|
|
|
|
|
cmsys::CommandLineArguments arg;
|
|
|
|
arg.Initialize(argc, argv);
|
|
|
|
typedef cmsys::CommandLineArguments argT;
|
|
|
|
// Help arguments
|
|
|
|
arg.AddArgument("--help", argT::NO_ARGUMENT, &help, "CPack help");
|
2006-03-09 16:32:08 +03:00
|
|
|
arg.AddArgument("--help-full", argT::SPACE_ARGUMENT, &helpFull,
|
2016-05-16 17:34:04 +03:00
|
|
|
"CPack help");
|
2006-03-09 16:32:08 +03:00
|
|
|
arg.AddArgument("--help-html", argT::SPACE_ARGUMENT, &helpHTML,
|
2016-05-16 17:34:04 +03:00
|
|
|
"CPack help");
|
2006-01-02 07:21:05 +03:00
|
|
|
arg.AddArgument("--help-man", argT::SPACE_ARGUMENT, &helpMAN, "CPack help");
|
|
|
|
arg.AddArgument("--version", argT::NO_ARGUMENT, &helpVersion, "CPack help");
|
|
|
|
|
2006-01-03 00:14:21 +03:00
|
|
|
arg.AddArgument("-V", argT::NO_ARGUMENT, &verbose, "CPack verbose");
|
|
|
|
arg.AddArgument("--verbose", argT::NO_ARGUMENT, &verbose, "-V");
|
|
|
|
arg.AddArgument("--debug", argT::NO_ARGUMENT, &debug, "-V");
|
2006-03-09 00:33:39 +03:00
|
|
|
arg.AddArgument("--config", argT::SPACE_ARGUMENT, &cpackConfigFile,
|
2016-05-16 17:34:04 +03:00
|
|
|
"CPack configuration file");
|
2006-03-09 00:33:39 +03:00
|
|
|
arg.AddArgument("-C", argT::SPACE_ARGUMENT, &cpackBuildConfig,
|
2016-05-16 17:34:04 +03:00
|
|
|
"CPack build configuration");
|
|
|
|
arg.AddArgument("-G", argT::SPACE_ARGUMENT, &generator, "CPack generator");
|
|
|
|
arg.AddArgument("-P", argT::SPACE_ARGUMENT, &cpackProjectName,
|
|
|
|
"CPack project name");
|
|
|
|
arg.AddArgument("-R", argT::SPACE_ARGUMENT, &cpackProjectVersion,
|
|
|
|
"CPack project version");
|
|
|
|
arg.AddArgument("-B", argT::SPACE_ARGUMENT, &cpackProjectDirectory,
|
|
|
|
"CPack project directory");
|
|
|
|
arg.AddArgument("--patch", argT::SPACE_ARGUMENT, &cpackProjectPatch,
|
|
|
|
"CPack project patch");
|
|
|
|
arg.AddArgument("--vendor", argT::SPACE_ARGUMENT, &cpackProjectVendor,
|
|
|
|
"CPack project vendor");
|
|
|
|
arg.AddCallback("-D", argT::SPACE_ARGUMENT, cpackDefinitionArgument,
|
|
|
|
&definitions, "CPack Definitions");
|
2006-01-02 07:21:05 +03:00
|
|
|
arg.SetUnknownArgumentCallback(cpackUnknownArgument);
|
|
|
|
|
2006-01-03 00:14:21 +03:00
|
|
|
// Parse command line
|
2006-01-02 07:21:05 +03:00
|
|
|
int parsed = arg.Parse();
|
|
|
|
|
2006-01-03 00:14:21 +03:00
|
|
|
// Setup logging
|
2016-05-16 17:34:04 +03:00
|
|
|
if (verbose) {
|
2006-01-03 00:14:21 +03:00
|
|
|
log.SetVerbose(verbose);
|
2010-07-02 18:58:00 +04:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Verbose" << std::endl);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (debug) {
|
2006-01-03 00:14:21 +03:00
|
|
|
log.SetDebug(debug);
|
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Debug" << std::endl);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-03 00:14:21 +03:00
|
|
|
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Read CPack config file: " << cpackConfigFile << std::endl);
|
2006-01-03 00:14:21 +03:00
|
|
|
|
2006-01-03 01:28:20 +03:00
|
|
|
cmake cminst;
|
2015-05-05 00:01:29 +03:00
|
|
|
cminst.SetHomeDirectory("");
|
|
|
|
cminst.SetHomeOutputDirectory("");
|
2015-10-13 22:48:46 +03:00
|
|
|
cminst.GetCurrentSnapshot().SetDefaultDefinitions();
|
2015-04-11 13:52:14 +03:00
|
|
|
cminst.GetState()->RemoveUnscriptableCommands();
|
2015-05-24 12:31:14 +03:00
|
|
|
cmGlobalGenerator cmgg(&cminst);
|
2015-08-02 12:41:51 +03:00
|
|
|
cmsys::auto_ptr<cmMakefile> globalMF(
|
2016-05-16 17:34:04 +03:00
|
|
|
new cmMakefile(&cmgg, cminst.GetCurrentSnapshot()));
|
2015-04-01 19:50:03 +03:00
|
|
|
#if defined(__CYGWIN__)
|
|
|
|
globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
|
|
|
|
#endif
|
2006-01-03 01:28:20 +03:00
|
|
|
|
|
|
|
bool cpackConfigFileSpecified = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cpackConfigFile.empty()) {
|
2006-01-03 01:28:20 +03:00
|
|
|
cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory();
|
2006-01-04 23:14:09 +03:00
|
|
|
cpackConfigFile += "/CPackConfig.cmake";
|
2006-01-03 01:28:20 +03:00
|
|
|
cpackConfigFileSpecified = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-03 00:14:21 +03:00
|
|
|
|
2007-11-06 00:33:19 +03:00
|
|
|
cmCPackGeneratorFactory generators;
|
2006-01-03 00:14:21 +03:00
|
|
|
generators.SetLogger(&log);
|
2007-11-06 00:55:45 +03:00
|
|
|
cmCPackGenerator* cpackGenerator = 0;
|
2006-01-02 07:21:05 +03:00
|
|
|
|
2011-11-14 01:44:53 +04:00
|
|
|
cmDocumentation doc;
|
|
|
|
doc.addCPackStandardDocSections();
|
2012-07-03 17:28:07 +04: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-05-16 17:34:04 +03:00
|
|
|
if ((doc.CheckOptions(argc, argv, "-G")) && !(argc == 1)) {
|
|
|
|
help = true;
|
|
|
|
} else {
|
|
|
|
help = false;
|
|
|
|
}
|
2006-01-02 07:21:05 +03:00
|
|
|
|
2012-01-03 03:54:08 +04:00
|
|
|
// This part is used for cpack documentation lookup as well.
|
|
|
|
cminst.AddCMakePaths();
|
2007-07-24 18:00:26 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (parsed && !help) {
|
2012-02-07 19:59:04 +04:00
|
|
|
// find out which system cpack is running on, so it can setup the search
|
|
|
|
// paths, so FIND_XXX() commands can be used in scripts
|
|
|
|
std::string systemFile =
|
|
|
|
globalMF->GetModulesFile("CMakeDetermineSystem.cmake");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!globalMF->ReadListFile(systemFile.c_str())) {
|
2012-02-07 19:59:04 +04:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Error reading CMakeDetermineSystem.cmake" << std::endl);
|
2012-02-07 19:59:04 +04:00
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-02-07 19:59:04 +04:00
|
|
|
|
|
|
|
systemFile =
|
|
|
|
globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!globalMF->ReadListFile(systemFile.c_str())) {
|
2012-02-07 19:59:04 +04:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Error reading CMakeSystemSpecificInformation.cmake"
|
|
|
|
<< std::endl);
|
2012-02-07 19:59:04 +04:00
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-02-07 19:59:04 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cpackBuildConfig.empty()) {
|
2014-05-15 21:12:40 +04:00
|
|
|
globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 21:12:40 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(cpackConfigFile.c_str())) {
|
|
|
|
cpackConfigFile = cmSystemTools::CollapseFullPath(cpackConfigFile);
|
2006-07-09 21:20:07 +04:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Read CPack configuration file: " << cpackConfigFile
|
|
|
|
<< std::endl);
|
|
|
|
if (!globalMF->ReadListFile(cpackConfigFile.c_str())) {
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Problem reading CPack config file: \""
|
|
|
|
<< cpackConfigFile << "\"" << std::endl);
|
2006-02-23 17:59:42 +03:00
|
|
|
return 1;
|
2006-01-03 01:28:20 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (cpackConfigFileSpecified) {
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Cannot find CPack config file: \"" << cpackConfigFile
|
|
|
|
<< "\"" << std::endl);
|
2006-01-03 01:28:20 +03:00
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-03 01:28:20 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!generator.empty()) {
|
2006-07-09 21:20:07 +04:00
|
|
|
globalMF->AddDefinition("CPACK_GENERATOR", generator.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!cpackProjectName.empty()) {
|
2006-07-09 21:20:07 +04:00
|
|
|
globalMF->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!cpackProjectVersion.empty()) {
|
2006-07-10 15:52:35 +04:00
|
|
|
globalMF->AddDefinition("CPACK_PACKAGE_VERSION",
|
2016-05-16 17:34:04 +03:00
|
|
|
cpackProjectVersion.c_str());
|
|
|
|
}
|
|
|
|
if (!cpackProjectVendor.empty()) {
|
2006-07-10 15:52:35 +04:00
|
|
|
globalMF->AddDefinition("CPACK_PACKAGE_VENDOR",
|
2016-05-16 17:34:04 +03:00
|
|
|
cpackProjectVendor.c_str());
|
|
|
|
}
|
2012-07-05 01:08:32 +04: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-05-16 17:34:04 +03:00
|
|
|
if (!cpackProjectDirectory.empty()) {
|
2006-07-09 21:20:07 +04:00
|
|
|
globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
|
2012-07-05 01:08:32 +04:00
|
|
|
cpackProjectDirectory.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-07-05 01:08:32 +04:00
|
|
|
// The value has not been set on the command line
|
2016-05-16 17:34:04 +03:00
|
|
|
else {
|
2012-07-05 01:08:32 +04:00
|
|
|
// get a default value (current working directory)
|
|
|
|
cpackProjectDirectory = cmsys::SystemTools::GetCurrentWorkingDirectory();
|
|
|
|
// use default value iff no value has been provided by the config file
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!globalMF->IsSet("CPACK_PACKAGE_DIRECTORY")) {
|
2012-07-05 01:08:32 +04:00
|
|
|
globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
|
|
|
|
cpackProjectDirectory.c_str());
|
2006-03-09 00:33:39 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-03 01:28:20 +03:00
|
|
|
cpackDefinitions::MapType::iterator cdit;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (cdit = definitions.Map.begin(); cdit != definitions.Map.end();
|
|
|
|
++cdit) {
|
2014-03-11 03:04:11 +04:00
|
|
|
globalMF->AddDefinition(cdit->first, cdit->second.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-03 01:28:20 +03:00
|
|
|
|
2006-10-17 17:34:07 +04:00
|
|
|
const char* cpackModulesPath =
|
|
|
|
globalMF->GetDefinition("CPACK_MODULE_PATH");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cpackModulesPath) {
|
2006-10-12 21:05:50 +04:00
|
|
|
globalMF->AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-07-09 21:20:07 +04:00
|
|
|
const char* genList = globalMF->GetDefinition("CPACK_GENERATOR");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!genList) {
|
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack generator not specified"
|
|
|
|
<< std::endl);
|
|
|
|
} else {
|
2006-07-27 19:55:34 +04:00
|
|
|
std::vector<std::string> generatorsVector;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(genList, generatorsVector);
|
2006-07-27 19:55:34 +04:00
|
|
|
std::vector<std::string>::iterator it;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = generatorsVector.begin(); it != generatorsVector.end(); ++it) {
|
2006-07-27 19:55:34 +04:00
|
|
|
const char* gen = it->c_str();
|
2015-08-02 12:41:51 +03:00
|
|
|
cmMakefile::ScopePushPop raii(globalMF.get());
|
|
|
|
cmMakefile* mf = globalMF.get();
|
2007-07-24 18:00:26 +04:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Specified generator: " << gen << std::endl);
|
|
|
|
if (parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME")) {
|
2007-07-24 18:00:26 +04:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"CPack project name not specified" << std::endl);
|
2007-07-24 18:00:26 +04:00
|
|
|
parsed = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-11 16:18:15 +04:00
|
|
|
if (parsed &&
|
|
|
|
!(mf->GetDefinition("CPACK_PACKAGE_VERSION") ||
|
|
|
|
(mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") &&
|
|
|
|
mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR") &&
|
2016-05-16 17:34:04 +03:00
|
|
|
mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH")))) {
|
2007-07-24 18:00:26 +04:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03: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);
|
2007-07-24 18:00:26 +04:00
|
|
|
parsed = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (parsed) {
|
2007-07-24 18:00:26 +04:00
|
|
|
cpackGenerator = generators.NewGenerator(gen);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cpackGenerator) {
|
2007-07-24 18:00:26 +04:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Cannot initialize CPack generator: " << gen
|
|
|
|
<< std::endl);
|
2007-07-24 18:00:26 +04:00
|
|
|
parsed = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (parsed && !cpackGenerator->Initialize(gen, mf)) {
|
2006-07-09 21:20:07 +04:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Cannot initialize the generator " << gen
|
|
|
|
<< std::endl);
|
2006-07-09 21:20:07 +04:00
|
|
|
parsed = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-07-24 18:00:26 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
|
|
|
|
!mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
|
|
|
|
!mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS")) {
|
|
|
|
cmCPack_Log(
|
|
|
|
&log, cmCPackLog::LOG_ERROR,
|
2007-07-24 18:00:26 +04:00
|
|
|
"Please specify build tree of the project that uses CMake "
|
|
|
|
"using CPACK_INSTALL_CMAKE_PROJECTS, specify "
|
|
|
|
"CPACK_INSTALL_COMMANDS, or specify "
|
|
|
|
"CPACK_INSTALLED_DIRECTORIES."
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
2006-07-09 21:20:07 +04:00
|
|
|
parsed = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (parsed) {
|
2007-07-24 18:00:26 +04:00
|
|
|
const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
|
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< cpackGenerator->GetNameOfClass() << std::endl);
|
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
|
|
|
"For project: " << projName << std::endl);
|
2007-07-24 18:00:26 +04:00
|
|
|
|
2011-10-13 21:51:18 +04:00
|
|
|
const char* projVersion =
|
2007-07-24 18:00:26 +04:00
|
|
|
mf->GetDefinition("CPACK_PACKAGE_VERSION");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!projVersion) {
|
|
|
|
const char* projVersionMajor =
|
|
|
|
mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
|
|
|
|
const char* projVersionMinor =
|
|
|
|
mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
|
|
|
|
const char* projVersionPatch =
|
|
|
|
mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream ostr;
|
2007-07-24 18:00:26 +04:00
|
|
|
ostr << projVersionMajor << "." << projVersionMinor << "."
|
2016-05-16 17:34:04 +03:00
|
|
|
<< projVersionPatch;
|
|
|
|
mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str().c_str());
|
|
|
|
}
|
2006-07-27 19:55:34 +04:00
|
|
|
|
2007-11-06 16:28:26 +03:00
|
|
|
int res = cpackGenerator->DoPackage();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!res) {
|
2006-07-27 19:55:34 +04:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Error when generating package: " << projName
|
|
|
|
<< std::endl);
|
2007-07-24 18:00:26 +04:00
|
|
|
return 1;
|
2006-07-09 21:20:07 +04:00
|
|
|
}
|
|
|
|
}
|
2006-01-02 07:21:05 +03:00
|
|
|
}
|
2006-07-27 19:55:34 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-02 07:21:05 +03:00
|
|
|
|
2011-11-05 17:41:23 +04: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-05-16 17:34:04 +03:00
|
|
|
if (help) {
|
2006-07-27 19:55:34 +04:00
|
|
|
// Construct and print requested documentation.
|
2011-11-14 01:44:53 +04:00
|
|
|
|
2006-07-27 19:55:34 +04:00
|
|
|
doc.SetName("cpack");
|
2016-05-16 17:34:04 +03:00
|
|
|
doc.SetSection("Name", cmDocumentationName);
|
|
|
|
doc.SetSection("Usage", cmDocumentationUsage);
|
|
|
|
doc.PrependSection("Options", cmDocumentationOptions);
|
2006-07-27 19:55:34 +04:00
|
|
|
|
|
|
|
std::vector<cmDocumentationEntry> v;
|
2007-11-06 00:33:19 +03:00
|
|
|
cmCPackGeneratorFactory::DescriptionsMap::const_iterator generatorIt;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (generatorIt = generators.GetGeneratorsList().begin();
|
|
|
|
generatorIt != generators.GetGeneratorsList().end(); ++generatorIt) {
|
2006-07-27 19:55:34 +04:00
|
|
|
cmDocumentationEntry e;
|
2016-05-26 23:52:22 +03:00
|
|
|
e.Name = generatorIt->first;
|
|
|
|
e.Brief = generatorIt->second;
|
2006-07-27 19:55:34 +04:00
|
|
|
v.push_back(e);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
doc.SetSection("Generators", v);
|
2006-07-09 21:20:07 +04:00
|
|
|
|
2006-01-03 00:14:21 +03:00
|
|
|
#undef cout
|
2016-05-16 17:34:04 +03:00
|
|
|
return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1;
|
2006-01-03 00:14:21 +03:00
|
|
|
#define cout no_cout_use_cmCPack_Log
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-02 07:21:05 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetErrorOccuredFlag()) {
|
2009-01-22 21:56:13 +03:00
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-22 21:56:13 +03:00
|
|
|
|
2006-01-02 07:21:05 +03:00
|
|
|
return 0;
|
|
|
|
}
|