From baaf5eae7d4439d1a678869d0936b4007972ed9b Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Thu, 11 Dec 2003 08:57:40 -0500 Subject: fix to the signature and argument parsing --- Source/cmTryCompileCommand.cxx | 39 +++++++++++++++++++++++---------------- Source/cmTryCompileCommand.h | 2 +- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index d786717..53f633c 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -33,24 +33,21 @@ int cmTryCompileCommand::CoreTryCompileCode( const char* projectName = 0; const char* targetName = 0; std::string tmpString; - - // do we have a srcfile signature - if (argv.size() == 3 || argv[3] == "CMAKE_FLAGS" || argv[3] == "COMPILE_DEFINITIONS" || - argv[3] == "OUTPUT_VARIABLE") - { - srcFileSignature = true; - } - + int extraArgs = 0; + // look for CMAKE_FLAGS and store them std::vector cmakeFlags; for (i = 3; i < argv.size(); ++i) { if (argv[i] == "CMAKE_FLAGS") { + extraArgs++; + ++i; for (; i < argv.size() && argv[i] != "COMPILE_DEFINITIONS" && argv[i] != "OUTPUT_VARIABLE"; ++i) { + extraArgs++; cmakeFlags.push_back(argv[i]); } break; @@ -69,6 +66,7 @@ int cmTryCompileCommand::CoreTryCompileCode( "OUTPUT_VARIABLE specified but there is no variable"); return -1; } + extraArgs += 2; outputVariable = argv[i+1]; break; } @@ -80,23 +78,32 @@ int cmTryCompileCommand::CoreTryCompileCode( { if (argv[i] == "COMPILE_DEFINITIONS") { - // only valid for srcfile signatures - if (!srcFileSignature) - { - cmSystemTools::Error( - "COMPILE_FLAGS specified on a srcdir type TRY_COMPILE"); - return -1; - } + extraArgs++; for (i = i + 1; i < argv.size() && argv[i] != "CMAKE_FLAGS" && argv[i] != "OUTPUT_VARIABLE"; ++i) { + extraArgs++; compileFlags.push_back(argv[i]); } break; } } + // do we have a srcfile signature + if (argv.size() - extraArgs == 3) + { + srcFileSignature = true; + } + + // only valid for srcfile signatures + if (!srcFileSignature && compileFlags.size()) + { + cmSystemTools::Error( + "COMPILE_FLAGS specified on a srcdir type TRY_COMPILE"); + return -1; + } + // compute the binary dir when TRY_COMPILE is called with a src file // signature if (srcFileSignature) @@ -203,7 +210,7 @@ int cmTryCompileCommand::CoreTryCompileCode( { projectName = argv[3].c_str(); - if (argv.size() == 5) + if (argv.size() - extraArgs == 5) { targetName = argv[4].c_str(); } diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index 5586f66..f2353d8 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -75,7 +75,7 @@ public: { return " TRY_COMPILE(RESULT_VAR bindir srcdir\n" - " projectName >\n" + " projectName >\n" " )\n" "Try compiling a program. Return the success or failure in RESULT_VAR. " "If is specified then build just that target " -- cgit v0.12