summaryrefslogtreecommitdiffstats
path: root/Source/cmTryRunCommand.cxx
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-05-24 15:27:51 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2007-05-24 15:27:51 (GMT)
commit7d7aba292c09170fc9f145d68644e1ff6d158eec (patch)
tree6b50a27fb13d788c4b977ea199c6311ceea04854 /Source/cmTryRunCommand.cxx
parent8fb8a44f5f1de4c659cc4b4cfe060e91b1e48b9c (diff)
downloadCMake-7d7aba292c09170fc9f145d68644e1ff6d158eec.zip
CMake-7d7aba292c09170fc9f145d68644e1ff6d158eec.tar.gz
CMake-7d7aba292c09170fc9f145d68644e1ff6d158eec.tar.bz2
ENH: add two simple tests for TRY_RUN()
STYLE: create a new base class cmCoreTryCompile, from which cmTryCompileCommand and cmTryRunCommand are derived, so there are no public static functions with lots of arguments anymore Alex
Diffstat (limited to 'Source/cmTryRunCommand.cxx')
-rw-r--r--Source/cmTryRunCommand.cxx84
1 files changed, 42 insertions, 42 deletions
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index 8179a77..bcebd0f 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -71,62 +71,62 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
}
}
// do the try compile
- std::string fullPath;
- int res = cmTryCompileCommand::CoreTryCompileCode(this->Makefile, tryCompile,
- false, this->GetName(), fullPath);
+ int res = this->TryCompileCode(tryCompile);
// now try running the command if it compiled
- if (!res==0)
- {
- if (fullPath.size() > 0)
+ if (!res)
{
- int retVal = -1;
- std::string output;
- std::string finalCommand = fullPath;
- finalCommand = cmSystemTools::ConvertToRunCommandPath(fullPath.c_str());
- if(runArgs.size())
+ fprintf(stderr, "running %s\n", this->OutputFile.c_str());
+ if (this->OutputFile.size() == 0)
{
- finalCommand += runArgs;
+ cmSystemTools::Error(this->FindErrorMessage.c_str());
}
- int timeout = 0;
- bool worked = cmSystemTools::RunSingleCommand(finalCommand.c_str(),
- &output, &retVal,
- 0, false, timeout);
- if(outputVariable.size())
+ else
{
- // if the TryCompileCore saved output in this outputVariable then
- // prepend that output to this output
- const char* compileOutput
- = this->Makefile->GetDefinition(outputVariable.c_str());
- if(compileOutput)
+ int retVal = -1;
+ std::string output;
+ std::string finalCommand = cmSystemTools::ConvertToRunCommandPath(
+ this->OutputFile.c_str());
+ if(runArgs.size())
{
- output = std::string(compileOutput) + output;
+ finalCommand += runArgs;
}
- this->Makefile->AddDefinition(outputVariable.c_str(), output.c_str());
- }
- // set the run var
- char retChar[1000];
- if(worked)
- {
- sprintf(retChar,"%i",retVal);
- }
- else
- {
- strcpy(retChar, "FAILED_TO_RUN");
+ int timeout = 0;
+ 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
+ = this->Makefile->GetDefinition(outputVariable.c_str());
+ if(compileOutput)
+ {
+ output = std::string(compileOutput) + output;
+ }
+ this->Makefile->AddDefinition(outputVariable.c_str(), output.c_str());
+ }
+ // set the run var
+ char retChar[1000];
+ if(worked)
+ {
+ sprintf(retChar,"%i",retVal);
+ }
+ else
+ {
+ strcpy(retChar, "FAILED_TO_RUN");
+ }
+ this->Makefile->AddCacheDefinition(argv[0].c_str(), retChar,
+ "Result of TRY_RUN",
+ cmCacheManager::INTERNAL);
}
- this->Makefile->AddCacheDefinition(argv[0].c_str(), retChar,
- "Result of TRY_RUN",
- cmCacheManager::INTERNAL);
- }
}
// if we created a directory etc, then cleanup after ourselves
if(!this->Makefile->GetCMakeInstance()->GetDebugTryCompile())
{
- std::string binaryDirectory = argv[2];
- binaryDirectory += cmake::GetCMakeFilesDirectory();
- binaryDirectory += "/CMakeTmp";
- cmTryCompileCommand::CleanupFiles(binaryDirectory.c_str());
+ this->CleanupFiles(this->BinaryDirectory.c_str());
}
return true;
}