summaryrefslogtreecommitdiffstats
path: root/Source/CPack/cmCPackGenericGenerator.cxx
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2006-04-15 17:02:18 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2006-04-15 17:02:18 (GMT)
commitc09c3c6bfadb41bd0b43082642ce76abbf02df06 (patch)
treed0aa5a228f589eddd9f75e0a980d8cf228326731 /Source/CPack/cmCPackGenericGenerator.cxx
parent1df8e12c42a0ba6228059f456849010db5695ec3 (diff)
downloadCMake-c09c3c6bfadb41bd0b43082642ce76abbf02df06.zip
CMake-c09c3c6bfadb41bd0b43082642ce76abbf02df06.tar.gz
CMake-c09c3c6bfadb41bd0b43082642ce76abbf02df06.tar.bz2
ENH: Support for packaging source, several cleanups and more yeehaa...
Diffstat (limited to 'Source/CPack/cmCPackGenericGenerator.cxx')
-rw-r--r--Source/CPack/cmCPackGenericGenerator.cxx77
1 files changed, 73 insertions, 4 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;
}