summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-03-19 15:26:12 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-03-19 15:26:20 (GMT)
commit888c1cb2769a1e82ba5cf8b3a9584eead684fa6c (patch)
treea9559043bc449c85bd5d239e35131db06fa07719
parent8cef887b8a3905eab7ca6ff2f2dde99d92279712 (diff)
parentc73b847b0311a0eff0eeaa113991bce0149532a7 (diff)
downloadCMake-888c1cb2769a1e82ba5cf8b3a9584eead684fa6c.zip
CMake-888c1cb2769a1e82ba5cf8b3a9584eead684fa6c.tar.gz
CMake-888c1cb2769a1e82ba5cf8b3a9584eead684fa6c.tar.bz2
Merge topic 'update_cuda_custom_toolkit_location_folder_structure'
c73b847b03 VS: switch to new folder structure while keeping the old one working Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Raul Tambre <raul@tambre.ee> Merge-request: !5911
-rw-r--r--Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst13
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake16
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx27
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h9
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx12
-rw-r--r--Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake6
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt4
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout-stderr.txt12
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout.cmake1
10 files changed, 81 insertions, 20 deletions
diff --git a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst
index 74db6b1..a19e7e1 100644
--- a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst
+++ b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst
@@ -9,10 +9,9 @@ The :ref:`Visual Studio Generators` for VS 2010 and above support using
a standalone (non-installed) NVIDIA CUDA toolkit. The path
may be specified by a field in :variable:`CMAKE_GENERATOR_TOOLSET` of
the form ``cuda=C:\path\to\cuda``. The given directory must at least
-contain a folder ``.\nvcc`` and must provide Visual Studio integration
-files in path ``.\CUDAVisualStudioIntegration\extras\
-visual_studio_integration\MSBuildExtensions\``. One can create a standalone
-CUDA toolkit directory by either opening a installer with 7zip or
-copying the files that are extracted by the running installer.
-The value may be empty if no path to a standalone CUDA Toolkit was
-specified.
+contain the nvcc compiler in path ``.\bin`` and must provide Visual Studio
+integration files in path ``.\extras\visual_studio_integration\
+MSBuildExtensions\``. One can create a standalone CUDA toolkit directory by
+either opening a installer with 7zip or copying the files that are extracted
+by the running installer. The value may be empty if no path to a standalone
+CUDA Toolkit was specified.
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 1595cfd..f406e5a 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -452,9 +452,19 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
set(id_ItemDefinitionGroup_entry "<CudaCompile>${cuda_target}<AdditionalOptions>%(AdditionalOptions)-v</AdditionalOptions><CodeGeneration>${cuda_codegen}</CodeGeneration></CudaCompile>")
set(id_PostBuildEvent_Command [[echo CMAKE_CUDA_COMPILER=$(CudaToolkitBinDir)\nvcc.exe]])
if(CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR)
- set(id_CudaToolkitCustomDir "<CudaToolkitCustomDir>${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}nvcc</CudaToolkitCustomDir>")
- string(CONCAT id_Import_props "<Import Project=\"${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}\\CUDAVisualStudioIntegration\\extras\\visual_studio_integration\\MSBuildExtensions\\${cuda_tools}.props\" />")
- string(CONCAT id_Import_targets "<Import Project=\"${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}\\CUDAVisualStudioIntegration\\extras\\visual_studio_integration\\MSBuildExtensions\\${cuda_tools}.targets\" />")
+ # check for legacy cuda custom toolkit folder structure
+ if(EXISTS ${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}nvcc)
+ set(id_CudaToolkitCustomDir "<CudaToolkitCustomDir>${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}nvcc</CudaToolkitCustomDir>")
+ else()
+ set(id_CudaToolkitCustomDir "<CudaToolkitCustomDir>${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}</CudaToolkitCustomDir>")
+ endif()
+ if(EXISTS ${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}CUDAVisualStudioIntegration)
+ string(CONCAT id_Import_props "<Import Project=\"${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}CUDAVisualStudioIntegration\\extras\\visual_studio_integration\\MSBuildExtensions\\${cuda_tools}.props\" />")
+ string(CONCAT id_Import_targets "<Import Project=\"${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}CUDAVisualStudioIntegration\\extras\\visual_studio_integration\\MSBuildExtensions\\${cuda_tools}.targets\" />")
+ else()
+ string(CONCAT id_Import_props "<Import Project=\"${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}\\extras\\visual_studio_integration\\MSBuildExtensions\\${cuda_tools}.props\" />")
+ string(CONCAT id_Import_targets "<Import Project=\"${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}\\extras\\visual_studio_integration\\MSBuildExtensions\\${cuda_tools}.targets\" />")
+ endif()
else()
string(CONCAT id_Import_props [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.props" />]])
string(CONCAT id_Import_targets [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.targets" />]])
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 74d8135..d33c763 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -263,8 +263,8 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
bcDir = this->VCTargetsPath + "/BuildCustomizations";
} else {
bcDir = this->GetPlatformToolsetCudaCustomDirString() +
- "CUDAVisualStudioIntegration\\extras\\"
- "visual_studio_integration\\MSBuildExtensions";
+ this->GetPlatformToolsetCudaVSIntegrationSubdirString() +
+ "extras\\visual_studio_integration\\MSBuildExtensions";
cmSystemTools::ConvertToUnixSlashes(bcDir);
}
cmsys::Glob gl;
@@ -470,6 +470,17 @@ bool cmGlobalVisualStudio10Generator::ProcessGeneratorToolsetField(
if (this->GeneratorToolsetCudaCustomDir.back() != '\\') {
this->GeneratorToolsetCudaCustomDir.push_back('\\');
}
+ /* check for legacy toolkit folder structure */
+ if (cmsys::SystemTools::FileIsDirectory(
+ cmStrCat(this->GeneratorToolsetCudaCustomDir, "nvcc"))) {
+ this->GeneratorToolsetCudaNvccSubdir = "nvcc\\";
+ }
+ if (cmsys::SystemTools::FileIsDirectory(
+ cmStrCat(this->GeneratorToolsetCudaCustomDir,
+ "CUDAVisualStudioIntegration"))) {
+ this->GeneratorToolsetCudaVSIntegrationSubdir =
+ "CUDAVisualStudioIntegration\\";
+ }
} else {
this->GeneratorToolsetCuda = value;
}
@@ -787,6 +798,18 @@ cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaCustomDirString() const
return this->GeneratorToolsetCudaCustomDir;
}
+std::string const&
+cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaNvccSubdirString() const
+{
+ return this->GeneratorToolsetCudaNvccSubdir;
+}
+
+std::string const& cmGlobalVisualStudio10Generator::
+ GetPlatformToolsetCudaVSIntegrationSubdirString() const
+{
+ return this->GeneratorToolsetCudaVSIntegrationSubdir;
+}
+
cmGlobalVisualStudio10Generator::AuxToolset
cmGlobalVisualStudio10Generator::FindAuxToolset(std::string&,
std::string&) const
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 5e42c17..e221d4c 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -78,6 +78,13 @@ public:
const char* GetPlatformToolsetCudaCustomDir() const;
std::string const& GetPlatformToolsetCudaCustomDirString() const;
+ /** The nvcc subdirectory of a custom cuda install directory */
+ std::string const& GetPlatformToolsetCudaNvccSubdirString() const;
+
+ /** The visual studio integration subdirectory of a custom cuda install
+ * directory */
+ std::string const& GetPlatformToolsetCudaVSIntegrationSubdirString() const;
+
/** Return whether we need to use No/Debug instead of false/true
for GenerateDebugInformation. */
bool GetPlatformToolsetNeedsDebugEnum() const
@@ -188,6 +195,8 @@ protected:
std::string GeneratorToolsetCustomVCTargetsDir;
std::string GeneratorToolsetCuda;
std::string GeneratorToolsetCudaCustomDir;
+ std::string GeneratorToolsetCudaNvccSubdir;
+ std::string GeneratorToolsetCudaVSIntegrationSubdir;
std::string DefaultPlatformToolset;
std::string DefaultPlatformToolsetHostArchitecture;
std::string DefaultAndroidToolset;
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 965ac3e..0255d60 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -545,7 +545,7 @@ void cmVisualStudio10TargetGenerator::Generate()
e1.Element(
"CudaToolkitCustomDir",
this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString() +
- "nvcc");
+ this->GlobalGenerator->GetPlatformToolsetCudaNvccSubdirString());
}
}
@@ -654,8 +654,9 @@ void cmVisualStudio10TargetGenerator::Generate()
std::string cudaPath = customDir.empty()
? "$(VCTargetsPath)\\BuildCustomizations\\"
: customDir +
- "CUDAVisualStudioIntegration\\extras\\"
- "visual_studio_integration\\MSBuildExtensions\\";
+ this->GlobalGenerator
+ ->GetPlatformToolsetCudaVSIntegrationSubdirString() +
+ "extras\\visual_studio_integration\\MSBuildExtensions\\";
Elem(e1, "Import")
.Attribute("Project",
std::move(cudaPath) + "CUDA " +
@@ -747,8 +748,9 @@ void cmVisualStudio10TargetGenerator::Generate()
std::string cudaPath = customDir.empty()
? "$(VCTargetsPath)\\BuildCustomizations\\"
: customDir +
- "CUDAVisualStudioIntegration\\extras\\"
- "visual_studio_integration\\MSBuildExtensions\\";
+ this->GlobalGenerator
+ ->GetPlatformToolsetCudaVSIntegrationSubdirString() +
+ "extras\\visual_studio_integration\\MSBuildExtensions\\";
Elem(e1, "Import")
.Attribute("Project",
std::move(cudaPath) + "CUDA " +
diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake
index 75ed677..3aa791d 100644
--- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake
@@ -12,8 +12,12 @@ if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012456]")
run_cmake(TestToolsetCudaVersionOnly)
set(RunCMake_GENERATOR_TOOLSET "cuda=0.0")
run_cmake(TestToolsetCudaVersionOnly)
- set(RunCMake_GENERATOR_TOOLSET "cuda=C:\\dummy\\cuda")
+ set(RunCMake_GENERATOR_TOOLSET "cuda=${CMAKE_CURRENT_BINARY_DIR}/CudaStandaloneToolset")
run_cmake(TestToolsetCudaPathOnly)
+ set(RunCMake_GENERATOR_TOOLSET "cuda=${CMAKE_CURRENT_BINARY_DIR}/CudaStandaloneToolset")
+ file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/CudaStandaloneToolset/CUDAVisualStudioIntegration")
+ run_cmake(TestToolsetCudaPathOnlyOldLayout)
+ file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/CudaStandaloneToolset")
if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[2456]")
set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64")
run_cmake(TestToolsetHostArchBoth)
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt
index b17745f..5236787 100644
--- a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt
@@ -5,8 +5,8 @@ CMake Error at CMakeLists.txt:[0-9]+ \(project\):
given toolset
- cuda=C:\\dummy\\cuda\\
+ cuda=.*/Tests/RunCMake/CudaStandaloneToolset\\
cannot detect Visual Studio integration files in path
- C:/dummy/cuda/CUDAVisualStudioIntegration/extras/visual_studio_integration/MSBuildExtensions
+ .*/Tests/RunCMake/CudaStandaloneToolset/extras/visual_studio_integration/MSBuildExtensions
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout-result.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout-stderr.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout-stderr.txt
new file mode 100644
index 0000000..3ce79f8
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout-stderr.txt
@@ -0,0 +1,12 @@
+CMake Error at CMakeLists.txt:[0-9]+ \(project\):
+ Generator
+
+ Visual Studio .*
+
+ given toolset
+
+ cuda=.*/Tests/RunCMake/CudaStandaloneToolset\\
+
+ cannot detect Visual Studio integration files in path
+
+ .*/Tests/RunCMake/CudaStandaloneToolset/CUDAVisualStudioIntegration/extras/visual_studio_integration/MSBuildExtensions
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout.cmake
new file mode 100644
index 0000000..2fc38e5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout.cmake
@@ -0,0 +1 @@
+message(FATAL_ERROR "This should not be reached!")