File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,37 @@ if (MSVC OR (NOT DEFINED CMAKE_CUDA_RUNTIME_LIBRARY))
11
11
set (CUDA_USE_STATIC_CUDA_RUNTIME OFF )
12
12
endif ()
13
13
14
+ if (MSVC )
15
+ # no plugin in BuildCustomizations and no specify cuda toolset
16
+ if (NOT CMAKE_VS_PLATFORM_TOOLSET_CUDA )
17
+ message (FATAL_ERROR "Please install CUDA MSBuildExtensions" )
18
+ endif ()
19
+
20
+ if (CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR )
21
+ # find_package(CUDA) required ENV{CUDA_PATH}
22
+ set (ENV{CUDA_PATH} ${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR} )
23
+ else ()
24
+ # we use CUDA_PATH and ignore nvcc.exe
25
+ # cmake will import highest cuda props version, which may not equal to CUDA_PATH
26
+ if (NOT (DEFINED ENV{CUDA_PATH} ))
27
+ message (FATAL_ERROR "Please set CUDA_PATH environment variable" )
28
+ endif ()
29
+
30
+ string (REGEX REPLACE ".*v([0-9]+)\\ ..*" "\\ 1" _MAJOR $ENV{CUDA_PATH} )
31
+ string (REGEX REPLACE ".*v[0-9]+\\ .([0-9]+).*" "\\ 1" _MINOR $ENV{CUDA_PATH} )
32
+ if (NOT (${CMAKE_VS_PLATFORM_TOOLSET_CUDA} STREQUAL "${_MAJOR} .${_MINOR} " ))
33
+ message (FATAL_ERROR "Auto detected cuda version ${CMAKE_VS_PLATFORM_TOOLSET_CUDA} "
34
+ " is mismatch with ENV{CUDA_PATH} $ENV{CUDA_PATH} . Please modify CUDA_PATH"
35
+ " to match ${CMAKE_VS_PLATFORM_TOOLSET_CUDA} or specify cuda toolset by"
36
+ " cmake -T cuda=/path/to/cuda .." )
37
+ endif ()
38
+
39
+ if (NOT (DEFINED ENV{CUDA_PATH_V${_MAJOR}_${_MINOR}} ))
40
+ message (FATAL_ERROR "Please set CUDA_PATH_V${_MAJOR} _${_MINOR} environment variable" )
41
+ endif ()
42
+ endif ()
43
+ endif ()
44
+
14
45
# nvcc compiler settings
15
46
find_package (CUDA REQUIRED )
16
47
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ else ()
29
29
message (FATAL_ERROR "Cannot find TensorRT libs" )
30
30
endif ()
31
31
32
+ include (FindPackageHandleStandardArgs )
32
33
find_package_handle_standard_args (TENSORRT DEFAULT_MSG TENSORRT_INCLUDE_DIR
33
34
TENSORRT_LIBRARY )
34
35
if (NOT TENSORRT_FOUND )
You can’t perform that action at this time.
0 commit comments