Fix tryrun to work on Linux

This commit is contained in:
Andy Cedilnik 2002-09-19 16:07:23 -04:00
parent 4027cfbb2d
commit 5d0716439f
1 changed files with 13 additions and 9 deletions

View File

@ -57,14 +57,14 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
int res = cmTryCompileCommand::CoreTryCompileCode(m_Makefile, tryCompile, false); int res = cmTryCompileCommand::CoreTryCompileCode(m_Makefile, tryCompile, false);
// now try running the command if it compiled // now try running the command if it compiled
std::string binaryDirectory = argv[1] + "/CMakeTmp"; std::string binaryDirectory = argv[2] + "/CMakeTmp";
if (!res) if (!res)
{ {
int retVal; int retVal;
std::string output; std::string output;
std::string command; std::string command;
command = binaryDirectory; command = binaryDirectory;
command += "/cmTryRunExec"; command += "/cmTryCompileExec";
command += cmSystemTools::GetExecutableExtension(); command += cmSystemTools::GetExecutableExtension();
std::string fullPath; std::string fullPath;
if(cmSystemTools::FileExists(command.c_str())) if(cmSystemTools::FileExists(command.c_str()))
@ -74,14 +74,19 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
else else
{ {
command = binaryDirectory; command = binaryDirectory;
command += "/Debug/cmTryRunExec"; command += "/Debug/cmTryCompileExec";
command += cmSystemTools::GetExecutableExtension(); command += cmSystemTools::GetExecutableExtension();
if(cmSystemTools::FileExists(command.c_str())) if(cmSystemTools::FileExists(command.c_str()))
{ {
fullPath = cmSystemTools::CollapseFullPath(command.c_str()); fullPath = cmSystemTools::CollapseFullPath(command.c_str());
} }
else
{
cmSystemTools::Error("Unable to find executable for TRY_RUN",
command.c_str());
}
} }
if (runArgs.size() > 1) if (fullPath.size() > 1)
{ {
std::string finalCommand = fullPath; std::string finalCommand = fullPath;
if(runArgs.size()) if(runArgs.size())
@ -93,11 +98,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
// set the run var // set the run var
char retChar[1000]; char retChar[1000];
sprintf(retChar,"%i",retVal); sprintf(retChar,"%i",retVal);
m_Makefile->AddDefinition(argv[1].c_str(), retChar); m_Makefile->AddDefinition(argv[0].c_str(), retChar);
}
else
{
cmSystemTools::Error("Unable to find executable for TRY_RUN");
} }
} }
@ -116,6 +117,9 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
cmSystemTools::RemoveFile(fullPath.c_str()); cmSystemTools::RemoveFile(fullPath.c_str());
} }
} }
std::string cacheFile = binaryDirectory;
cacheFile += "/CMakeLists.txt";
cmListFileCache::GetInstance()->FlushCache(cacheFile.c_str());
return true; return true;
} }