summaryrefslogtreecommitdiffstats
path: root/Source/CPack
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2006-01-02 22:28:20 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2006-01-02 22:28:20 (GMT)
commitebbe10193ff5f41c77f2e3cafae06f7c0f30c0c4 (patch)
treef6dca7a842541b94f8261aa250a23cb349c8d343 /Source/CPack
parentf00b344adac6ec59d5432311d3986a21582a62f9 (diff)
downloadCMake-ebbe10193ff5f41c77f2e3cafae06f7c0f30c0c4.zip
CMake-ebbe10193ff5f41c77f2e3cafae06f7c0f30c0c4.tar.gz
CMake-ebbe10193ff5f41c77f2e3cafae06f7c0f30c0c4.tar.bz2
ENH: Start working on CPack input file and cleanups
Diffstat (limited to 'Source/CPack')
-rw-r--r--Source/CPack/cmCPackGenerators.cxx5
-rw-r--r--Source/CPack/cmCPackGenericGenerator.cxx31
-rw-r--r--Source/CPack/cmCPackGenericGenerator.h8
-rw-r--r--Source/CPack/cmCPackNSISGenerator.cxx14
-rw-r--r--Source/CPack/cmCPackNSISGenerator.h7
-rw-r--r--Source/CPack/cmCPackPackageMakerGenerator.cxx10
-rw-r--r--Source/CPack/cmCPackPackageMakerGenerator.h7
-rw-r--r--Source/CPack/cmCPackSTGZGenerator.cxx12
-rw-r--r--Source/CPack/cmCPackSTGZGenerator.h10
-rw-r--r--Source/CPack/cmCPackTGZGenerator.cxx12
-rw-r--r--Source/CPack/cmCPackTGZGenerator.h11
-rw-r--r--Source/CPack/cpack.cxx72
12 files changed, 66 insertions, 133 deletions
diff --git a/Source/CPack/cmCPackGenerators.cxx b/Source/CPack/cmCPackGenerators.cxx
index 913686c..29fc10e 100644
--- a/Source/CPack/cmCPackGenerators.cxx
+++ b/Source/CPack/cmCPackGenerators.cxx
@@ -52,11 +52,6 @@ cmCPackGenericGenerator* cmCPackGenerators::NewGenerator(const char* name)
{
return 0;
}
- if ( !gen->Initialize(name) )
- {
- delete gen;
- return 0;
- }
m_Generators.push_back(gen);
gen->SetLogger(m_Logger);
return gen;
diff --git a/Source/CPack/cmCPackGenericGenerator.cxx b/Source/CPack/cmCPackGenericGenerator.cxx
index c6c76ed..7647144 100644
--- a/Source/CPack/cmCPackGenericGenerator.cxx
+++ b/Source/CPack/cmCPackGenericGenerator.cxx
@@ -17,11 +17,11 @@
#include "cmCPackGenericGenerator.h"
+#include "cmMakefile.h"
+#include "cmCPackLog.h"
#include "cmake.h"
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
-#include "cmMakefile.h"
-#include "cmCPackLog.h"
#include <cmsys/SystemTools.hxx>
#include <cmsys/Glob.hxx>
@@ -31,31 +31,13 @@
cmCPackGenericGenerator::cmCPackGenericGenerator()
{
m_GeneratorVerbose = false;
- m_GlobalGenerator = 0;
- m_LocalGenerator = 0;
m_MakefileMap = 0;
- m_CMakeInstance = 0;
m_Logger = 0;
}
//----------------------------------------------------------------------
cmCPackGenericGenerator::~cmCPackGenericGenerator()
{
- if ( m_GlobalGenerator )
- {
- delete m_GlobalGenerator;
- m_GlobalGenerator = 0;
- }
- if ( m_LocalGenerator )
- {
- delete m_LocalGenerator;
- m_LocalGenerator = 0;
- }
- if ( m_CMakeInstance )
- {
- delete m_CMakeInstance;
- m_CMakeInstance = 0;
- }
m_MakefileMap = 0;
}
@@ -258,14 +240,9 @@ int cmCPackGenericGenerator::ProcessGenerator()
}
//----------------------------------------------------------------------
-int cmCPackGenericGenerator::Initialize(const char* name)
+int cmCPackGenericGenerator::Initialize(const char* name, cmMakefile* mf)
{
- m_CMakeInstance = new cmake;
- m_CMakeInstance->AddCMakePaths(m_CMakeRoot.c_str());
- m_GlobalGenerator = new cmGlobalGenerator;
- m_GlobalGenerator->SetCMakeInstance(m_CMakeInstance);
- m_LocalGenerator = m_GlobalGenerator->CreateLocalGenerator();
- m_MakefileMap = m_LocalGenerator->GetMakefile();
+ m_MakefileMap = mf;
m_Name = name;
return 1;
}
diff --git a/Source/CPack/cmCPackGenericGenerator.h b/Source/CPack/cmCPackGenericGenerator.h
index 8ec0fb6..9e17364 100644
--- a/Source/CPack/cmCPackGenericGenerator.h
+++ b/Source/CPack/cmCPackGenericGenerator.h
@@ -43,9 +43,6 @@
#define cout no_cout_use_cmCPack_Log
class cmMakefile;
-class cmLocalGenerator;
-class cmGlobalGenerator;
-class cmake;
class cmCPackLog;
/** \class cmCPackGenericGenerator
@@ -70,7 +67,7 @@ public:
/**
* Initialize generator
*/
- virtual int Initialize(const char* name);
+ virtual int Initialize(const char* name, cmMakefile* mf);
/**
* Construct generator
@@ -114,10 +111,7 @@ protected:
cmCPackLog* m_Logger;
private:
- cmGlobalGenerator* m_GlobalGenerator;
- cmLocalGenerator* m_LocalGenerator;
cmMakefile* m_MakefileMap;
- cmake* m_CMakeInstance;
};
#endif
diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx
index 8dd31de..7706fbb 100644
--- a/Source/CPack/cmCPackNSISGenerator.cxx
+++ b/Source/CPack/cmCPackNSISGenerator.cxx
@@ -39,12 +39,6 @@ cmCPackNSISGenerator::~cmCPackNSISGenerator()
}
//----------------------------------------------------------------------
-int cmCPackNSISGenerator::ProcessGenerator()
-{
- return this->Superclass::ProcessGenerator();
-}
-
-//----------------------------------------------------------------------
int cmCPackNSISGenerator::CompressFiles(const char* outFileName, const char* toplevel,
const std::vector<std::string>& files)
{
@@ -84,10 +78,14 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, const char* top
}
//----------------------------------------------------------------------
-int cmCPackNSISGenerator::Initialize(const char* name)
+int cmCPackNSISGenerator::Initialize(const char* name, cmMakefile* mf)
{
+ int res = this->Superclass::Initialize(name, mf);
+ if ( !res )
+ {
+ return res;
+ }
cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackNSISGenerator::Initialize()" << std::endl);
- int res = this->Superclass::Initialize(name);
std::vector<std::string> path;
std::string nsisPath;
if ( !cmsys::SystemTools::ReadRegistryValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS",
diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h
index 9d91909..afa90f3 100644
--- a/Source/CPack/cmCPackNSISGenerator.h
+++ b/Source/CPack/cmCPackNSISGenerator.h
@@ -31,16 +31,11 @@ class cmCPackNSISGenerator : public cmCPackGenericGenerator
{
public:
cmCPackTypeMacro(cmCPackNSISGenerator, cmCPackGenericGenerator);
- /**
- * Do the actual processing. Subclass has to override it.
- * Return < 0 if error.
- */
- virtual int ProcessGenerator();
/**
* Initialize generator
*/
- virtual int Initialize(const char* name);
+ virtual int Initialize(const char* name, cmMakefile* mf);
/**
* Construct generator
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx
index 143e761..4e23d7c 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.cxx
+++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx
@@ -38,12 +38,6 @@ cmCPackPackageMakerGenerator::~cmCPackPackageMakerGenerator()
}
//----------------------------------------------------------------------
-int cmCPackPackageMakerGenerator::ProcessGenerator()
-{
- return this->Superclass::ProcessGenerator();
-}
-
-//----------------------------------------------------------------------
int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, const char* toplevel,
const std::vector<std::string>& files)
{
@@ -126,10 +120,10 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, const c
}
//----------------------------------------------------------------------
-int cmCPackPackageMakerGenerator::Initialize(const char* name)
+int cmCPackPackageMakerGenerator::Initialize(const char* name, cmMakefile* mf)
{
+ int res = this->Superclass::Initialize(name, mf);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackPackageMakerGenerator::Initialize()" << std::endl);
- int res = this->Superclass::Initialize(name);
std::vector<std::string> path;
std::string pkgPath = "/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS";
path.push_back(pkgPath);
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h
index a3f3465..acc44cb 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.h
+++ b/Source/CPack/cmCPackPackageMakerGenerator.h
@@ -31,16 +31,11 @@ class cmCPackPackageMakerGenerator : public cmCPackGenericGenerator
{
public:
cmCPackTypeMacro(cmCPackPackageMakerGenerator, cmCPackGenericGenerator);
- /**
- * Do the actual processing. Subclass has to override it.
- * Return < 0 if error.
- */
- virtual int ProcessGenerator();
/**
* Initialize generator
*/
- virtual int Initialize(const char* name);
+ virtual int Initialize(const char* name, cmMakefile* mf);
/**
* Construct generator
diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx
index 6987fa8..ca021a4 100644
--- a/Source/CPack/cmCPackSTGZGenerator.cxx
+++ b/Source/CPack/cmCPackSTGZGenerator.cxx
@@ -36,18 +36,6 @@ cmCPackSTGZGenerator::~cmCPackSTGZGenerator()
}
//----------------------------------------------------------------------
-int cmCPackSTGZGenerator::ProcessGenerator()
-{
- return this->Superclass::ProcessGenerator();
-}
-
-//----------------------------------------------------------------------
-int cmCPackSTGZGenerator::Initialize(const char* name)
-{
- return this->Superclass::Initialize(name);
-}
-
-//----------------------------------------------------------------------
int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
{
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Writing header" << std::endl);
diff --git a/Source/CPack/cmCPackSTGZGenerator.h b/Source/CPack/cmCPackSTGZGenerator.h
index e7dee02..5561552 100644
--- a/Source/CPack/cmCPackSTGZGenerator.h
+++ b/Source/CPack/cmCPackSTGZGenerator.h
@@ -29,16 +29,6 @@ class cmCPackSTGZGenerator : public cmCPackTGZGenerator
{
public:
cmCPackTypeMacro(cmCPackSTGZGenerator, cmCPackTGZGenerator);
- /**
- * Do the actual processing. Subclass has to override it.
- * Return < 0 if error.
- */
- virtual int ProcessGenerator();
-
- /**
- * Initialize generator
- */
- virtual int Initialize(const char* name);
/**
* Construct generator
diff --git a/Source/CPack/cmCPackTGZGenerator.cxx b/Source/CPack/cmCPackTGZGenerator.cxx
index d7ffd9a..d4d8d96 100644
--- a/Source/CPack/cmCPackTGZGenerator.cxx
+++ b/Source/CPack/cmCPackTGZGenerator.cxx
@@ -53,18 +53,6 @@ cmCPackTGZGenerator::~cmCPackTGZGenerator()
}
//----------------------------------------------------------------------
-int cmCPackTGZGenerator::ProcessGenerator()
-{
- return this->Superclass::ProcessGenerator();
-}
-
-//----------------------------------------------------------------------
-int cmCPackTGZGenerator::Initialize(const char* name)
-{
- return this->Superclass::Initialize(name);
-}
-
-//----------------------------------------------------------------------
class cmCPackTGZ_Data
{
public:
diff --git a/Source/CPack/cmCPackTGZGenerator.h b/Source/CPack/cmCPackTGZGenerator.h
index 1d2b028..81a0cdb 100644
--- a/Source/CPack/cmCPackTGZGenerator.h
+++ b/Source/CPack/cmCPackTGZGenerator.h
@@ -34,17 +34,6 @@ public:
cmCPackTypeMacro(cmCPackTGZGenerator, cmCPackGenericGenerator);
/**
- * Do the actual processing. Subclass has to override it.
- * Return < 0 if error.
- */
- virtual int ProcessGenerator();
-
- /**
- * Initialize generator
- */
- virtual int Initialize(const char* name);
-
- /**
* Construct generator
*/
cmCPackTGZGenerator();
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index 1fbb39b..41170f3 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -21,6 +21,10 @@
#include "cmDocumentation.h"
#include "cmCPackGenerators.h"
#include "cmCPackGenericGenerator.h"
+#include "cmake.h"
+#include "cmGlobalGenerator.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
#include "cmCPackLog.h"
@@ -129,6 +133,7 @@ int main (int argc, char *argv[])
log.SetErrorPrefix("CPack Error: ");
log.SetWarningPrefix("CPack Warning: ");
log.SetOutputPrefix("CPack: ");
+ log.SetVerbosePrefix("CPack Verbose: ");
int res = 0;
cmSystemTools::EnableMSVCDebugHook();
@@ -158,8 +163,7 @@ int main (int argc, char *argv[])
cpackDefinitions definitions;
definitions.m_Log = &log;
- cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory();
- cpackConfigFile += "/CPack.cmake";
+ cpackConfigFile = "";
cmDocumentation doc;
cmsys::CommandLineArguments arg;
@@ -203,6 +207,19 @@ int main (int argc, char *argv[])
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Read CPack config file: " << cpackConfigFile.c_str() << std::endl);
+ cmake cminst;
+ cmGlobalGenerator cmgg;
+ cmgg.SetCMakeInstance(&cminst);
+ cmLocalGenerator* cmlg = cmgg.CreateLocalGenerator();
+ cmMakefile* mf = cmlg->GetMakefile();
+
+ bool cpackConfigFileSpecified = true;
+ if ( cpackConfigFile.empty() )
+ {
+ cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory();
+ cpackConfigFile += "/CPack.cmake";
+ cpackConfigFileSpecified = false;
+ }
cmCPackGenerators generators;
generators.SetLogger(&log);
@@ -215,29 +232,55 @@ int main (int argc, char *argv[])
if ( parsed && !help )
{
- if ( generator.empty() )
+ if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) && !mf->ReadListFile(0, cpackConfigFile.c_str()) )
+ {
+ cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Problem reding CPack config file: \"" << cpackConfigFile.c_str() << "\"" << std::endl);
+ return 1;
+ }
+ else if ( cpackConfigFileSpecified )
+ {
+ cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Cannot find CPack config file: \"" << cpackConfigFile.c_str() << "\"" << std::endl);
+ return 1;
+ }
+
+ if ( !generator.empty() ) { mf->AddDefinition("CPACK_GENERATOR", generator.c_str()); }
+ if ( !cpackProjectName.empty() ) { mf->AddDefinition("CPACK_PROJECT_NAME", cpackProjectName.c_str()); }
+ if ( !cpackProjectVersion.empty() ) { mf->AddDefinition("CPACK_PROJECT_VERSION", cpackProjectVersion.c_str()); }
+ if ( !cpackProjectPatch.empty() ) { mf->AddDefinition("CPACK_PROJECT_VERSION_PATCH", cpackProjectPatch.c_str()); }
+ if ( !cpackProjectVendor.empty() ) { mf->AddDefinition("CPACK_PROJECT_VENDOR", cpackProjectVendor.c_str()); }
+ if ( !cpackProjectDirectory.empty() ) { mf->AddDefinition("CPACK_PROJECT_DIRECTORY", cpackProjectDirectory.c_str()); }
+ if ( !cpackBuildConfig.empty() ) { mf->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str()); }
+ cpackDefinitions::MapType::iterator cdit;
+ for ( cdit = definitions.m_Map.begin(); cdit != definitions.m_Map.end(); ++cdit )
+ {
+ cpackGenerator->SetOption(cdit->first.c_str(), cdit->second.c_str());
+ }
+
+ const char* gen = mf->GetDefinition("CPACK_GENERATOR");
+ if ( !gen )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack generator not specified" << std::endl);
parsed = 0;
}
- if ( parsed && cpackProjectName.empty() )
+ if ( parsed && !mf->GetDefinition("CPACK_PROJECT_NAME") )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack project name not specified" << std::endl);
parsed = 0;
}
- if ( parsed && cpackProjectVersion.empty() )
+ if ( parsed && !mf->GetDefinition("CPACK_PROJECT_VERSION"))
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack project version not specified" << std::endl);
parsed = 0;
}
if ( parsed )
{
- cpackGenerator = generators.NewGenerator(generator.c_str());
+ cpackGenerator = generators.NewGenerator(gen);
if ( !cpackGenerator )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Cannot initialize CPack generator: " << generator.c_str() << std::endl);
parsed = 0;
}
+ cpackGenerator->Initialize(gen, mf);
if ( parsed && !cpackGenerator->FindRunningCMake(argv[0]) )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Cannot initialize the generator" << std::endl);
@@ -274,22 +317,9 @@ int main (int argc, char *argv[])
cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str());
#endif
+ const char* projName = mf->GetDefinition("CPACK_PROJECT_NAME");
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: " << cpackGenerator->GetNameOfClass() << std::endl);
- cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: " << cpackProjectName.c_str() << std::endl);
- cpackGenerator->SetOption("CPACK_PROJECT_NAME", cpackProjectName.c_str());
- cpackGenerator->SetOption("CPACK_PROJECT_VERSION", cpackProjectVersion.c_str());
- cpackGenerator->SetOption("CPACK_PROJECT_VERSION_PATCH", cpackProjectPatch.c_str());
- cpackGenerator->SetOption("CPACK_PROJECT_VENDOR", cpackProjectVendor.c_str());
- cpackGenerator->SetOption("CPACK_PROJECT_DIRECTORY", cpackProjectDirectory.c_str());
- if ( !cpackBuildConfig.empty() )
- {
- cpackGenerator->SetOption("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
- }
- cpackDefinitions::MapType::iterator cdit;
- for ( cdit = definitions.m_Map.begin(); cdit != definitions.m_Map.end(); ++cdit )
- {
- cpackGenerator->SetOption(cdit->first.c_str(), cdit->second.c_str());
- }
+ cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: " << projName << std::endl);
res = cpackGenerator->ProcessGenerator();
if ( !res )