mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-18 08:51:52 +08:00
VS: switch to new folder structure while keeping the old one working
Fixes: #21170
This commit is contained in:
@@ -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.
|
||||
|
@@ -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" />]])
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -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 " +
|
||||
|
@@ -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)
|
||||
|
@@ -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
|
||||
|
@@ -0,0 +1 @@
|
||||
1
|
@@ -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
|
@@ -0,0 +1 @@
|
||||
message(FATAL_ERROR "This should not be reached!")
|
Reference in New Issue
Block a user