Merge topic 'simplify-cmake-E-command-line'

d4c3de2 cmake: Simplify -E command line processing
This commit is contained in:
Brad King 2013-10-18 10:02:15 -04:00 committed by CMake Topic Stage
commit 037887e7ab
1 changed files with 31 additions and 25 deletions

View File

@ -84,6 +84,17 @@ static const char * cmDocumentationOptions[][2] =
#endif #endif
static int do_command(int ac, char** av)
{
std::vector<std::string> args;
args.push_back(av[0]);
for(int i = 2; i < ac; ++i)
{
args.push_back(av[i]);
}
return cmcmd::ExecuteCMakeCommand(args);
}
int do_cmake(int ac, char** av); int do_cmake(int ac, char** av);
static int do_build(int ac, char** av); static int do_build(int ac, char** av);
@ -157,9 +168,16 @@ int main(int ac, char** av)
{ {
cmSystemTools::EnableMSVCDebugHook(); cmSystemTools::EnableMSVCDebugHook();
cmSystemTools::FindExecutableDirectory(av[0]); cmSystemTools::FindExecutableDirectory(av[0]);
if(ac > 1 && strcmp(av[1], "--build") == 0) if(ac > 1)
{ {
return do_build(ac, av); if(strcmp(av[1], "--build") == 0)
{
return do_build(ac, av);
}
else if(strcmp(av[1], "-E") == 0)
{
return do_command(ac, av);
}
} }
int ret = do_cmake(ac, av); int ret = do_cmake(ac, av);
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
@ -180,7 +198,7 @@ int do_cmake(int ac, char** av)
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
cmDocumentation doc; cmDocumentation doc;
doc.addCMakeStandardDocSections(); doc.addCMakeStandardDocSections();
if(doc.CheckOptions(ac, av, "-E")) if(doc.CheckOptions(ac, av))
{ {
// Construct and print requested documentation. // Construct and print requested documentation.
cmake hcm; cmake hcm;
@ -220,7 +238,6 @@ int do_cmake(int ac, char** av)
bool wiz = false; bool wiz = false;
bool sysinfo = false; bool sysinfo = false;
bool command = false;
bool list_cached = false; bool list_cached = false;
bool list_all_cached = false; bool list_all_cached = false;
bool list_help = false; bool list_help = false;
@ -229,43 +246,37 @@ int do_cmake(int ac, char** av)
std::vector<std::string> args; std::vector<std::string> args;
for(int i =0; i < ac; ++i) for(int i =0; i < ac; ++i)
{ {
if(!command && strcmp(av[i], "-i") == 0) if(strcmp(av[i], "-i") == 0)
{ {
wiz = true; wiz = true;
} }
else if(!command && strcmp(av[i], "--system-information") == 0) else if(strcmp(av[i], "--system-information") == 0)
{ {
sysinfo = true; sysinfo = true;
} }
// if command has already been set, then else if (strcmp(av[i], "-N") == 0)
// do not eat the -E
else if (!command && strcmp(av[i], "-E") == 0)
{
command = true;
}
else if (!command && strcmp(av[i], "-N") == 0)
{ {
view_only = true; view_only = true;
} }
else if (!command && strcmp(av[i], "-L") == 0) else if (strcmp(av[i], "-L") == 0)
{ {
list_cached = true; list_cached = true;
} }
else if (!command && strcmp(av[i], "-LA") == 0) else if (strcmp(av[i], "-LA") == 0)
{ {
list_all_cached = true; list_all_cached = true;
} }
else if (!command && strcmp(av[i], "-LH") == 0) else if (strcmp(av[i], "-LH") == 0)
{ {
list_cached = true; list_cached = true;
list_help = true; list_help = true;
} }
else if (!command && strcmp(av[i], "-LAH") == 0) else if (strcmp(av[i], "-LAH") == 0)
{ {
list_all_cached = true; list_all_cached = true;
list_help = true; list_help = true;
} }
else if (!command && strncmp(av[i], "-P", strlen("-P")) == 0) else if (strncmp(av[i], "-P", strlen("-P")) == 0)
{ {
if ( i == ac -1 ) if ( i == ac -1 )
{ {
@ -279,8 +290,8 @@ int do_cmake(int ac, char** av)
args.push_back(av[i]); args.push_back(av[i]);
} }
} }
else if (!command && strncmp(av[i], "--find-package", else if (strncmp(av[i], "--find-package",
strlen("--find-package")) == 0) strlen("--find-package")) == 0)
{ {
workingMode = cmake::FIND_PACKAGE_MODE; workingMode = cmake::FIND_PACKAGE_MODE;
args.push_back(av[i]); args.push_back(av[i]);
@ -290,11 +301,6 @@ int do_cmake(int ac, char** av)
args.push_back(av[i]); args.push_back(av[i]);
} }
} }
if(command)
{
int ret = cmcmd::ExecuteCMakeCommand(args);
return ret;
}
if (wiz) if (wiz)
{ {
cmakewizard wizard; cmakewizard wizard;