Commit 5164e9a6 authored by Brad King's avatar Brad King 💬
Browse files

VS: Provide an option to specify CUDA toolset version

The NVIDIA CUDA Toolkit provides MSBuild toolset files for integration
with Visual Studio.  Multiple versions may be installed so we need a way
to tell our VS generators which CUDA toolset to use.  Extend the
`CMAKE_GENERATOR_TOOLSET` specification to provide a `cuda=...` field
specifying the version number.
parent 83bf980c
......@@ -82,6 +82,7 @@ Variables that Provide Information
/variable/CMAKE_VS_NsightTegra_VERSION
/variable/CMAKE_VS_PLATFORM_NAME
/variable/CMAKE_VS_PLATFORM_TOOLSET
/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA
/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE
/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION
/variable/CMAKE_XCODE_PLATFORM_TOOLSET
......
CMAKE_VS_PLATFORM_TOOLSET_CUDA
------------------------------
NVIDIA CUDA Toolkit version whose Visual Studio toolset to use.
The :ref:`Visual Studio Generators` for VS 2010 and above support using
a CUDA toolset provided by a CUDA Toolkit. The toolset version number
may be specified by a field in :variable:`CMAKE_GENERATOR_TOOLSET` of
the form ``cuda=8.0``. CMake provides the selected CUDA toolset version
in this variable. The value may be empty if no version was specified.
......@@ -186,6 +186,9 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
if (const char* hostArch = this->GetPlatformToolsetHostArchitecture()) {
mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE", hostArch);
}
if (const char* cuda = this->GetPlatformToolsetCuda()) {
mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_CUDA", cuda);
}
return true;
}
......@@ -261,8 +264,10 @@ bool cmGlobalVisualStudio10Generator::ParseGeneratorToolset(
bool cmGlobalVisualStudio10Generator::ProcessGeneratorToolsetField(
std::string const& key, std::string const& value)
{
static_cast<void>(key);
static_cast<void>(value);
if (key == "cuda") {
this->GeneratorToolsetCuda = value;
return true;
}
return false;
}
......@@ -463,6 +468,20 @@ cmGlobalVisualStudio10Generator::GetPlatformToolsetHostArchitecture() const
return CM_NULLPTR;
}
const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetCuda() const
{
if (!this->GeneratorToolsetCuda.empty()) {
return this->GeneratorToolsetCuda.c_str();
}
return CM_NULLPTR;
}
std::string const&
cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaString() const
{
return this->GeneratorToolsetCuda;
}
bool cmGlobalVisualStudio10Generator::FindMakeProgram(cmMakefile* mf)
{
if (!this->cmGlobalVisualStudio8Generator::FindMakeProgram(mf)) {
......
......@@ -53,6 +53,10 @@ public:
/** The toolset host architecture name (e.g. x64 for 64-bit host tools). */
const char* GetPlatformToolsetHostArchitecture() const;
/** The cuda toolset version. */
const char* GetPlatformToolsetCuda() const;
std::string const& GetPlatformToolsetCudaString() const;
/** Return the CMAKE_SYSTEM_NAME. */
std::string const& GetSystemName() const { return this->SystemName; }
......@@ -118,6 +122,7 @@ protected:
std::string GeneratorToolset;
std::string GeneratorToolsetHostArchitecture;
std::string GeneratorToolsetCuda;
std::string DefaultPlatformToolset;
std::string WindowsTargetPlatformVersion;
std::string SystemName;
......
......@@ -6,6 +6,12 @@ run_cmake(NoToolset)
if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[01245]")
set(RunCMake_GENERATOR_TOOLSET "Test Toolset")
run_cmake(TestToolset)
set(RunCMake_GENERATOR_TOOLSET "Test Toolset,cuda=Test Cuda")
run_cmake(TestToolsetCudaBoth)
set(RunCMake_GENERATOR_TOOLSET ",cuda=Test Cuda")
run_cmake(TestToolsetCudaOnly)
set(RunCMake_GENERATOR_TOOLSET "cuda=Test Cuda")
run_cmake(TestToolsetCudaOnly)
if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[245]")
set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64")
run_cmake(TestToolsetHostArchBoth)
......
-- CMAKE_VS_PLATFORM_TOOLSET='Test Toolset'
-- CMAKE_VS_PLATFORM_TOOLSET_CUDA='Test Cuda'
message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'")
message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_CUDA='${CMAKE_VS_PLATFORM_TOOLSET_CUDA}'")
-- CMAKE_VS_PLATFORM_TOOLSET='(v[0-9]+|Windows7.1SDK)'
-- CMAKE_VS_PLATFORM_TOOLSET_CUDA='Test Cuda'
message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'")
message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_CUDA='${CMAKE_VS_PLATFORM_TOOLSET_CUDA}'")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment