[cmake-commits] martink committed cmTryRunCommand.cxx 1.22 1.23
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu May 3 15:25:43 EDT 2007
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv19310
Modified Files:
cmTryRunCommand.cxx
Log Message:
ENH: look at CMAKE_TRY_COMPILE_CONFIGURATION var for TryRun as well
Index: cmTryRunCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTryRunCommand.cxx,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cmTryRunCommand.cxx 14 Jun 2006 16:28:30 -0000 1.22
+++ cmTryRunCommand.cxx 3 May 2007 19:25:41 -0000 1.23
@@ -76,6 +76,7 @@
int retVal = -1;
std::string output;
std::string command1 = binaryDirectory;
+ std::vector<std::string> attemptedPaths;
command1 += "/cmTryCompileExec";
command1 += cmSystemTools::GetExecutableExtension();
std::string fullPath;
@@ -83,34 +84,68 @@
{
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;
- command2 += "/Debug/cmTryCompileExec";
- command2 += cmSystemTools::GetExecutableExtension();
- if(cmSystemTools::FileExists(command2.c_str()))
+ const char* config =
+ this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
+ // if a config was specified try that first
+ 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());
+ }
+ attemptedPaths.push_back(command1);
}
- else
+ }
+ // try Debug if still not found
+ if (fullPath.empty())
+ {
+ command1 = binaryDirectory;
+ command1 += "/Debug/cmTryCompileExec";
+ command1 += cmSystemTools::GetExecutableExtension();
+ if(cmSystemTools::FileExists(command1.c_str()))
{
- std::string command3 = binaryDirectory;
- command3 += "/Development/cmTryCompileExec";
- command3 += cmSystemTools::GetExecutableExtension();
- if(cmSystemTools::FileExists(command3.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;
+ emsg << "Unable to find executable for TRY_RUN: tried \"";
+ for (i = 0; i < attemptedPaths.size(); ++i)
+ {
+ emsg << attemptedPaths[i];
+ if (i < attemptedPaths.size() - 1)
{
- fullPath = cmSystemTools::CollapseFullPath(command3.c_str());
+ emsg << "\" and \"";
}
else
{
- cmOStringStream emsg;
- emsg << "Unable to find executable for TRY_RUN: tried \""
- << command1 << "\" and \""
- << command2 << "\" and \""
- << command3 << "\".";
- cmSystemTools::Error(emsg.str().c_str());
+ emsg << "\".";
}
}
+ cmSystemTools::Error(emsg.str().c_str());
}
if (fullPath.size() > 1)
{
@@ -148,7 +183,7 @@
}
this->Makefile->AddCacheDefinition(argv[0].c_str(), retChar,
"Result of TRY_RUN",
- cmCacheManager::INTERNAL);
+ cmCacheManager::INTERNAL);
}
}
More information about the Cmake-commits
mailing list