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.
This commit is contained in:
parent
4fd5342956
commit
650c647160
|
@ -79,6 +79,14 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
|
||||||
"ProductDir", vc10Express, cmSystemTools::KeyWOW64_32);
|
"ProductDir", vc10Express, cmSystemTools::KeyWOW64_32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts)
|
||||||
|
{
|
||||||
|
this->PlatformToolset = ts;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf)
|
void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,8 @@ public:
|
||||||
const char* architectureId, const char* additionalPlatformDefinition);
|
const char* architectureId, const char* additionalPlatformDefinition);
|
||||||
static cmGlobalGeneratorFactory* NewFactory();
|
static cmGlobalGeneratorFactory* NewFactory();
|
||||||
|
|
||||||
|
virtual bool SetGeneratorToolset(std::string const& ts);
|
||||||
|
|
||||||
virtual std::string
|
virtual std::string
|
||||||
GenerateBuildCommand(const char* makeProgram,
|
GenerateBuildCommand(const char* makeProgram,
|
||||||
const char *projectName,
|
const char *projectName,
|
||||||
|
|
|
@ -540,6 +540,8 @@ private:
|
||||||
{"-T <toolset-name>", "Specify toolset name if supported by generator.", \
|
{"-T <toolset-name>", "Specify toolset name if supported by generator.", \
|
||||||
"Some CMake generators support a toolset name to be given to the " \
|
"Some CMake generators support a toolset name to be given to the " \
|
||||||
"native build system to choose a compiler. " \
|
"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."}, \
|
"See native build system documentation for allowed toolset names."}, \
|
||||||
{"-Wno-dev", "Suppress developer warnings.",\
|
{"-Wno-dev", "Suppress developer warnings.",\
|
||||||
"Suppress warnings that are meant for the author"\
|
"Suppress warnings that are meant for the author"\
|
||||||
|
|
|
@ -2,9 +2,15 @@ include(RunCMake)
|
||||||
|
|
||||||
run_cmake(NoToolset)
|
run_cmake(NoToolset)
|
||||||
|
|
||||||
|
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")
|
set(RunCMake_TEST_OPTIONS -T "Bad Toolset")
|
||||||
run_cmake(BadToolset)
|
run_cmake(BadToolset)
|
||||||
unset(RunCMake_TEST_OPTIONS)
|
unset(RunCMake_TEST_OPTIONS)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(RunCMake_TEST_OPTIONS -T "Toolset 1" "-TToolset 2")
|
set(RunCMake_TEST_OPTIONS -T "Toolset 1" "-TToolset 2")
|
||||||
run_cmake(TwoToolsets)
|
run_cmake(TwoToolsets)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -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\)
|
|
@ -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()
|
Loading…
Reference in New Issue