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
|
|
|
|
2007-11-06 00:55:45 +03:00
|
|
|
#include "cmCPackGenerator.h"
|
2006-01-02 07:21:05 +03:00
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmCPackComponentGroup.h"
|
2006-01-03 01:28:20 +03:00
|
|
|
#include "cmCPackLog.h"
|
2016-08-31 18:05:15 +03:00
|
|
|
#include "cmCryptoHash.h"
|
2006-01-11 19:23:48 +03:00
|
|
|
#include "cmGeneratedFileStream.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmMakefile.h"
|
2016-09-07 01:21:35 +03:00
|
|
|
#include "cmState.h"
|
2009-02-06 00:31:37 +03:00
|
|
|
#include "cmXMLSafe.h"
|
2016-09-07 01:21:35 +03:00
|
|
|
#include "cm_auto_ptr.hxx"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmake.h"
|
2006-01-02 07:21:05 +03:00
|
|
|
|
2011-03-05 00:57:37 +03:00
|
|
|
#include <algorithm>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <cmsys/FStream.hxx>
|
|
|
|
#include <cmsys/Glob.hxx>
|
2016-09-07 01:21:35 +03:00
|
|
|
#include <cmsys/RegularExpression.hxx>
|
2015-01-12 23:17:55 +03:00
|
|
|
#include <list>
|
2016-09-07 01:21:35 +03:00
|
|
|
#include <utility>
|
2006-01-02 07:21:05 +03:00
|
|
|
|
2009-09-30 16:31:53 +04:00
|
|
|
#if defined(__HAIKU__)
|
2013-10-05 18:31:36 +04:00
|
|
|
#include <FindDirectory.h>
|
|
|
|
#include <StorageDefs.h>
|
2009-09-30 16:31:53 +04:00
|
|
|
#endif
|
|
|
|
|
2007-11-06 00:55:45 +03:00
|
|
|
cmCPackGenerator::cmCPackGenerator()
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2011-07-26 11:26:18 +04:00
|
|
|
this->GeneratorVerbose = cmSystemTools::OUTPUT_NONE;
|
2016-06-27 23:44:16 +03:00
|
|
|
this->MakefileMap = CM_NULLPTR;
|
|
|
|
this->Logger = CM_NULLPTR;
|
2011-03-25 19:18:59 +03:00
|
|
|
this->componentPackageMethod = ONE_PACKAGE_PER_GROUP;
|
2006-01-02 07:21:05 +03:00
|
|
|
}
|
|
|
|
|
2007-11-06 00:55:45 +03:00
|
|
|
cmCPackGenerator::~cmCPackGenerator()
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2016-06-27 23:44:16 +03:00
|
|
|
this->MakefileMap = CM_NULLPTR;
|
2006-01-02 07:21:05 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmCPackGeneratorProgress(const char* msg, float prog, void* ptr)
|
2006-06-02 19:26:10 +04:00
|
|
|
{
|
2007-11-06 00:55:45 +03:00
|
|
|
cmCPackGenerator* self = static_cast<cmCPackGenerator*>(ptr);
|
2006-06-02 19:26:10 +04:00
|
|
|
self->DisplayVerboseOutput(msg, prog);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmCPackGenerator::DisplayVerboseOutput(const char* msg, float progress)
|
2006-06-02 19:26:10 +04:00
|
|
|
{
|
2006-06-04 02:43:30 +04:00
|
|
|
(void)progress;
|
2006-06-02 19:26:10 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "" << msg << std::endl);
|
|
|
|
}
|
|
|
|
|
2007-11-06 00:55:45 +03:00
|
|
|
int cmCPackGenerator::PrepareNames()
|
2012-05-14 22:26:15 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Create temp directory." << std::endl);
|
2007-10-31 15:50:17 +03:00
|
|
|
|
2012-05-14 22:26:15 +04:00
|
|
|
// checks CPACK_SET_DESTDIR support
|
2016-05-16 17:34:04 +03:00
|
|
|
if (IsOn("CPACK_SET_DESTDIR")) {
|
|
|
|
if (SETDESTDIR_UNSUPPORTED == SupportsSetDestdir()) {
|
|
|
|
cmCPackLogger(
|
|
|
|
cmCPackLog::LOG_ERROR, "CPACK_SET_DESTDIR is set to ON but the '"
|
|
|
|
<< Name << "' generator does NOT support it." << std::endl);
|
|
|
|
return 0;
|
2016-08-18 20:47:32 +03:00
|
|
|
}
|
|
|
|
if (SETDESTDIR_SHOULD_NOT_BE_USED == SupportsSetDestdir()) {
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_WARNING,
|
|
|
|
"CPACK_SET_DESTDIR is set to ON but it is "
|
|
|
|
<< "usually a bad idea to do that with '" << Name
|
|
|
|
<< "' generator. Use at your own risk." << std::endl);
|
|
|
|
}
|
2012-05-14 22:26:15 +04:00
|
|
|
}
|
|
|
|
|
2006-01-04 23:14:09 +03:00
|
|
|
std::string tempDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
|
2006-01-02 07:21:05 +03:00
|
|
|
tempDirectory += "/_CPack_Packages/";
|
2006-04-15 21:02:18 +04:00
|
|
|
const char* toplevelTag = this->GetOption("CPACK_TOPLEVEL_TAG");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (toplevelTag) {
|
2006-04-15 21:02:18 +04:00
|
|
|
tempDirectory += toplevelTag;
|
|
|
|
tempDirectory += "/";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-02 07:21:05 +03:00
|
|
|
tempDirectory += this->GetOption("CPACK_GENERATOR");
|
|
|
|
std::string topDirectory = tempDirectory;
|
2008-03-07 19:06:44 +03:00
|
|
|
const char* pfname = this->GetOption("CPACK_PACKAGE_FILE_NAME");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!pfname) {
|
2008-03-07 19:06:44 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
|
|
|
"CPACK_PACKAGE_FILE_NAME not specified" << std::endl);
|
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-08-13 21:42:58 +04:00
|
|
|
std::string outName = pfname;
|
2006-01-11 19:08:15 +03:00
|
|
|
tempDirectory += "/" + outName;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->GetOutputExtension()) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "No output extension specified"
|
|
|
|
<< std::endl);
|
2008-03-07 19:06:44 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-02 07:21:05 +03:00
|
|
|
outName += this->GetOutputExtension();
|
2008-03-07 19:06:44 +03:00
|
|
|
const char* pdir = this->GetOption("CPACK_PACKAGE_DIRECTORY");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!pdir) {
|
2008-03-07 19:06:44 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
|
|
|
"CPACK_PACKAGE_DIRECTORY not specified" << std::endl);
|
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-02 07:21:05 +03:00
|
|
|
|
2008-03-07 19:06:44 +03:00
|
|
|
std::string destFile = pdir;
|
2010-08-11 21:48:39 +04:00
|
|
|
this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_PREFIX", destFile.c_str());
|
2006-01-02 07:21:05 +03:00
|
|
|
destFile += "/" + outName;
|
|
|
|
std::string outFile = topDirectory + "/" + outName;
|
2006-05-02 16:49:01 +04:00
|
|
|
this->SetOptionIfNotSet("CPACK_TOPLEVEL_DIRECTORY", topDirectory.c_str());
|
|
|
|
this->SetOptionIfNotSet("CPACK_TEMPORARY_DIRECTORY", tempDirectory.c_str());
|
|
|
|
this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_NAME", outName.c_str());
|
|
|
|
this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_PATH", destFile.c_str());
|
2006-07-10 15:59:05 +04:00
|
|
|
this->SetOptionIfNotSet("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
|
2006-05-12 22:44:24 +04:00
|
|
|
outFile.c_str());
|
2006-05-02 16:49:01 +04:00
|
|
|
this->SetOptionIfNotSet("CPACK_INSTALL_DIRECTORY", this->GetInstallPath());
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SetOptionIfNotSet(
|
|
|
|
"CPACK_NATIVE_INSTALL_DIRECTORY",
|
2006-01-02 07:21:05 +03:00
|
|
|
cmsys::SystemTools::ConvertToOutputPath(this->GetInstallPath()).c_str());
|
2006-07-10 15:59:05 +04:00
|
|
|
this->SetOptionIfNotSet("CPACK_TEMPORARY_INSTALL_DIRECTORY",
|
2008-06-17 19:39:26 +04:00
|
|
|
tempDirectory.c_str());
|
2006-01-02 07:21:05 +03:00
|
|
|
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Look for: CPACK_PACKAGE_DESCRIPTION_FILE" << std::endl);
|
|
|
|
const char* descFileName = this->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE");
|
|
|
|
if (descFileName) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for: " << descFileName
|
|
|
|
<< std::endl);
|
|
|
|
if (!cmSystemTools::FileExists(descFileName)) {
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
2012-08-13 21:42:58 +04:00
|
|
|
"Cannot find description file name: ["
|
2016-05-16 17:34:04 +03:00
|
|
|
<< descFileName << "]" << std::endl);
|
2006-01-02 07:21:05 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-01-04 09:47:13 +04:00
|
|
|
cmsys::ifstream ifs(descFileName);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ifs) {
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Cannot open description file name: " << descFileName
|
|
|
|
<< std::endl);
|
2006-01-02 07:21:05 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream ostr;
|
2006-01-02 07:21:05 +03:00
|
|
|
std::string line;
|
2006-01-04 23:14:09 +03:00
|
|
|
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Read description file: " << descFileName << std::endl);
|
|
|
|
while (ifs && cmSystemTools::GetLineFromStream(ifs, line)) {
|
2009-02-06 00:31:37 +03:00
|
|
|
ostr << cmXMLSafe(line) << std::endl;
|
2006-01-02 07:21:05 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SetOptionIfNotSet("CPACK_PACKAGE_DESCRIPTION", ostr.str().c_str());
|
|
|
|
}
|
|
|
|
if (!this->GetOption("CPACK_PACKAGE_DESCRIPTION")) {
|
|
|
|
cmCPackLogger(
|
|
|
|
cmCPackLog::LOG_ERROR,
|
2006-03-09 00:33:39 +03:00
|
|
|
"Project description not specified. Please specify "
|
|
|
|
"CPACK_PACKAGE_DESCRIPTION or CPACK_PACKAGE_DESCRIPTION_FILE."
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
2006-01-02 07:21:05 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-08-31 18:05:15 +03:00
|
|
|
const char* algoSignature = this->GetOption("CPACK_PACKAGE_CHECKSUM");
|
|
|
|
if (algoSignature) {
|
|
|
|
if (cmCryptoHash::New(algoSignature).get() == CM_NULLPTR) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot recognize algorithm: "
|
|
|
|
<< algoSignature << std::endl);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2006-01-02 07:21:05 +03:00
|
|
|
|
2006-07-09 21:20:07 +04:00
|
|
|
this->SetOptionIfNotSet("CPACK_REMOVE_TOPLEVEL_DIRECTORY", "1");
|
2006-05-02 16:49:01 +04:00
|
|
|
|
2006-01-02 07:21:05 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-11-06 00:55:45 +03:00
|
|
|
int cmCPackGenerator::InstallProject()
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2006-04-10 19:09:52 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Install projects" << std::endl);
|
2006-06-09 21:45:09 +04:00
|
|
|
this->CleanTemporaryDirectory();
|
2008-06-17 19:39:26 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string bareTempInstallDirectory =
|
|
|
|
this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
|
2008-06-17 19:39:26 +04:00
|
|
|
std::string tempInstallDirectoryStr = bareTempInstallDirectory;
|
2016-05-16 17:34:04 +03:00
|
|
|
bool setDestDir = cmSystemTools::IsOn(this->GetOption("CPACK_SET_DESTDIR")) |
|
|
|
|
cmSystemTools::IsInternallyOn(this->GetOption("CPACK_SET_DESTDIR"));
|
|
|
|
if (!setDestDir) {
|
2008-06-17 19:39:26 +04:00
|
|
|
tempInstallDirectoryStr += this->GetPackagingInstallPrefix();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-06-17 19:39:26 +04:00
|
|
|
|
|
|
|
const char* tempInstallDirectory = tempInstallDirectoryStr.c_str();
|
2006-01-11 19:23:48 +03:00
|
|
|
int res = 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmsys::SystemTools::MakeDirectory(bareTempInstallDirectory.c_str())) {
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Problem creating temporary directory: "
|
|
|
|
<< (tempInstallDirectory ? tempInstallDirectory : "(NULL)")
|
|
|
|
<< std::endl);
|
2006-01-02 07:21:05 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-07-09 21:20:07 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (setDestDir) {
|
2006-01-02 07:21:05 +03:00
|
|
|
std::string destDir = "DESTDIR=";
|
|
|
|
destDir += tempInstallDirectory;
|
2014-11-23 13:05:50 +03:00
|
|
|
cmSystemTools::PutEnv(destDir);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-10-31 15:50:17 +03:00
|
|
|
// Make sure there is no destdir
|
|
|
|
cmSystemTools::PutEnv("DESTDIR=");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-07-09 21:20:07 +04:00
|
|
|
|
2006-06-09 21:45:09 +04:00
|
|
|
// If the CPackConfig file sets CPACK_INSTALL_COMMANDS then run them
|
|
|
|
// as listed
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->InstallProjectViaInstallCommands(setDestDir,
|
|
|
|
tempInstallDirectory)) {
|
2006-07-09 21:20:07 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-07-10 15:59:05 +04:00
|
|
|
|
2006-10-12 21:05:50 +04:00
|
|
|
// If the CPackConfig file sets CPACK_INSTALL_SCRIPT then run them
|
|
|
|
// as listed
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->InstallProjectViaInstallScript(setDestDir,
|
|
|
|
tempInstallDirectory)) {
|
2006-10-12 21:05:50 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-10-12 21:05:50 +04:00
|
|
|
|
2006-07-10 15:59:05 +04:00
|
|
|
// If the CPackConfig file sets CPACK_INSTALLED_DIRECTORIES
|
2006-07-09 21:20:07 +04:00
|
|
|
// then glob it and copy it to CPACK_TEMPORARY_DIRECTORY
|
2010-11-13 19:56:36 +03:00
|
|
|
// This is used in Source packaging
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->InstallProjectViaInstalledDirectories(setDestDir,
|
|
|
|
tempInstallDirectory)) {
|
2006-07-09 21:20:07 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-07-09 21:20:07 +04:00
|
|
|
|
|
|
|
// If the project is a CMAKE project then run pre-install
|
|
|
|
// and then read the cmake_install script to run it
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->InstallProjectViaInstallCMakeProjects(setDestDir,
|
|
|
|
bareTempInstallDirectory)) {
|
2006-07-09 21:20:07 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-07-09 21:20:07 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (setDestDir) {
|
2006-07-09 21:20:07 +04:00
|
|
|
cmSystemTools::PutEnv("DESTDIR=");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-07-09 21:20:07 +04:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2007-11-06 00:55:45 +03:00
|
|
|
int cmCPackGenerator::InstallProjectViaInstallCommands(
|
2014-02-07 23:43:19 +04:00
|
|
|
bool setDestDir, const std::string& tempInstallDirectory)
|
2006-07-09 21:20:07 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
(void)setDestDir;
|
2006-01-11 19:23:48 +03:00
|
|
|
const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (installCommands && *installCommands) {
|
2006-10-12 21:05:50 +04:00
|
|
|
std::string tempInstallDirectoryEnv = "CMAKE_INSTALL_PREFIX=";
|
|
|
|
tempInstallDirectoryEnv += tempInstallDirectory;
|
2014-11-23 13:05:50 +03:00
|
|
|
cmSystemTools::PutEnv(tempInstallDirectoryEnv);
|
2006-01-11 19:23:48 +03:00
|
|
|
std::vector<std::string> installCommandsVector;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(installCommands, installCommandsVector);
|
2006-01-11 19:23:48 +03:00
|
|
|
std::vector<std::string>::iterator it;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = installCommandsVector.begin(); it != installCommandsVector.end();
|
|
|
|
++it) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << *it << std::endl);
|
2006-01-11 19:23:48 +03:00
|
|
|
std::string output;
|
|
|
|
int retVal = 1;
|
2016-06-27 23:44:16 +03:00
|
|
|
bool resB =
|
|
|
|
cmSystemTools::RunSingleCommand(it->c_str(), &output, &output, &retVal,
|
|
|
|
CM_NULLPTR, this->GeneratorVerbose, 0);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!resB || retVal) {
|
2006-01-11 19:23:48 +03:00
|
|
|
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
|
|
|
tmpFile += "/InstallOutput.log";
|
|
|
|
cmGeneratedFileStream ofs(tmpFile.c_str());
|
2014-03-11 16:35:32 +04:00
|
|
|
ofs << "# Run command: " << *it << std::endl
|
2016-05-16 17:34:04 +03:00
|
|
|
<< "# Output:" << std::endl
|
|
|
|
<< output << std::endl;
|
|
|
|
cmCPackLogger(
|
|
|
|
cmCPackLog::LOG_ERROR, "Problem running install command: "
|
|
|
|
<< *it << std::endl
|
|
|
|
<< "Please check " << tmpFile << " for errors" << std::endl);
|
2006-07-09 21:20:07 +04:00
|
|
|
return 0;
|
2006-01-11 19:23:48 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-07-09 21:20:07 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-11-06 00:55:45 +03:00
|
|
|
int cmCPackGenerator::InstallProjectViaInstalledDirectories(
|
2014-02-07 23:43:19 +04:00
|
|
|
bool setDestDir, const std::string& tempInstallDirectory)
|
2006-07-09 21:20:07 +04:00
|
|
|
{
|
2007-10-31 15:50:17 +03:00
|
|
|
(void)setDestDir;
|
2006-07-10 15:59:05 +04:00
|
|
|
(void)tempInstallDirectory;
|
2006-07-09 21:20:07 +04:00
|
|
|
std::vector<cmsys::RegularExpression> ignoreFilesRegex;
|
|
|
|
const char* cpackIgnoreFiles = this->GetOption("CPACK_IGNORE_FILES");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cpackIgnoreFiles) {
|
2006-07-09 21:20:07 +04:00
|
|
|
std::vector<std::string> ignoreFilesRegexString;
|
|
|
|
cmSystemTools::ExpandListArgument(cpackIgnoreFiles,
|
|
|
|
ignoreFilesRegexString);
|
|
|
|
std::vector<std::string>::iterator it;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = ignoreFilesRegexString.begin();
|
|
|
|
it != ignoreFilesRegexString.end(); ++it) {
|
2006-07-09 21:20:07 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Create ignore files regex for: " << *it << std::endl);
|
2006-07-09 21:20:07 +04:00
|
|
|
ignoreFilesRegex.push_back(it->c_str());
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
const char* installDirectories =
|
|
|
|
this->GetOption("CPACK_INSTALLED_DIRECTORIES");
|
|
|
|
if (installDirectories && *installDirectories) {
|
2006-02-14 18:28:40 +03:00
|
|
|
std::vector<std::string> installDirectoriesVector;
|
2006-03-09 00:33:39 +03:00
|
|
|
cmSystemTools::ExpandListArgument(installDirectories,
|
2016-05-16 17:34:04 +03:00
|
|
|
installDirectoriesVector);
|
|
|
|
if (installDirectoriesVector.size() % 2 != 0) {
|
|
|
|
cmCPackLogger(
|
|
|
|
cmCPackLog::LOG_ERROR,
|
2006-03-09 00:33:39 +03:00
|
|
|
"CPACK_INSTALLED_DIRECTORIES should contain pairs of <directory> and "
|
2006-03-09 16:32:08 +03:00
|
|
|
"<subdirectory>. The <subdirectory> can be '.' to be installed in "
|
2016-05-16 17:34:04 +03:00
|
|
|
"the toplevel directory of installation."
|
|
|
|
<< std::endl);
|
2006-02-14 18:28:40 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-02-14 18:28:40 +03:00
|
|
|
std::vector<std::string>::iterator it;
|
2014-02-07 23:43:19 +04:00
|
|
|
const std::string& tempDir = tempInstallDirectory;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = installDirectoriesVector.begin();
|
|
|
|
it != installDirectoriesVector.end(); ++it) {
|
|
|
|
std::list<std::pair<std::string, std::string> > symlinkedFiles;
|
2006-02-14 18:28:40 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl);
|
|
|
|
cmsys::Glob gl;
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string top = *it;
|
2016-05-16 17:34:04 +03:00
|
|
|
it++;
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string subdir = *it;
|
2010-08-12 00:17:09 +04:00
|
|
|
std::string findExpr = top;
|
2006-02-14 18:28:40 +03:00
|
|
|
findExpr += "/*";
|
2006-04-15 21:02:18 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
"- Install directory: " << top << std::endl);
|
2006-02-14 18:28:40 +03:00
|
|
|
gl.RecurseOn();
|
2015-09-28 23:50:15 +03:00
|
|
|
gl.SetRecurseListDirs(true);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!gl.FindFiles(findExpr)) {
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Cannot find any files in the installed directory"
|
|
|
|
<< std::endl);
|
2006-02-14 18:28:40 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-08-12 22:18:46 +04:00
|
|
|
files = gl.GetFiles();
|
2006-02-14 18:28:40 +03:00
|
|
|
std::vector<std::string>::iterator gfit;
|
2006-04-15 21:02:18 +04:00
|
|
|
std::vector<cmsys::RegularExpression>::iterator regIt;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (gfit = files.begin(); gfit != files.end(); ++gfit) {
|
2006-04-15 21:02:18 +04:00
|
|
|
bool skip = false;
|
2015-09-28 23:50:15 +03:00
|
|
|
std::string inFile = *gfit;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileIsDirectory(*gfit)) {
|
2015-09-28 23:50:15 +03:00
|
|
|
inFile += '/';
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (regIt = ignoreFilesRegex.begin(); regIt != ignoreFilesRegex.end();
|
|
|
|
++regIt) {
|
|
|
|
if (regIt->find(inFile.c_str())) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
|
|
|
|
"Ignore file: " << inFile << std::endl);
|
2006-04-15 21:02:18 +04:00
|
|
|
skip = true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (skip) {
|
2006-04-15 21:02:18 +04:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-02-14 18:28:40 +03:00
|
|
|
std::string filePath = tempDir;
|
2016-05-16 17:34:04 +03:00
|
|
|
filePath += "/" + subdir + "/" +
|
|
|
|
cmSystemTools::RelativePath(top.c_str(), gfit->c_str());
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< inFile << " -> " << filePath << std::endl);
|
2010-08-28 18:50:06 +04:00
|
|
|
/* If the file is a symlink we will have to re-create it */
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileIsSymlink(inFile)) {
|
2010-08-28 18:50:06 +04:00
|
|
|
std::string targetFile;
|
|
|
|
std::string inFileRelative =
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::RelativePath(top.c_str(), inFile.c_str());
|
|
|
|
cmSystemTools::ReadSymlink(inFile, targetFile);
|
|
|
|
symlinkedFiles.push_back(
|
|
|
|
std::pair<std::string, std::string>(targetFile, inFileRelative));
|
|
|
|
}
|
2010-08-28 18:50:06 +04:00
|
|
|
/* If it is not a symlink then do a plain copy */
|
2016-05-16 17:34:04 +03:00
|
|
|
else if (!(cmSystemTools::CopyFileIfDifferent(inFile.c_str(),
|
|
|
|
filePath.c_str()) &&
|
|
|
|
cmSystemTools::CopyFileTime(inFile.c_str(),
|
|
|
|
filePath.c_str()))) {
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< inFile << " -> " << filePath << std::endl);
|
2006-04-10 21:44:39 +04:00
|
|
|
return 0;
|
2006-02-14 18:28:40 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-08-28 18:50:06 +04:00
|
|
|
/* rebuild symlinks in the installed tree */
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!symlinkedFiles.empty()) {
|
|
|
|
std::list<std::pair<std::string, std::string> >::iterator symlinkedIt;
|
2010-08-28 18:50:06 +04:00
|
|
|
std::string curDir = cmSystemTools::GetCurrentWorkingDirectory();
|
|
|
|
std::string goToDir = tempDir;
|
2016-05-16 17:34:04 +03:00
|
|
|
goToDir += "/" + subdir;
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Change dir to: " << goToDir
|
|
|
|
<< std::endl);
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::ChangeDirectory(goToDir);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (symlinkedIt = symlinkedFiles.begin();
|
|
|
|
symlinkedIt != symlinkedFiles.end(); ++symlinkedIt) {
|
2010-08-28 18:50:06 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Will create a symlink: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< symlinkedIt->second << "--> "
|
|
|
|
<< symlinkedIt->first << std::endl);
|
2015-01-29 19:52:30 +03:00
|
|
|
// make sure directory exists for symlink
|
|
|
|
std::string destDir =
|
|
|
|
cmSystemTools::GetFilenamePath(symlinkedIt->second);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!destDir.empty() && !cmSystemTools::MakeDirectory(destDir)) {
|
2015-01-29 19:52:30 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create dir: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< destDir << "\nTrying to create symlink: "
|
|
|
|
<< symlinkedIt->second << "--> "
|
|
|
|
<< symlinkedIt->first << std::endl);
|
|
|
|
}
|
2014-11-23 13:05:50 +03:00
|
|
|
if (!cmSystemTools::CreateSymlink(symlinkedIt->first,
|
2016-05-16 17:34:04 +03:00
|
|
|
symlinkedIt->second)) {
|
2010-08-28 18:50:06 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create symlink: "
|
|
|
|
<< symlinkedIt->second << "--> "
|
|
|
|
<< symlinkedIt->first << std::endl);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Going back to: " << curDir
|
|
|
|
<< std::endl);
|
|
|
|
cmSystemTools::ChangeDirectory(curDir);
|
2006-02-14 18:28:40 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-07-09 21:20:07 +04:00
|
|
|
return 1;
|
|
|
|
}
|
2006-06-09 21:45:09 +04:00
|
|
|
|
2007-11-06 00:55:45 +03:00
|
|
|
int cmCPackGenerator::InstallProjectViaInstallScript(
|
2014-02-07 23:43:19 +04:00
|
|
|
bool setDestDir, const std::string& tempInstallDirectory)
|
2006-10-12 21:05:50 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmakeScripts = this->GetOption("CPACK_INSTALL_SCRIPT");
|
|
|
|
if (cmakeScripts && *cmakeScripts) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install scripts: " << cmakeScripts
|
|
|
|
<< std::endl);
|
2006-10-12 21:05:50 +04:00
|
|
|
std::vector<std::string> cmakeScriptsVector;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(cmakeScripts, cmakeScriptsVector);
|
2006-10-12 21:05:50 +04:00
|
|
|
std::vector<std::string>::iterator it;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = cmakeScriptsVector.begin(); it != cmakeScriptsVector.end();
|
|
|
|
++it) {
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string installScript = *it;
|
2006-10-12 21:05:50 +04:00
|
|
|
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
"- Install script: " << installScript << std::endl);
|
2007-10-31 15:50:17 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (setDestDir) {
|
2007-10-31 15:50:17 +03:00
|
|
|
// For DESTDIR based packaging, use the *project* CMAKE_INSTALL_PREFIX
|
|
|
|
// underneath the tempInstallDirectory. The value of the project's
|
|
|
|
// CMAKE_INSTALL_PREFIX is sent in here as the value of the
|
|
|
|
// CPACK_INSTALL_PREFIX variable.
|
2010-08-23 18:14:40 +04:00
|
|
|
|
|
|
|
std::string dir;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetOption("CPACK_INSTALL_PREFIX")) {
|
2007-10-31 15:50:17 +03:00
|
|
|
dir += this->GetOption("CPACK_INSTALL_PREFIX");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-10-31 15:50:17 +03:00
|
|
|
this->SetOption("CMAKE_INSTALL_PREFIX", dir.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(
|
|
|
|
cmCPackLog::LOG_DEBUG,
|
2007-10-31 15:50:17 +03:00
|
|
|
"- Using DESTDIR + CPACK_INSTALL_PREFIX... (this->SetOption)"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
2007-10-31 15:50:17 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
2016-05-16 17:34:04 +03:00
|
|
|
"- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'"
|
|
|
|
<< std::endl);
|
|
|
|
} else {
|
2014-02-07 23:43:19 +04:00
|
|
|
this->SetOption("CMAKE_INSTALL_PREFIX", tempInstallDirectory.c_str());
|
2007-10-31 15:50:17 +03:00
|
|
|
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
2016-05-16 17:34:04 +03:00
|
|
|
"- Using non-DESTDIR install... (this->SetOption)"
|
|
|
|
<< std::endl);
|
2007-10-31 15:50:17 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
2016-05-16 17:34:04 +03:00
|
|
|
"- Setting CMAKE_INSTALL_PREFIX to '"
|
|
|
|
<< tempInstallDirectory << "'" << std::endl);
|
|
|
|
}
|
2007-10-31 15:50:17 +03:00
|
|
|
|
2006-10-15 15:54:52 +04:00
|
|
|
this->SetOptionIfNotSet("CMAKE_CURRENT_BINARY_DIR",
|
2016-05-16 17:34:04 +03:00
|
|
|
tempInstallDirectory.c_str());
|
2006-10-15 15:54:52 +04:00
|
|
|
this->SetOptionIfNotSet("CMAKE_CURRENT_SOURCE_DIR",
|
2016-05-16 17:34:04 +03:00
|
|
|
tempInstallDirectory.c_str());
|
2015-04-18 15:50:37 +03:00
|
|
|
int res = this->MakefileMap->ReadListFile(installScript.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetErrorOccuredFlag() || !res) {
|
2006-10-12 21:05:50 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-10-12 21:05:50 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-11-06 00:55:45 +03:00
|
|
|
int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
|
2014-02-07 23:43:19 +04:00
|
|
|
bool setDestDir, const std::string& baseTempInstallDirectory)
|
2006-07-09 21:20:07 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmakeProjects = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS");
|
|
|
|
const char* cmakeGenerator = this->GetOption("CPACK_CMAKE_GENERATOR");
|
2010-08-23 19:38:33 +04:00
|
|
|
std::string absoluteDestFiles;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmakeProjects && *cmakeProjects) {
|
|
|
|
if (!cmakeGenerator) {
|
2006-04-10 21:44:39 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
2006-05-12 22:44:24 +04:00
|
|
|
"CPACK_INSTALL_CMAKE_PROJECTS is specified, but "
|
|
|
|
"CPACK_CMAKE_GENERATOR is not. CPACK_CMAKE_GENERATOR "
|
|
|
|
"is required to install the project."
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
2006-04-10 21:44:39 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-04-10 19:09:52 +04:00
|
|
|
std::vector<std::string> cmakeProjectsVector;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(cmakeProjects, cmakeProjectsVector);
|
2006-04-10 19:09:52 +04:00
|
|
|
std::vector<std::string>::iterator it;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = cmakeProjectsVector.begin(); it != cmakeProjectsVector.end();
|
|
|
|
++it) {
|
|
|
|
if (it + 1 == cmakeProjectsVector.end() ||
|
|
|
|
it + 2 == cmakeProjectsVector.end() ||
|
|
|
|
it + 3 == cmakeProjectsVector.end()) {
|
|
|
|
cmCPackLogger(
|
|
|
|
cmCPackLog::LOG_ERROR,
|
2006-04-14 16:58:13 +04:00
|
|
|
"Not enough items on list: CPACK_INSTALL_CMAKE_PROJECTS. "
|
|
|
|
"CPACK_INSTALL_CMAKE_PROJECTS should hold quadruplet of install "
|
|
|
|
"directory, install project name, install component, and install "
|
|
|
|
"subdirectory."
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
2006-04-14 16:58:13 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string installDirectory = *it;
|
2006-04-10 19:09:52 +04:00
|
|
|
++it;
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string installProjectName = *it;
|
2006-04-14 16:58:13 +04:00
|
|
|
++it;
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string installComponent = *it;
|
2006-04-14 16:58:13 +04:00
|
|
|
++it;
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string installSubDirectory = *it;
|
2006-04-10 21:44:39 +04:00
|
|
|
std::string installFile = installDirectory + "/cmake_install.cmake";
|
|
|
|
|
2008-06-17 19:39:26 +04:00
|
|
|
std::vector<std::string> componentsVector;
|
|
|
|
|
|
|
|
bool componentInstall = false;
|
2010-12-12 14:30:42 +03:00
|
|
|
/*
|
|
|
|
* We do a component install iff
|
|
|
|
* - the CPack generator support component
|
|
|
|
* - the user did not request Monolithic install
|
|
|
|
* (this works at CPack time too)
|
|
|
|
*/
|
|
|
|
if (this->SupportsComponentInstallation() &
|
2016-05-16 17:34:04 +03:00
|
|
|
!(this->IsOn("CPACK_MONOLITHIC_INSTALL"))) {
|
2008-06-17 19:39:26 +04:00
|
|
|
// Determine the installation types for this project (if provided).
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string installTypesVar = "CPACK_" +
|
|
|
|
cmSystemTools::UpperCase(installComponent) + "_INSTALL_TYPES";
|
|
|
|
const char* installTypes = this->GetOption(installTypesVar);
|
|
|
|
if (installTypes && *installTypes) {
|
2008-06-17 19:39:26 +04:00
|
|
|
std::vector<std::string> installTypesVector;
|
|
|
|
cmSystemTools::ExpandListArgument(installTypes, installTypesVector);
|
|
|
|
std::vector<std::string>::iterator installTypeIt;
|
|
|
|
for (installTypeIt = installTypesVector.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
installTypeIt != installTypesVector.end(); ++installTypeIt) {
|
|
|
|
this->GetInstallationType(installProjectName, *installTypeIt);
|
2008-06-17 19:39:26 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-06-17 19:39:26 +04:00
|
|
|
|
|
|
|
// Determine the set of components that will be used in this project
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string componentsVar =
|
|
|
|
"CPACK_COMPONENTS_" + cmSystemTools::UpperCase(installComponent);
|
|
|
|
const char* components = this->GetOption(componentsVar);
|
|
|
|
if (components && *components) {
|
2008-06-17 19:39:26 +04:00
|
|
|
cmSystemTools::ExpandListArgument(components, componentsVector);
|
|
|
|
std::vector<std::string>::iterator compIt;
|
|
|
|
for (compIt = componentsVector.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
compIt != componentsVector.end(); ++compIt) {
|
2014-03-11 03:04:11 +04:00
|
|
|
GetComponent(installProjectName, *compIt);
|
2008-06-17 19:39:26 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
componentInstall = true;
|
2008-06-17 19:39:26 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (componentsVector.empty()) {
|
2008-06-17 19:39:26 +04:00
|
|
|
componentsVector.push_back(installComponent);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-06-17 19:39:26 +04:00
|
|
|
|
2014-02-10 07:48:34 +04:00
|
|
|
const char* buildConfigCstr = this->GetOption("CPACK_BUILD_CONFIG");
|
|
|
|
std::string buildConfig = buildConfigCstr ? buildConfigCstr : "";
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGlobalGenerator* globalGenerator =
|
|
|
|
this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator(
|
2006-04-10 21:44:39 +04:00
|
|
|
cmakeGenerator);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!globalGenerator) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
|
|
|
"Specified package generator not found. "
|
|
|
|
"CPACK_CMAKE_GENERATOR value is invalid."
|
|
|
|
<< std::endl);
|
|
|
|
return 0;
|
2015-01-02 12:46:08 +03:00
|
|
|
}
|
2006-07-10 15:59:05 +04:00
|
|
|
// set the global flag for unix style paths on cmSystemTools as
|
2006-05-03 23:17:09 +04:00
|
|
|
// soon as the generator is set. This allows gmake to be used
|
|
|
|
// on windows.
|
|
|
|
cmSystemTools::SetForceUnixPaths(globalGenerator->GetForceUnixPaths());
|
2006-07-10 15:59:05 +04:00
|
|
|
|
2006-04-10 21:44:39 +04:00
|
|
|
// Does this generator require pre-install?
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* preinstall =
|
|
|
|
globalGenerator->GetPreinstallTargetName()) {
|
|
|
|
std::string buildCommand = globalGenerator->GenerateCMakeBuildCommand(
|
|
|
|
preinstall, buildConfig, "", false);
|
2006-04-10 21:44:39 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
2016-05-16 17:34:04 +03:00
|
|
|
"- Install command: " << buildCommand << std::endl);
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Run preinstall target for: "
|
|
|
|
<< installProjectName << std::endl);
|
2006-04-10 21:44:39 +04:00
|
|
|
std::string output;
|
|
|
|
int retVal = 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
bool resB = cmSystemTools::RunSingleCommand(
|
|
|
|
buildCommand.c_str(), &output, &output, &retVal,
|
|
|
|
installDirectory.c_str(), this->GeneratorVerbose, 0);
|
|
|
|
if (!resB || retVal) {
|
2006-04-10 21:44:39 +04:00
|
|
|
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
|
|
|
tmpFile += "/PreinstallOutput.log";
|
|
|
|
cmGeneratedFileStream ofs(tmpFile.c_str());
|
2015-03-31 17:26:29 +03:00
|
|
|
ofs << "# Run command: " << buildCommand << std::endl
|
2016-05-16 17:34:04 +03:00
|
|
|
<< "# Directory: " << installDirectory << std::endl
|
|
|
|
<< "# Output:" << std::endl
|
|
|
|
<< output << std::endl;
|
|
|
|
cmCPackLogger(
|
|
|
|
cmCPackLog::LOG_ERROR, "Problem running install command: "
|
|
|
|
<< buildCommand << std::endl
|
|
|
|
<< "Please check " << tmpFile << " for errors" << std::endl);
|
2006-04-10 21:44:39 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-04-10 21:44:39 +04:00
|
|
|
delete globalGenerator;
|
2006-07-10 15:59:05 +04:00
|
|
|
|
2006-04-10 19:09:52 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
"- Install project: " << installProjectName << std::endl);
|
2007-10-31 15:50:17 +03:00
|
|
|
|
2008-06-17 19:39:26 +04:00
|
|
|
// Run the installation for each component
|
|
|
|
std::vector<std::string>::iterator componentIt;
|
|
|
|
for (componentIt = componentsVector.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
componentIt != componentsVector.end(); ++componentIt) {
|
2008-06-17 19:39:26 +04:00
|
|
|
std::string tempInstallDirectory = baseTempInstallDirectory;
|
|
|
|
installComponent = *componentIt;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (componentInstall) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install component: "
|
|
|
|
<< installComponent << std::endl);
|
|
|
|
}
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2008-06-17 19:39:26 +04:00
|
|
|
cmake cm;
|
2015-05-05 00:01:29 +03:00
|
|
|
cm.SetHomeDirectory("");
|
|
|
|
cm.SetHomeOutputDirectory("");
|
2015-10-13 22:48:46 +03:00
|
|
|
cm.GetCurrentSnapshot().SetDefaultDefinitions();
|
2008-06-17 19:39:26 +04:00
|
|
|
cm.AddCMakePaths();
|
|
|
|
cm.SetProgressCallback(cmCPackGeneratorProgress, this);
|
2015-05-24 12:31:14 +03:00
|
|
|
cmGlobalGenerator gg(&cm);
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmMakefile> mf(
|
2016-05-16 17:34:04 +03:00
|
|
|
new cmMakefile(&gg, cm.GetCurrentSnapshot()));
|
2016-07-19 17:07:12 +03:00
|
|
|
if (!installSubDirectory.empty() && installSubDirectory != "/" &&
|
|
|
|
installSubDirectory != ".") {
|
2016-02-18 01:30:05 +03:00
|
|
|
tempInstallDirectory += installSubDirectory;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (componentInstall) {
|
2008-06-17 19:39:26 +04:00
|
|
|
tempInstallDirectory += "/";
|
2011-02-06 23:23:10 +03:00
|
|
|
// Some CPack generators would rather chose
|
|
|
|
// the local installation directory suffix.
|
|
|
|
// Some (e.g. RPM) use
|
|
|
|
// one install directory for each component **GROUP**
|
|
|
|
// instead of the default
|
|
|
|
// one install directory for each component.
|
|
|
|
tempInstallDirectory +=
|
|
|
|
GetComponentInstallDirNameSuffix(installComponent);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
|
2012-01-14 01:01:53 +04:00
|
|
|
tempInstallDirectory += "/";
|
|
|
|
tempInstallDirectory += this->GetOption("CPACK_PACKAGE_FILE_NAME");
|
2007-10-31 15:50:17 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-10-31 15:50:17 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!setDestDir) {
|
2008-06-17 19:39:26 +04:00
|
|
|
tempInstallDirectory += this->GetPackagingInstallPrefix();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-10-31 15:50:17 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (setDestDir) {
|
2008-10-02 17:18:47 +04:00
|
|
|
// For DESTDIR based packaging, use the *project*
|
|
|
|
// CMAKE_INSTALL_PREFIX underneath the tempInstallDirectory. The
|
|
|
|
// value of the project's CMAKE_INSTALL_PREFIX is sent in here as
|
|
|
|
// the value of the CPACK_INSTALL_PREFIX variable.
|
2008-10-15 17:35:27 +04:00
|
|
|
//
|
2010-08-23 18:14:40 +04:00
|
|
|
// If DESTDIR has been 'internally set ON' this means that
|
|
|
|
// the underlying CPack specific generator did ask for that
|
2010-11-13 19:56:36 +03:00
|
|
|
// In this case we may override CPACK_INSTALL_PREFIX with
|
2010-08-23 18:14:40 +04:00
|
|
|
// CPACK_PACKAGING_INSTALL_PREFIX
|
|
|
|
// I know this is tricky and awkward but it's the price for
|
|
|
|
// CPACK_SET_DESTDIR backward compatibility.
|
2010-09-16 00:41:41 +04:00
|
|
|
if (cmSystemTools::IsInternallyOn(
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("CPACK_SET_DESTDIR"))) {
|
2010-09-16 00:41:41 +04:00
|
|
|
this->SetOption("CPACK_INSTALL_PREFIX",
|
|
|
|
this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"));
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-06-17 19:39:26 +04:00
|
|
|
std::string dir;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetOption("CPACK_INSTALL_PREFIX")) {
|
2008-06-17 19:39:26 +04:00
|
|
|
dir += this->GetOption("CPACK_INSTALL_PREFIX");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-06-17 19:39:26 +04:00
|
|
|
mf->AddDefinition("CMAKE_INSTALL_PREFIX", dir.c_str());
|
|
|
|
|
2008-10-01 17:04:27 +04:00
|
|
|
cmCPackLogger(
|
|
|
|
cmCPackLog::LOG_DEBUG,
|
|
|
|
"- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf->AddDefinition)"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
2008-06-17 19:39:26 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
2012-08-13 21:42:58 +04:00
|
|
|
"- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
2008-10-15 17:35:27 +04:00
|
|
|
|
|
|
|
// Make sure that DESTDIR + CPACK_INSTALL_PREFIX directory
|
|
|
|
// exists:
|
|
|
|
//
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::StringStartsWith(dir.c_str(), "/")) {
|
2008-10-15 17:35:27 +04:00
|
|
|
dir = tempInstallDirectory + dir;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-10-15 17:35:27 +04:00
|
|
|
dir = tempInstallDirectory + "/" + dir;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-11-13 19:56:36 +03:00
|
|
|
/*
|
|
|
|
* We must re-set DESTDIR for each component
|
|
|
|
* We must not add the CPACK_INSTALL_PREFIX part because
|
|
|
|
* it will be added using the override of CMAKE_INSTALL_PREFIX
|
|
|
|
* The main reason for this awkward trick is that
|
|
|
|
* are using DESTDIR for 2 different reasons:
|
|
|
|
* - Because it was asked by the CPack Generator or the user
|
|
|
|
* using CPACK_SET_DESTDIR
|
|
|
|
* - Because it was already used for component install
|
|
|
|
* in order to put things in subdirs...
|
|
|
|
*/
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::PutEnv(std::string("DESTDIR=") +
|
|
|
|
tempInstallDirectory);
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Creating directory: '"
|
|
|
|
<< dir << "'" << std::endl);
|
|
|
|
|
|
|
|
if (!cmsys::SystemTools::MakeDirectory(dir.c_str())) {
|
|
|
|
cmCPackLogger(
|
|
|
|
cmCPackLog::LOG_ERROR,
|
|
|
|
"Problem creating temporary directory: " << dir << std::endl);
|
2008-10-15 17:35:27 +04:00
|
|
|
return 0;
|
2008-06-17 19:39:26 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-10-02 17:18:47 +04:00
|
|
|
mf->AddDefinition("CMAKE_INSTALL_PREFIX",
|
|
|
|
tempInstallDirectory.c_str());
|
2007-10-31 15:50:17 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmsys::SystemTools::MakeDirectory(
|
|
|
|
tempInstallDirectory.c_str())) {
|
2008-07-08 19:52:25 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
2012-08-13 21:42:58 +04:00
|
|
|
"Problem creating temporary directory: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< tempInstallDirectory << std::endl);
|
2008-07-08 19:52:25 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-07-08 19:52:25 +04:00
|
|
|
|
2008-06-17 19:39:26 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
2008-10-01 17:04:27 +04:00
|
|
|
"- Using non-DESTDIR install... (mf->AddDefinition)"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
2008-06-17 19:39:26 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
2008-10-01 17:04:27 +04:00
|
|
|
"- Setting CMAKE_INSTALL_PREFIX to '"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< tempInstallDirectory << "'" << std::endl);
|
|
|
|
}
|
2006-04-10 19:09:52 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!buildConfig.empty()) {
|
2014-02-10 07:48:34 +04:00
|
|
|
mf->AddDefinition("BUILD_TYPE", buildConfig.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
std::string installComponentLowerCase =
|
|
|
|
cmSystemTools::LowerCase(installComponent);
|
|
|
|
if (installComponentLowerCase != "all") {
|
2008-06-17 19:39:26 +04:00
|
|
|
mf->AddDefinition("CMAKE_INSTALL_COMPONENT",
|
|
|
|
installComponent.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-06-17 19:39:26 +04:00
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
// strip on TRUE, ON, 1, one or several file names, but not on
|
2008-06-17 19:39:26 +04:00
|
|
|
// FALSE, OFF, 0 and an empty string
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::IsOff(this->GetOption("CPACK_STRIP_FILES"))) {
|
2008-06-17 19:39:26 +04:00
|
|
|
mf->AddDefinition("CMAKE_INSTALL_DO_STRIP", "1");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-04 00:43:31 +03:00
|
|
|
// Remember the list of files before installation
|
|
|
|
// of the current component (if we are in component install)
|
|
|
|
const char* InstallPrefix = tempInstallDirectory.c_str();
|
|
|
|
std::vector<std::string> filesBefore;
|
|
|
|
std::string findExpr(InstallPrefix);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (componentInstall) {
|
2011-03-04 00:43:31 +03:00
|
|
|
cmsys::Glob glB;
|
|
|
|
findExpr += "/*";
|
|
|
|
glB.RecurseOn();
|
2015-09-28 23:50:15 +03:00
|
|
|
glB.SetRecurseListDirs(true);
|
2011-03-04 00:43:31 +03:00
|
|
|
glB.FindFiles(findExpr);
|
|
|
|
filesBefore = glB.GetFiles();
|
2016-05-16 17:34:04 +03:00
|
|
|
std::sort(filesBefore.begin(), filesBefore.end());
|
|
|
|
}
|
2012-05-15 01:29:42 +04:00
|
|
|
|
|
|
|
// If CPack was asked to warn on ABSOLUTE INSTALL DESTINATION
|
|
|
|
// then forward request to cmake_install.cmake script
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")) {
|
|
|
|
mf->AddDefinition("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION", "1");
|
|
|
|
}
|
2012-05-15 01:29:42 +04:00
|
|
|
// If current CPack generator does support
|
|
|
|
// ABSOLUTE INSTALL DESTINATION or CPack has been asked for
|
|
|
|
// then ask cmake_install.cmake script to error out
|
|
|
|
// as soon as it occurs (before installing file)
|
|
|
|
if (!SupportsAbsoluteDestination() ||
|
2016-05-16 17:34:04 +03:00
|
|
|
this->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")) {
|
|
|
|
mf->AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION",
|
|
|
|
"1");
|
|
|
|
}
|
2011-03-04 00:43:31 +03:00
|
|
|
// do installation
|
2015-04-18 15:50:37 +03:00
|
|
|
int res = mf->ReadListFile(installFile.c_str());
|
2012-05-20 19:28:54 +04:00
|
|
|
// forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES
|
|
|
|
// to CPack (may be used by generators like CPack RPM or DEB)
|
|
|
|
// in order to transparently handle ABSOLUTE PATH
|
2016-05-16 17:34:04 +03:00
|
|
|
if (mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) {
|
|
|
|
mf->AddDefinition(
|
|
|
|
"CPACK_ABSOLUTE_DESTINATION_FILES",
|
|
|
|
mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES"));
|
|
|
|
}
|
2012-05-15 01:29:42 +04:00
|
|
|
|
2011-03-04 00:43:31 +03:00
|
|
|
// Now rebuild the list of files after installation
|
|
|
|
// of the current component (if we are in component install)
|
2016-05-16 17:34:04 +03:00
|
|
|
if (componentInstall) {
|
2011-03-04 00:43:31 +03:00
|
|
|
cmsys::Glob glA;
|
|
|
|
glA.RecurseOn();
|
2015-09-28 23:50:15 +03:00
|
|
|
glA.SetRecurseListDirs(true);
|
2011-03-04 00:43:31 +03:00
|
|
|
glA.FindFiles(findExpr);
|
|
|
|
std::vector<std::string> filesAfter = glA.GetFiles();
|
2016-05-16 17:34:04 +03:00
|
|
|
std::sort(filesAfter.begin(), filesAfter.end());
|
2011-03-04 00:43:31 +03:00
|
|
|
std::vector<std::string>::iterator diff;
|
|
|
|
std::vector<std::string> result(filesAfter.size());
|
2016-05-16 17:34:04 +03:00
|
|
|
diff = std::set_difference(filesAfter.begin(), filesAfter.end(),
|
|
|
|
filesBefore.begin(), filesBefore.end(),
|
|
|
|
result.begin());
|
2011-03-04 00:43:31 +03:00
|
|
|
|
|
|
|
std::vector<std::string>::iterator fit;
|
|
|
|
std::string localFileName;
|
|
|
|
// Populate the File field of each component
|
2016-05-16 17:34:04 +03:00
|
|
|
for (fit = result.begin(); fit != diff; ++fit) {
|
2011-03-05 00:57:37 +03:00
|
|
|
localFileName =
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::RelativePath(InstallPrefix, fit->c_str());
|
|
|
|
localFileName = localFileName.substr(
|
|
|
|
localFileName.find_first_not_of('/'), std::string::npos);
|
2011-03-04 00:43:31 +03:00
|
|
|
Components[installComponent].Files.push_back(localFileName);
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file <"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< localFileName << "> to component <"
|
|
|
|
<< installComponent << ">" << std::endl);
|
2011-03-04 00:43:31 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-04 00:43:31 +03:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
if (CM_NULLPTR !=
|
|
|
|
mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) {
|
2015-01-16 00:39:38 +03:00
|
|
|
if (!absoluteDestFiles.empty()) {
|
2016-05-16 17:34:04 +03:00
|
|
|
absoluteDestFiles += ";";
|
2010-08-23 19:38:33 +04:00
|
|
|
}
|
2010-09-16 00:41:41 +04:00
|
|
|
absoluteDestFiles +=
|
|
|
|
mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
|
2010-08-23 19:38:33 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Got some ABSOLUTE DESTINATION FILES: "
|
|
|
|
<< absoluteDestFiles << std::endl);
|
2011-04-17 19:12:38 +04:00
|
|
|
// define component specific var
|
2016-05-16 17:34:04 +03:00
|
|
|
if (componentInstall) {
|
2011-04-17 19:12:38 +04:00
|
|
|
std::string absoluteDestFileComponent =
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + "_" +
|
|
|
|
GetComponentInstallDirNameSuffix(installComponent);
|
2016-06-27 23:44:16 +03:00
|
|
|
if (CM_NULLPTR != this->GetOption(absoluteDestFileComponent)) {
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string absoluteDestFilesListComponent =
|
|
|
|
this->GetOption(absoluteDestFileComponent);
|
|
|
|
absoluteDestFilesListComponent += ";";
|
|
|
|
absoluteDestFilesListComponent +=
|
|
|
|
mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
|
2014-03-11 03:04:11 +04:00
|
|
|
this->SetOption(absoluteDestFileComponent,
|
2016-05-16 17:34:04 +03:00
|
|
|
absoluteDestFilesListComponent.c_str());
|
|
|
|
} else {
|
|
|
|
this->SetOption(
|
|
|
|
absoluteDestFileComponent,
|
|
|
|
mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
|
2011-04-17 19:12:38 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-08-23 19:38:33 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetErrorOccuredFlag() || !res) {
|
2008-06-17 19:39:26 +04:00
|
|
|
return 0;
|
2006-05-02 16:49:01 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-09-16 00:41:41 +04:00
|
|
|
this->SetOption("CPACK_ABSOLUTE_DESTINATION_FILES",
|
|
|
|
absoluteDestFiles.c_str());
|
2006-07-09 21:20:07 +04:00
|
|
|
return 1;
|
2006-01-02 07:21:05 +03:00
|
|
|
}
|
|
|
|
|
2007-11-06 00:55:45 +03:00
|
|
|
bool cmCPackGenerator::ReadListFile(const char* moduleName)
|
2007-07-24 20:52:39 +04:00
|
|
|
{
|
2011-03-19 13:12:31 +03:00
|
|
|
bool retval;
|
2007-07-24 20:52:39 +04:00
|
|
|
std::string fullPath = this->MakefileMap->GetModulesFile(moduleName);
|
2015-04-18 15:50:37 +03:00
|
|
|
retval = this->MakefileMap->ReadListFile(fullPath.c_str());
|
2011-03-19 13:12:31 +03:00
|
|
|
// include FATAL_ERROR and ERROR in the return status
|
2016-05-16 17:34:04 +03:00
|
|
|
retval = retval && (!cmSystemTools::GetErrorOccuredFlag());
|
2011-03-19 13:12:31 +03:00
|
|
|
return retval;
|
2007-07-24 20:52:39 +04:00
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
void cmCPackGenerator::SetOptionIfNotSet(const std::string& op,
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* value)
|
2006-04-15 21:02:18 +04:00
|
|
|
{
|
2007-07-24 20:52:39 +04:00
|
|
|
const char* def = this->MakefileMap->GetDefinition(op);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (def && *def) {
|
2006-04-15 21:02:18 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-04-15 21:02:18 +04:00
|
|
|
this->SetOption(op, value);
|
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
void cmCPackGenerator::SetOption(const std::string& op, const char* value)
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!value) {
|
2007-07-24 20:52:39 +04:00
|
|
|
this->MakefileMap->RemoveDefinition(op);
|
2006-01-02 07:21:05 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, this->GetNameOfClass()
|
2016-05-16 17:34:04 +03:00
|
|
|
<< "::SetOption(" << op << ", " << value << ")"
|
|
|
|
<< std::endl);
|
2007-07-24 20:52:39 +04:00
|
|
|
this->MakefileMap->AddDefinition(op, value);
|
2006-01-02 07:21:05 +03:00
|
|
|
}
|
|
|
|
|
2007-11-06 16:28:26 +03:00
|
|
|
int cmCPackGenerator::DoPackage()
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Create package using " << this->Name
|
|
|
|
<< std::endl);
|
2006-07-09 21:20:07 +04:00
|
|
|
|
2012-05-14 22:26:15 +04:00
|
|
|
// Prepare CPack internal name and check
|
|
|
|
// values for many CPACK_xxx vars
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->PrepareNames()) {
|
2006-01-02 07:21:05 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-03-07 19:06:44 +03:00
|
|
|
|
2011-02-06 23:23:10 +03:00
|
|
|
// Digest Component grouping specification
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->PrepareGroupingKind()) {
|
2011-02-06 23:23:10 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-02-06 23:23:10 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::IsOn(
|
|
|
|
this->GetOption("CPACK_REMOVE_TOPLEVEL_DIRECTORY"))) {
|
|
|
|
const char* toplevelDirectory =
|
|
|
|
this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
|
|
|
if (cmSystemTools::FileExists(toplevelDirectory)) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Remove toplevel directory: "
|
|
|
|
<< toplevelDirectory << std::endl);
|
|
|
|
if (!cmSystemTools::RepeatedRemoveDirectory(toplevelDirectory)) {
|
2006-07-09 21:20:07 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Problem removing toplevel directory: "
|
|
|
|
<< toplevelDirectory << std::endl);
|
2006-07-09 21:20:07 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "About to install project "
|
|
|
|
<< std::endl);
|
2008-03-07 19:06:44 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->InstallProject()) {
|
2006-01-02 07:21:05 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Done install project " << std::endl);
|
2006-01-02 07:21:05 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* tempPackageFileName =
|
|
|
|
this->GetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME");
|
2006-01-02 07:21:05 +03:00
|
|
|
const char* tempDirectory = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
|
|
|
|
|
2006-01-03 00:14:21 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl);
|
2006-01-02 07:21:05 +03:00
|
|
|
cmsys::Glob gl;
|
|
|
|
std::string findExpr = tempDirectory;
|
|
|
|
findExpr += "/*";
|
|
|
|
gl.RecurseOn();
|
2015-09-28 23:50:15 +03:00
|
|
|
gl.SetRecurseListDirs(true);
|
2011-08-27 21:34:37 +04:00
|
|
|
gl.SetRecurseThroughSymlinks(false);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!gl.FindFiles(findExpr)) {
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Cannot find any files in the packaging tree" << 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
|
|
|
|
2010-08-24 23:42:21 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Create package" << std::endl);
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Package files to: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< (tempPackageFileName ? tempPackageFileName : "(NULL)")
|
|
|
|
<< std::endl);
|
|
|
|
if (cmSystemTools::FileExists(tempPackageFileName)) {
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Remove old package file"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
2006-01-09 19:26:31 +03:00
|
|
|
cmSystemTools::RemoveFile(tempPackageFileName);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (cmSystemTools::IsOn(
|
|
|
|
this->GetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY"))) {
|
2006-04-02 19:20:58 +04:00
|
|
|
tempDirectory = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-06-17 19:39:26 +04:00
|
|
|
|
|
|
|
// The files to be installed
|
2010-08-11 21:48:39 +04:00
|
|
|
files = gl.GetFiles();
|
2008-06-17 19:39:26 +04:00
|
|
|
|
2010-08-11 21:48:39 +04:00
|
|
|
packageFileNames.clear();
|
|
|
|
/* Put at least one file name into the list of
|
|
|
|
* wanted packageFileNames. The specific generator
|
|
|
|
* may update this during PackageFiles.
|
|
|
|
* (either putting several names or updating the provided one)
|
|
|
|
*/
|
2014-03-07 02:22:09 +04:00
|
|
|
packageFileNames.push_back(tempPackageFileName ? tempPackageFileName : "");
|
2010-08-11 21:48:39 +04:00
|
|
|
toplevel = tempDirectory;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag()) {
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem compressing the directory"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< 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
|
|
|
|
2016-08-31 18:05:15 +03:00
|
|
|
/* Prepare checksum algorithm*/
|
|
|
|
const char* algo = this->GetOption("CPACK_PACKAGE_CHECKSUM");
|
|
|
|
CM_AUTO_PTR<cmCryptoHash> crypto = cmCryptoHash::New(algo ? algo : "");
|
|
|
|
|
2010-08-11 21:48:39 +04:00
|
|
|
/*
|
|
|
|
* Copy the generated packages to final destination
|
|
|
|
* - there may be several of them
|
|
|
|
* - the initially provided name may have changed
|
|
|
|
* (because the specific generator did 'normalize' it)
|
|
|
|
*/
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Copying final package(s) ["
|
2016-05-16 17:34:04 +03:00
|
|
|
<< packageFileNames.size() << "]:" << std::endl);
|
2010-08-11 21:48:39 +04:00
|
|
|
std::vector<std::string>::iterator it;
|
|
|
|
/* now copy package one by one */
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = packageFileNames.begin(); it != packageFileNames.end(); ++it) {
|
2010-08-11 21:48:39 +04:00
|
|
|
std::string tmpPF(this->GetOption("CPACK_OUTPUT_FILE_PREFIX"));
|
2016-08-31 18:05:15 +03:00
|
|
|
std::string filename(cmSystemTools::GetFilenameName(*it));
|
2010-08-11 21:48:39 +04:00
|
|
|
tempPackageFileName = it->c_str();
|
2016-08-31 18:05:15 +03:00
|
|
|
tmpPF += "/" + filename;
|
2014-08-05 18:22:36 +04:00
|
|
|
const char* packageFileName = tmpPF.c_str();
|
2010-08-11 21:48:39 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy final package(s): "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< (tempPackageFileName ? tempPackageFileName : "(NULL)")
|
|
|
|
<< " to " << (packageFileName ? packageFileName : "(NULL)")
|
|
|
|
<< std::endl);
|
|
|
|
if (!cmSystemTools::CopyFileIfDifferent(tempPackageFileName,
|
|
|
|
packageFileName)) {
|
|
|
|
cmCPackLogger(
|
|
|
|
cmCPackLog::LOG_ERROR, "Problem copying the package: "
|
|
|
|
<< (tempPackageFileName ? tempPackageFileName : "(NULL)") << " to "
|
|
|
|
<< (packageFileName ? packageFileName : "(NULL)") << std::endl);
|
2010-08-11 21:48:39 +04:00
|
|
|
return 0;
|
2006-01-02 07:21:05 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- package: "
|
|
|
|
<< packageFileName << " generated." << std::endl);
|
2016-08-31 18:05:15 +03:00
|
|
|
|
|
|
|
/* Generate checksum file */
|
|
|
|
if (crypto.get() != CM_NULLPTR) {
|
|
|
|
std::string hashFile(this->GetOption("CPACK_OUTPUT_FILE_PREFIX"));
|
|
|
|
hashFile +=
|
|
|
|
"/" + filename.substr(0, filename.rfind(this->GetOutputExtension()));
|
|
|
|
hashFile += "." + cmSystemTools::LowerCase(algo);
|
|
|
|
cmsys::ofstream outF(hashFile.c_str());
|
|
|
|
if (!outF) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create checksum file: "
|
|
|
|
<< hashFile << std::endl);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
outF << crypto->HashFile(packageFileName) << " " << filename << "\n";
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- checksum file: "
|
|
|
|
<< hashFile << " generated." << std::endl);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-02 07:21:05 +03:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-02-22 04:05:55 +04:00
|
|
|
int cmCPackGenerator::Initialize(const std::string& name, cmMakefile* mf)
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2007-07-24 20:52:39 +04:00
|
|
|
this->MakefileMap = mf;
|
2006-03-10 21:06:26 +03:00
|
|
|
this->Name = name;
|
2007-10-31 19:55:04 +03:00
|
|
|
// set the running generator name
|
|
|
|
this->SetOption("CPACK_GENERATOR", this->Name.c_str());
|
|
|
|
// Load the project specific config file
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* config = this->GetOption("CPACK_PROJECT_CONFIG_FILE");
|
|
|
|
if (config) {
|
2015-04-18 15:50:37 +03:00
|
|
|
mf->ReadListFile(config);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-08-03 23:26:30 +04:00
|
|
|
int result = this->InitializeInternal();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetErrorOccuredFlag()) {
|
2007-08-03 23:26:30 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-08-03 23:26:30 +04:00
|
|
|
|
2007-10-31 15:50:17 +03:00
|
|
|
// If a generator subclass did not already set this option in its
|
|
|
|
// InitializeInternal implementation, and the project did not already set
|
|
|
|
// it, the default value should be:
|
|
|
|
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/");
|
|
|
|
|
2007-08-03 23:26:30 +04:00
|
|
|
return result;
|
2006-04-15 21:02:18 +04:00
|
|
|
}
|
|
|
|
|
2007-11-06 00:55:45 +03:00
|
|
|
int cmCPackGenerator::InitializeInternal()
|
2006-04-15 21:02:18 +04:00
|
|
|
{
|
2006-01-02 07:21:05 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
bool cmCPackGenerator::IsSet(const std::string& name) const
|
2007-07-24 20:52:39 +04:00
|
|
|
{
|
|
|
|
return this->MakefileMap->IsSet(name);
|
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
bool cmCPackGenerator::IsOn(const std::string& name) const
|
2010-12-12 14:55:02 +03:00
|
|
|
{
|
|
|
|
return cmSystemTools::IsOn(GetOption(name));
|
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
const char* cmCPackGenerator::GetOption(const std::string& op) const
|
2012-08-13 21:42:58 +04:00
|
|
|
{
|
2008-03-13 04:54:27 +03:00
|
|
|
const char* ret = this->MakefileMap->GetDefinition(op);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ret) {
|
2012-08-13 21:42:58 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Warning, GetOption return NULL for: " << op << std::endl);
|
|
|
|
}
|
2008-03-13 04:54:27 +03:00
|
|
|
return ret;
|
2006-01-02 07:21:05 +03:00
|
|
|
}
|
|
|
|
|
2014-03-02 02:13:35 +04:00
|
|
|
std::vector<std::string> cmCPackGenerator::GetOptions() const
|
|
|
|
{
|
|
|
|
return this->MakefileMap->GetDefinitions();
|
|
|
|
}
|
|
|
|
|
2010-08-11 21:48:39 +04:00
|
|
|
int cmCPackGenerator::PackageFiles()
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-11-06 00:55:45 +03:00
|
|
|
const char* cmCPackGenerator::GetInstallPath()
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->InstallPath.empty()) {
|
2006-03-10 21:06:26 +03:00
|
|
|
return this->InstallPath.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-02 07:21:05 +03:00
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
2016-07-08 00:54:05 +03:00
|
|
|
std::string prgfiles;
|
|
|
|
std::string sysDrive;
|
|
|
|
if (cmsys::SystemTools::GetEnv("ProgramFiles", prgfiles)) {
|
2006-03-10 21:06:26 +03:00
|
|
|
this->InstallPath = prgfiles;
|
2016-07-08 00:54:05 +03:00
|
|
|
} else if (cmsys::SystemTools::GetEnv("SystemDrive", sysDrive)) {
|
2006-03-10 21:06:26 +03:00
|
|
|
this->InstallPath = sysDrive;
|
|
|
|
this->InstallPath += "/Program Files";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-03-10 21:06:26 +03:00
|
|
|
this->InstallPath = "c:/Program Files";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-10 21:06:26 +03:00
|
|
|
this->InstallPath += "/";
|
|
|
|
this->InstallPath += this->GetOption("CPACK_PACKAGE_NAME");
|
|
|
|
this->InstallPath += "-";
|
|
|
|
this->InstallPath += this->GetOption("CPACK_PACKAGE_VERSION");
|
2009-09-30 16:31:53 +04:00
|
|
|
#elif defined(__HAIKU__)
|
2013-10-05 18:31:36 +04:00
|
|
|
char dir[B_PATH_NAME_LENGTH];
|
2016-05-16 17:34:04 +03:00
|
|
|
if (find_directory(B_SYSTEM_DIRECTORY, -1, false, dir, sizeof(dir)) ==
|
|
|
|
B_OK) {
|
2013-10-05 18:31:36 +04:00
|
|
|
this->InstallPath = dir;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2013-10-05 18:31:36 +04:00
|
|
|
this->InstallPath = "/boot/system";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-01-02 07:21:05 +03:00
|
|
|
#else
|
2006-03-10 21:06:26 +03:00
|
|
|
this->InstallPath = "/usr/local/";
|
2006-01-02 07:21:05 +03:00
|
|
|
#endif
|
2006-03-10 21:06:26 +03:00
|
|
|
return this->InstallPath.c_str();
|
2006-01-02 07:21:05 +03:00
|
|
|
}
|
|
|
|
|
2007-11-06 00:55:45 +03:00
|
|
|
const char* cmCPackGenerator::GetPackagingInstallPrefix()
|
2007-10-31 15:50:17 +03:00
|
|
|
{
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "GetPackagingInstallPrefix: '"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX") << "'"
|
|
|
|
<< std::endl);
|
2007-10-31 15:50:17 +03:00
|
|
|
|
|
|
|
return this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
|
|
|
|
}
|
|
|
|
|
2007-11-06 00:55:45 +03:00
|
|
|
std::string cmCPackGenerator::FindTemplate(const char* name)
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2006-03-09 00:33:39 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for template: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< (name ? name : "(NULL)") << std::endl);
|
2007-07-24 20:52:39 +04:00
|
|
|
std::string ffile = this->MakefileMap->GetModulesFile(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: " << ffile
|
|
|
|
<< std::endl);
|
2006-01-05 21:27:48 +03:00
|
|
|
return ffile;
|
2006-01-02 07:21:05 +03:00
|
|
|
}
|
|
|
|
|
2007-11-06 00:55:45 +03:00
|
|
|
bool cmCPackGenerator::ConfigureString(const std::string& inString,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string& outString)
|
2006-04-18 16:25:24 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->MakefileMap->ConfigureString(inString, outString, true, false);
|
2006-04-18 16:25:24 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCPackGenerator::ConfigureFile(const char* inName, const char* outName,
|
|
|
|
bool copyOnly /* = false */)
|
2006-01-02 07:21:05 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return this->MakefileMap->ConfigureFile(inName, outName, copyOnly, true,
|
|
|
|
false) == 1;
|
2006-01-02 07:21:05 +03:00
|
|
|
}
|
2006-06-09 21:45:09 +04:00
|
|
|
|
2007-11-06 00:55:45 +03:00
|
|
|
int cmCPackGenerator::CleanTemporaryDirectory()
|
2006-06-09 21:45:09 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string tempInstallDirectoryWithPostfix =
|
|
|
|
this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
|
2007-01-10 23:30:26 +03:00
|
|
|
const char* tempInstallDirectory = tempInstallDirectoryWithPostfix.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmsys::SystemTools::FileExists(tempInstallDirectory)) {
|
2006-06-09 21:45:09 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
"- Clean temporary : " << tempInstallDirectory << std::endl);
|
|
|
|
if (!cmSystemTools::RepeatedRemoveDirectory(tempInstallDirectory)) {
|
2006-06-09 21:45:09 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Problem removing temporary directory: "
|
|
|
|
<< tempInstallDirectory << std::endl);
|
2006-06-09 21:45:09 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-06-09 21:45:09 +04:00
|
|
|
return 1;
|
|
|
|
}
|
2008-06-17 19:39:26 +04:00
|
|
|
|
2014-05-15 21:12:40 +04:00
|
|
|
cmInstalledFile const* cmCPackGenerator::GetInstalledFile(
|
|
|
|
std::string const& name) const
|
|
|
|
{
|
|
|
|
cmake const* cm = this->MakefileMap->GetCMakeInstance();
|
|
|
|
return cm->GetInstalledFile(name);
|
|
|
|
}
|
|
|
|
|
2010-11-13 19:56:36 +03:00
|
|
|
int cmCPackGenerator::PrepareGroupingKind()
|
|
|
|
{
|
2011-03-25 19:18:59 +03:00
|
|
|
// find a component package method specified by the user
|
|
|
|
ComponentPackageMethod method = UNKNOWN_COMPONENT_PACKAGE_METHOD;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetOption("CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE")) {
|
2011-03-25 19:18:59 +03:00
|
|
|
method = ONE_PACKAGE;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-25 19:18:59 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetOption("CPACK_COMPONENTS_IGNORE_GROUPS")) {
|
2011-03-25 19:18:59 +03:00
|
|
|
method = ONE_PACKAGE_PER_COMPONENT;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-25 19:18:59 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetOption("CPACK_COMPONENTS_ONE_PACKAGE_PER_GROUP")) {
|
2011-03-25 19:18:59 +03:00
|
|
|
method = ONE_PACKAGE_PER_GROUP;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-11-13 19:56:36 +03:00
|
|
|
|
|
|
|
std::string groupingType;
|
|
|
|
|
|
|
|
// Second way to specify grouping
|
2016-06-27 23:44:16 +03:00
|
|
|
if (CM_NULLPTR != this->GetOption("CPACK_COMPONENTS_GROUPING")) {
|
2016-05-16 17:34:04 +03:00
|
|
|
groupingType = this->GetOption("CPACK_COMPONENTS_GROUPING");
|
2010-11-13 19:56:36 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!groupingType.empty()) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
|
|
|
|
<< this->Name << "]"
|
|
|
|
<< " requested component grouping = " << groupingType
|
|
|
|
<< std::endl);
|
|
|
|
if (groupingType == "ALL_COMPONENTS_IN_ONE") {
|
2011-03-25 19:18:59 +03:00
|
|
|
method = ONE_PACKAGE;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (groupingType == "IGNORE") {
|
2011-03-25 19:18:59 +03:00
|
|
|
method = ONE_PACKAGE_PER_COMPONENT;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (groupingType == "ONE_PER_GROUP") {
|
2011-03-25 19:18:59 +03:00
|
|
|
method = ONE_PACKAGE_PER_GROUP;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
cmCPackLogger(
|
|
|
|
cmCPackLog::LOG_WARNING, "["
|
2011-04-01 21:21:51 +04:00
|
|
|
<< this->Name << "]"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< " requested component grouping type <" << groupingType
|
2011-04-01 21:21:51 +04:00
|
|
|
<< "> UNKNOWN not in (ALL_COMPONENTS_IN_ONE,IGNORE,ONE_PER_GROUP)"
|
|
|
|
<< std::endl);
|
2010-11-13 19:56:36 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-11-13 19:56:36 +03:00
|
|
|
|
|
|
|
// Some components were defined but NO group
|
2011-03-25 19:18:59 +03:00
|
|
|
// fallback to default if not group based
|
2016-05-16 17:34:04 +03:00
|
|
|
if (method == ONE_PACKAGE_PER_GROUP && this->ComponentGroups.empty() &&
|
|
|
|
!this->Components.empty()) {
|
|
|
|
if (componentPackageMethod == ONE_PACKAGE) {
|
2011-03-25 19:18:59 +03:00
|
|
|
method = ONE_PACKAGE;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2011-03-25 19:18:59 +03:00
|
|
|
method = ONE_PACKAGE_PER_COMPONENT;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(
|
|
|
|
cmCPackLog::LOG_WARNING, "["
|
|
|
|
<< this->Name << "]"
|
|
|
|
<< " One package per component group requested, "
|
|
|
|
<< "but NO component groups exist: Ignoring component group."
|
|
|
|
<< std::endl);
|
|
|
|
}
|
2011-03-25 19:18:59 +03:00
|
|
|
|
|
|
|
// if user specified packaging method, override the default packaging method
|
2016-05-16 17:34:04 +03:00
|
|
|
if (method != UNKNOWN_COMPONENT_PACKAGE_METHOD) {
|
2011-03-25 19:18:59 +03:00
|
|
|
componentPackageMethod = method;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-03-25 19:18:59 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* method_names[] = { "ALL_COMPONENTS_IN_ONE", "IGNORE_GROUPS",
|
|
|
|
"ONE_PER_GROUP" };
|
2011-03-25 19:18:59 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
|
|
|
|
<< this->Name << "]"
|
|
|
|
<< " requested component grouping = "
|
|
|
|
<< method_names[componentPackageMethod] << std::endl);
|
2010-11-13 19:56:36 +03:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-02-06 23:23:10 +03:00
|
|
|
std::string cmCPackGenerator::GetComponentInstallDirNameSuffix(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& componentName)
|
|
|
|
{
|
2011-02-06 23:23:10 +03:00
|
|
|
return componentName;
|
|
|
|
}
|
2011-02-23 01:49:49 +03:00
|
|
|
std::string cmCPackGenerator::GetComponentPackageFileName(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& initialPackageFileName,
|
|
|
|
const std::string& groupOrComponentName, bool isGroupName)
|
|
|
|
{
|
2011-02-23 01:49:49 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* the default behavior is to use the
|
|
|
|
* component [group] name as a suffix
|
|
|
|
*/
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string suffix = "-" + groupOrComponentName;
|
2011-02-23 01:49:49 +03:00
|
|
|
/* check if we should use DISPLAY name */
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string dispNameVar = "CPACK_" + Name + "_USE_DISPLAY_NAME_IN_FILENAME";
|
|
|
|
if (IsOn(dispNameVar)) {
|
2011-02-23 01:49:49 +03:00
|
|
|
/* the component Group case */
|
2016-05-16 17:34:04 +03:00
|
|
|
if (isGroupName) {
|
|
|
|
std::string groupDispVar = "CPACK_COMPONENT_GROUP_" +
|
|
|
|
cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
|
2014-03-11 03:04:11 +04:00
|
|
|
const char* groupDispName = GetOption(groupDispVar);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (groupDispName) {
|
|
|
|
suffix = "-" + std::string(groupDispName);
|
2011-02-23 01:49:49 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-02-23 01:49:49 +03:00
|
|
|
/* the [single] component case */
|
2016-05-16 17:34:04 +03:00
|
|
|
else {
|
|
|
|
std::string dispVar = "CPACK_COMPONENT_" +
|
|
|
|
cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
|
|
|
|
const char* dispName = GetOption(dispVar);
|
|
|
|
if (dispName) {
|
|
|
|
suffix = "-" + std::string(dispName);
|
2011-02-23 01:49:49 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
}
|
2011-02-23 01:49:49 +03:00
|
|
|
return initialPackageFileName + suffix;
|
|
|
|
}
|
2011-02-06 23:23:10 +03:00
|
|
|
|
2012-05-14 22:26:15 +04:00
|
|
|
enum cmCPackGenerator::CPackSetDestdirSupport
|
|
|
|
cmCPackGenerator::SupportsSetDestdir() const
|
|
|
|
{
|
|
|
|
return cmCPackGenerator::SETDESTDIR_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
2012-05-15 01:29:42 +04:00
|
|
|
bool cmCPackGenerator::SupportsAbsoluteDestination() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-06-17 19:39:26 +04:00
|
|
|
bool cmCPackGenerator::SupportsComponentInstallation() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-03-18 23:21:35 +04:00
|
|
|
bool cmCPackGenerator::WantsComponentInstallation() const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
return (!IsOn("CPACK_MONOLITHIC_INSTALL") && SupportsComponentInstallation()
|
|
|
|
// check that we have at least one group or component
|
|
|
|
&& (!this->ComponentGroups.empty() || !this->Components.empty()));
|
2012-03-18 23:21:35 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackInstallationType* cmCPackGenerator::GetInstallationType(
|
|
|
|
const std::string& projectName, const std::string& name)
|
2008-06-17 19:39:26 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
(void)projectName;
|
2008-06-17 19:39:26 +04:00
|
|
|
bool hasInstallationType = this->InstallationTypes.count(name) != 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackInstallationType* installType = &this->InstallationTypes[name];
|
|
|
|
if (!hasInstallationType) {
|
2008-06-17 19:39:26 +04:00
|
|
|
// Define the installation type
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string macroPrefix =
|
|
|
|
"CPACK_INSTALL_TYPE_" + cmsys::SystemTools::UpperCase(name);
|
2008-06-17 19:39:26 +04:00
|
|
|
installType->Name = name;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME");
|
|
|
|
if (displayName && *displayName) {
|
2008-06-17 19:39:26 +04:00
|
|
|
installType->DisplayName = displayName;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-06-17 19:39:26 +04:00
|
|
|
installType->DisplayName = installType->Name;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
|
|
|
|
installType->Index = static_cast<unsigned>(this->InstallationTypes.size());
|
|
|
|
}
|
2008-06-17 19:39:26 +04:00
|
|
|
return installType;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackComponent* cmCPackGenerator::GetComponent(
|
|
|
|
const std::string& projectName, const std::string& name)
|
2008-06-17 19:39:26 +04:00
|
|
|
{
|
|
|
|
bool hasComponent = this->Components.count(name) != 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackComponent* component = &this->Components[name];
|
|
|
|
if (!hasComponent) {
|
2008-06-17 19:39:26 +04:00
|
|
|
// Define the component
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string macroPrefix =
|
|
|
|
"CPACK_COMPONENT_" + cmsys::SystemTools::UpperCase(name);
|
2008-06-17 19:39:26 +04:00
|
|
|
component->Name = name;
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME");
|
|
|
|
if (displayName && *displayName) {
|
2008-06-17 19:39:26 +04:00
|
|
|
component->DisplayName = displayName;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-06-17 19:39:26 +04:00
|
|
|
component->DisplayName = component->Name;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
component->IsHidden = this->IsOn(macroPrefix + "_HIDDEN");
|
|
|
|
component->IsRequired = this->IsOn(macroPrefix + "_REQUIRED");
|
|
|
|
component->IsDisabledByDefault = this->IsOn(macroPrefix + "_DISABLED");
|
|
|
|
component->IsDownloaded = this->IsOn(macroPrefix + "_DOWNLOADED") ||
|
|
|
|
cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL"));
|
|
|
|
|
|
|
|
const char* archiveFile = this->GetOption(macroPrefix + "_ARCHIVE_FILE");
|
|
|
|
if (archiveFile && *archiveFile) {
|
2008-07-08 19:52:25 +04:00
|
|
|
component->ArchiveFile = archiveFile;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-07-08 19:52:25 +04:00
|
|
|
|
2014-03-11 03:04:11 +04:00
|
|
|
const char* groupName = this->GetOption(macroPrefix + "_GROUP");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (groupName && *groupName) {
|
2008-06-17 19:39:26 +04:00
|
|
|
component->Group = GetComponentGroup(projectName, groupName);
|
|
|
|
component->Group->Components.push_back(component);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2016-06-27 23:44:16 +03:00
|
|
|
component->Group = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-06-17 19:39:26 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* description = this->GetOption(macroPrefix + "_DESCRIPTION");
|
|
|
|
if (description && *description) {
|
2008-06-17 19:39:26 +04:00
|
|
|
component->Description = description;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-06-17 19:39:26 +04:00
|
|
|
|
|
|
|
// Determine the installation types.
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* installTypes = this->GetOption(macroPrefix + "_INSTALL_TYPES");
|
|
|
|
if (installTypes && *installTypes) {
|
2008-06-17 19:39:26 +04:00
|
|
|
std::vector<std::string> installTypesVector;
|
|
|
|
cmSystemTools::ExpandListArgument(installTypes, installTypesVector);
|
|
|
|
std::vector<std::string>::iterator installTypesIt;
|
2012-08-13 21:42:58 +04:00
|
|
|
for (installTypesIt = installTypesVector.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
installTypesIt != installTypesVector.end(); ++installTypesIt) {
|
2008-06-17 19:39:26 +04:00
|
|
|
component->InstallationTypes.push_back(
|
2014-02-04 06:04:22 +04:00
|
|
|
this->GetInstallationType(projectName, *installTypesIt));
|
2008-06-17 19:39:26 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-06-17 19:39:26 +04:00
|
|
|
|
|
|
|
// Determine the component dependencies.
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* depends = this->GetOption(macroPrefix + "_DEPENDS");
|
|
|
|
if (depends && *depends) {
|
2008-06-17 19:39:26 +04:00
|
|
|
std::vector<std::string> dependsVector;
|
|
|
|
cmSystemTools::ExpandListArgument(depends, dependsVector);
|
|
|
|
std::vector<std::string>::iterator dependIt;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (dependIt = dependsVector.begin(); dependIt != dependsVector.end();
|
|
|
|
++dependIt) {
|
|
|
|
cmCPackComponent* child = GetComponent(projectName, *dependIt);
|
2008-06-17 19:39:26 +04:00
|
|
|
component->Dependencies.push_back(child);
|
|
|
|
child->ReverseDependencies.push_back(component);
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-06-17 19:39:26 +04:00
|
|
|
return component;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackComponentGroup* cmCPackGenerator::GetComponentGroup(
|
|
|
|
const std::string& projectName, const std::string& name)
|
2008-06-17 19:39:26 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
(void)projectName;
|
|
|
|
std::string macroPrefix =
|
|
|
|
"CPACK_COMPONENT_GROUP_" + cmsys::SystemTools::UpperCase(name);
|
2008-06-17 19:39:26 +04:00
|
|
|
bool hasGroup = this->ComponentGroups.count(name) != 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackComponentGroup* group = &this->ComponentGroups[name];
|
|
|
|
if (!hasGroup) {
|
2008-06-17 19:39:26 +04:00
|
|
|
// Define the group
|
|
|
|
group->Name = name;
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* displayName = this->GetOption(macroPrefix + "_DISPLAY_NAME");
|
|
|
|
if (displayName && *displayName) {
|
2008-06-17 19:39:26 +04:00
|
|
|
group->DisplayName = displayName;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-06-17 19:39:26 +04:00
|
|
|
group->DisplayName = group->Name;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-06-17 19:39:26 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* description = this->GetOption(macroPrefix + "_DESCRIPTION");
|
|
|
|
if (description && *description) {
|
2008-06-17 19:39:26 +04:00
|
|
|
group->Description = description;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
group->IsBold = this->IsOn(macroPrefix + "_BOLD_TITLE");
|
|
|
|
group->IsExpandedByDefault = this->IsOn(macroPrefix + "_EXPANDED");
|
|
|
|
const char* parentGroupName =
|
|
|
|
this->GetOption(macroPrefix + "_PARENT_GROUP");
|
|
|
|
if (parentGroupName && *parentGroupName) {
|
2008-07-08 19:52:25 +04:00
|
|
|
group->ParentGroup = GetComponentGroup(projectName, parentGroupName);
|
|
|
|
group->ParentGroup->Subgroups.push_back(group);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2016-06-27 23:44:16 +03:00
|
|
|
group->ParentGroup = CM_NULLPTR;
|
2008-06-17 19:39:26 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-06-17 19:39:26 +04:00
|
|
|
return group;
|
|
|
|
}
|