CMake/Source/CPack/cmCPackGeneratorFactory.cxx

184 lines
5.5 KiB
C++
Raw Normal View History

/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
2006-01-02 04:21:05 +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
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"
#include "cmCPackTarBZip2Generator.h"
#include "cmCPackTarCompressGenerator.h"
#include "cmCPackZIPGenerator.h"
2006-01-02 04:21:05 +00:00
#include "cmCPackSTGZGenerator.h"
#include "cmCPackNSISGenerator.h"
#ifdef __APPLE__
# include "cmCPackDragNDropGenerator.h"
# include "cmCPackBundleGenerator.h"
# include "cmCPackPackageMakerGenerator.h"
# include "cmCPackOSXX11Generator.h"
#endif
2006-01-02 04:21:05 +00:00
#ifdef __CYGWIN__
# include "cmCPackCygwinBinaryGenerator.h"
# include "cmCPackCygwinSourceGenerator.h"
#endif
#if !defined(_WIN32) \
&& !defined(__QNXNTO__) && !defined(__BEOS__)
# include "cmCPackDebGenerator.h"
# include "cmCPackRPMGenerator.h"
#endif
2006-01-02 21:14:21 +00:00
#include "cmCPackLog.h"
#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
{
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);
}
#ifdef __CYGWIN__
if (cmCPackCygwinBinaryGenerator::CanGenerate())
{
this->RegisterGenerator("CygwinBinary", "Cygwin Binary Installer",
cmCPackCygwinBinaryGenerator::CreateGenerator);
}
if (cmCPackCygwinSourceGenerator::CanGenerate())
{
this->RegisterGenerator("CygwinSource", "Cygwin Source Installer",
cmCPackCygwinSourceGenerator::CreateGenerator);
}
#endif
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__
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
#if !defined(_WIN32) \
2007-07-26 12:40:51 +00:00
&& !defined(__QNXNTO__) && !defined(__BEOS__)
if (cmCPackDebGenerator::CanGenerate())
{
this->RegisterGenerator("DEB", "Debian packages",
cmCPackDebGenerator::CreateGenerator);
}
if (cmCPackRPMGenerator::CanGenerate())
{
this->RegisterGenerator("RPM", "RPM packages",
cmCPackRPMGenerator::CreateGenerator);
}
#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(
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,
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
}