summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2005-02-10 04:00:16 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2005-02-10 04:00:16 (GMT)
commitb7b501bbe8fa7a1a5ee5b342341c5512e7e604ca (patch)
tree32a489074211be98116fc94d45763922e62cc46b /Source
parentaa947ff48b6cf78663c658b46f37105467c04aea (diff)
downloadCMake-b7b501bbe8fa7a1a5ee5b342341c5512e7e604ca.zip
CMake-b7b501bbe8fa7a1a5ee5b342341c5512e7e604ca.tar.gz
CMake-b7b501bbe8fa7a1a5ee5b342341c5512e7e604ca.tar.bz2
ENH: fix for 1450
Diffstat (limited to 'Source')
-rw-r--r--Source/cmTryRunCommand.cxx25
-rw-r--r--Source/cmTryRunCommand.h5
2 files changed, 21 insertions, 9 deletions
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index 47f1d26..a5d5599 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -61,7 +61,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
if ( argv.size() <= (i+1) )
{
cmSystemTools::Error(
- "OUTPUT_VARIABLE specified but there is no variable");
+ "OUTPUT_VARIABLE specified but there is no variable");
return false;
}
outputVariable = argv[i+1];
@@ -75,7 +75,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
std::string binaryDirectory = argv[2] + "/CMakeTmp";
if (!res)
{
- int retVal;
+ int retVal = -1;
std::string output;
std::string command;
command = binaryDirectory;
@@ -110,25 +110,34 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
finalCommand += runArgs;
}
int timeout = 0;
- cmSystemTools::RunSingleCommand(finalCommand.c_str(), &output, &retVal,
- 0, false, timeout);
+ bool worked = cmSystemTools::RunSingleCommand(finalCommand.c_str(),
+ &output, &retVal,
+ 0, false, timeout);
if(outputVariable.size())
{
// if the TryCompileCore saved output in this outputVariable then
// prepend that output to this output
- const char* compileOutput = m_Makefile->GetDefinition(outputVariable.c_str());
+ const char* compileOutput
+ = m_Makefile->GetDefinition(outputVariable.c_str());
if(compileOutput)
{
output = std::string(compileOutput) + output;
}
m_Makefile->AddDefinition(outputVariable.c_str(), output.c_str());
}
-
// set the run var
char retChar[1000];
- sprintf(retChar,"%i",retVal);
+ if(worked)
+ {
+ sprintf(retChar,"%i",retVal);
+ }
+ else
+ {
+ strcpy(retChar, "FAILED_TO_RUN");
+ }
m_Makefile->AddCacheDefinition(argv[0].c_str(), retChar,
- "Result of TRY_RUN", cmCacheManager::INTERNAL);
+ "Result of TRY_RUN",
+ cmCacheManager::INTERNAL);
}
}
diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h
index a10000b..43f1318 100644
--- a/Source/cmTryRunCommand.h
+++ b/Source/cmTryRunCommand.h
@@ -66,7 +66,10 @@ public:
" <ARGUMENTS <arg1> <arg2>...>)\n"
"Try compiling a srcfile. Return the success or failure in "
"COMPILE_RESULT_VAR. Then if the compile succeeded, run the "
- "executable and return the result in RUN_RESULT_VAR.";
+ "executable and return the result in RUN_RESULT_VAR."
+ "If the executable was built, but failed for to run for some "
+ "reason, then RUN_RESULT_VAR will be set to FAILED_TO_RUN, and "
+ "the output will be in the COMPILE_RESULT_VAR.";
}
cmTypeMacro(cmTryRunCommand, cmCommand);