summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/GeneratorToolset
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-12-10 15:52:10 (GMT)
committerBrad King <brad.king@kitware.com>2013-02-07 16:06:28 (GMT)
commit650c6471600fa8b06ed343ff3a4f3d16a3dc95bc (patch)
treeacb198ff664687a5cfad1fa238d46a9c80e74570 /Tests/RunCMake/GeneratorToolset
parent4fd534295642b1c08c72229d705db6c7265ecd28 (diff)
downloadCMake-650c6471600fa8b06ed343ff3a4f3d16a3dc95bc.zip
CMake-650c6471600fa8b06ed343ff3a4f3d16a3dc95bc.tar.gz
CMake-650c6471600fa8b06ed343ff3a4f3d16a3dc95bc.tar.bz2
VS: Implement generator toolset selection (#10722, #13774)
Implement generator toolset selection (cmake -T) for VS >= 10 by setting the PlatformToolset. Extend the RunCMake.GeneratorToolset test case to verify CMAKE_GENERATOR_TOOLSET when the generator supports -T. Since commit 485a940e (VS: Simplify MSVC version reporting, 2012-08-23) all MSVC version information is detected during the compiler id step from the actual compiler invoked by generated build systems rather than hard-coded in VS generators. Therefore we can set the PlatformToolset in VS >= 10 project files and support toolsets from other VS versions.
Diffstat (limited to 'Tests/RunCMake/GeneratorToolset')
-rw-r--r--Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake12
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolset-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolset-stderr.txt4
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolset.cmake7
4 files changed, 21 insertions, 3 deletions
diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake
index cd63f48..49b63de 100644
--- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake
@@ -2,9 +2,15 @@ include(RunCMake)
run_cmake(NoToolset)
-set(RunCMake_TEST_OPTIONS -T "Bad Toolset")
-run_cmake(BadToolset)
-unset(RunCMake_TEST_OPTIONS)
+if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[01]")
+ set(RunCMake_TEST_OPTIONS -T "Test Toolset")
+ run_cmake(TestToolset)
+ unset(RunCMake_TEST_OPTIONS)
+else()
+ set(RunCMake_TEST_OPTIONS -T "Bad Toolset")
+ run_cmake(BadToolset)
+ unset(RunCMake_TEST_OPTIONS)
+endif()
set(RunCMake_TEST_OPTIONS -T "Toolset 1" "-TToolset 2")
run_cmake(TwoToolsets)
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolset-result.txt b/Tests/RunCMake/GeneratorToolset/TestToolset-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolset-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolset-stderr.txt b/Tests/RunCMake/GeneratorToolset/TestToolset-stderr.txt
new file mode 100644
index 0000000..d5726af
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolset-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at TestToolset.cmake:2 \(message\):
+ CMAKE_GENERATOR_TOOLSET is "Test Toolset" as expected.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolset.cmake b/Tests/RunCMake/GeneratorToolset/TestToolset.cmake
new file mode 100644
index 0000000..6f83bef
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolset.cmake
@@ -0,0 +1,7 @@
+if("x${CMAKE_GENERATOR_TOOLSET}" STREQUAL "xTest Toolset")
+ message(FATAL_ERROR "CMAKE_GENERATOR_TOOLSET is \"Test Toolset\" as expected.")
+else()
+ message(FATAL_ERROR
+ "CMAKE_GENERATOR_TOOLSET is \"${CMAKE_GENERATOR_TOOLSET}\" "
+ "but should be \"Test Toolset\"!")
+endif()