CMake/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain.cmake
Brad King 528e8af19f 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.
2014-06-04 14:27:02 -04:00

26 lines
995 B
CMake

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()