diff options
author | Ken Martin <ken.martin@kitware.com> | 2003-12-11 13:57:40 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2003-12-11 13:57:40 (GMT) |
commit | baaf5eae7d4439d1a678869d0936b4007972ed9b (patch) | |
tree | e958f8ac1ab2722256b26fab5114f8d89d92fe53 /Source/cmTryCompileCommand.cxx | |
parent | afc33a19909a5db044d19d86a0e8019e29ec5f97 (diff) | |
download | CMake-baaf5eae7d4439d1a678869d0936b4007972ed9b.zip CMake-baaf5eae7d4439d1a678869d0936b4007972ed9b.tar.gz CMake-baaf5eae7d4439d1a678869d0936b4007972ed9b.tar.bz2 |
fix to the signature and argument parsing
Diffstat (limited to 'Source/cmTryCompileCommand.cxx')
-rw-r--r-- | Source/cmTryCompileCommand.cxx | 39 |
1 files changed, 23 insertions, 16 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<std::string> 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(); } |