summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-03-08 13:39:37 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-03-08 13:39:37 (GMT)
commita6e6f93b6c32c941e2ccc91c754812df049f9832 (patch)
treeca5be413f08f23bad9580a3810da2617decfe4f8
parentb14fe5c176141244a71736c34e905a3a30e84601 (diff)
parent72e0dc58d3caf63a57975e97ce13c5dc4b38cf9b (diff)
downloadCMake-a6e6f93b6c32c941e2ccc91c754812df049f9832.zip
CMake-a6e6f93b6c32c941e2ccc91c754812df049f9832.tar.gz
CMake-a6e6f93b6c32c941e2ccc91c754812df049f9832.tar.bz2
Merge topic 'toolchain-file-project'
72e0dc58 Diagnose recursive project/enable_language without crashing (#15999)
-rw-r--r--Source/cmGlobalGenerator.cxx21
-rw-r--r--Source/cmGlobalGenerator.h1
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/ToolchainFile/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/ToolchainFile/CallEnableLanguage-result.txt1
-rw-r--r--Tests/RunCMake/ToolchainFile/CallEnableLanguage-stderr.txt5
-rw-r--r--Tests/RunCMake/ToolchainFile/CallEnableLanguage-toolchain.cmake1
-rw-r--r--Tests/RunCMake/ToolchainFile/CallEnableLanguage.cmake0
-rw-r--r--Tests/RunCMake/ToolchainFile/CallProject-result.txt1
-rw-r--r--Tests/RunCMake/ToolchainFile/CallProject-stderr.txt5
-rw-r--r--Tests/RunCMake/ToolchainFile/CallProject-toolchain.cmake1
-rw-r--r--Tests/RunCMake/ToolchainFile/CallProject.cmake0
-rw-r--r--Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake9
13 files changed, 49 insertions, 0 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 848028f..c628406 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -398,6 +398,21 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
return;
}
+ std::set<std::string> cur_languages(languages.begin(), languages.end());
+ for (std::set<std::string>::iterator li = cur_languages.begin();
+ li != cur_languages.end(); ++li)
+ {
+ if (!this->LanguagesInProgress.insert(*li).second)
+ {
+ std::ostringstream e;
+ e << "Language '" << *li << "' is currently being enabled. "
+ "Recursive call not allowed.";
+ mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ cmSystemTools::SetFatalErrorOccured();
+ return;
+ }
+ }
+
if(this->TryCompileOuterMakefile)
{
// In a try-compile we can only enable languages provided by caller.
@@ -823,6 +838,12 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
{
cmSystemTools::SetFatalErrorOccured();
}
+
+ for (std::set<std::string>::iterator li = cur_languages.begin();
+ li != cur_languages.end(); ++li)
+ {
+ this->LanguagesInProgress.erase(*li);
+ }
}
//----------------------------------------------------------------------------
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 48fa704..6e819d3 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -457,6 +457,7 @@ private:
// in EnableLanguagesFromGenerator
std::map<std::string, bool> IgnoreExtensions;
std::set<std::string> LanguagesReady; // Ready for try_compile
+ std::set<std::string> LanguagesInProgress;
std::map<std::string, std::string> OutputExtensions;
std::map<std::string, std::string> LanguageToOutputExtension;
std::map<std::string, std::string> ExtensionToLanguage;
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 5bef629..23b9b42 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -152,6 +152,7 @@ add_RunCMake_test(ObjectLibrary)
add_RunCMake_test(Swift)
add_RunCMake_test(TargetObjects)
add_RunCMake_test(TargetSources)
+add_RunCMake_test(ToolchainFile)
add_RunCMake_test(find_dependency)
add_RunCMake_test(CompileDefinitions)
add_RunCMake_test(CompileFeatures)
diff --git a/Tests/RunCMake/ToolchainFile/CMakeLists.txt b/Tests/RunCMake/ToolchainFile/CMakeLists.txt
new file mode 100644
index 0000000..93ee9df
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.5)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/ToolchainFile/CallEnableLanguage-result.txt b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ToolchainFile/CallEnableLanguage-stderr.txt b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-stderr.txt
new file mode 100644
index 0000000..0de51c6
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at CallEnableLanguage-toolchain.cmake:[0-9]+ \(enable_language\):
+ Language 'NONE' is currently being enabled. Recursive call not allowed.
+Call Stack \(most recent call first\):
+ .*/Modules/CMakeDetermineSystem.cmake:[0-9]+ \(include\)
+ CMakeLists.txt:[0-9]+ \(project\)$
diff --git a/Tests/RunCMake/ToolchainFile/CallEnableLanguage-toolchain.cmake b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-toolchain.cmake
new file mode 100644
index 0000000..8145101
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/CallEnableLanguage-toolchain.cmake
@@ -0,0 +1 @@
+enable_language(NONE)
diff --git a/Tests/RunCMake/ToolchainFile/CallEnableLanguage.cmake b/Tests/RunCMake/ToolchainFile/CallEnableLanguage.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/CallEnableLanguage.cmake
diff --git a/Tests/RunCMake/ToolchainFile/CallProject-result.txt b/Tests/RunCMake/ToolchainFile/CallProject-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/CallProject-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ToolchainFile/CallProject-stderr.txt b/Tests/RunCMake/ToolchainFile/CallProject-stderr.txt
new file mode 100644
index 0000000..e2b9f1b
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/CallProject-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at CallProject-toolchain.cmake:[0-9]+ \(project\):
+ Language 'NONE' is currently being enabled. Recursive call not allowed.
+Call Stack \(most recent call first\):
+ .*/Modules/CMakeDetermineSystem.cmake:[0-9]+ \(include\)
+ CMakeLists.txt:[0-9]+ \(project\)$
diff --git a/Tests/RunCMake/ToolchainFile/CallProject-toolchain.cmake b/Tests/RunCMake/ToolchainFile/CallProject-toolchain.cmake
new file mode 100644
index 0000000..b113c13
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/CallProject-toolchain.cmake
@@ -0,0 +1 @@
+project(Bad NONE)
diff --git a/Tests/RunCMake/ToolchainFile/CallProject.cmake b/Tests/RunCMake/ToolchainFile/CallProject.cmake
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/CallProject.cmake
diff --git a/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake
new file mode 100644
index 0000000..75293e7
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake
@@ -0,0 +1,9 @@
+include(RunCMake)
+
+function(run_cmake_toolchain t)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/${t}-toolchain.cmake)
+ run_cmake(${t})
+endfunction()
+
+run_cmake_toolchain(CallEnableLanguage)
+run_cmake_toolchain(CallProject)