[Enhancement] Support cmake configure when system exists multiple cuda versions. (#1740)
* update cmake * typospull/1761/head
parent
e519898adb
commit
599c701655
|
@ -11,6 +11,37 @@ if (MSVC OR (NOT DEFINED CMAKE_CUDA_RUNTIME_LIBRARY))
|
||||||
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
|
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if (MSVC)
|
||||||
|
# no plugin in BuildCustomizations and no specify cuda toolset
|
||||||
|
if (NOT CMAKE_VS_PLATFORM_TOOLSET_CUDA)
|
||||||
|
message(FATAL_ERROR "Please install CUDA MSBuildExtensions")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR)
|
||||||
|
# find_package(CUDA) required ENV{CUDA_PATH}
|
||||||
|
set(ENV{CUDA_PATH} ${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR})
|
||||||
|
else ()
|
||||||
|
# we use CUDA_PATH and ignore nvcc.exe
|
||||||
|
# cmake will import highest cuda props version, which may not equal to CUDA_PATH
|
||||||
|
if (NOT (DEFINED ENV{CUDA_PATH}))
|
||||||
|
message(FATAL_ERROR "Please set CUDA_PATH environment variable")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
string(REGEX REPLACE ".*v([0-9]+)\\..*" "\\1" _MAJOR $ENV{CUDA_PATH})
|
||||||
|
string(REGEX REPLACE ".*v[0-9]+\\.([0-9]+).*" "\\1" _MINOR $ENV{CUDA_PATH})
|
||||||
|
if (NOT (${CMAKE_VS_PLATFORM_TOOLSET_CUDA} STREQUAL "${_MAJOR}.${_MINOR}"))
|
||||||
|
message(FATAL_ERROR "Auto detected cuda version ${CMAKE_VS_PLATFORM_TOOLSET_CUDA}"
|
||||||
|
" is mismatch with ENV{CUDA_PATH} $ENV{CUDA_PATH}. Please modify CUDA_PATH"
|
||||||
|
" to match ${CMAKE_VS_PLATFORM_TOOLSET_CUDA} or specify cuda toolset by"
|
||||||
|
" cmake -T cuda=/path/to/cuda ..")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (NOT (DEFINED ENV{CUDA_PATH_V${_MAJOR}_${_MINOR}}))
|
||||||
|
message(FATAL_ERROR "Please set CUDA_PATH_V${_MAJOR}_${_MINOR} environment variable")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
# nvcc compiler settings
|
# nvcc compiler settings
|
||||||
find_package(CUDA REQUIRED)
|
find_package(CUDA REQUIRED)
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ else ()
|
||||||
message(FATAL_ERROR "Cannot find TensorRT libs")
|
message(FATAL_ERROR "Cannot find TensorRT libs")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(TENSORRT DEFAULT_MSG TENSORRT_INCLUDE_DIR
|
find_package_handle_standard_args(TENSORRT DEFAULT_MSG TENSORRT_INCLUDE_DIR
|
||||||
TENSORRT_LIBRARY)
|
TENSORRT_LIBRARY)
|
||||||
if (NOT TENSORRT_FOUND)
|
if (NOT TENSORRT_FOUND)
|
||||||
|
|
Loading…
Reference in New Issue