summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-03-07 18:31:25 (GMT)
committerBrad King <brad.king@kitware.com>2016-03-07 18:52:38 (GMT)
commit72e0dc58d3caf63a57975e97ce13c5dc4b38cf9b (patch)
treec4011b95d6067e77f6074026d4ad9d5b381eee5b /Tests/RunCMake
parent8256d021c8324779c7269658a094848ebeafb82e (diff)
downloadCMake-72e0dc58d3caf63a57975e97ce13c5dc4b38cf9b.zip
CMake-72e0dc58d3caf63a57975e97ce13c5dc4b38cf9b.tar.gz
CMake-72e0dc58d3caf63a57975e97ce13c5dc4b38cf9b.tar.bz2
Diagnose recursive project/enable_language without crashing (#15999)
Calling `project()` or `enable_language()` from a toolchain file will infinitely recurse since those commands load the toolchain file. Diagnose and reject this case with an error message instead of crashing when the stack eventually overflows.
Diffstat (limited to 'Tests/RunCMake')
-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
11 files changed, 27 insertions, 0 deletions
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)