diff options
Diffstat (limited to 'Source/CPack')
-rw-r--r-- | Source/CPack/cpack.cxx | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 6f5055c..b603585 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -207,8 +207,7 @@ int main (int argc, char *argv[]) std::string helpHTML; std::string cpackProjectName; - std::string cpackProjectDirectory - = cmsys::SystemTools::GetCurrentWorkingDirectory(); + std::string cpackProjectDirectory; std::string cpackBuildConfig; std::string cpackProjectVersion; std::string cpackProjectPatch; @@ -294,8 +293,12 @@ int main (int argc, char *argv[]) cmDocumentation doc; doc.addCPackStandardDocSections(); - /* Were we invoked to display doc or to do some work ? */ - if(doc.CheckOptions(argc, argv,"-G") || nocwd) + /* Were we invoked to display doc or to do some work ? + * Unlike cmake launching cpack with zero argument + * should launch cpack using "cpackConfigFile" if it exists + * in the current directory. + */ + if((doc.CheckOptions(argc, argv,"-G") || nocwd) && !(argc==1)) { help = true; } @@ -370,10 +373,24 @@ int main (int argc, char *argv[]) globalMF->AddDefinition("CPACK_PACKAGE_VENDOR", cpackProjectVendor.c_str()); } + // if this is not empty it has been set on the command line + // go for it. Command line override values set in config file. if ( !cpackProjectDirectory.empty() ) { globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY", - cpackProjectDirectory.c_str()); + cpackProjectDirectory.c_str()); + } + // The value has not been set on the command line + else + { + // get a default value (current working directory) + cpackProjectDirectory = cmsys::SystemTools::GetCurrentWorkingDirectory(); + // use default value iff no value has been provided by the config file + if (!globalMF->IsSet("CPACK_PACKAGE_DIRECTORY")) + { + globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY", + cpackProjectDirectory.c_str()); + } } if ( !cpackBuildConfig.empty() ) { |