diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2006-04-15 17:02:18 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2006-04-15 17:02:18 (GMT) |
commit | c09c3c6bfadb41bd0b43082642ce76abbf02df06 (patch) | |
tree | d0aa5a228f589eddd9f75e0a980d8cf228326731 /Source | |
parent | 1df8e12c42a0ba6228059f456849010db5695ec3 (diff) | |
download | CMake-c09c3c6bfadb41bd0b43082642ce76abbf02df06.zip CMake-c09c3c6bfadb41bd0b43082642ce76abbf02df06.tar.gz CMake-c09c3c6bfadb41bd0b43082642ce76abbf02df06.tar.bz2 |
ENH: Support for packaging source, several cleanups and more yeehaa...
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CPack/cmCPackGenericGenerator.cxx | 77 | ||||
-rw-r--r-- | Source/CPack/cmCPackGenericGenerator.h | 4 | ||||
-rw-r--r-- | Source/CPack/cmCPackNSISGenerator.cxx | 13 | ||||
-rw-r--r-- | Source/CPack/cmCPackNSISGenerator.h | 6 | ||||
-rw-r--r-- | Source/CPack/cmCPackPackageMakerGenerator.cxx | 9 | ||||
-rw-r--r-- | Source/CPack/cmCPackPackageMakerGenerator.h | 6 | ||||
-rw-r--r-- | Source/CPack/cmCPackSTGZGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/CPack/cmCPackSTGZGenerator.h | 1 | ||||
-rw-r--r-- | Source/CPack/cmCPackTGZGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/CPack/cmCPackTGZGenerator.h | 1 | ||||
-rw-r--r-- | Source/CPack/cmCPackZIPGenerator.cxx | 16 | ||||
-rw-r--r-- | Source/CPack/cmCPackZIPGenerator.h | 5 |
12 files changed, 109 insertions, 43 deletions
diff --git a/Source/CPack/cmCPackGenericGenerator.cxx b/Source/CPack/cmCPackGenericGenerator.cxx index a26f1e2..7d7975e 100644 --- a/Source/CPack/cmCPackGenericGenerator.cxx +++ b/Source/CPack/cmCPackGenericGenerator.cxx @@ -48,6 +48,12 @@ int cmCPackGenericGenerator::PrepareNames() this->SetOption("CPACK_GENERATOR", this->Name.c_str()); std::string tempDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY"); tempDirectory += "/_CPack_Packages/"; + const char* toplevelTag = this->GetOption("CPACK_TOPLEVEL_TAG"); + if ( toplevelTag ) + { + tempDirectory += toplevelTag; + tempDirectory += "/"; + } tempDirectory += this->GetOption("CPACK_GENERATOR"); std::string topDirectory = tempDirectory; @@ -120,6 +126,22 @@ int cmCPackGenericGenerator::PrepareNames() int cmCPackGenericGenerator::InstallProject() { cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Install projects" << std::endl); + std::vector<cmsys::RegularExpression> ignoreFilesRegex; + const char* cpackIgnoreFiles = this->GetOption("CPACK_IGNORE_FILES"); + if ( cpackIgnoreFiles ) + { + std::vector<std::string> ignoreFilesRegexString; + cmSystemTools::ExpandListArgument(cpackIgnoreFiles,ignoreFilesRegexString); + std::vector<std::string>::iterator it; + for ( it = ignoreFilesRegexString.begin(); + it != ignoreFilesRegexString.end(); + ++it ) + { + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "Create ignore files regex for: " << it->c_str() << std::endl); + ignoreFilesRegex.push_back(it->c_str()); + } + } const char* tempInstallDirectory = this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY"); int res = 1; @@ -143,7 +165,7 @@ int cmCPackGenericGenerator::InstallProject() cmSystemTools::PutEnv(destDir.c_str()); } const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS"); - if ( installCommands ) + if ( installCommands && *installCommands ) { std::vector<std::string> installCommandsVector; cmSystemTools::ExpandListArgument(installCommands,installCommandsVector); @@ -177,7 +199,7 @@ int cmCPackGenericGenerator::InstallProject() } const char* installDirectories = this->GetOption("CPACK_INSTALLED_DIRECTORIES"); - if ( installDirectories ) + if ( installDirectories && *installDirectories ) { std::vector<std::string> installDirectoriesVector; cmSystemTools::ExpandListArgument(installDirectories, @@ -203,6 +225,8 @@ int cmCPackGenericGenerator::InstallProject() std::string subdir = it->c_str(); std::string findExpr = toplevel; findExpr += "/*"; + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- Install directory: " << toplevel << std::endl); gl.RecurseOn(); if ( !gl.FindFiles(findExpr) ) { @@ -212,12 +236,29 @@ int cmCPackGenericGenerator::InstallProject() } std::vector<std::string>& files = gl.GetFiles(); std::vector<std::string>::iterator gfit; + std::vector<cmsys::RegularExpression>::iterator regIt; for ( gfit = files.begin(); gfit != files.end(); ++ gfit ) { + bool skip = false; + std::string &inFile = *gfit; + for ( regIt= ignoreFilesRegex.begin(); + regIt!= ignoreFilesRegex.end(); + ++ regIt) + { + if ( regIt->find(inFile.c_str()) ) + { + cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Ignore file: " + << inFile.c_str() << std::endl); + skip = true; + } + } + if ( skip ) + { + continue; + } std::string filePath = tempDir; filePath += "/" + subdir + "/" + cmSystemTools::RelativePath(toplevel.c_str(), gfit->c_str()); - std::string &inFile = *gfit; cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: " << inFile.c_str() << " -> " << filePath.c_str() << std::endl); if ( !cmSystemTools::CopyFileIfDifferent(inFile.c_str(), @@ -234,7 +275,7 @@ int cmCPackGenericGenerator::InstallProject() = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS"); const char* cmakeGenerator = this->GetOption("CPACK_CMAKE_GENERATOR"); - if ( cmakeProjects ) + if ( cmakeProjects && *cmakeProjects ) { if ( !cmakeGenerator ) { @@ -324,6 +365,11 @@ int cmCPackGenericGenerator::InstallProject() std::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator()); lg->SetGlobalGenerator(&gg); cmMakefile *mf = lg->GetMakefile(); + std::string realInstallDirectory = tempInstallDirectory; + if ( !installSubDirectory.empty() && installSubDirectory != "/" ) + { + realInstallDirectory += installSubDirectory; + } if ( movable ) { mf->AddDefinition("CMAKE_INSTALL_PREFIX", tempInstallDirectory); @@ -332,6 +378,12 @@ int cmCPackGenericGenerator::InstallProject() { mf->AddDefinition("BUILD_TYPE", buildConfig); } + std::string installComponentLowerCase + = cmSystemTools::LowerCase(installComponent); + if ( installComponentLowerCase != "all" ) + { + mf->AddDefinition("CMAKE_INSTALL_COMPONENT", installComponent.c_str()); + } res = mf->ReadListFile(0, installFile.c_str()); if ( cmSystemTools::GetErrorOccuredFlag() ) @@ -384,6 +436,17 @@ int cmCPackGenericGenerator::InstallProject() } //---------------------------------------------------------------------- +void cmCPackGenericGenerator::SetOptionIfNotSet(const char* op, + const char* value) +{ + if ( this->MakefileMap->GetDefinition(op) ) + { + return; + } + this->SetOption(op, value); +} + +//---------------------------------------------------------------------- void cmCPackGenericGenerator::SetOption(const char* op, const char* value) { if ( !op ) @@ -473,6 +536,12 @@ int cmCPackGenericGenerator::Initialize(const char* name, cmMakefile* mf) { this->MakefileMap = mf; this->Name = name; + return this->InitializeInternal(); +} + +//---------------------------------------------------------------------- +int cmCPackGenericGenerator::InitializeInternal() +{ return 1; } diff --git a/Source/CPack/cmCPackGenericGenerator.h b/Source/CPack/cmCPackGenericGenerator.h index f553f31..40e8740 100644 --- a/Source/CPack/cmCPackGenericGenerator.h +++ b/Source/CPack/cmCPackGenericGenerator.h @@ -68,7 +68,7 @@ public: /** * Initialize generator */ - virtual int Initialize(const char* name, cmMakefile* mf); + int Initialize(const char* name, cmMakefile* mf); /** * Construct generator @@ -78,6 +78,7 @@ public: //! Set and get the options void SetOption(const char* op, const char* value); + void SetOptionIfNotSet(const char* op, const char* value); const char* GetOption(const char* op); //! Set all the variables @@ -99,6 +100,7 @@ protected: virtual std::string FindTemplate(const char* name); virtual bool ConfigureFile(const char* inName, const char* outName); + virtual int InitializeInternal(); bool GeneratorVerbose; std::string Name; diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index f4afea1..2f5363d 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -115,17 +115,14 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, } //---------------------------------------------------------------------- -int cmCPackNSISGenerator::Initialize(const char* name, cmMakefile* mf) +int cmCPackNSISGenerator::InitializeInternal() { - int res = this->Superclass::Initialize(name, mf); - if ( !res ) - { - return res; - } if ( cmSystemTools::IsOn(this->GetOption( "CPACK_INCLUDE_TOPLEVEL_DIRECTORY")) ) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "NSIS Generator cannot work with CPACK_INCLUDE_TOPLEVEL_DIRECTORY. This option will be ignored." + cmCPackLogger(cmCPackLog::LOG_ERROR, + "NSIS Generator cannot work with CPACK_INCLUDE_TOPLEVEL_DIRECTORY. " + "This option will be ignored." << std::endl); this->SetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", 0); } @@ -222,7 +219,7 @@ int cmCPackNSISGenerator::Initialize(const char* name, cmMakefile* mf) this->SetOption("CPACK_NSIS_DELETE_ICONS", deleteStr.str().c_str()); } - return res; + return this->Superclass::InitializeInternal(); } //---------------------------------------------------------------------- diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h index c22f979..db3fd67 100644 --- a/Source/CPack/cmCPackNSISGenerator.h +++ b/Source/CPack/cmCPackNSISGenerator.h @@ -32,17 +32,13 @@ public: cmCPackTypeMacro(cmCPackNSISGenerator, cmCPackGenericGenerator); /** - * Initialize generator - */ - virtual int Initialize(const char* name, cmMakefile* mf); - - /** * Construct generator */ cmCPackNSISGenerator(); virtual ~cmCPackNSISGenerator(); protected: + virtual int InitializeInternal(); int CompressFiles(const char* outFileName, const char* toplevel, const std::vector<std::string>& files); virtual const char* GetOutputExtension() { return "exe"; } diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index b667415..1d6cb35 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -137,13 +137,8 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, } //---------------------------------------------------------------------- -int cmCPackPackageMakerGenerator::Initialize(const char* name, cmMakefile* mf) +int cmCPackPackageMakerGenerator::InitializeInternal() { - int res = this->Superclass::Initialize(name, mf); - if ( !res ) - { - return res; - } cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackPackageMakerGenerator::Initialize()" << std::endl); std::vector<std::string> path; @@ -228,7 +223,7 @@ int cmCPackPackageMakerGenerator::Initialize(const char* name, cmMakefile* mf) } this->SetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE", pkgPath.c_str()); - return res; + return this->Superclass::InitializeInternal(); } //---------------------------------------------------------------------- diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h index 56bdbb74..b7881de 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.h +++ b/Source/CPack/cmCPackPackageMakerGenerator.h @@ -33,17 +33,13 @@ public: cmCPackTypeMacro(cmCPackPackageMakerGenerator, cmCPackGenericGenerator); /** - * Initialize generator - */ - virtual int Initialize(const char* name, cmMakefile* mf); - - /** * Construct generator */ cmCPackPackageMakerGenerator(); virtual ~cmCPackPackageMakerGenerator(); protected: + virtual int InitializeInternal(); int CompressFiles(const char* outFileName, const char* toplevel, const std::vector<std::string>& files); virtual const char* GetOutputExtension() { return "dmg"; } diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 96c4453..1ce9935 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -36,6 +36,13 @@ cmCPackSTGZGenerator::~cmCPackSTGZGenerator() } //---------------------------------------------------------------------- +int cmCPackSTGZGenerator::InitializeInternal() +{ + this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0"); + return this->Superclass::InitializeInternal(); +} + +//---------------------------------------------------------------------- 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 bf7dec8..050da9d 100644 --- a/Source/CPack/cmCPackSTGZGenerator.h +++ b/Source/CPack/cmCPackSTGZGenerator.h @@ -37,6 +37,7 @@ public: virtual ~cmCPackSTGZGenerator(); protected: + virtual int InitializeInternal(); int GenerateHeader(std::ostream* os); virtual const char* GetOutputExtension() { return "sh"; } }; diff --git a/Source/CPack/cmCPackTGZGenerator.cxx b/Source/CPack/cmCPackTGZGenerator.cxx index 4be3d43..1daaee9 100644 --- a/Source/CPack/cmCPackTGZGenerator.cxx +++ b/Source/CPack/cmCPackTGZGenerator.cxx @@ -179,6 +179,13 @@ int cmCPackTGZ_Data_Close(void *client_data) } //---------------------------------------------------------------------- +int cmCPackTGZGenerator::InitializeInternal() +{ + this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1"); + return this->Superclass::InitializeInternal(); +} + +//---------------------------------------------------------------------- int cmCPackTGZGenerator::CompressFiles(const char* outFileName, const char* toplevel, const std::vector<std::string>& files) { diff --git a/Source/CPack/cmCPackTGZGenerator.h b/Source/CPack/cmCPackTGZGenerator.h index a486a24..7dd5875 100644 --- a/Source/CPack/cmCPackTGZGenerator.h +++ b/Source/CPack/cmCPackTGZGenerator.h @@ -40,6 +40,7 @@ public: virtual ~cmCPackTGZGenerator(); protected: + virtual int InitializeInternal(); virtual int GenerateHeader(std::ostream* os); int CompressFiles(const char* outFileName, const char* toplevel, const std::vector<std::string>& files); diff --git a/Source/CPack/cmCPackZIPGenerator.cxx b/Source/CPack/cmCPackZIPGenerator.cxx index 0781991..8297cc4 100644 --- a/Source/CPack/cmCPackZIPGenerator.cxx +++ b/Source/CPack/cmCPackZIPGenerator.cxx @@ -38,13 +38,9 @@ cmCPackZIPGenerator::~cmCPackZIPGenerator() } //---------------------------------------------------------------------- -int cmCPackZIPGenerator::Initialize(const char* name, cmMakefile* mf) +int cmCPackZIPGenerator::InitializeInternal() { - int res = this->Superclass::Initialize(name, mf); - if ( !res ) - { - return res; - } + this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1"); std::vector<std::string> path; std::string pkgPath = "c:/Program Files/WinZip"; path.push_back(pkgPath); @@ -68,7 +64,8 @@ int cmCPackZIPGenerator::Initialize(const char* name, cmMakefile* mf) pkgPath = cmSystemTools::FindProgram("zip", path, false); if ( pkgPath.empty() ) { - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Cannot find unix ZIP" << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Cannot find unix ZIP" + << std::endl); } else { @@ -83,9 +80,10 @@ int cmCPackZIPGenerator::Initialize(const char* name, cmMakefile* mf) return 0; } this->SetOption("CPACK_INSTALLER_PROGRAM", pkgPath.c_str()); - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Found ZIP program: " << pkgPath.c_str() + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Found ZIP program: " + << pkgPath.c_str() << std::endl); - return 1; + return this->Superclass::InitializeInternal(); } //---------------------------------------------------------------------- diff --git a/Source/CPack/cmCPackZIPGenerator.h b/Source/CPack/cmCPackZIPGenerator.h index 2bb75fe..640ef24 100644 --- a/Source/CPack/cmCPackZIPGenerator.h +++ b/Source/CPack/cmCPackZIPGenerator.h @@ -32,10 +32,6 @@ public: cmCPackTypeMacro(cmCPackZIPGenerator, cmCPackGenericGenerator); /** - * Initialize generator - */ - virtual int Initialize(const char* name, cmMakefile* mf); - /** * Construct generator */ cmCPackZIPGenerator(); @@ -49,6 +45,7 @@ public: }; protected: + virtual int InitializeInternal(); int CompressFiles(const char* outFileName, const char* toplevel, const std::vector<std::string>& files); virtual const char* GetOutputExtension() { return "zip"; } |