enable_language: Allow CMakeDetermine<LANG>Compiler module to fail early

If the module reports a FATAL_ERROR, skip the rest of the steps to
enable the language to avoid unnecessary following error messages.
This commit is contained in:
Brad King 2015-06-29 14:51:14 -04:00
parent bbfebcbc13
commit 327490e698
6 changed files with 15 additions and 0 deletions

View File

@ -564,6 +564,10 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
cmSystemTools::Error("Could not find cmake module file: ",
determineCompiler.c_str());
}
if (cmSystemTools::GetFatalErrorOccured())
{
return;
}
needTestLanguage[lang] = true;
// Some generators like visual studio should not use the env variables
// So the global generator can specify that in this variable

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,5 @@
^CMake Error at Modules/CMakeDetermineFailCompiler.cmake:[0-9]+ \(message\):
This language is not supported.
Call Stack \(most recent call first\):
DetermineFail.cmake:[0-9]+ \(enable_language\)
CMakeLists.txt:[0-9]+ \(include\)

View File

@ -0,0 +1,2 @@
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules)
enable_language(Fail)

View File

@ -0,0 +1 @@
message(FATAL_ERROR "This language is not supported.")

View File

@ -4,3 +4,5 @@ run_cmake(NoLangSHARED)
run_cmake(LINK_LANGUAGE-genex)
run_cmake(link-libraries-TARGET_FILE-genex)
run_cmake(link-libraries-TARGET_FILE-genex-ok)
run_cmake(DetermineFail)