Use Encoding::CommandLineArguments for main() functions.

This commit is contained in:
Clinton Stimpson 2013-12-18 14:38:56 -07:00
parent 7fb2b80662
commit a1e542f195
5 changed files with 44 additions and 14 deletions

View File

@ -25,6 +25,7 @@
#include <cmsys/CommandLineArguments.hxx> #include <cmsys/CommandLineArguments.hxx>
#include <cmsys/SystemTools.hxx> #include <cmsys/SystemTools.hxx>
#include <cmsys/Encoding.hxx>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
static const char * cmDocumentationName[][2] = static const char * cmDocumentationName[][2] =
@ -97,8 +98,13 @@ int cpackDefinitionArgument(const char* argument, const char* cValue,
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// this is CPack. // this is CPack.
int main (int argc, char *argv[]) int main (int argc, char const* const* argv)
{ {
cmsys::Encoding::CommandLineArguments args =
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
argc = args.argc();
argv = args.argv();
cmSystemTools::FindCMakeResources(argv[0]); cmSystemTools::FindCMakeResources(argv[0]);
cmCPackLog log; cmCPackLog log;

View File

@ -19,6 +19,7 @@
#include "cmCursesMainForm.h" #include "cmCursesMainForm.h"
#include "cmCursesStandardIncludes.h" #include "cmCursesStandardIncludes.h"
#include <cmsys/Encoding.hxx>
#include <form.h> #include <form.h>
@ -78,8 +79,13 @@ void CMakeErrorHandler(const char* message, const char* title, bool&, void* clie
self->AddError(message, title); self->AddError(message, title);
} }
int main(int argc, char** argv) int main(int argc, char const* const* argv)
{ {
cmsys::Encoding::CommandLineArguments encoding_args =
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
argc = encoding_args.argc();
argv = encoding_args.argv();
cmSystemTools::FindCMakeResources(argv[0]); cmSystemTools::FindCMakeResources(argv[0]);
cmDocumentation doc; cmDocumentation doc;
doc.addCMakeStandardDocSections(); doc.addCMakeStandardDocSections();

View File

@ -21,6 +21,7 @@
#include "cmVersion.h" #include "cmVersion.h"
#include <cmsys/CommandLineArguments.hxx> #include <cmsys/CommandLineArguments.hxx>
#include <cmsys/SystemTools.hxx> #include <cmsys/SystemTools.hxx>
#include <cmsys/Encoding.hxx>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
static const char * cmDocumentationName[][2] = static const char * cmDocumentationName[][2] =
@ -48,12 +49,17 @@ static const char * cmDocumentationOptions[][2] =
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
cmSystemTools::FindCMakeResources(argv[0]); cmsys::Encoding::CommandLineArguments encoding_args =
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
int argc2 = encoding_args.argc();
char const* const* argv2 = encoding_args.argv();
cmSystemTools::FindCMakeResources(argv2[0]);
// check docs first so that X is not need to get docs // check docs first so that X is not need to get docs
// do docs, if args were given // do docs, if args were given
cmDocumentation doc; cmDocumentation doc;
doc.addCMakeStandardDocSections(); doc.addCMakeStandardDocSections();
if(argc >1 && doc.CheckOptions(argc, argv)) if(argc2 >1 && doc.CheckOptions(argc2, argv2))
{ {
// Construct and print requested documentation. // Construct and print requested documentation.
cmake hcm; cmake hcm;
@ -80,9 +86,9 @@ int main(int argc, char** argv)
} }
// if arg for install // if arg for install
for(int i =0; i < argc; i++) for(int i =0; i < argc2; i++)
{ {
if(strcmp(argv[i], "--mac-install") == 0) if(strcmp(argv2[i], "--mac-install") == 0)
{ {
QMacInstallDialog setupdialog(0); QMacInstallDialog setupdialog(0);
setupdialog.exec(); setupdialog.exec();
@ -116,7 +122,7 @@ int main(int argc, char** argv)
dialog.show(); dialog.show();
cmsys::CommandLineArguments arg; cmsys::CommandLineArguments arg;
arg.Initialize(argc, argv); arg.Initialize(argc2, argv2);
std::string binaryDirectory; std::string binaryDirectory;
std::string sourceDirectory; std::string sourceDirectory;
typedef cmsys::CommandLineArguments argT; typedef cmsys::CommandLineArguments argT;

View File

@ -24,6 +24,7 @@
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include <cmsys/Encoding.hxx>
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -79,7 +80,7 @@ static const char * cmDocumentationOptions[][2] =
#endif #endif
static int do_command(int ac, char** av) static int do_command(int ac, char const* const* av)
{ {
std::vector<std::string> args; std::vector<std::string> args;
args.push_back(av[0]); args.push_back(av[0]);
@ -90,8 +91,8 @@ static int do_command(int ac, char** av)
return cmcmd::ExecuteCMakeCommand(args); return cmcmd::ExecuteCMakeCommand(args);
} }
int do_cmake(int ac, char** av); int do_cmake(int ac, char const* const* av);
static int do_build(int ac, char** av); static int do_build(int ac, char const* const* av);
static cmMakefile* cmakemainGetMakefile(void *clientdata) static cmMakefile* cmakemainGetMakefile(void *clientdata)
{ {
@ -159,8 +160,13 @@ static void cmakemainProgressCallback(const char *m, float prog,
} }
int main(int ac, char** av) int main(int ac, char const* const* av)
{ {
cmsys::Encoding::CommandLineArguments args =
cmsys::Encoding::CommandLineArguments::Main(ac, av);
ac = args.argc();
av = args.argv();
cmSystemTools::EnableMSVCDebugHook(); cmSystemTools::EnableMSVCDebugHook();
cmSystemTools::FindCMakeResources(av[0]); cmSystemTools::FindCMakeResources(av[0]);
if(ac > 1) if(ac > 1)
@ -181,7 +187,7 @@ int main(int ac, char** av)
return ret; return ret;
} }
int do_cmake(int ac, char** av) int do_cmake(int ac, char const* const* av)
{ {
if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 ) if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 )
{ {
@ -352,7 +358,7 @@ int do_cmake(int ac, char** av)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
static int do_build(int ac, char** av) static int do_build(int ac, char const* const* av)
{ {
#ifndef CMAKE_BUILD_WITH_CMAKE #ifndef CMAKE_BUILD_WITH_CMAKE
std::cerr << "This cmake does not support --build\n"; std::cerr << "This cmake does not support --build\n";

View File

@ -18,6 +18,7 @@
#include "CTest/cmCTestScriptHandler.h" #include "CTest/cmCTestScriptHandler.h"
#include "CTest/cmCTestLaunch.h" #include "CTest/cmCTestLaunch.h"
#include "cmsys/Encoding.hxx"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
static const char * cmDocumentationName[][2] = static const char * cmDocumentationName[][2] =
@ -111,8 +112,13 @@ static const char * cmDocumentationOptions[][2] =
}; };
// this is a test driver program for cmCTest. // this is a test driver program for cmCTest.
int main (int argc, char *argv[]) int main (int argc, char const* const* argv)
{ {
cmsys::Encoding::CommandLineArguments encoding_args =
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
argc = encoding_args.argc();
argv = encoding_args.argv();
cmSystemTools::DoNotInheritStdPipes(); cmSystemTools::DoNotInheritStdPipes();
cmSystemTools::EnableMSVCDebugHook(); cmSystemTools::EnableMSVCDebugHook();
cmSystemTools::FindCMakeResources(argv[0]); cmSystemTools::FindCMakeResources(argv[0]);