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.
|
|
|
|
#include "cmake.h"
|
|
|
|
#include "cmDocumentation.h"
|
2011-11-14 01:44:53 +04:00
|
|
|
#include "cmCPackDocumentVariables.h"
|
|
|
|
#include "cmCPackDocumentMacros.h"
|
2007-11-06 00:33:19 +03:00
|
|
|
#include "cmCPackGeneratorFactory.h"
|
2007-11-06 00:55:45 +03:00
|
|
|
#include "cmCPackGenerator.h"
|
2006-01-03 01:28:20 +03:00
|
|
|
#include "cmake.h"
|
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmLocalGenerator.h"
|
|
|
|
#include "cmMakefile.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>
|
2012-02-02 04:44:21 +04:00
|
|
|
#include <cmsys/SystemTools.hxx>
|
2008-04-18 18:55:04 +04:00
|
|
|
#include <memory> // auto_ptr
|
2006-01-02 07:21:05 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char * cmDocumentationName[][3] =
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
|
|
|
" cpack - Packaging driver provided by CMake.", 0},
|
|
|
|
{0,0,0}
|
2006-01-02 07:21:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char * cmDocumentationUsage[][3] =
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2006-05-04 05:42:51 +04:00
|
|
|
" cpack -G <generator> [options]",
|
2007-10-09 22:35:25 +04:00
|
|
|
0},
|
|
|
|
{0,0,0}
|
2006-01-02 07:21:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char * cmDocumentationDescription[][3] =
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2006-01-02 07:21:05 +03:00
|
|
|
"The \"cpack\" executable is the CMake packaging program. "
|
|
|
|
"CMake-generated build trees created for projects that use "
|
|
|
|
"the INSTALL_* commands have packaging support. "
|
2007-10-09 22:35:25 +04:00
|
|
|
"This program will generate the package.", 0},
|
2006-01-02 07:21:05 +03:00
|
|
|
CMAKE_STANDARD_INTRODUCTION,
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,0,0}
|
2006-01-02 07:21:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char * cmDocumentationOptions[][3] =
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
|
|
|
{"-G <generator>", "Use the specified generator to generate package.",
|
2006-03-09 16:32:08 +03:00
|
|
|
"CPack may support multiple native packaging systems on certain "
|
|
|
|
"platforms. A generator is responsible for generating input files for "
|
|
|
|
"particular system and invoking that systems. Possible generator names "
|
|
|
|
"are specified in the Generators section." },
|
2006-02-07 20:53:35 +03:00
|
|
|
{"-C <Configuration>", "Specify the project configuration",
|
2006-03-09 16:32:08 +03:00
|
|
|
"This option specifies the configuration that the project was build "
|
|
|
|
"with, for example 'Debug', 'Release'." },
|
2006-01-02 07:21:05 +03:00
|
|
|
{"-D <var>=<value>", "Set a CPack variable.", \
|
|
|
|
"Set a variable that can be used by the generator."}, \
|
2006-05-04 05:42:51 +04:00
|
|
|
{"--config <config file>", "Specify the config file.",
|
|
|
|
"Specify the config file to use to create the package. By default "
|
|
|
|
"CPackConfig.cmake in the current directory will be used." },
|
2011-11-05 17:41:23 +04:00
|
|
|
{"--verbose,-V","enable verbose output","Run cpack with verbose output."},
|
|
|
|
{"--debug","enable debug output (for CPack developers)",
|
|
|
|
"Run cpack with debug output (for CPack developers)."},
|
|
|
|
{"-P <package name>","override/define CPACK_PACKAGE_NAME",
|
|
|
|
"If the package name is not specified on cpack commmand line then"
|
|
|
|
"CPack.cmake defines it as CMAKE_PROJECT_NAME"},
|
|
|
|
{"-R <package version>","override/define CPACK_PACKAGE_VERSION",
|
|
|
|
"If version is not specified on cpack command line then"
|
|
|
|
"CPack.cmake defines it from CPACK_PACKAGE_VERSION_[MAJOR|MINOR|PATCH]"
|
|
|
|
"look into CPack.cmake for detail"},
|
|
|
|
{"-B <package directory>","override/define CPACK_PACKAGE_DIRECTORY",
|
|
|
|
"The directory where CPack will be doing its packaging work."
|
|
|
|
"The resulting package will be found there. Inside this directory"
|
|
|
|
"CPack creates '_CPack_Packages' sub-directory which is the"
|
|
|
|
"CPack temporary directory."},
|
|
|
|
{"--vendor <vendor name>","override/define CPACK_PACKAGE_VENDOR",
|
|
|
|
"If vendor is not specified on cpack command line "
|
|
|
|
"(or inside CMakeLists.txt) then"
|
|
|
|
"CPack.cmake defines it with a default value"},
|
2011-11-14 01:44:53 +04:00
|
|
|
{"--help-command cmd [file]", "Print help for a single command and exit.",
|
|
|
|
"Full documentation specific to the given command is displayed. "
|
|
|
|
"If a file is specified, the documentation is written into and the output "
|
|
|
|
"format is determined depending on the filename suffix. Supported are man "
|
|
|
|
"page, HTML, DocBook and plain text."},
|
|
|
|
{"--help-command-list [file]", "List available commands and exit.",
|
|
|
|
"The list contains all commands for which help may be obtained by using "
|
|
|
|
"the --help-command argument followed by a command name. "
|
|
|
|
"If a file is specified, the documentation is written into and the output "
|
|
|
|
"format is determined depending on the filename suffix. Supported are man "
|
|
|
|
"page, HTML, DocBook and plain text."},
|
|
|
|
{"--help-commands [file]", "Print help for all commands and exit.",
|
|
|
|
"Full documentation specific for all current command is displayed."
|
|
|
|
"If a file is specified, the documentation is written into and the output "
|
|
|
|
"format is determined depending on the filename suffix. Supported are man "
|
|
|
|
"page, HTML, DocBook and plain text."},
|
|
|
|
{"--help-variable var [file]",
|
|
|
|
"Print help for a single variable and exit.",
|
|
|
|
"Full documentation specific to the given variable is displayed."
|
|
|
|
"If a file is specified, the documentation is written into and the output "
|
|
|
|
"format is determined depending on the filename suffix. Supported are man "
|
|
|
|
"page, HTML, DocBook and plain text."},
|
|
|
|
{"--help-variable-list [file]", "List documented variables and exit.",
|
|
|
|
"The list contains all variables for which help may be obtained by using "
|
|
|
|
"the --help-variable argument followed by a variable name. If a file is "
|
|
|
|
"specified, the help is written into it."
|
|
|
|
"If a file is specified, the documentation is written into and the output "
|
|
|
|
"format is determined depending on the filename suffix. Supported are man "
|
|
|
|
"page, HTML, DocBook and plain text."},
|
|
|
|
{"--help-variables [file]", "Print help for all variables and exit.",
|
|
|
|
"Full documentation for all variables is displayed."
|
|
|
|
"If a file is specified, the documentation is written into and the output "
|
|
|
|
"format is determined depending on the filename suffix. Supported are man "
|
|
|
|
"page, HTML, DocBook and plain text."},
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,0,0}
|
2006-01-02 07:21:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char * cmDocumentationSeeAlso[][3] =
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0, "cmake", 0},
|
|
|
|
{0, "ccmake", 0},
|
|
|
|
{0, 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
|
|
|
|
{
|
|
|
|
typedef std::map<cmStdString, cmStdString> MapType;
|
2006-03-10 21:06:26 +03:00
|
|
|
MapType Map;
|
|
|
|
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,
|
2006-01-03 00:14:21 +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;
|
|
|
|
size_t pos = value.find_first_of("=");
|
|
|
|
if ( pos == std::string::npos )
|
|
|
|
{
|
2006-03-10 21:06:26 +03:00
|
|
|
cmCPack_Log(def->Log, cmCPackLog::LOG_ERROR,
|
2006-03-09 00:33:39 +03:00
|
|
|
"Please specify CPack definitions as: KEY=VALUE" << std::endl);
|
2006-01-02 07:21:05 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
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: "
|
2006-03-09 00:33:39 +03:00
|
|
|
<< key.c_str() << " to \"" << value.c_str() << "\"" << std::endl);
|
2006-01-02 07:21:05 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-11-14 01:44:53 +04:00
|
|
|
|
2006-01-02 07:21:05 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// this is CPack.
|
|
|
|
int main (int argc, char *argv[])
|
|
|
|
{
|
2007-12-14 01:56:50 +03:00
|
|
|
cmSystemTools::FindExecutableDirectory(argv[0]);
|
2006-01-03 00:14:21 +03:00
|
|
|
cmCPackLog log;
|
2011-11-14 01:44:53 +04:00
|
|
|
int nocwd = 0;
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 )
|
|
|
|
{
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
|
|
|
"Current working directory cannot be established." << std::endl);
|
2011-11-14 01:44:53 +04:00
|
|
|
nocwd = 1;
|
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;
|
2006-03-09 00:33:39 +03:00
|
|
|
std::string cpackProjectDirectory
|
|
|
|
= cmsys::SystemTools::GetCurrentWorkingDirectory();
|
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,
|
|
|
|
"CPack help");
|
|
|
|
arg.AddArgument("--help-html", argT::SPACE_ARGUMENT, &helpHTML,
|
|
|
|
"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,
|
|
|
|
"CPack configuration file");
|
|
|
|
arg.AddArgument("-C", argT::SPACE_ARGUMENT, &cpackBuildConfig,
|
|
|
|
"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
|
|
|
|
if ( verbose )
|
|
|
|
{
|
|
|
|
log.SetVerbose(verbose);
|
2010-07-02 18:58:00 +04:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Verbose" << std::endl);
|
2006-01-03 00:14:21 +03:00
|
|
|
}
|
|
|
|
if ( debug )
|
|
|
|
{
|
|
|
|
log.SetDebug(debug);
|
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Debug" << std::endl);
|
|
|
|
}
|
|
|
|
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
|
|
|
"Read CPack config file: " << cpackConfigFile.c_str() << std::endl);
|
2006-01-03 00:14:21 +03:00
|
|
|
|
2006-01-03 01:28:20 +03:00
|
|
|
cmake cminst;
|
2007-07-27 16:59:59 +04:00
|
|
|
cminst.RemoveUnscriptableCommands();
|
2006-01-03 01:28:20 +03:00
|
|
|
cmGlobalGenerator cmgg;
|
|
|
|
cmgg.SetCMakeInstance(&cminst);
|
2008-04-17 20:06:20 +04:00
|
|
|
std::auto_ptr<cmLocalGenerator> cmlg(cmgg.CreateLocalGenerator());
|
2006-07-09 21:20:07 +04:00
|
|
|
cmMakefile* globalMF = cmlg->GetMakefile();
|
2006-01-03 01:28:20 +03:00
|
|
|
|
|
|
|
bool cpackConfigFileSpecified = true;
|
|
|
|
if ( cpackConfigFile.empty() )
|
|
|
|
{
|
|
|
|
cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory();
|
2006-01-04 23:14:09 +03:00
|
|
|
cpackConfigFile += "/CPackConfig.cmake";
|
2006-01-03 01:28:20 +03:00
|
|
|
cpackConfigFileSpecified = false;
|
|
|
|
}
|
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();
|
|
|
|
/* Were we invoked to display doc or to do some work ? */
|
|
|
|
if(doc.CheckOptions(argc, argv,"-G") || nocwd)
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2011-11-14 01:44:53 +04:00
|
|
|
help = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
help = false;
|
2006-01-02 07:21:05 +03:00
|
|
|
}
|
|
|
|
|
2012-01-03 03:54:08 +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
|
|
|
|
// This part is used for cpack documentation lookup as well.
|
|
|
|
cminst.AddCMakePaths();
|
|
|
|
std::string systemFile =
|
|
|
|
globalMF->GetModulesFile("CMakeDetermineSystem.cmake");
|
|
|
|
if (!globalMF->ReadListFile(0, systemFile.c_str()))
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2012-01-03 03:54:08 +04:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
|
|
|
"Error reading CMakeDetermineSystem.cmake" << std::endl);
|
|
|
|
return 1;
|
|
|
|
}
|
2007-07-24 18:00:26 +04:00
|
|
|
|
2012-01-03 03:54:08 +04:00
|
|
|
systemFile =
|
|
|
|
globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake");
|
|
|
|
if (!globalMF->ReadListFile(0, systemFile.c_str()))
|
|
|
|
{
|
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
|
|
|
"Error reading CMakeSystemSpecificInformation.cmake" << std::endl);
|
|
|
|
return 1;
|
|
|
|
}
|
2007-07-24 18:00:26 +04:00
|
|
|
|
2012-01-03 03:54:08 +04:00
|
|
|
if ( parsed && !help )
|
|
|
|
{
|
2006-02-23 17:59:42 +03:00
|
|
|
if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) )
|
2006-01-03 01:28:20 +03:00
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
cpackConfigFile =
|
2006-05-12 22:44:24 +04:00
|
|
|
cmSystemTools::CollapseFullPath(cpackConfigFile.c_str());
|
2006-07-09 21:20:07 +04:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
|
|
|
"Read CPack configuration file: " << cpackConfigFile.c_str()
|
|
|
|
<< std::endl);
|
|
|
|
if ( !globalMF->ReadListFile(0, cpackConfigFile.c_str()) )
|
2006-02-23 17:59:42 +03:00
|
|
|
{
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
2007-07-19 19:13:01 +04:00
|
|
|
"Problem reading CPack config file: \""
|
2006-03-09 00:33:39 +03:00
|
|
|
<< cpackConfigFile.c_str() << "\"" << std::endl);
|
2006-02-23 17:59:42 +03:00
|
|
|
return 1;
|
|
|
|
}
|
2006-01-03 01:28:20 +03:00
|
|
|
}
|
|
|
|
else if ( cpackConfigFileSpecified )
|
|
|
|
{
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
|
|
|
"Cannot find CPack config file: \"" << cpackConfigFile.c_str()
|
|
|
|
<< "\"" << std::endl);
|
2006-01-03 01:28:20 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-03-09 00:33:39 +03:00
|
|
|
if ( !generator.empty() )
|
|
|
|
{
|
2006-07-09 21:20:07 +04:00
|
|
|
globalMF->AddDefinition("CPACK_GENERATOR", generator.c_str());
|
2006-03-09 00:33:39 +03:00
|
|
|
}
|
|
|
|
if ( !cpackProjectName.empty() )
|
|
|
|
{
|
2006-07-09 21:20:07 +04:00
|
|
|
globalMF->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str());
|
2006-03-09 00:33:39 +03:00
|
|
|
}
|
|
|
|
if ( !cpackProjectVersion.empty() )
|
|
|
|
{
|
2006-07-10 15:52:35 +04:00
|
|
|
globalMF->AddDefinition("CPACK_PACKAGE_VERSION",
|
|
|
|
cpackProjectVersion.c_str());
|
2006-03-09 00:33:39 +03:00
|
|
|
}
|
|
|
|
if ( !cpackProjectVendor.empty() )
|
|
|
|
{
|
2006-07-10 15:52:35 +04:00
|
|
|
globalMF->AddDefinition("CPACK_PACKAGE_VENDOR",
|
|
|
|
cpackProjectVendor.c_str());
|
2006-03-09 00:33:39 +03:00
|
|
|
}
|
|
|
|
if ( !cpackProjectDirectory.empty() )
|
|
|
|
{
|
2006-07-09 21:20:07 +04:00
|
|
|
globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
|
2006-03-09 00:33:39 +03:00
|
|
|
cpackProjectDirectory.c_str());
|
|
|
|
}
|
|
|
|
if ( !cpackBuildConfig.empty() )
|
|
|
|
{
|
2006-07-09 21:20:07 +04:00
|
|
|
globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
|
2006-03-09 00:33:39 +03:00
|
|
|
}
|
2006-01-03 01:28:20 +03:00
|
|
|
cpackDefinitions::MapType::iterator cdit;
|
2006-03-10 21:06:26 +03:00
|
|
|
for ( cdit = definitions.Map.begin();
|
|
|
|
cdit != definitions.Map.end();
|
2006-03-09 00:33:39 +03:00
|
|
|
++cdit )
|
2006-01-03 01:28:20 +03:00
|
|
|
{
|
2006-07-09 21:20:07 +04:00
|
|
|
globalMF->AddDefinition(cdit->first.c_str(), cdit->second.c_str());
|
2006-01-03 01:28:20 +03:00
|
|
|
}
|
|
|
|
|
2006-10-17 17:34:07 +04:00
|
|
|
const char* cpackModulesPath =
|
|
|
|
globalMF->GetDefinition("CPACK_MODULE_PATH");
|
2006-10-12 21:05:50 +04:00
|
|
|
if ( cpackModulesPath )
|
|
|
|
{
|
|
|
|
globalMF->AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath);
|
|
|
|
}
|
2006-07-09 21:20:07 +04:00
|
|
|
const char* genList = globalMF->GetDefinition("CPACK_GENERATOR");
|
|
|
|
if ( !genList )
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
|
|
|
"CPack generator not specified" << std::endl);
|
2006-07-27 19:55:34 +04:00
|
|
|
parsed = 0;
|
2006-01-02 07:21:05 +03:00
|
|
|
}
|
2006-07-27 19:55:34 +04:00
|
|
|
else
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2006-07-27 19:55:34 +04:00
|
|
|
std::vector<std::string> generatorsVector;
|
|
|
|
cmSystemTools::ExpandListArgument(genList,
|
|
|
|
generatorsVector);
|
|
|
|
std::vector<std::string>::iterator it;
|
|
|
|
for ( it = generatorsVector.begin();
|
|
|
|
it != generatorsVector.end();
|
|
|
|
++it )
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2006-07-27 19:55:34 +04:00
|
|
|
const char* gen = it->c_str();
|
|
|
|
cmMakefile newMF(*globalMF);
|
|
|
|
cmMakefile* mf = &newMF;
|
2007-07-24 18:00:26 +04:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
|
|
|
"Specified generator: " << gen << std::endl);
|
|
|
|
if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") )
|
|
|
|
{
|
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
|
|
|
"CPack project name not specified" << std::endl);
|
|
|
|
parsed = 0;
|
|
|
|
}
|
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") &&
|
|
|
|
mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH"))))
|
2006-07-09 21:20:07 +04:00
|
|
|
{
|
2007-07-24 18:00:26 +04:00
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
|
|
|
"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);
|
|
|
|
parsed = 0;
|
|
|
|
}
|
|
|
|
if ( parsed )
|
|
|
|
{
|
|
|
|
cpackGenerator = generators.NewGenerator(gen);
|
|
|
|
if ( !cpackGenerator )
|
|
|
|
{
|
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
|
|
|
"Cannot initialize CPack generator: "
|
2007-08-03 23:26:30 +04:00
|
|
|
<< gen << std::endl);
|
2007-07-24 18:00:26 +04:00
|
|
|
parsed = 0;
|
|
|
|
}
|
2008-09-24 18:01:32 +04:00
|
|
|
if ( parsed && !cpackGenerator->Initialize(gen, mf) )
|
2006-07-09 21:20:07 +04:00
|
|
|
{
|
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
2007-08-03 23:26:30 +04:00
|
|
|
"Cannot initialize the generator " << gen << std::endl);
|
2006-07-09 21:20:07 +04:00
|
|
|
parsed = 0;
|
|
|
|
}
|
2007-07-24 18:00:26 +04:00
|
|
|
|
|
|
|
if ( !mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
|
|
|
|
!mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
|
|
|
|
!mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS") )
|
2006-07-09 21:20:07 +04:00
|
|
|
{
|
|
|
|
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."
|
2006-07-27 19:55:34 +04:00
|
|
|
<< std::endl);
|
2006-07-09 21:20:07 +04:00
|
|
|
parsed = 0;
|
|
|
|
}
|
2006-07-27 19:55:34 +04:00
|
|
|
if ( parsed )
|
2006-07-09 21:20:07 +04:00
|
|
|
{
|
2007-07-24 18:00:26 +04:00
|
|
|
#ifdef _WIN32
|
|
|
|
std::string comspec = "cmw9xcom.exe";
|
|
|
|
cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
|
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: "
|
|
|
|
<< cpackGenerator->GetNameOfClass() << std::endl);
|
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: "
|
|
|
|
<< projName << std::endl);
|
|
|
|
|
2011-10-13 21:51:18 +04:00
|
|
|
const char* projVersion =
|
2007-07-24 18:00:26 +04:00
|
|
|
mf->GetDefinition("CPACK_PACKAGE_VERSION");
|
|
|
|
if ( !projVersion )
|
2006-07-27 19:55:34 +04:00
|
|
|
{
|
2007-07-24 18:00:26 +04:00
|
|
|
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");
|
|
|
|
cmOStringStream ostr;
|
|
|
|
ostr << projVersionMajor << "." << projVersionMinor << "."
|
|
|
|
<< projVersionPatch;
|
2011-10-13 21:51:18 +04:00
|
|
|
mf->AddDefinition("CPACK_PACKAGE_VERSION",
|
2007-07-24 18:00:26 +04:00
|
|
|
ostr.str().c_str());
|
2006-07-27 19:55:34 +04:00
|
|
|
}
|
|
|
|
|
2007-11-06 16:28:26 +03:00
|
|
|
int res = cpackGenerator->DoPackage();
|
2007-07-24 18:00:26 +04:00
|
|
|
if ( !res )
|
2006-07-27 19:55:34 +04:00
|
|
|
{
|
|
|
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
2007-07-24 18:00:26 +04:00
|
|
|
"Error when generating package: " << projName << std::endl);
|
|
|
|
return 1;
|
2006-07-27 19:55:34 +04:00
|
|
|
}
|
2006-07-09 21:20:07 +04:00
|
|
|
}
|
|
|
|
}
|
2006-01-02 07:21:05 +03:00
|
|
|
}
|
2006-07-27 19:55:34 +04: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
|
|
|
|
*/
|
2007-08-03 23:26:30 +04:00
|
|
|
if ( help )
|
2006-07-27 19:55:34 +04:00
|
|
|
{
|
|
|
|
// Construct and print requested documentation.
|
2011-11-14 01:44:53 +04:00
|
|
|
std::vector<cmDocumentationEntry> variables;
|
|
|
|
|
2006-07-27 19:55:34 +04:00
|
|
|
doc.SetName("cpack");
|
2007-10-22 20:49:09 +04:00
|
|
|
doc.SetSection("Name",cmDocumentationName);
|
|
|
|
doc.SetSection("Usage",cmDocumentationUsage);
|
|
|
|
doc.SetSection("Description",cmDocumentationDescription);
|
2011-10-12 18:24:04 +04:00
|
|
|
doc.PrependSection("Options",cmDocumentationOptions);
|
2006-07-27 19:55:34 +04:00
|
|
|
|
2012-01-03 03:54:08 +04:00
|
|
|
// statically (in C++ code) defined variables
|
2011-11-14 01:44:53 +04:00
|
|
|
cmCPackDocumentVariables::DefineVariables(&cminst);
|
2011-11-15 23:24:38 +04:00
|
|
|
|
|
|
|
std::vector<cmDocumentationEntry> commands;
|
|
|
|
|
2012-02-04 15:15:57 +04:00
|
|
|
std::string docedFile;
|
|
|
|
std::string docPath;
|
|
|
|
cmDocumentation::documentedModulesList_t docedModList;
|
2012-01-03 03:54:08 +04:00
|
|
|
|
2012-02-02 04:44:21 +04:00
|
|
|
docedFile = globalMF->GetModulesFile("CPack.cmake");
|
|
|
|
if (docedFile.length()!=0)
|
|
|
|
{
|
2012-02-04 15:15:57 +04:00
|
|
|
docPath = cmSystemTools::GetFilenamePath(docedFile.c_str());
|
|
|
|
doc.getDocumentedModulesListInDir(docPath,"CPack*.cmake",docedModList);
|
2012-02-02 04:44:21 +04:00
|
|
|
}
|
2012-01-03 03:54:08 +04:00
|
|
|
|
|
|
|
// parse the files for documentation.
|
2012-02-04 15:15:57 +04:00
|
|
|
cmDocumentation::documentedModulesList_t::iterator docedIt;
|
|
|
|
for (docedIt = docedModList.begin();
|
|
|
|
docedIt!= docedModList.end(); ++docedIt)
|
2012-01-03 03:54:08 +04:00
|
|
|
{
|
2012-02-04 15:15:57 +04:00
|
|
|
doc.GetStructuredDocFromFile(
|
|
|
|
(docedIt->first).c_str(),
|
|
|
|
commands,&cminst,(docedIt->second).c_str());
|
|
|
|
}
|
2011-11-15 23:24:38 +04:00
|
|
|
|
2011-11-14 01:44:53 +04:00
|
|
|
std::map<std::string,cmDocumentationSection *> propDocs;
|
|
|
|
cminst.GetPropertiesDocumentation(propDocs);
|
|
|
|
doc.SetSections(propDocs);
|
2012-01-03 03:54:08 +04:00
|
|
|
cminst.GetCommandDocumentation(commands,true,false);
|
|
|
|
// statically (in C++ code) defined macros/commands
|
2011-11-14 01:44:53 +04:00
|
|
|
cmCPackDocumentMacros::GetMacrosDocumentation(commands);
|
|
|
|
doc.SetSection("Commands",commands);
|
|
|
|
|
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;
|
2006-07-27 19:55:34 +04:00
|
|
|
for( generatorIt = generators.GetGeneratorsList().begin();
|
|
|
|
generatorIt != generators.GetGeneratorsList().end();
|
|
|
|
++ generatorIt )
|
|
|
|
{
|
|
|
|
cmDocumentationEntry e;
|
2007-10-22 20:49:09 +04:00
|
|
|
e.Name = generatorIt->first.c_str();
|
|
|
|
e.Brief = generatorIt->second.c_str();
|
|
|
|
e.Full = "";
|
2006-07-27 19:55:34 +04:00
|
|
|
v.push_back(e);
|
|
|
|
}
|
2007-10-22 20:49:09 +04:00
|
|
|
doc.SetSection("Generators",v);
|
2006-07-09 21:20:07 +04:00
|
|
|
|
2006-07-27 19:55:34 +04:00
|
|
|
doc.SetSeeAlsoList(cmDocumentationSeeAlso);
|
2006-01-03 00:14:21 +03:00
|
|
|
#undef cout
|
2006-07-27 19:55:34 +04:00
|
|
|
return doc.PrintRequestedDocumentation(std::cout)? 0:1;
|
2006-01-03 00:14:21 +03:00
|
|
|
#define cout no_cout_use_cmCPack_Log
|
2006-01-02 07:21:05 +03:00
|
|
|
}
|
|
|
|
|
2009-01-22 21:56:13 +03:00
|
|
|
if (cmSystemTools::GetErrorOccuredFlag())
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-01-02 07:21:05 +03:00
|
|
|
return 0;
|
|
|
|
}
|