BUG: Fix issue #8383. Avoid crashing when using the Bundle CPack generator and CPACK_BUNDLE_NAME is not set. Instead, fail gracefully giving an informative error message and non-zero exit code.

This commit is contained in:
David Cole 2009-01-22 13:56:13 -05:00
parent c332e0bf3c
commit 6bf31875ce
4 changed files with 28 additions and 0 deletions

View File

@ -31,6 +31,22 @@ cmCPackBundleGenerator::~cmCPackBundleGenerator()
{
}
//----------------------------------------------------------------------
int cmCPackBundleGenerator::InitializeInternal()
{
const char* name = this->GetOption("CPACK_BUNDLE_NAME");
if(0 == name)
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPACK_BUNDLE_NAME must be set to use the Bundle generator."
<< std::endl);
return 0;
}
return this->Superclass::InitializeInternal();
}
//----------------------------------------------------------------------
const char* cmCPackBundleGenerator::GetPackagingInstallPrefix()
{

View File

@ -34,6 +34,7 @@ public:
virtual ~cmCPackBundleGenerator();
protected:
virtual int InitializeInternal();
virtual const char* GetPackagingInstallPrefix();
int CompressFiles(const char* outFileName, const char* toplevel,
const std::vector<std::string>& files);

View File

@ -18,6 +18,7 @@
#include "cmCPackLog.h"
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
//----------------------------------------------------------------------
cmCPackLog::cmCPackLog()
@ -221,4 +222,9 @@ void cmCPackLog::Log(int tag, const char* file, int line,
{
this->NewLine = true;
}
if ( error )
{
cmSystemTools::SetErrorOccured();
}
}

View File

@ -474,5 +474,10 @@ int main (int argc, char *argv[])
#define cout no_cout_use_cmCPack_Log
}
if (cmSystemTools::GetErrorOccuredFlag())
{
return 1;
}
return 0;
}