summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-10-28 12:39:29 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-10-28 12:39:29 (GMT)
commit16df2456a440d87fb3e8e53fb59a2817b288b9af (patch)
treea44c27696661e6edd6222dc01e4d783f3821010c /Source
parentecc6d7f9190a660c0f442c4d03854b06e3fc7856 (diff)
parent3e04946f7b69418f6b222875ad18fed3438e0fa1 (diff)
downloadCMake-16df2456a440d87fb3e8e53fb59a2817b288b9af.zip
CMake-16df2456a440d87fb3e8e53fb59a2817b288b9af.tar.gz
CMake-16df2456a440d87fb3e8e53fb59a2817b288b9af.tar.bz2
Merge topic 'enable-language-require-compiler'
3e04946 Require CMAKE_<LANG>_COMPILER to be found as a full path 6007f7c CMakeDetermineCompilerId: Always use compiler detected from IDE 332771c CMakeDetermine*Compiler: Remove temporary cache entry
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalGenerator.cxx120
-rw-r--r--Source/cmGlobalGenerator.h2
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h1
-rw-r--r--Source/cmGlobalXCodeGenerator.h1
4 files changed, 99 insertions, 25 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index e26f59f..5b0df2c 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -138,15 +138,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
if((path.size() == 0 || !cmSystemTools::FileExists(path.c_str()))
&& (optional==false))
{
- std::string message = "your ";
- message += lang;
- message += " compiler: \"";
- message += name;
- message += "\" was not found. Please set ";
- message += langComp;
- message += " to a valid compiler path or name.";
- cmSystemTools::Error(message.c_str());
- path = name;
+ return;
}
std::string doc = lang;
doc += " compiler.";
@@ -334,7 +326,7 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
void
cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
- cmMakefile *mf, bool)
+ cmMakefile *mf, bool optional)
{
if(languages.size() == 0)
{
@@ -370,6 +362,8 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
}
}
+ bool fatalError = false;
+
mf->AddDefinition("RUN_CONFIGURE", true);
std::string rootBin = mf->GetHomeOutputDirectory();
rootBin += cmake::GetCMakeFilesDirectory();
@@ -556,6 +550,65 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
this->SetLanguageEnabled("NONE", mf);
continue;
}
+
+ // Check that the compiler was found.
+ std::string compilerName = "CMAKE_";
+ compilerName += lang;
+ compilerName += "_COMPILER";
+ std::string compilerEnv = "CMAKE_";
+ compilerEnv += lang;
+ compilerEnv += "_COMPILER_ENV_VAR";
+ cmOStringStream noCompiler;
+ const char* compilerFile = mf->GetDefinition(compilerName.c_str());
+ if(!compilerFile || !*compilerFile ||
+ cmSystemTools::IsNOTFOUND(compilerFile))
+ {
+ noCompiler <<
+ "No " << compilerName << " could be found.\n"
+ ;
+ }
+ else if(strcmp(lang, "RC") != 0)
+ {
+ if(!cmSystemTools::FileIsFullPath(compilerFile))
+ {
+ noCompiler <<
+ "The " << compilerName << ":\n"
+ " " << compilerFile << "\n"
+ "is not a full path and was not found in the PATH.\n"
+ ;
+ }
+ else if(!cmSystemTools::FileExists(compilerFile))
+ {
+ noCompiler <<
+ "The " << compilerName << ":\n"
+ " " << compilerFile << "\n"
+ "is not a full path to an existing compiler tool.\n"
+ ;
+ }
+ }
+ if(!noCompiler.str().empty())
+ {
+ // Skip testing this language since the compiler is not found.
+ needTestLanguage[lang] = false;
+ if(!optional)
+ {
+ // The compiler was not found and it is not optional. Remove
+ // CMake(LANG)Compiler.cmake so we try again next time CMake runs.
+ std::string compilerLangFile = rootBin;
+ compilerLangFile += "/CMake";
+ compilerLangFile += lang;
+ compilerLangFile += "Compiler.cmake";
+ cmSystemTools::RemoveFile(compilerLangFile.c_str());
+ if(!this->CMakeInstance->GetIsInTryCompile())
+ {
+ this->PrintCompilerAdvice(noCompiler, lang,
+ mf->GetDefinition(compilerEnv.c_str()));
+ mf->IssueMessage(cmake::FATAL_ERROR, noCompiler.str());
+ fatalError = true;
+ }
+ }
+ }
+
std::string langLoadedVar = "CMAKE_";
langLoadedVar += lang;
langLoadedVar += "_INFORMATION_LOADED";
@@ -582,26 +635,12 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
}
this->LanguagesReady.insert(lang);
- std::string compilerName = "CMAKE_";
- compilerName += lang;
- compilerName += "_COMPILER";
- std::string compilerLangFile = rootBin;
- compilerLangFile += "/CMake";
- compilerLangFile += lang;
- compilerLangFile += "Compiler.cmake";
// Test the compiler for the language just setup
// (but only if a compiler has been actually found)
// At this point we should have enough info for a try compile
// which is used in the backward stuff
// If the language is untested then test it now with a try compile.
- if (!mf->IsSet(compilerName.c_str()))
- {
- // if the compiler did not work, then remove the
- // CMake(LANG)Compiler.cmake file so that it will get tested the
- // next time cmake is run
- cmSystemTools::RemoveFile(compilerLangFile.c_str());
- }
- else if(needTestLanguage[lang])
+ if(needTestLanguage[lang])
{
if (!this->CMakeInstance->GetIsInTryCompile())
{
@@ -622,6 +661,10 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
// next time cmake is run
if(!mf->IsOn(compilerWorks.c_str()))
{
+ std::string compilerLangFile = rootBin;
+ compilerLangFile += "/CMake";
+ compilerLangFile += lang;
+ compilerLangFile += "Compiler.cmake";
cmSystemTools::RemoveFile(compilerLangFile.c_str());
}
} // end if in try compile
@@ -652,6 +695,33 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
{
mf->ReadListFile(0,projectCompatibility.c_str());
}
+
+ if(fatalError)
+ {
+ cmSystemTools::SetFatalErrorOccured();
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os,
+ std::string lang,
+ const char* envVar)
+{
+ // Subclasses override this method if they do not support this advice.
+ os <<
+ "Tell CMake where to find the compiler by setting "
+ ;
+ if(envVar)
+ {
+ os <<
+ "either the environment variable \"" << envVar << "\" or "
+ ;
+ }
+ os <<
+ "the CMake cache entry CMAKE_" << lang << "_COMPILER "
+ "to the full path to the compiler, or to the compiler name "
+ "if it is in the PATH."
+ ;
}
//----------------------------------------------------------------------------
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index c930b2b..3c4ddb2 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -392,6 +392,8 @@ private:
void WriteSummary();
void WriteSummary(cmTarget* target);
+ virtual void PrintCompilerAdvice(std::ostream& os, std::string lang,
+ const char* envVar);
void CheckCompilerIdCompatibility(cmMakefile* mf, std::string lang);
cmExternalMakefileProjectGenerator* ExtraGenerator;
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index b665158..ce03a0e 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -107,6 +107,7 @@ protected:
const char* AdditionalPlatformDefinition;
private:
+ void PrintCompilerAdvice(std::ostream&, std::string, const char*) {}
void ComputeTargetObjects(cmGeneratorTarget* gt) const;
void FollowLinkDepends(cmTarget* target, std::set<cmTarget*>& linked);
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index c053943..97072b2 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -210,6 +210,7 @@ protected:
std::vector<cmXCodeObject*> XCodeObjects;
cmXCodeObject* RootObject;
private:
+ void PrintCompilerAdvice(std::ostream&, std::string, const char*) {}
void ComputeTargetObjects(cmGeneratorTarget* gt) const;
std::string GetObjectsNormalDirectory(