Skip to content

Commit 6c71ba8

Browse files
committed
Suppress nvcc unsupported compiler error for MSVC 2022 with CUDA 11.7 to 12.4
https://forums.developer.nvidia.com/t/problems-with-latest-vs2022-update/294150/12
1 parent 2c1c158 commit 6c71ba8

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

3rdparty/find_dependencies.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ set(ExternalProject_CMAKE_ARGS
167167
-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}
168168
-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}
169169
-DCMAKE_CUDA_COMPILER_LAUNCHER=${CMAKE_CUDA_COMPILER_LAUNCHER}
170+
-DCMAKE_CUDA_FLAGS=${CMAKE_CUDA_FLAGS}
170171
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
171172
-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}
172173
-DCMAKE_INSTALL_LIBDIR=${Open3D_INSTALL_LIB_DIR}

CMakeLists.txt

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,6 @@ else()
299299
endif()
300300
set(CMAKE_CXX_EXTENSIONS OFF) # Improved compatibility
301301

302-
# FIXME: Remove this workaround once a fixed Visual Studio 16.10 version is released.
303-
if (BUILD_CUDA_MODULE
304-
AND CMAKE_CXX_COMPILER MATCHES "MSVC"
305-
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "19.29"
306-
)
307-
# Keep C++14 standard for unaffected C++ files, but use C++17 for CUDA files.
308-
set(CMAKE_CUDA_STANDARD 17)
309-
# Suppress warnings for deprecated C++17 functions.
310-
add_compile_definitions($<$<COMPILE_LANGUAGE:CUDA>:_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING>)
311-
message(WARNING "Visual Studio 16.10 (MSVC 19.29) introduced a compiler bug when compiling CUDA code with C++14. "
312-
"Workaround this bug by setting the CUDA standard to C++17.")
313-
endif()
314-
315302
# CMake modules
316303
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmake")
317304

@@ -400,6 +387,14 @@ cmake_language(EVAL CODE "cmake_language(DEFER CALL open3d_patch_findthreads_mod
400387

401388
# Build CUDA module by default if CUDA is available
402389
if(BUILD_CUDA_MODULE)
390+
# Suppress nvcc unsupported compiler error for MSVC 2022 with CUDA 11.7 to 12.4
391+
# https://forums.developer.nvidia.com/t/problems-with-latest-vs2022-update/294150/12
392+
if (MSVC AND MSVC_VERSION VERSION_LESS_EQUAL "1949")
393+
# Set this before any CUDA checks
394+
set(CMAKE_CUDA_FLAGS "--allow-unsupported-compiler" CACHE STRING "Additional flags for nvcc" FORCE)
395+
message(WARNING "Using --allow-unsupported-compiler flag for nvcc with MSVC 2022.")
396+
endif()
397+
403398
include(Open3DMakeCudaArchitectures)
404399
open3d_make_cuda_architectures(CUDA_ARCHS)
405400
set(CMAKE_CUDA_ARCHITECTURES ${CUDA_ARCHS})

0 commit comments

Comments
 (0)