diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 0fcbbb7518..40658ea1fe 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -347,8 +347,14 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
set(cuda_tools "CUDA ${CMAKE_VS_PLATFORM_TOOLSET_CUDA}")
set(id_compile "CudaCompile")
set(id_PostBuildEvent_Command [[echo CMAKE_CUDA_COMPILER=$(CudaToolkitBinDir)\nvcc.exe]])
- string(CONCAT id_Import_props [[]])
- string(CONCAT id_Import_targets [[]])
+ if(CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR)
+ set(id_CudaToolkitCustomDir "${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}nvcc")
+ string(CONCAT id_Import_props "")
+ string(CONCAT id_Import_targets "")
+ else()
+ string(CONCAT id_Import_props [[]])
+ string(CONCAT id_Import_targets [[]])
+ endif()
if(CMAKE_VS_PLATFORM_NAME STREQUAL x64)
set(id_ItemDefinitionGroup_entry "64")
endif()
diff --git a/Modules/CompilerId/VS-10.vcxproj.in b/Modules/CompilerId/VS-10.vcxproj.in
index 32c4ffcc44..d742274c4c 100644
--- a/Modules/CompilerId/VS-10.vcxproj.in
+++ b/Modules/CompilerId/VS-10.vcxproj.in
@@ -14,6 +14,7 @@
@id_system_version@
@id_WindowsTargetPlatformVersion@
@id_WindowsSDKDesktopARMSupport@
+ @id_CudaToolkitCustomDir@
@id_toolset_version_props@