CPack add easy possibility to warn about CPACK_SET_DESTDIR

CPackNSIS will only warn but sooner or later it should error out
This commit is contained in:
Eric NOULARD 2012-05-14 20:26:15 +02:00
parent 75c0304a9e
commit 6ba055bacd
4 changed files with 63 additions and 1 deletions

View File

@ -62,10 +62,31 @@ void cmCPackGenerator::DisplayVerboseOutput(const char* msg,
//----------------------------------------------------------------------
int cmCPackGenerator::PrepareNames()
{
{
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Create temp directory." << std::endl);
// checks CPACK_SET_DESTDIR support
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;
}
else if (SETDESTDIR_SHOULD_NOT_BE_USED==SupportsSetDestdir())
{
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);
}
}
std::string tempDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
tempDirectory += "/_CPack_Packages/";
const char* toplevelTag = this->GetOption("CPACK_TOPLEVEL_TAG");
@ -953,6 +974,8 @@ int cmCPackGenerator::DoPackage()
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"Create package using " << this->Name.c_str() << std::endl);
// Prepare CPack internal name and check
// values for many CPACK_xxx vars
if ( !this->PrepareNames() )
{
return 0;
@ -1430,6 +1453,13 @@ std::string cmCPackGenerator::GetComponentPackageFileName(
return initialPackageFileName + suffix;
}
//----------------------------------------------------------------------
enum cmCPackGenerator::CPackSetDestdirSupport
cmCPackGenerator::SupportsSetDestdir() const
{
return cmCPackGenerator::SETDESTDIR_SUPPORTED;
}
//----------------------------------------------------------------------
bool cmCPackGenerator::SupportsComponentInstallation() const
{

View File

@ -189,6 +189,29 @@ protected:
virtual int InstallProjectViaInstallCMakeProjects(
bool setDestDir, const char* tempInstallDirectory);
/**
* The various level of support of
* CPACK_SET_DESTDIR used by the generator.
*/
enum CPackSetDestdirSupport {
/* the generator works with or without it */
SETDESTDIR_SUPPORTED,
/* the generator works best if automatically handled */
SETDESTDIR_INTERNALLY_SUPPORTED,
/* no official support, use at your own risk */
SETDESTDIR_SHOULD_NOT_BE_USED,
/* officially NOT supported */
SETDESTDIR_UNSUPPORTED
};
/**
* Does the CPack generator support CPACK_SET_DESTDIR?
* The default legacy value is 'true' generator
* have to override it in order change this.
* @return CPackSetDestdirSupport
*/
virtual enum CPackSetDestdirSupport SupportsSetDestdir() const;
/**
* Does the CPack generator support component installation?.
* Some Generators requires the user to set

View File

@ -64,6 +64,7 @@ int cmCPackNSISGenerator::PackageFiles()
<< std::endl);
return false;
}
std::string nsisFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
std::string tmpFile = nsisFileName;
tmpFile += "/NSISOutput.log";
@ -630,6 +631,13 @@ bool cmCPackNSISGenerator::GetListOfSubdirectories(const char* topdir,
return true;
}
//----------------------------------------------------------------------
enum cmCPackGenerator::CPackSetDestdirSupport
cmCPackNSISGenerator::SupportsSetDestdir() const
{
return cmCPackGenerator::SETDESTDIR_SHOULD_NOT_BE_USED;
}
//----------------------------------------------------------------------
bool cmCPackNSISGenerator::SupportsComponentInstallation() const
{

View File

@ -44,6 +44,7 @@ protected:
bool GetListOfSubdirectories(const char* dir,
std::vector<std::string>& dirs);
enum cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir() const;
virtual bool SupportsComponentInstallation() const;
/// Produce a string that contains the NSIS code to describe a