diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fb7af690..03a61fe2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,12 @@ if(OpenMVS_USE_CUDA) FIND_PACKAGE(CUDA) if(CUDA_FOUND) ENABLE_LANGUAGE(CUDA) + # CUDA-11.x can not be compiled using C++14 standard on Windows + string(REGEX MATCH "^[0-9]+" CUDA_MAJOR ${CMAKE_CUDA_COMPILER_VERSION}) + if(${CUDA_MAJOR} GREATER 10 AND CMAKE_CXX_COMPILER MATCHES "MSVC" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "19.29") + message("Working around windows build failure with visual studio. Visual studio 16.10 introduced a compiler bug with compilng CUDA code with C++14. Set the cuda standard to 17 as a workaround.") + set(CMAKE_CUDA_STANDARD 17) + endif() if(NOT OpenMVS_MAX_CUDA_COMPATIBILITY) if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) SET(CMAKE_CUDA_ARCHITECTURES 75)