diff options
author | Brad King <brad.king@kitware.com> | 2014-06-04 17:21:55 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-06-04 18:27:02 (GMT) |
commit | 528e8af19f68c01c3a42af9e74801a39c16237dd (patch) | |
tree | d6af200ff75eb396cf5157ff9bc12f797ed8ef7c /Tests/RunCMake | |
parent | 98afb4549f66c692eeec8bbc8a1f7b333d3051a5 (diff) | |
download | CMake-528e8af19f68c01c3a42af9e74801a39c16237dd.zip CMake-528e8af19f68c01c3a42af9e74801a39c16237dd.tar.gz CMake-528e8af19f68c01c3a42af9e74801a39c16237dd.tar.bz2 |
Allow a toolchain file to specify a generator toolset
Delay use of CMAKE_GENERATOR_TOOLSET until the CMakeSystem.cmake
file has been configured and loaded during the first project() or
enable_language() command. This gives the toolchain file named by
CMAKE_TOOLCHAIN_FILE a chance to set CMAKE_GENERATOR_TOOLSET. This
point is still early enough to set the generator toolset prior to
the initialization of any languages that might use the toolset.
The cmake::GeneratorToolset member variable remains an indication
of what was specified by the -T option or loaded from the cache.
It does not need to be updated based on the toolchain file setting.
The cmMakefile::TryCompile can still pass cmake::GeneratorToolset
into the inner instance because the try-compiled project will do
platform and language initialization using the CMakeSystem module
configured for the outer project.
Extend the RunCMake.GeneratorToolset test with cases that use a
toolchain file to set CMAKE_GENERATOR_TOOLSET.
Diffstat (limited to 'Tests/RunCMake')
10 files changed, 61 insertions, 1 deletions
diff --git a/Tests/RunCMake/GeneratorToolset/BadToolset-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolset-stderr.txt index bf1f190..d0d526c 100644 --- a/Tests/RunCMake/GeneratorToolset/BadToolset-stderr.txt +++ b/Tests/RunCMake/GeneratorToolset/BadToolset-stderr.txt @@ -1,4 +1,4 @@ -CMake Error: +CMake Error at CMakeLists.txt:[0-9]+ \(project\): Generator .* diff --git a/Tests/RunCMake/GeneratorToolset/BadToolset-toolchain.cmake b/Tests/RunCMake/GeneratorToolset/BadToolset-toolchain.cmake new file mode 100644 index 0000000..7bbf327 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolset-toolchain.cmake @@ -0,0 +1 @@ +set(CMAKE_GENERATOR_TOOLSET "Bad Toolset") diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetToolchain-result.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetToolchain-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetToolchain-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetToolchain-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetToolchain-stderr.txt new file mode 100644 index 0000000..d0d526c --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetToolchain-stderr.txt @@ -0,0 +1,10 @@ +CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + .* + + does not support toolset specification, but toolset + + Bad Toolset + + was specified.$ diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetToolchain.cmake b/Tests/RunCMake/GeneratorToolset/BadToolsetToolchain.cmake new file mode 100644 index 0000000..2fc38e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetToolchain.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake index 1ccc1ad..d39f33f 100644 --- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake @@ -12,6 +12,17 @@ else() endif() set(RunCMake_GENERATOR_TOOLSET "") + set(RunCMake_TEST_OPTIONS -T "Extra Toolset") run_cmake(TwoToolsets) unset(RunCMake_TEST_OPTIONS) + +if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012]|Xcode" AND NOT XCODE_BELOW_3) + set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/TestToolset-toolchain.cmake) + run_cmake(TestToolsetToolchain) + unset(RunCMake_TEST_OPTIONS) +else() + set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/BadToolset-toolchain.cmake) + run_cmake(BadToolsetToolchain) + unset(RunCMake_TEST_OPTIONS) +endif() diff --git a/Tests/RunCMake/GeneratorToolset/TestToolset-toolchain.cmake b/Tests/RunCMake/GeneratorToolset/TestToolset-toolchain.cmake new file mode 100644 index 0000000..bee2ae4 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolset-toolchain.cmake @@ -0,0 +1 @@ +set(CMAKE_GENERATOR_TOOLSET "Test Toolset") diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain-result.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain-stderr.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain-stderr.txt new file mode 100644 index 0000000..0623e90 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at TestToolsetToolchain.cmake:[0-9]+ \(message\): + CMAKE_GENERATOR_TOOLSET is "Test Toolset" as expected. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at TestToolsetToolchain.cmake:[0-9]+ \(message\): + CMAKE_(VS|XCODE)_PLATFORM_TOOLSET is "Test Toolset" as expected. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain.cmake new file mode 100644 index 0000000..7c1c415 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain.cmake @@ -0,0 +1,25 @@ +if("x${CMAKE_GENERATOR_TOOLSET}" STREQUAL "xTest Toolset") + message(SEND_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() +if(CMAKE_GENERATOR MATCHES "Visual Studio") + if("x${CMAKE_VS_PLATFORM_TOOLSET}" STREQUAL "xTest Toolset") + message(SEND_ERROR "CMAKE_VS_PLATFORM_TOOLSET is \"Test Toolset\" as expected.") + else() + message(FATAL_ERROR + "CMAKE_VS_PLATFORM_TOOLSET is \"${CMAKE_VS_PLATFORM_TOOLSET}\" " + "but should be \"Test Toolset\"!") + endif() +endif() +if(CMAKE_GENERATOR MATCHES "Xcode") + if("x${CMAKE_XCODE_PLATFORM_TOOLSET}" STREQUAL "xTest Toolset") + message(SEND_ERROR "CMAKE_XCODE_PLATFORM_TOOLSET is \"Test Toolset\" as expected.") + else() + message(FATAL_ERROR + "CMAKE_XCODE_PLATFORM_TOOLSET is \"${CMAKE_XCODE_PLATFORM_TOOLSET}\" " + "but should be \"Test Toolset\"!") + endif() +endif() |