BUG: Fix executing and help

This commit is contained in:
Andy Cedilnik 2006-07-27 11:55:34 -04:00
parent 0b196d1aef
commit 7e3310e6e5
1 changed files with 115 additions and 112 deletions

View File

@ -306,140 +306,143 @@ int main (int argc, char *argv[])
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"CPack generator not specified" << std::endl);
return 1;
parsed = 0;
}
std::vector<std::string> generatorsVector;
cmSystemTools::ExpandListArgument(genList,
generatorsVector);
std::vector<std::string>::iterator it;
for ( it = generatorsVector.begin();
it != generatorsVector.end();
++it )
else
{
const char* gen = it->c_str();
cmMakefile newMF(*globalMF);
cmMakefile* mf = &newMF;
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_VERBOSE,
"Specified generator: " << gen << std::endl);
if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") )
const char* gen = it->c_str();
cmMakefile newMF(*globalMF);
cmMakefile* mf = &newMF;
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"CPack project name not specified" << std::endl);
parsed = 0;
}
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_VERBOSE,
"Specified generator: " << gen << std::endl);
if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Cannot initialize CPack generator: "
<< generator.c_str() << std::endl);
"CPack project name not specified" << std::endl);
parsed = 0;
}
if ( parsed && !cpackGenerator->Initialize(gen, mf, argv[0]) )
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,
"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."
"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 || help )
{
doc.CheckOptions(argc, argv);
// Construct and print requested documentation.
doc.SetName("cpack");
doc.SetNameSection(cmDocumentationName);
doc.SetUsageSection(cmDocumentationUsage);
doc.SetDescriptionSection(cmDocumentationDescription);
doc.SetOptionsSection(cmDocumentationOptions);
std::vector<cmDocumentationEntry> v;
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
return doc.PrintRequestedDocumentation(std::cout)? 0:1;
#define cout no_cout_use_cmCPack_Log
}
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;
}
#ifdef _WIN32
std::string comspec = "cmw9xcom.exe";
cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str());
std::string comspec = "cmw9xcom.exe";
cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str());
#endif
const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: "
<< cpackGenerator->GetNameOfClass() << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: "
<< projName << std::endl);
const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: "
<< cpackGenerator->GetNameOfClass() << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: "
<< projName << std::endl);
const char* projVersion = mf->GetDefinition("CPACK_PACKAGE_VERSION");
if ( !projVersion )
{
const char* projVersionMajor
= mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
const char* projVersionMinor
= mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
const char* projVersionPatch
= mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
cmOStringStream ostr;
ostr << projVersionMajor << "." << projVersionMinor << "."
<< projVersionPatch;
mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str().c_str());
}
const char* projVersion = mf->GetDefinition("CPACK_PACKAGE_VERSION");
if ( !projVersion )
{
const char* projVersionMajor
= mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
const char* projVersionMinor
= mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
const char* projVersionPatch
= mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
cmOStringStream ostr;
ostr << projVersionMajor << "." << projVersionMinor << "."
<< projVersionPatch;
mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str().c_str());
}
int res = cpackGenerator->ProcessGenerator();
if ( !res )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Error when generating package: " << projName << std::endl);
return 1;
int res = cpackGenerator->ProcessGenerator();
if ( !res )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Error when generating package: " << projName << std::endl);
return 1;
}
}
}
}
}
}
if ( !parsed || help )
{
doc.CheckOptions(argc, argv);
// Construct and print requested documentation.
doc.SetName("cpack");
doc.SetNameSection(cmDocumentationName);
doc.SetUsageSection(cmDocumentationUsage);
doc.SetDescriptionSection(cmDocumentationDescription);
doc.SetOptionsSection(cmDocumentationOptions);
std::vector<cmDocumentationEntry> v;
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
return doc.PrintRequestedDocumentation(std::cout)? 0:1;
#define cout no_cout_use_cmCPack_Log
}
return 0;
}