summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalVisualStudio10Generator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-09-03 13:32:02 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-09-03 13:34:46 (GMT)
commitcee20ad5374e2547cad9f2847006cf753c301042 (patch)
tree46f5114f0f2db7b2ad9da463e52f21c05c51ee2c /Source/cmGlobalVisualStudio10Generator.cxx
parentd8e323761152dcf494606ca3436637a9cbbe1741 (diff)
parent25f29b974182ae7da36ace86e846b4c0b2807a68 (diff)
downloadCMake-cee20ad5374e2547cad9f2847006cf753c301042.zip
CMake-cee20ad5374e2547cad9f2847006cf753c301042.tar.gz
CMake-cee20ad5374e2547cad9f2847006cf753c301042.tar.bz2
Merge topic 'vs-cuda-custom-dir'
25f29b9741 cuda: Adapted tests to work with modified cuda toolset ee86770a3f cuda: Added docs for extended cuda toolset 0ad180d712 cuda: Extend cuda compiler detection to work with custom cuda path 55b0532128 cuda: Extend vs10 target generator to use custom cuda path df0247a371 cuda: Extend toolset argument to accept path Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3713
Diffstat (limited to 'Source/cmGlobalVisualStudio10Generator.cxx')
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx58
1 files changed, 56 insertions, 2 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 48b17c0..7d437f3 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -232,7 +232,15 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
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";
+ std::string bcDir;
+ if (this->GeneratorToolsetCudaCustomDir.empty()) {
+ bcDir = this->VCTargetsPath + "/BuildCustomizations";
+ } else {
+ bcDir = this->GetPlatformToolsetCudaCustomDirString() +
+ "CUDAVisualStudioIntegration\\extras\\"
+ "visual_studio_integration\\MSBuildExtensions";
+ cmSystemTools::ConvertToUnixSlashes(bcDir);
+ }
cmsys::Glob gl;
gl.SetRelative(bcDir.c_str());
if (gl.FindFiles(bcDir + "/CUDA *.props")) {
@@ -243,6 +251,24 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
std::sort(cudaTools.begin(), cudaTools.end(),
cmSystemTools::VersionCompareGreater);
this->GeneratorToolsetCuda = cudaTools.at(0);
+ } else if (!this->GeneratorToolsetCudaCustomDir.empty()) {
+ // Generate an error if Visual Studio integration files are not found
+ // inside of custom cuda toolset.
+ std::ostringstream e;
+ /* clang-format off */
+ e <<
+ "Generator\n"
+ " " << this->GetName() << "\n"
+ "given toolset\n"
+ " cuda=" << this->GeneratorToolsetCudaCustomDir << "\n"
+ "cannot detect Visual Studio integration files in path\n"
+ " " << bcDir;
+
+ /* clang-format on */
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+
+ // Clear the configured tool-set
+ this->GeneratorToolsetCuda.clear();
}
}
@@ -319,6 +345,9 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
if (const char* cuda = this->GetPlatformToolsetCuda()) {
mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_CUDA", cuda);
}
+ if (const char* cudaDir = this->GetPlatformToolsetCudaCustomDir()) {
+ mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR", cudaDir);
+ }
return true;
}
@@ -395,7 +424,17 @@ bool cmGlobalVisualStudio10Generator::ProcessGeneratorToolsetField(
std::string const& key, std::string const& value)
{
if (key == "cuda") {
- this->GeneratorToolsetCuda = value;
+ /* test if cuda toolset is path to custom dir or cuda version */
+ auto pos = value.find_first_not_of("0123456789.");
+ if (pos != std::string::npos) {
+ this->GeneratorToolsetCudaCustomDir = value;
+ /* ensure trailing backslash for easy path joining */
+ if (this->GeneratorToolsetCudaCustomDir.back() != '\\') {
+ this->GeneratorToolsetCudaCustomDir.push_back('\\');
+ }
+ } else {
+ this->GeneratorToolsetCuda = value;
+ }
return true;
}
if (key == "version") {
@@ -643,6 +682,21 @@ cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaString() const
return this->GeneratorToolsetCuda;
}
+const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaCustomDir()
+ const
+{
+ if (!this->GeneratorToolsetCudaCustomDir.empty()) {
+ return this->GeneratorToolsetCudaCustomDir.c_str();
+ }
+ return nullptr;
+}
+
+std::string const&
+cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaCustomDirString() const
+{
+ return this->GeneratorToolsetCudaCustomDir;
+}
+
bool cmGlobalVisualStudio10Generator::IsDefaultToolset(
const std::string&) const
{