Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
- Exposed `get_plotly_fig` and modified `draw_plotly` to return the `Figure` it creates. (PR #7258)
- Fix build with librealsense v2.44.0 and upcoming VS 2022 17.13 (PR #7074)
- Fix `deprecated-declarations` warnings when compiling code with C++20 standard (PR #7303)
- Fix logic for adding -allow-unsupported-compiler to nvcc (PR #7337)

## 0.13

Expand Down
32 changes: 24 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,30 @@ cmake_language(EVAL CODE "cmake_language(DEFER CALL open3d_patch_findthreads_mod

# Build CUDA module by default if CUDA is available
if(BUILD_CUDA_MODULE)
# 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
if (MSVC AND MSVC_VERSION VERSION_LESS_EQUAL "1949")
# Set this before any CUDA checks
add_compile_definitions(_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH)
set(CMAKE_CUDA_FLAGS "--allow-unsupported-compiler" CACHE STRING "Additional flags for nvcc" FORCE)
message(WARNING "Using --allow-unsupported-compiler flag for nvcc with MSVC 2022. "
"Set $Env:NVCC_PREPEND_FLAGS='--allow-unsupported-compiler' if nvcc still fails.")
if(MSVC)
# Handle/suppress nvcc unsupported compiler error for MSVC>=1940 with CUDA 11.7 to 12.4:
# (https://forums.developer.nvidia.com/t/problems-with-latest-vs2022-update/294150/12)
# Find CUDAToolkit first to get CUDAToolkit_VERSION:
find_package(CUDAToolkit REQUIRED)
if (CUDAToolkit_VERSION VERSION_LESS "12.5" AND MSVC_VERSION GREATER_EQUAL 1940)
# Set required nvcc flags before enable_language(CUDA), if they are not already set.
# Note: CMake >=3.29.4 might be needed for CMAKE_CUDA_FLAGS to be passed correctly to
# CMake's try_compile environment.
# Append -allow-unsupported-compiler (match - or --) if not already present:
if(NOT CMAKE_CUDA_FLAGS MATCHES "(^| )--?allow-unsupported-compiler($| )")
set(CMAKE_CUDA_FLAGS
"${CMAKE_CUDA_FLAGS} -allow-unsupported-compiler"
CACHE STRING "Flags for NVCC" FORCE)
endif()
# Append -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH if not already present:
if(NOT CMAKE_CUDA_FLAGS MATCHES "(^| )-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH($| )")
set(CMAKE_CUDA_FLAGS
"${CMAKE_CUDA_FLAGS} -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH"
CACHE STRING "Flags for NVCC" FORCE)
endif()
message(WARNING "Using --allow-unsupported-compiler flag and -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH for nvcc<=12.4 with MSVC>=1940. "
"Set $Env:NVCC_PREPEND_FLAGS='--allow-unsupported-compiler' if nvcc still fails.")
endif()
endif()
if (CMAKE_CUDA_ARCHITECTURES)
message(STATUS "Building with user-provided CUDA architectures: ${CMAKE_CUDA_ARCHITECTURES}")
Expand Down
Loading