From 6bf31875ce3a87078ba3e90ce2e8cde44d561d86 Mon Sep 17 00:00:00 2001 From: David Cole Date: Thu, 22 Jan 2009 13:56:13 -0500 Subject: 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. --- Source/CPack/cmCPackBundleGenerator.cxx | 16 ++++++++++++++++ Source/CPack/cmCPackBundleGenerator.h | 1 + Source/CPack/cmCPackLog.cxx | 6 ++++++ Source/CPack/cpack.cxx | 5 +++++ 4 files changed, 28 insertions(+) diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index d564308..62183e6 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -32,6 +32,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() { this->InstallPrefix = "/"; diff --git a/Source/CPack/cmCPackBundleGenerator.h b/Source/CPack/cmCPackBundleGenerator.h index 04c57b4..52c3c3a 100644 --- a/Source/CPack/cmCPackBundleGenerator.h +++ b/Source/CPack/cmCPackBundleGenerator.h @@ -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& files); diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx index 7b58039..82b990d 100644 --- a/Source/CPack/cmCPackLog.cxx +++ b/Source/CPack/cmCPackLog.cxx @@ -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(); + } } diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 330d61f..51001aa 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -474,5 +474,10 @@ int main (int argc, char *argv[]) #define cout no_cout_use_cmCPack_Log } + if (cmSystemTools::GetErrorOccuredFlag()) + { + return 1; + } + return 0; } -- cgit v0.12