ENH: look at CMAKE_TRY_COMPILE_CONFIGURATION var for TryRun as well

This commit is contained in:
Ken Martin 2007-05-03 15:25:41 -04:00
parent aa4d7847ee
commit 2450835267

View File

@ -76,6 +76,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
int retVal = -1; int retVal = -1;
std::string output; std::string output;
std::string command1 = binaryDirectory; std::string command1 = binaryDirectory;
std::vector<std::string> attemptedPaths;
command1 += "/cmTryCompileExec"; command1 += "/cmTryCompileExec";
command1 += cmSystemTools::GetExecutableExtension(); command1 += cmSystemTools::GetExecutableExtension();
std::string fullPath; std::string fullPath;
@ -83,35 +84,69 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
{ {
fullPath = cmSystemTools::CollapseFullPath(command1.c_str()); fullPath = cmSystemTools::CollapseFullPath(command1.c_str());
} }
else attemptedPaths.push_back(command1);
command1 = binaryDirectory;
// try CMAKE_TRY_COMPILE_CONFIGURATION if it is set
if (fullPath.empty())
{ {
std::string command2 = binaryDirectory; const char* config =
command2 += "/Debug/cmTryCompileExec"; this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
command2 += cmSystemTools::GetExecutableExtension(); // if a config was specified try that first
if(cmSystemTools::FileExists(command2.c_str())) if (config && config[0])
{ {
fullPath = cmSystemTools::CollapseFullPath(command2.c_str()); command1 += "/";
command1 += config;
command1 += "/cmTryCompileExec";
command1 += cmSystemTools::GetExecutableExtension();
if(cmSystemTools::FileExists(command1.c_str()))
{
fullPath = cmSystemTools::CollapseFullPath(command1.c_str());
} }
else attemptedPaths.push_back(command1);
{
std::string command3 = binaryDirectory;
command3 += "/Development/cmTryCompileExec";
command3 += cmSystemTools::GetExecutableExtension();
if(cmSystemTools::FileExists(command3.c_str()))
{
fullPath = cmSystemTools::CollapseFullPath(command3.c_str());
} }
else }
// try Debug if still not found
if (fullPath.empty())
{
command1 = binaryDirectory;
command1 += "/Debug/cmTryCompileExec";
command1 += cmSystemTools::GetExecutableExtension();
if(cmSystemTools::FileExists(command1.c_str()))
{
fullPath = cmSystemTools::CollapseFullPath(command1.c_str());
}
attemptedPaths.push_back(command1);
}
// try Deployment if still not found
if (fullPath.empty())
{
command1 = binaryDirectory;
command1 += "/Development/cmTryCompileExec";
command1 += cmSystemTools::GetExecutableExtension();
if(cmSystemTools::FileExists(command1.c_str()))
{
fullPath = cmSystemTools::CollapseFullPath(command1.c_str());
}
attemptedPaths.push_back(command1);
}
if (fullPath.empty())
{ {
cmOStringStream emsg; cmOStringStream emsg;
emsg << "Unable to find executable for TRY_RUN: tried \"" emsg << "Unable to find executable for TRY_RUN: tried \"";
<< command1 << "\" and \"" for (i = 0; i < attemptedPaths.size(); ++i)
<< command2 << "\" and \"" {
<< command3 << "\"."; emsg << attemptedPaths[i];
if (i < attemptedPaths.size() - 1)
{
emsg << "\" and \"";
}
else
{
emsg << "\".";
}
}
cmSystemTools::Error(emsg.str().c_str()); cmSystemTools::Error(emsg.str().c_str());
} }
}
}
if (fullPath.size() > 1) if (fullPath.size() > 1)
{ {
std::string finalCommand = fullPath; std::string finalCommand = fullPath;