summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2005-04-13 18:43:23 (GMT)
committerBrad King <brad.king@kitware.com>2005-04-13 18:43:23 (GMT)
commit925743e1e7fd2054022dc92400dcab2907c71dc7 (patch)
treecbc409ba7c79235b923c6a82dcd31567d1ade84d /Source
parentbf70e83397ab8db10f8c65c84f57b2cf0e14aac7 (diff)
downloadCMake-925743e1e7fd2054022dc92400dcab2907c71dc7.zip
CMake-925743e1e7fd2054022dc92400dcab2907c71dc7.tar.gz
CMake-925743e1e7fd2054022dc92400dcab2907c71dc7.tar.bz2
ENH: Added better error message when TRY_COMPILE does not recognize an extension.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmTryCompileCommand.cxx19
1 files changed, 11 insertions, 8 deletions
diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx
index 328c170..df06871 100644
--- a/Source/cmTryCompileCommand.cxx
+++ b/Source/cmTryCompileCommand.cxx
@@ -145,27 +145,30 @@ int cmTryCompileCommand::CoreTryCompileCode(
cmSystemTools::ReportLastSystemError("");
return -1;
}
-
+
std::string source = argv[2];
- const char* lang = mf->GetCMakeInstance()->GetGlobalGenerator()->GetLanguageFromExtension(
- cmSystemTools::GetFilenameExtension(source).c_str());
+ std::string ext = cmSystemTools::GetFilenameExtension(source);
+ const char* lang = (mf->GetCMakeInstance()->GetGlobalGenerator()
+ ->GetLanguageFromExtension(ext.c_str()));
if(lang)
{
fprintf(fout, "PROJECT(CMAKE_TRY_COMPILE %s)\n", lang);
}
else
{
+ cmOStringStream err;
+ err << "Unknown extension \"" << ext << "\" for file \""
+ << source << "\". TRY_COMPILE only works for enabled languages.\n"
+ << "Currently enabled languages are:";
std::vector<std::string> langs;
mf->GetCMakeInstance()->GetGlobalGenerator()->GetEnabledLanguages(langs);
- std::string msg = "TRY_COMPILE only works for enabled languages files,"
- "\nCurrently enabled languages are:\n";
for(std::vector<std::string>::iterator l = langs.begin();
l != langs.end(); ++l)
{
- msg += *l;
- msg += " ";
+ err << " " << *l;
}
- cmSystemTools::Error("Unknown file format for file: ", source.c_str(), msg.c_str());
+ err << "\nSee PROJECT command for help enabling other languages.";
+ cmSystemTools::Error(err.str().c_str());
return -1;
}
std::string langFlags = "CMAKE_";