fix to the signature and argument parsing
This commit is contained in:
parent
afc33a1990
commit
baaf5eae7d
|
@ -33,13 +33,7 @@ int cmTryCompileCommand::CoreTryCompileCode(
|
||||||
const char* projectName = 0;
|
const char* projectName = 0;
|
||||||
const char* targetName = 0;
|
const char* targetName = 0;
|
||||||
std::string tmpString;
|
std::string tmpString;
|
||||||
|
int extraArgs = 0;
|
||||||
// do we have a srcfile signature
|
|
||||||
if (argv.size() == 3 || argv[3] == "CMAKE_FLAGS" || argv[3] == "COMPILE_DEFINITIONS" ||
|
|
||||||
argv[3] == "OUTPUT_VARIABLE")
|
|
||||||
{
|
|
||||||
srcFileSignature = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// look for CMAKE_FLAGS and store them
|
// look for CMAKE_FLAGS and store them
|
||||||
std::vector<std::string> cmakeFlags;
|
std::vector<std::string> cmakeFlags;
|
||||||
|
@ -47,10 +41,13 @@ int cmTryCompileCommand::CoreTryCompileCode(
|
||||||
{
|
{
|
||||||
if (argv[i] == "CMAKE_FLAGS")
|
if (argv[i] == "CMAKE_FLAGS")
|
||||||
{
|
{
|
||||||
|
extraArgs++;
|
||||||
|
++i;
|
||||||
for (; i < argv.size() && argv[i] != "COMPILE_DEFINITIONS" &&
|
for (; i < argv.size() && argv[i] != "COMPILE_DEFINITIONS" &&
|
||||||
argv[i] != "OUTPUT_VARIABLE";
|
argv[i] != "OUTPUT_VARIABLE";
|
||||||
++i)
|
++i)
|
||||||
{
|
{
|
||||||
|
extraArgs++;
|
||||||
cmakeFlags.push_back(argv[i]);
|
cmakeFlags.push_back(argv[i]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -69,6 +66,7 @@ int cmTryCompileCommand::CoreTryCompileCode(
|
||||||
"OUTPUT_VARIABLE specified but there is no variable");
|
"OUTPUT_VARIABLE specified but there is no variable");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
extraArgs += 2;
|
||||||
outputVariable = argv[i+1];
|
outputVariable = argv[i+1];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -80,23 +78,32 @@ int cmTryCompileCommand::CoreTryCompileCode(
|
||||||
{
|
{
|
||||||
if (argv[i] == "COMPILE_DEFINITIONS")
|
if (argv[i] == "COMPILE_DEFINITIONS")
|
||||||
{
|
{
|
||||||
// only valid for srcfile signatures
|
extraArgs++;
|
||||||
if (!srcFileSignature)
|
|
||||||
{
|
|
||||||
cmSystemTools::Error(
|
|
||||||
"COMPILE_FLAGS specified on a srcdir type TRY_COMPILE");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
for (i = i + 1; i < argv.size() && argv[i] != "CMAKE_FLAGS" &&
|
for (i = i + 1; i < argv.size() && argv[i] != "CMAKE_FLAGS" &&
|
||||||
argv[i] != "OUTPUT_VARIABLE";
|
argv[i] != "OUTPUT_VARIABLE";
|
||||||
++i)
|
++i)
|
||||||
{
|
{
|
||||||
|
extraArgs++;
|
||||||
compileFlags.push_back(argv[i]);
|
compileFlags.push_back(argv[i]);
|
||||||
}
|
}
|
||||||
break;
|
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
|
// compute the binary dir when TRY_COMPILE is called with a src file
|
||||||
// signature
|
// signature
|
||||||
if (srcFileSignature)
|
if (srcFileSignature)
|
||||||
|
@ -203,7 +210,7 @@ int cmTryCompileCommand::CoreTryCompileCode(
|
||||||
{
|
{
|
||||||
projectName = argv[3].c_str();
|
projectName = argv[3].c_str();
|
||||||
|
|
||||||
if (argv.size() == 5)
|
if (argv.size() - extraArgs == 5)
|
||||||
{
|
{
|
||||||
targetName = argv[4].c_str();
|
targetName = argv[4].c_str();
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
" TRY_COMPILE(RESULT_VAR bindir srcdir\n"
|
" TRY_COMPILE(RESULT_VAR bindir srcdir\n"
|
||||||
" projectName <CMAKE_FLAGS <Flags>>\n"
|
" projectName <targetname> <CMAKE_FLAGS <Flags>>\n"
|
||||||
" <OUTPUT_VARIABLE var>)\n"
|
" <OUTPUT_VARIABLE var>)\n"
|
||||||
"Try compiling a program. Return the success or failure in RESULT_VAR. "
|
"Try compiling a program. Return the success or failure in RESULT_VAR. "
|
||||||
"If <target name> is specified then build just that target "
|
"If <target name> is specified then build just that target "
|
||||||
|
|
Loading…
Reference in New Issue