2009-09-28 15:43:28 +00:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2006-01-02 04:21:05 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2006-01-02 04:21:05 +00:00
|
|
|
|
2009-09-28 15:43:28 +00: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 04:21:05 +00:00
|
|
|
|
2007-11-05 21:33:19 +00:00
|
|
|
#include "cmCPackGeneratorFactory.h"
|
2006-01-02 04:21:05 +00:00
|
|
|
|
2007-11-05 21:55:45 +00:00
|
|
|
#include "cmCPackGenerator.h"
|
2006-01-02 04:21:05 +00:00
|
|
|
#include "cmCPackTGZGenerator.h"
|
2006-05-04 01:42:51 +00:00
|
|
|
#include "cmCPackTarBZip2Generator.h"
|
2006-05-02 21:07:16 +00:00
|
|
|
#include "cmCPackTarCompressGenerator.h"
|
2006-04-02 15:20:58 +00:00
|
|
|
#include "cmCPackZIPGenerator.h"
|
2006-01-02 04:21:05 +00:00
|
|
|
#include "cmCPackSTGZGenerator.h"
|
2007-06-18 13:00:33 +00:00
|
|
|
#include "cmCPackNSISGenerator.h"
|
2007-01-10 20:30:26 +00:00
|
|
|
#ifdef __APPLE__
|
2009-01-22 17:12:44 +00:00
|
|
|
# include "cmCPackDragNDropGenerator.h"
|
2008-06-18 13:53:29 +00:00
|
|
|
# include "cmCPackBundleGenerator.h"
|
2007-01-10 20:30:26 +00:00
|
|
|
# include "cmCPackPackageMakerGenerator.h"
|
|
|
|
# include "cmCPackOSXX11Generator.h"
|
|
|
|
#endif
|
2006-01-02 04:21:05 +00:00
|
|
|
|
2007-02-02 19:40:26 +00:00
|
|
|
#ifdef __CYGWIN__
|
|
|
|
# include "cmCPackCygwinBinaryGenerator.h"
|
|
|
|
# include "cmCPackCygwinSourceGenerator.h"
|
|
|
|
#endif
|
|
|
|
|
2012-03-30 15:07:06 +00:00
|
|
|
#if !defined(_WIN32) \
|
2007-07-25 14:57:33 +00:00
|
|
|
&& !defined(__QNXNTO__) && !defined(__BEOS__)
|
|
|
|
# include "cmCPackDebGenerator.h"
|
2007-08-08 15:33:42 +00:00
|
|
|
# include "cmCPackRPMGenerator.h"
|
2007-07-25 14:57:33 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-01-02 21:14:21 +00:00
|
|
|
#include "cmCPackLog.h"
|
|
|
|
|
2012-05-21 12:39:18 +00:00
|
|
|
#if defined(__BORLANDC__)
|
|
|
|
# pragma warn -8008 /* condition is always true */
|
|
|
|
#endif
|
|
|
|
|
2006-01-02 04:21:05 +00:00
|
|
|
//----------------------------------------------------------------------
|
2007-11-05 21:33:19 +00:00
|
|
|
cmCPackGeneratorFactory::cmCPackGeneratorFactory()
|
2006-01-02 04:21:05 +00:00
|
|
|
{
|
2012-03-30 15:07:06 +00:00
|
|
|
if (cmCPackTGZGenerator::CanGenerate())
|
|
|
|
{
|
|
|
|
this->RegisterGenerator("TGZ", "Tar GZip compression",
|
|
|
|
cmCPackTGZGenerator::CreateGenerator);
|
|
|
|
}
|
|
|
|
if (cmCPackSTGZGenerator::CanGenerate())
|
|
|
|
{
|
|
|
|
this->RegisterGenerator("STGZ", "Self extracting Tar GZip compression",
|
|
|
|
cmCPackSTGZGenerator::CreateGenerator);
|
|
|
|
}
|
|
|
|
if (cmCPackNSISGenerator::CanGenerate())
|
|
|
|
{
|
|
|
|
this->RegisterGenerator("NSIS", "Null Soft Installer",
|
|
|
|
cmCPackNSISGenerator::CreateGenerator);
|
|
|
|
}
|
2007-02-02 19:40:26 +00:00
|
|
|
#ifdef __CYGWIN__
|
2012-03-30 15:07:06 +00:00
|
|
|
if (cmCPackCygwinBinaryGenerator::CanGenerate())
|
|
|
|
{
|
|
|
|
this->RegisterGenerator("CygwinBinary", "Cygwin Binary Installer",
|
|
|
|
cmCPackCygwinBinaryGenerator::CreateGenerator);
|
|
|
|
}
|
|
|
|
if (cmCPackCygwinSourceGenerator::CanGenerate())
|
|
|
|
{
|
|
|
|
this->RegisterGenerator("CygwinSource", "Cygwin Source Installer",
|
|
|
|
cmCPackCygwinSourceGenerator::CreateGenerator);
|
|
|
|
}
|
2007-02-02 19:40:26 +00:00
|
|
|
#endif
|
|
|
|
|
2012-03-30 15:07:06 +00:00
|
|
|
if (cmCPackZIPGenerator::CanGenerate())
|
|
|
|
{
|
|
|
|
this->RegisterGenerator("ZIP", "ZIP file format",
|
|
|
|
cmCPackZIPGenerator::CreateGenerator);
|
|
|
|
}
|
|
|
|
if (cmCPackTarBZip2Generator::CanGenerate())
|
|
|
|
{
|
|
|
|
this->RegisterGenerator("TBZ2", "Tar BZip2 compression",
|
|
|
|
cmCPackTarBZip2Generator::CreateGenerator);
|
|
|
|
}
|
|
|
|
if (cmCPackTarCompressGenerator::CanGenerate())
|
|
|
|
{
|
|
|
|
this->RegisterGenerator("TZ", "Tar Compress compression",
|
|
|
|
cmCPackTarCompressGenerator::CreateGenerator);
|
|
|
|
}
|
2006-05-02 21:52:22 +00:00
|
|
|
#ifdef __APPLE__
|
2012-03-30 15:07:06 +00:00
|
|
|
if (cmCPackDragNDropGenerator::CanGenerate())
|
|
|
|
{
|
|
|
|
this->RegisterGenerator("DragNDrop", "Mac OSX Drag And Drop",
|
|
|
|
cmCPackDragNDropGenerator::CreateGenerator);
|
|
|
|
}
|
|
|
|
if (cmCPackBundleGenerator::CanGenerate())
|
|
|
|
{
|
|
|
|
this->RegisterGenerator("Bundle", "Mac OSX bundle",
|
|
|
|
cmCPackBundleGenerator::CreateGenerator);
|
|
|
|
}
|
|
|
|
if (cmCPackPackageMakerGenerator::CanGenerate())
|
|
|
|
{
|
|
|
|
this->RegisterGenerator("PackageMaker", "Mac OSX Package Maker installer",
|
|
|
|
cmCPackPackageMakerGenerator::CreateGenerator);
|
|
|
|
}
|
|
|
|
if (cmCPackOSXX11Generator::CanGenerate())
|
|
|
|
{
|
|
|
|
this->RegisterGenerator("OSXX11", "Mac OSX X11 bundle",
|
|
|
|
cmCPackOSXX11Generator::CreateGenerator);
|
|
|
|
}
|
2006-05-02 21:52:22 +00:00
|
|
|
#endif
|
2012-03-30 15:07:06 +00:00
|
|
|
#if !defined(_WIN32) \
|
2007-07-26 12:40:51 +00:00
|
|
|
&& !defined(__QNXNTO__) && !defined(__BEOS__)
|
2012-03-30 15:07:06 +00:00
|
|
|
if (cmCPackDebGenerator::CanGenerate())
|
|
|
|
{
|
|
|
|
this->RegisterGenerator("DEB", "Debian packages",
|
|
|
|
cmCPackDebGenerator::CreateGenerator);
|
|
|
|
}
|
|
|
|
if (cmCPackRPMGenerator::CanGenerate())
|
|
|
|
{
|
|
|
|
this->RegisterGenerator("RPM", "RPM packages",
|
|
|
|
cmCPackRPMGenerator::CreateGenerator);
|
|
|
|
}
|
2007-07-25 14:57:33 +00:00
|
|
|
#endif
|
2006-01-02 04:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2007-11-05 21:33:19 +00:00
|
|
|
cmCPackGeneratorFactory::~cmCPackGeneratorFactory()
|
2006-01-02 04:21:05 +00:00
|
|
|
{
|
2007-11-05 21:55:45 +00:00
|
|
|
std::vector<cmCPackGenerator*>::iterator it;
|
2006-03-10 18:06:26 +00:00
|
|
|
for ( it = this->Generators.begin(); it != this->Generators.end(); ++ it )
|
2006-01-02 04:21:05 +00:00
|
|
|
{
|
|
|
|
delete *it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2007-11-05 21:55:45 +00:00
|
|
|
cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(const char* name)
|
2006-01-02 04:21:05 +00:00
|
|
|
{
|
2007-11-05 21:55:45 +00:00
|
|
|
cmCPackGenerator* gen = this->NewGeneratorInternal(name);
|
2006-01-02 04:21:05 +00:00
|
|
|
if ( !gen )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2006-03-10 18:06:26 +00:00
|
|
|
this->Generators.push_back(gen);
|
|
|
|
gen->SetLogger(this->Logger);
|
2006-01-02 04:21:05 +00:00
|
|
|
return gen;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2007-11-05 21:55:45 +00:00
|
|
|
cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal(
|
2006-03-08 21:33:39 +00:00
|
|
|
const char* name)
|
2006-01-02 04:21:05 +00:00
|
|
|
{
|
|
|
|
if ( !name )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2007-11-05 21:33:19 +00:00
|
|
|
cmCPackGeneratorFactory::t_GeneratorCreatorsMap::iterator it
|
2006-03-10 18:06:26 +00:00
|
|
|
= this->GeneratorCreators.find(name);
|
|
|
|
if ( it == this->GeneratorCreators.end() )
|
2006-01-02 04:21:05 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return (it->second)();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2007-11-05 21:33:19 +00:00
|
|
|
void cmCPackGeneratorFactory::RegisterGenerator(const char* name,
|
2006-05-02 21:52:22 +00:00
|
|
|
const char* generatorDescription,
|
2006-03-08 21:33:39 +00:00
|
|
|
CreateGeneratorCall* createGenerator)
|
2006-01-02 04:21:05 +00:00
|
|
|
{
|
|
|
|
if ( !name || !createGenerator )
|
|
|
|
{
|
2006-03-10 18:06:26 +00:00
|
|
|
cmCPack_Log(this->Logger, cmCPackLog::LOG_ERROR,
|
|
|
|
"Cannot register generator" << std::endl);
|
2006-01-02 04:21:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-03-10 18:06:26 +00:00
|
|
|
this->GeneratorCreators[name] = createGenerator;
|
2006-05-02 21:52:22 +00:00
|
|
|
this->GeneratorDescriptions[name] = generatorDescription;
|
2006-01-02 04:21:05 +00:00
|
|
|
}
|