summaryrefslogtreecommitdiff
path: root/Source/cmGlobalVisualStudio10Generator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-02-08 16:25:03 -0500
committerBrad King <brad.king@kitware.com>2017-03-10 10:19:53 -0500
commit62b308515abe01fbe03ce0e1c7fee4879ca665b1 (patch)
treecc4315cc6d8a00a06c8520095defa59c22cb1ca1 /Source/cmGlobalVisualStudio10Generator.cxx
parent5164e9a6510137eaac1c7b736a6b24fe02ce17a9 (diff)
downloadcmake-62b308515abe01fbe03ce0e1c7fee4879ca665b1.tar.gz
VS: Select highest available CUDA toolset by default
If `CMAKE_GENERATOR_TOOLSET` does not have a `cuda=...` field then find available CUDA toolsets and choose the highest version.
Diffstat (limited to 'Source/cmGlobalVisualStudio10Generator.cxx')
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx27
1 files changed, 27 insertions, 0 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 55babda723..2cea693035 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -22,8 +22,11 @@
#include "cmake.h"
#include <cmsys/FStream.hxx>
+#include <cmsys/Glob.hxx>
#include <cmsys/RegularExpression.hxx>
+#include <algorithm>
+
static const char vs10generatorName[] = "Visual Studio 10 2010";
// Map generator name without year to name with year.
@@ -160,6 +163,13 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorPlatform(
return true;
}
+static void cmCudaToolVersion(std::string& s)
+{
+ // "CUDA x.y.props" => "x.y"
+ s = s.substr(5);
+ s = s.substr(0, s.size() - 6);
+}
+
bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
std::string const& ts, cmMakefile* mf)
{
@@ -180,6 +190,23 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
return false;
}
+ if (this->GeneratorToolsetCuda.empty()) {
+ // Find the highest available version of the CUDA tools.
+ std::vector<std::string> cudaTools;
+ std::string const bcDir = this->VCTargetsPath + "/BuildCustomizations";
+ cmsys::Glob gl;
+ gl.SetRelative(bcDir.c_str());
+ if (gl.FindFiles(bcDir + "/CUDA *.props")) {
+ cudaTools = gl.GetFiles();
+ }
+ if (!cudaTools.empty()) {
+ std::for_each(cudaTools.begin(), cudaTools.end(), cmCudaToolVersion);
+ std::sort(cudaTools.begin(), cudaTools.end(),
+ cmSystemTools::VersionCompareGreater);
+ this->GeneratorToolsetCuda = cudaTools.at(0);
+ }
+ }
+
if (const char* toolset = this->GetPlatformToolset()) {
mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET", toolset);
}