VS: Improve error message when CUDA integration is not installed

Fixes: #28142
This commit is contained in:
Brad King committed 2026-10-06 11:09:33 -04:00
1 parent b6bb95a8bf
commit fe7ad024a1
3 files changed
+19 -2

No files matched your search

+13 -1
View File
@@ -727,7 +727,19 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
set(id_Link_AdditionalDependencies "")
if(lang STREQUAL CUDA)
if(NOT CMAKE_VS_PLATFORM_TOOLSET_CUDA)
message(FATAL_ERROR "No CUDA toolset found.")
set(maybe_dir "")
if(_CMAKE_VS_PLATFORM_TOOLSET_CUDA_INTEGRATION_DIR)
string(CONCAT maybe_dir " "
"The folder:\n"
" \"${_CMAKE_VS_PLATFORM_TOOLSET_CUDA_INTEGRATION_DIR}\"\n"
"does not contain any \"CUDA *.props\" files.")
endif()
message(FATAL_ERROR
"No CUDA Toolkit integration found in Visual Studio.${maybe_dir}\n"
"Install the CUDA Toolkit with its Visual Studio integration component. "
"Make sure the CUDA Toolkit version supports integration with\n"
" ${CMAKE_GENERATOR}\n"
)
endif()
set(cuda_tools "CUDA ${CMAKE_VS_PLATFORM_TOOLSET_CUDA}")
set(id_compile "CudaCompile")
+5 -1
View File
@@ -181,6 +181,7 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
if (gl.FindFiles(cmStrCat(bcDir, "/CUDA *.props"))) {
cudaTools = gl.GetFiles();
}
this->GeneratorToolsetCudaVSIntegrationFolder = std::move(bcDir);
if (!cudaTools.empty()) {
std::for_each(cudaTools.begin(), cudaTools.end(), cmCudaToolVersion);
std::sort(cudaTools.begin(), cudaTools.end(),
@@ -201,7 +202,7 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
"\n"
"cannot detect Visual Studio integration files in path\n"
" ",
bcDir));
this->GeneratorToolsetCudaVSIntegrationFolder));
// Clear the configured tool-set
this->GeneratorToolsetCuda.clear();
@@ -340,6 +341,9 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
}
if (char const* cuda = this->GetPlatformToolsetCuda()) {
mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_CUDA", cuda);
} else if (!this->GeneratorToolsetCudaVSIntegrationFolder.empty()) {
mf->AddDefinition("_CMAKE_VS_PLATFORM_TOOLSET_CUDA_INTEGRATION_DIR",
this->GeneratorToolsetCudaVSIntegrationFolder);
}
if (char const* cudaDir = this->GetPlatformToolsetCudaCustomDir()) {
mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR", cudaDir);
+1
View File
@@ -234,6 +234,7 @@ protected:
std::string GeneratorToolsetCuda;
std::string GeneratorToolsetCudaCustomDir;
std::string GeneratorToolsetCudaNvccSubdir;
std::string GeneratorToolsetCudaVSIntegrationFolder;
std::string GeneratorToolsetCudaVSIntegrationSubdir;
cm::optional<std::string> GeneratorToolsetFortran;
cm::optional<std::string> DefaultToolsetFortran;