diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index d9920366b..cac72fc4d 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -79,6 +79,14 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( "ProductDir", vc10Express, cmSystemTools::KeyWOW64_32); } +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts) +{ + this->PlatformToolset = ts; + return true; +} + //---------------------------------------------------------------------------- void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf) { diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index b377a203d..5926e0f21 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -28,6 +28,8 @@ public: const char* architectureId, const char* additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); + virtual bool SetGeneratorToolset(std::string const& ts); + virtual std::string GenerateBuildCommand(const char* makeProgram, const char *projectName, diff --git a/Source/cmake.h b/Source/cmake.h index 7253b39a5..dd0eb6b35 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -540,6 +540,8 @@ private: {"-T ", "Specify toolset name if supported by generator.", \ "Some CMake generators support a toolset name to be given to the " \ "native build system to choose a compiler. " \ + "This is supported only on specific generators:\n" \ + " Visual Studio >= 10\n" \ "See native build system documentation for allowed toolset names."}, \ {"-Wno-dev", "Suppress developer warnings.",\ "Suppress warnings that are meant for the author"\ diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake index cd63f48fc..49b63deab 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 000000000..d00491fd7 --- /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 000000000..d5726af5f --- /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 000000000..6f83bef28 --- /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()