ENH: Several cleanups and support for multiple generators
This commit is contained in:
parent
fbdac25f81
commit
e36ae0fcb8
|
@ -92,13 +92,13 @@ cpack_check_file_exists("${CPACK_RESOURCE_FILE_WELCOME}" "welcome resource")
|
||||||
IF(NOT CPACK_GENERATOR)
|
IF(NOT CPACK_GENERATOR)
|
||||||
IF(UNIX)
|
IF(UNIX)
|
||||||
IF(APPLE)
|
IF(APPLE)
|
||||||
SET(CPACK_GENERATOR "PackageMaker")
|
SET(CPACK_GENERATOR "PackageMaker;STGZ;TGZ")
|
||||||
ELSE(APPLE)
|
ELSE(APPLE)
|
||||||
SET(CPACK_GENERATOR "STGZ")
|
SET(CPACK_GENERATOR "STGZ;TGZ;TZ")
|
||||||
ENDIF(APPLE)
|
ENDIF(APPLE)
|
||||||
SET(CPACK_SOURCE_GENERATOR "TGZ")
|
SET(CPACK_SOURCE_GENERATOR "TGZ;TZ")
|
||||||
ELSE(UNIX)
|
ELSE(UNIX)
|
||||||
SET(CPACK_GENERATOR "NSIS")
|
SET(CPACK_GENERATOR "NSIS;ZIP")
|
||||||
SET(CPACK_SOURCE_GENERATOR "ZIP")
|
SET(CPACK_SOURCE_GENERATOR "ZIP")
|
||||||
ENDIF(UNIX)
|
ENDIF(UNIX)
|
||||||
ENDIF(NOT CPACK_GENERATOR)
|
ENDIF(NOT CPACK_GENERATOR)
|
||||||
|
|
|
@ -142,6 +142,7 @@ int cmCPackGenericGenerator::PrepareNames()
|
||||||
{
|
{
|
||||||
this->SetOptionIfNotSet("CPACK_STRIP_COMMAND", pkgPath.c_str());
|
this->SetOptionIfNotSet("CPACK_STRIP_COMMAND", pkgPath.c_str());
|
||||||
}
|
}
|
||||||
|
this->SetOptionIfNotSet("CPACK_REMOVE_TOPLEVEL_DIRECTORY", "1");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -150,23 +151,6 @@ int cmCPackGenericGenerator::PrepareNames()
|
||||||
int cmCPackGenericGenerator::InstallProject()
|
int cmCPackGenericGenerator::InstallProject()
|
||||||
{
|
{
|
||||||
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Install projects" << std::endl);
|
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_VERBOSE,
|
|
||||||
"Create ignore files regex for: " << it->c_str() << std::endl);
|
|
||||||
ignoreFilesRegex.push_back(it->c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this->CleanTemporaryDirectory();
|
this->CleanTemporaryDirectory();
|
||||||
const char* tempInstallDirectory
|
const char* tempInstallDirectory
|
||||||
= this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
|
= this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
|
||||||
|
@ -178,6 +162,7 @@ int cmCPackGenericGenerator::InstallProject()
|
||||||
<< std::endl);
|
<< std::endl);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool movable = true;
|
bool movable = true;
|
||||||
if ( movable )
|
if ( movable )
|
||||||
{
|
{
|
||||||
|
@ -190,9 +175,80 @@ int cmCPackGenericGenerator::InstallProject()
|
||||||
destDir += tempInstallDirectory;
|
destDir += tempInstallDirectory;
|
||||||
cmSystemTools::PutEnv(destDir.c_str());
|
cmSystemTools::PutEnv(destDir.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the CPackConfig file sets CPACK_INSTALL_COMMANDS then run them
|
// If the CPackConfig file sets CPACK_INSTALL_COMMANDS then run them
|
||||||
// as listed
|
// as listed
|
||||||
|
if ( !this->InstallProjectViaInstallCommands(movable, tempInstallDirectory) )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the CPackConfig file sets CPACK_INSTALLED_DIRECTORIES
|
||||||
|
// then glob it and copy it to CPACK_TEMPORARY_DIRECTORY
|
||||||
|
// This is used in Source packageing
|
||||||
|
if ( !this->InstallProjectViaInstalledDirectories(movable, tempInstallDirectory) )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// If the project is a CMAKE project then run pre-install
|
||||||
|
// and then read the cmake_install script to run it
|
||||||
|
if ( !this->InstallProjectViaInstallCMakeProjects(movable, tempInstallDirectory) )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !movable )
|
||||||
|
{
|
||||||
|
cmSystemTools::PutEnv("DESTDIR=");
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* stripExecutable = this->GetOption("CPACK_STRIP_COMMAND");
|
||||||
|
const char* stripFiles
|
||||||
|
= this->GetOption("CPACK_STRIP_FILES");
|
||||||
|
if ( stripFiles && *stripFiles && stripExecutable && *stripExecutable )
|
||||||
|
{
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Strip files" << std::endl);
|
||||||
|
std::vector<std::string> stripFilesVector;
|
||||||
|
cmSystemTools::ExpandListArgument(stripFiles,
|
||||||
|
stripFilesVector);
|
||||||
|
std::vector<std::string>::iterator it;
|
||||||
|
for ( it = stripFilesVector.begin();
|
||||||
|
it != stripFilesVector.end();
|
||||||
|
++it )
|
||||||
|
{
|
||||||
|
std::string fileName = tempInstallDirectory;
|
||||||
|
fileName += "/" + *it;
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
|
||||||
|
" Strip file: " << fileName.c_str()
|
||||||
|
<< std::endl);
|
||||||
|
std::string stripCommand = stripExecutable;
|
||||||
|
stripCommand += " \"";
|
||||||
|
stripCommand += fileName + "\"";
|
||||||
|
int retVal = 1;
|
||||||
|
std::string output;
|
||||||
|
bool resB =
|
||||||
|
cmSystemTools::RunSingleCommand(stripCommand.c_str(), &output,
|
||||||
|
&retVal, 0,
|
||||||
|
this->GeneratorVerbose, 0);
|
||||||
|
if ( !resB || retVal )
|
||||||
|
{
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
|
"Problem running install command: " << stripCommand.c_str()
|
||||||
|
<< std::endl
|
||||||
|
<< "Error was: \"" << output.c_str() << "\""
|
||||||
|
<< std::endl);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
int cmCPackGenericGenerator::InstallProjectViaInstallCommands(bool movable, const char* tempInstallDirectory)
|
||||||
|
{
|
||||||
const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS");
|
const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS");
|
||||||
if ( installCommands && *installCommands )
|
if ( installCommands && *installCommands )
|
||||||
{
|
{
|
||||||
|
@ -221,15 +277,33 @@ int cmCPackGenericGenerator::InstallProject()
|
||||||
"Problem running install command: " << it->c_str() << std::endl
|
"Problem running install command: " << it->c_str() << std::endl
|
||||||
<< "Please check " << tmpFile.c_str() << " for errors"
|
<< "Please check " << tmpFile.c_str() << " for errors"
|
||||||
<< std::endl);
|
<< std::endl);
|
||||||
res = 0;
|
return 0;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
// If the CPackConfig file sets CPACK_INSTALLED_DIRECTORIES
|
}
|
||||||
// then glob it and copy it to CPACK_TEMPORARY_DIRECTORY
|
|
||||||
// This is used in Source packageing
|
//----------------------------------------------------------------------
|
||||||
|
int cmCPackGenericGenerator::InstallProjectViaInstalledDirectories(bool movable, const char* tempInstallDirectory)
|
||||||
|
{
|
||||||
|
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_VERBOSE,
|
||||||
|
"Create ignore files regex for: " << it->c_str() << std::endl);
|
||||||
|
ignoreFilesRegex.push_back(it->c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
const char* installDirectories
|
const char* installDirectories
|
||||||
= this->GetOption("CPACK_INSTALLED_DIRECTORIES");
|
= this->GetOption("CPACK_INSTALLED_DIRECTORIES");
|
||||||
if ( installDirectories && *installDirectories )
|
if ( installDirectories && *installDirectories )
|
||||||
|
@ -304,9 +378,12 @@ int cmCPackGenericGenerator::InstallProject()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// If the project is a CMAKE project then run pre-install
|
//----------------------------------------------------------------------
|
||||||
// and then read the cmake_install script to run it
|
int cmCPackGenericGenerator::InstallProjectViaInstallCMakeProjects(bool movable, const char* tempInstallDirectory)
|
||||||
|
{
|
||||||
const char* cmakeProjects
|
const char* cmakeProjects
|
||||||
= this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS");
|
= this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS");
|
||||||
const char* cmakeGenerator
|
const char* cmakeGenerator
|
||||||
|
@ -434,96 +511,14 @@ int cmCPackGenericGenerator::InstallProject()
|
||||||
installComponent.c_str());
|
installComponent.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
res = mf->ReadListFile(0, installFile.c_str());
|
int res = mf->ReadListFile(0, installFile.c_str());
|
||||||
if ( cmSystemTools::GetErrorOccuredFlag() )
|
if ( cmSystemTools::GetErrorOccuredFlag() || !res )
|
||||||
{
|
{
|
||||||
res = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ?????
|
|
||||||
const char* binaryDirectories = this->GetOption("CPACK_BINARY_DIR");
|
|
||||||
if ( binaryDirectories && !cmakeProjects )
|
|
||||||
{
|
|
||||||
std::vector<std::string> binaryDirectoriesVector;
|
|
||||||
cmSystemTools::ExpandListArgument(binaryDirectories,
|
|
||||||
binaryDirectoriesVector);
|
|
||||||
std::vector<std::string>::iterator it;
|
|
||||||
for ( it = binaryDirectoriesVector.begin();
|
|
||||||
it != binaryDirectoriesVector.end();
|
|
||||||
++it )
|
|
||||||
{
|
|
||||||
std::string installFile = it->c_str();
|
|
||||||
installFile += "/cmake_install.cmake";
|
|
||||||
cmake cm;
|
|
||||||
cmGlobalGenerator gg;
|
|
||||||
gg.SetCMakeInstance(&cm);
|
|
||||||
std::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
|
|
||||||
lg->SetGlobalGenerator(&gg);
|
|
||||||
cmMakefile *mf = lg->GetMakefile();
|
|
||||||
if ( movable )
|
|
||||||
{
|
|
||||||
mf->AddDefinition("CMAKE_INSTALL_PREFIX", tempInstallDirectory);
|
|
||||||
}
|
|
||||||
const char* buildConfig = this->GetOption("CPACK_BUILD_CONFIG");
|
|
||||||
if ( buildConfig && *buildConfig )
|
|
||||||
{
|
|
||||||
mf->AddDefinition("BUILD_TYPE", buildConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
res = mf->ReadListFile(0, installFile.c_str());
|
|
||||||
if ( cmSystemTools::GetErrorOccuredFlag() )
|
|
||||||
{
|
|
||||||
res = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( !movable )
|
|
||||||
{
|
|
||||||
cmSystemTools::PutEnv("DESTDIR=");
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* stripExecutable = this->GetOption("CPACK_STRIP_COMMAND");
|
|
||||||
const char* stripFiles
|
|
||||||
= this->GetOption("CPACK_STRIP_FILES");
|
|
||||||
if ( stripFiles && *stripFiles && stripExecutable && *stripExecutable )
|
|
||||||
{
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Strip files" << std::endl);
|
|
||||||
std::vector<std::string> stripFilesVector;
|
|
||||||
cmSystemTools::ExpandListArgument(stripFiles,
|
|
||||||
stripFilesVector);
|
|
||||||
std::vector<std::string>::iterator it;
|
|
||||||
for ( it = stripFilesVector.begin();
|
|
||||||
it != stripFilesVector.end();
|
|
||||||
++it )
|
|
||||||
{
|
|
||||||
std::string fileName = tempInstallDirectory;
|
|
||||||
fileName += "/" + *it;
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
|
|
||||||
" Strip file: " << fileName.c_str()
|
|
||||||
<< std::endl);
|
|
||||||
std::string stripCommand = stripExecutable;
|
|
||||||
stripCommand += " \"";
|
|
||||||
stripCommand += fileName + "\"";
|
|
||||||
int retVal = 1;
|
|
||||||
std::string output;
|
|
||||||
bool resB =
|
|
||||||
cmSystemTools::RunSingleCommand(stripCommand.c_str(), &output,
|
|
||||||
&retVal, 0,
|
|
||||||
this->GeneratorVerbose, 0);
|
|
||||||
if ( !resB || retVal )
|
|
||||||
{
|
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
|
||||||
"Problem running install command: " << stripCommand.c_str()
|
|
||||||
<< std::endl
|
|
||||||
<< "Error was: \"" << output.c_str() << "\""
|
|
||||||
<< std::endl);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -557,10 +552,30 @@ void cmCPackGenericGenerator::SetOption(const char* op, const char* value)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
int cmCPackGenericGenerator::ProcessGenerator()
|
int cmCPackGenericGenerator::ProcessGenerator()
|
||||||
{
|
{
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
|
||||||
|
"Create package using " << this->Name.c_str() << std::endl);
|
||||||
|
|
||||||
if ( !this->PrepareNames() )
|
if ( !this->PrepareNames() )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if ( cmSystemTools::IsOn(this->GetOption("CPACK_REMOVE_TOPLEVEL_DIRECTORY")) )
|
||||||
|
{
|
||||||
|
const char* toplevelDirectory = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
||||||
|
if ( cmSystemTools::FileExists(toplevelDirectory) )
|
||||||
|
{
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Remove toplevel directory: "
|
||||||
|
<< toplevelDirectory << std::endl);
|
||||||
|
if ( !cmSystemTools::RemoveADirectory(toplevelDirectory) )
|
||||||
|
{
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
|
"Problem removing toplevel directory: "
|
||||||
|
<< toplevelDirectory
|
||||||
|
<< std::endl);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if ( !this->InstallProject() )
|
if ( !this->InstallProject() )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -668,7 +683,7 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
|
||||||
{
|
{
|
||||||
failures.push_back(this->CPackSelf);
|
failures.push_back(this->CPackSelf);
|
||||||
cmOStringStream msg;
|
cmOStringStream msg;
|
||||||
msg << "CTEST can not find the command line program ctest.\n";
|
msg << "CPack can not find the command line program ctest.\n";
|
||||||
msg << " argv[0] = \"" << arg0 << "\"\n";
|
msg << " argv[0] = \"" << arg0 << "\"\n";
|
||||||
msg << " Attempted paths:\n";
|
msg << " Attempted paths:\n";
|
||||||
std::vector<cmStdString>::iterator i;
|
std::vector<cmStdString>::iterator i;
|
||||||
|
@ -676,7 +691,9 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
|
||||||
{
|
{
|
||||||
msg << " \"" << i->c_str() << "\"\n";
|
msg << " \"" << i->c_str() << "\"\n";
|
||||||
}
|
}
|
||||||
cmSystemTools::Error(msg.str().c_str());
|
cmCPackLogger(cmCPackLog::LOG_ERROR, msg.str().c_str()
|
||||||
|
<< std::endl);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
std::string dir;
|
std::string dir;
|
||||||
std::string file;
|
std::string file;
|
||||||
|
@ -708,7 +725,7 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
|
||||||
{
|
{
|
||||||
failures.push_back(this->CMakeSelf);
|
failures.push_back(this->CMakeSelf);
|
||||||
cmOStringStream msg;
|
cmOStringStream msg;
|
||||||
msg << "CTEST can not find the command line program cmake.\n";
|
msg << "CPack can not find the command line program cmake.\n";
|
||||||
msg << " argv[0] = \"" << arg0 << "\"\n";
|
msg << " argv[0] = \"" << arg0 << "\"\n";
|
||||||
msg << " Attempted paths:\n";
|
msg << " Attempted paths:\n";
|
||||||
std::vector<cmStdString>::iterator i;
|
std::vector<cmStdString>::iterator i;
|
||||||
|
@ -716,7 +733,9 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
|
||||||
{
|
{
|
||||||
msg << " \"" << i->c_str() << "\"\n";
|
msg << " \"" << i->c_str() << "\"\n";
|
||||||
}
|
}
|
||||||
cmSystemTools::Error(msg.str().c_str());
|
cmCPackLogger(cmCPackLog::LOG_ERROR, msg.str().c_str()
|
||||||
|
<< std::endl);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// do CMAKE_ROOT, look for the environment variable first
|
// do CMAKE_ROOT, look for the environment variable first
|
||||||
|
@ -792,10 +811,12 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
|
||||||
if (!cmSystemTools::FileExists(modules.c_str()))
|
if (!cmSystemTools::FileExists(modules.c_str()))
|
||||||
{
|
{
|
||||||
// couldn't find modules
|
// couldn't find modules
|
||||||
cmSystemTools::Error("Could not find CMAKE_ROOT !!!\n"
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||||
"CMake has most likely not been installed correctly.\n"
|
"Could not find CMAKE_ROOT !!!" << std::endl
|
||||||
"Modules directory not found in\n",
|
<< "CMake has most likely not been installed correctly." << std::endl
|
||||||
cMakeRoot.c_str());
|
<<"Modules directory not found in" << std::endl
|
||||||
|
<< cMakeRoot.c_str()
|
||||||
|
<< std::endl);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
this->CMakeRoot = cMakeRoot;
|
this->CMakeRoot = cMakeRoot;
|
||||||
|
|
|
@ -106,6 +106,15 @@ protected:
|
||||||
virtual bool ConfigureString(const std::string& input, std::string& output);
|
virtual bool ConfigureString(const std::string& input, std::string& output);
|
||||||
virtual int InitializeInternal();
|
virtual int InitializeInternal();
|
||||||
|
|
||||||
|
|
||||||
|
//! Run install commands if specified
|
||||||
|
virtual int InstallProjectViaInstallCommands(
|
||||||
|
bool movable, const char* tempInstallDirectory);
|
||||||
|
virtual int InstallProjectViaInstalledDirectories(
|
||||||
|
bool movable, const char* tempInstallDirectory);
|
||||||
|
virtual int InstallProjectViaInstallCMakeProjects(
|
||||||
|
bool movable, const char* tempInstallDirectory);
|
||||||
|
|
||||||
bool GeneratorVerbose;
|
bool GeneratorVerbose;
|
||||||
std::string Name;
|
std::string Name;
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ int main (int argc, char *argv[])
|
||||||
cmGlobalGenerator cmgg;
|
cmGlobalGenerator cmgg;
|
||||||
cmgg.SetCMakeInstance(&cminst);
|
cmgg.SetCMakeInstance(&cminst);
|
||||||
cmLocalGenerator* cmlg = cmgg.CreateLocalGenerator();
|
cmLocalGenerator* cmlg = cmgg.CreateLocalGenerator();
|
||||||
cmMakefile* mf = cmlg->GetMakefile();
|
cmMakefile* globalMF = cmlg->GetMakefile();
|
||||||
|
|
||||||
bool cpackConfigFileSpecified = true;
|
bool cpackConfigFileSpecified = true;
|
||||||
if ( cpackConfigFile.empty() )
|
if ( cpackConfigFile.empty() )
|
||||||
|
@ -247,7 +247,10 @@ int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
cpackConfigFile =
|
cpackConfigFile =
|
||||||
cmSystemTools::CollapseFullPath(cpackConfigFile.c_str());
|
cmSystemTools::CollapseFullPath(cpackConfigFile.c_str());
|
||||||
if ( !mf->ReadListFile(0, cpackConfigFile.c_str()) )
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
||||||
|
"Read CPack configuration file: " << cpackConfigFile.c_str()
|
||||||
|
<< std::endl);
|
||||||
|
if ( !globalMF->ReadListFile(0, cpackConfigFile.c_str()) )
|
||||||
{
|
{
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"Problem reding CPack config file: \""
|
"Problem reding CPack config file: \""
|
||||||
|
@ -265,157 +268,173 @@ int main (int argc, char *argv[])
|
||||||
|
|
||||||
if ( !generator.empty() )
|
if ( !generator.empty() )
|
||||||
{
|
{
|
||||||
mf->AddDefinition("CPACK_GENERATOR", generator.c_str());
|
globalMF->AddDefinition("CPACK_GENERATOR", generator.c_str());
|
||||||
}
|
}
|
||||||
if ( !cpackProjectName.empty() )
|
if ( !cpackProjectName.empty() )
|
||||||
{
|
{
|
||||||
mf->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str());
|
globalMF->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str());
|
||||||
}
|
}
|
||||||
if ( !cpackProjectVersion.empty() )
|
if ( !cpackProjectVersion.empty() )
|
||||||
{
|
{
|
||||||
mf->AddDefinition("CPACK_PACKAGE_VERSION", cpackProjectVersion.c_str());
|
globalMF->AddDefinition("CPACK_PACKAGE_VERSION", cpackProjectVersion.c_str());
|
||||||
}
|
}
|
||||||
if ( !cpackProjectVendor.empty() )
|
if ( !cpackProjectVendor.empty() )
|
||||||
{
|
{
|
||||||
mf->AddDefinition("CPACK_PACKAGE_VENDOR", cpackProjectVendor.c_str());
|
globalMF->AddDefinition("CPACK_PACKAGE_VENDOR", cpackProjectVendor.c_str());
|
||||||
}
|
}
|
||||||
if ( !cpackProjectDirectory.empty() )
|
if ( !cpackProjectDirectory.empty() )
|
||||||
{
|
{
|
||||||
mf->AddDefinition("CPACK_PACKAGE_DIRECTORY",
|
globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
|
||||||
cpackProjectDirectory.c_str());
|
cpackProjectDirectory.c_str());
|
||||||
}
|
}
|
||||||
if ( !cpackBuildConfig.empty() )
|
if ( !cpackBuildConfig.empty() )
|
||||||
{
|
{
|
||||||
mf->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
|
globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
|
||||||
}
|
}
|
||||||
cpackDefinitions::MapType::iterator cdit;
|
cpackDefinitions::MapType::iterator cdit;
|
||||||
for ( cdit = definitions.Map.begin();
|
for ( cdit = definitions.Map.begin();
|
||||||
cdit != definitions.Map.end();
|
cdit != definitions.Map.end();
|
||||||
++cdit )
|
++cdit )
|
||||||
{
|
{
|
||||||
mf->AddDefinition(cdit->first.c_str(), cdit->second.c_str());
|
globalMF->AddDefinition(cdit->first.c_str(), cdit->second.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* gen = mf->GetDefinition("CPACK_GENERATOR");
|
const char* genList = globalMF->GetDefinition("CPACK_GENERATOR");
|
||||||
if ( !gen )
|
if ( !genList )
|
||||||
{
|
{
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"CPack generator not specified" << std::endl);
|
"CPack generator not specified" << std::endl);
|
||||||
parsed = 0;
|
parsed = 0;
|
||||||
}
|
}
|
||||||
if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") )
|
std::vector<std::string> generatorsVector;
|
||||||
|
cmSystemTools::ExpandListArgument(genList,
|
||||||
|
generatorsVector);
|
||||||
|
std::vector<std::string>::iterator it;
|
||||||
|
for ( it = generatorsVector.begin();
|
||||||
|
it != generatorsVector.end();
|
||||||
|
++it )
|
||||||
{
|
{
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
const char* gen = it->c_str();
|
||||||
"CPack project name not specified" << std::endl);
|
cmMakefile newMF(*globalMF);
|
||||||
parsed = 0;
|
cmMakefile* mf = &newMF;
|
||||||
}
|
|
||||||
if ( parsed && !(mf->GetDefinition("CPACK_PACKAGE_VERSION")
|
|
||||||
|| mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") &&
|
|
||||||
mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR")
|
|
||||||
&& mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH")) )
|
|
||||||
{
|
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
|
||||||
"CPack project version not specified" << std::endl
|
|
||||||
<< "Specify CPACK_PACKAGE_VERSION, or CPACK_PACKAGE_VERSION_MAJOR, "
|
|
||||||
"CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH."
|
|
||||||
<< std::endl);
|
|
||||||
parsed = 0;
|
|
||||||
}
|
|
||||||
if ( parsed )
|
|
||||||
{
|
|
||||||
cpackGenerator = generators.NewGenerator(gen);
|
|
||||||
if ( !cpackGenerator )
|
|
||||||
{
|
{
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
|
||||||
"Cannot initialize CPack generator: "
|
"Specified generator: " << gen << std::endl);
|
||||||
<< generator.c_str() << std::endl);
|
if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") )
|
||||||
parsed = 0;
|
{
|
||||||
}
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
if ( parsed && !cpackGenerator->Initialize(gen, mf, argv[0]) )
|
"CPack project name not specified" << std::endl);
|
||||||
{
|
parsed = 0;
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
}
|
||||||
"Cannot initialize the generator" << std::endl);
|
if ( parsed && !(mf->GetDefinition("CPACK_PACKAGE_VERSION")
|
||||||
parsed = 0;
|
|| mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") &&
|
||||||
|
mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR")
|
||||||
|
&& mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH")) )
|
||||||
|
{
|
||||||
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
|
"CPack project version not specified" << std::endl
|
||||||
|
<< "Specify CPACK_PACKAGE_VERSION, or CPACK_PACKAGE_VERSION_MAJOR, "
|
||||||
|
"CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH."
|
||||||
|
<< std::endl);
|
||||||
|
parsed = 0;
|
||||||
|
}
|
||||||
|
if ( parsed )
|
||||||
|
{
|
||||||
|
cpackGenerator = generators.NewGenerator(gen);
|
||||||
|
if ( !cpackGenerator )
|
||||||
|
{
|
||||||
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
|
"Cannot initialize CPack generator: "
|
||||||
|
<< generator.c_str() << std::endl);
|
||||||
|
parsed = 0;
|
||||||
|
}
|
||||||
|
if ( parsed && !cpackGenerator->Initialize(gen, mf, argv[0]) )
|
||||||
|
{
|
||||||
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
|
"Cannot initialize the generator" << std::endl);
|
||||||
|
parsed = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
|
||||||
|
!mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
|
||||||
|
!mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS") )
|
||||||
|
{
|
||||||
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
|
"Please specify build tree of the project that uses CMake using "
|
||||||
|
" CPACK_INSTALL_CMAKE_PROJECTS, specify CPACK_INSTALL_COMMANDS, or "
|
||||||
|
"specify CPACK_INSTALLED_DIRECTORIES."
|
||||||
|
<< std::endl);
|
||||||
|
parsed = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
|
if ( !parsed || help )
|
||||||
!mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
|
|
||||||
!mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS") )
|
|
||||||
{
|
{
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
doc.CheckOptions(argc, argv);
|
||||||
"Please specify build tree of the project that uses CMake using "
|
// Construct and print requested documentation.
|
||||||
" CPACK_INSTALL_CMAKE_PROJECTS, specify CPACK_INSTALL_COMMANDS, or "
|
doc.SetName("cpack");
|
||||||
"specify CPACK_INSTALLED_DIRECTORIES."
|
doc.SetNameSection(cmDocumentationName);
|
||||||
<< std::endl);
|
doc.SetUsageSection(cmDocumentationUsage);
|
||||||
parsed = 0;
|
doc.SetDescriptionSection(cmDocumentationDescription);
|
||||||
}
|
doc.SetOptionsSection(cmDocumentationOptions);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !parsed || help )
|
std::vector<cmDocumentationEntry> v;
|
||||||
{
|
cmCPackGenerators::DescriptionsMap::const_iterator generatorIt;
|
||||||
doc.CheckOptions(argc, argv);
|
for( generatorIt = generators.GetGeneratorsList().begin();
|
||||||
// Construct and print requested documentation.
|
generatorIt != generators.GetGeneratorsList().end();
|
||||||
doc.SetName("cpack");
|
++ generatorIt )
|
||||||
doc.SetNameSection(cmDocumentationName);
|
{
|
||||||
doc.SetUsageSection(cmDocumentationUsage);
|
cmDocumentationEntry e;
|
||||||
doc.SetDescriptionSection(cmDocumentationDescription);
|
e.name = generatorIt->first.c_str();
|
||||||
doc.SetOptionsSection(cmDocumentationOptions);
|
e.brief = generatorIt->second.c_str();
|
||||||
|
e.full = "";
|
||||||
|
v.push_back(e);
|
||||||
|
}
|
||||||
|
cmDocumentationEntry empty = {0,0,0};
|
||||||
|
v.push_back(empty);
|
||||||
|
doc.SetGeneratorsSection(&v[0]);
|
||||||
|
|
||||||
std::vector<cmDocumentationEntry> v;
|
doc.SetSeeAlsoList(cmDocumentationSeeAlso);
|
||||||
cmCPackGenerators::DescriptionsMap::const_iterator generatorIt;
|
|
||||||
for( generatorIt = generators.GetGeneratorsList().begin();
|
|
||||||
generatorIt != generators.GetGeneratorsList().end();
|
|
||||||
++ generatorIt )
|
|
||||||
{
|
|
||||||
cmDocumentationEntry e;
|
|
||||||
e.name = generatorIt->first.c_str();
|
|
||||||
e.brief = generatorIt->second.c_str();
|
|
||||||
e.full = "";
|
|
||||||
v.push_back(e);
|
|
||||||
}
|
|
||||||
cmDocumentationEntry empty = {0,0,0};
|
|
||||||
v.push_back(empty);
|
|
||||||
doc.SetGeneratorsSection(&v[0]);
|
|
||||||
|
|
||||||
doc.SetSeeAlsoList(cmDocumentationSeeAlso);
|
|
||||||
#undef cout
|
#undef cout
|
||||||
return doc.PrintRequestedDocumentation(std::cout)? 0:1;
|
return doc.PrintRequestedDocumentation(std::cout)? 0:1;
|
||||||
#define cout no_cout_use_cmCPack_Log
|
#define cout no_cout_use_cmCPack_Log
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
std::string comspec = "cmw9xcom.exe";
|
std::string comspec = "cmw9xcom.exe";
|
||||||
cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str());
|
cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
|
const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: "
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: "
|
||||||
<< cpackGenerator->GetNameOfClass() << std::endl);
|
<< cpackGenerator->GetNameOfClass() << std::endl);
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: "
|
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: "
|
||||||
<< projName << std::endl);
|
<< projName << std::endl);
|
||||||
|
|
||||||
const char* projVersion = mf->GetDefinition("CPACK_PACKAGE_VERSION");
|
const char* projVersion = mf->GetDefinition("CPACK_PACKAGE_VERSION");
|
||||||
if ( !projVersion )
|
if ( !projVersion )
|
||||||
{
|
{
|
||||||
const char* projVersionMajor
|
const char* projVersionMajor
|
||||||
= mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
|
= mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
|
||||||
const char* projVersionMinor
|
const char* projVersionMinor
|
||||||
= mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
|
= mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
|
||||||
const char* projVersionPatch
|
const char* projVersionPatch
|
||||||
= mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
|
= mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
|
||||||
cmOStringStream ostr;
|
cmOStringStream ostr;
|
||||||
ostr << projVersionMajor << "." << projVersionMinor << "."
|
ostr << projVersionMajor << "." << projVersionMinor << "."
|
||||||
<< projVersionPatch;
|
<< projVersionPatch;
|
||||||
mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str().c_str());
|
mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = cpackGenerator->ProcessGenerator();
|
int res = cpackGenerator->ProcessGenerator();
|
||||||
if ( !res )
|
if ( !res )
|
||||||
{
|
{
|
||||||
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
|
||||||
"Error when generating package: " << projName << std::endl);
|
"Error when generating package: " << projName << std::endl);
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue