CPack Backward-compatibly enforce DESTDIR for DEB and RPM
This commit is contained in:
parent
b718597b8b
commit
40dc97dc73
|
@ -43,7 +43,10 @@ cmCPackDebGenerator::~cmCPackDebGenerator()
|
||||||
int cmCPackDebGenerator::InitializeInternal()
|
int cmCPackDebGenerator::InitializeInternal()
|
||||||
{
|
{
|
||||||
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
|
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
|
||||||
|
if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR")))
|
||||||
|
{
|
||||||
|
this->SetOption("CPACK_SET_DESTDIR", "I_ON");
|
||||||
|
}
|
||||||
return this->Superclass::InitializeInternal();
|
return this->Superclass::InitializeInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,8 @@ int cmCPackGenerator::InstallProject()
|
||||||
std::string bareTempInstallDirectory
|
std::string bareTempInstallDirectory
|
||||||
= this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
|
= this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
|
||||||
std::string tempInstallDirectoryStr = bareTempInstallDirectory;
|
std::string tempInstallDirectoryStr = bareTempInstallDirectory;
|
||||||
bool setDestDir = cmSystemTools::IsOn(this->GetOption("CPACK_SET_DESTDIR"));
|
bool setDestDir = cmSystemTools::IsOn(this->GetOption("CPACK_SET_DESTDIR"))
|
||||||
|
| cmSystemTools::IsInternallyOn(this->GetOption("CPACK_SET_DESTDIR"));
|
||||||
if (!setDestDir)
|
if (!setDestDir)
|
||||||
{
|
{
|
||||||
tempInstallDirectoryStr += this->GetPackagingInstallPrefix();
|
tempInstallDirectoryStr += this->GetPackagingInstallPrefix();
|
||||||
|
@ -414,6 +415,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript(
|
||||||
// underneath the tempInstallDirectory. The value of the project's
|
// underneath the tempInstallDirectory. The value of the project's
|
||||||
// CMAKE_INSTALL_PREFIX is sent in here as the value of the
|
// CMAKE_INSTALL_PREFIX is sent in here as the value of the
|
||||||
// CPACK_INSTALL_PREFIX variable.
|
// CPACK_INSTALL_PREFIX variable.
|
||||||
|
|
||||||
std::string dir;
|
std::string dir;
|
||||||
if (this->GetOption("CPACK_INSTALL_PREFIX"))
|
if (this->GetOption("CPACK_INSTALL_PREFIX"))
|
||||||
{
|
{
|
||||||
|
@ -643,6 +645,16 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
|
||||||
// value of the project's CMAKE_INSTALL_PREFIX is sent in here as
|
// value of the project's CMAKE_INSTALL_PREFIX is sent in here as
|
||||||
// the value of the CPACK_INSTALL_PREFIX variable.
|
// the value of the CPACK_INSTALL_PREFIX variable.
|
||||||
//
|
//
|
||||||
|
// If DESTDIR has been 'internally set ON' this means that
|
||||||
|
// the underlying CPack specific generator did ask for that
|
||||||
|
// In this case we may overrode CPACK_INSTALL_PREFIX with
|
||||||
|
// CPACK_PACKAGING_INSTALL_PREFIX
|
||||||
|
// I know this is tricky and awkward but it's the price for
|
||||||
|
// CPACK_SET_DESTDIR backward compatibility.
|
||||||
|
if (cmSystemTools::IsInternallyOn(this->GetOption("CPACK_SET_DESTDIR")))
|
||||||
|
{
|
||||||
|
this->SetOption("CPACK_INSTALL_PREFIX",this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"));
|
||||||
|
}
|
||||||
std::string dir;
|
std::string dir;
|
||||||
if (this->GetOption("CPACK_INSTALL_PREFIX"))
|
if (this->GetOption("CPACK_INSTALL_PREFIX"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
============================================================================*/
|
============================================================================*/
|
||||||
#include "cmCPackRPMGenerator.h"
|
#include "cmCPackRPMGenerator.h"
|
||||||
#include "cmCPackLog.h"
|
#include "cmCPackLog.h"
|
||||||
|
#include "cmSystemTools.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
cmCPackRPMGenerator::cmCPackRPMGenerator()
|
cmCPackRPMGenerator::cmCPackRPMGenerator()
|
||||||
|
@ -26,7 +27,10 @@ cmCPackRPMGenerator::~cmCPackRPMGenerator()
|
||||||
int cmCPackRPMGenerator::InitializeInternal()
|
int cmCPackRPMGenerator::InitializeInternal()
|
||||||
{
|
{
|
||||||
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
|
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
|
||||||
|
if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR")))
|
||||||
|
{
|
||||||
|
this->SetOption("CPACK_SET_DESTDIR", "I_ON");
|
||||||
|
}
|
||||||
return this->Superclass::InitializeInternal();
|
return this->Superclass::InitializeInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -283,6 +283,21 @@ void cmSystemTools::ReportLastSystemError(const char* msg)
|
||||||
cmSystemTools::Error(m.c_str());
|
cmSystemTools::Error(m.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cmSystemTools::IsInternallyOn(const char* val)
|
||||||
|
{
|
||||||
|
if (!val)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
std::basic_string<char> v = val;
|
||||||
|
|
||||||
|
for(std::basic_string<char>::iterator c = v.begin();
|
||||||
|
c != v.end(); c++)
|
||||||
|
{
|
||||||
|
*c = static_cast<char>(toupper(*c));
|
||||||
|
}
|
||||||
|
return (v == "I_ON" || v == "i_on");
|
||||||
|
}
|
||||||
|
|
||||||
bool cmSystemTools::IsOn(const char* val)
|
bool cmSystemTools::IsOn(const char* val)
|
||||||
{
|
{
|
||||||
|
|
|
@ -103,6 +103,12 @@ public:
|
||||||
cmSystemTools::s_ErrorOccured = false;
|
cmSystemTools::s_ErrorOccured = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does a string indicates that CMake/CPack/CTest internally
|
||||||
|
* forced this value. This is not the same as On, but this
|
||||||
|
* may be considered as "internally switched on".
|
||||||
|
*/
|
||||||
|
static bool IsInternallyOn(const char* val);
|
||||||
/**
|
/**
|
||||||
* does a string indicate a true or on value ? This is not the same
|
* does a string indicate a true or on value ? This is not the same
|
||||||
* as ifdef.
|
* as ifdef.
|
||||||
|
|
Loading…
Reference in New Issue