Skip to content

Commit 7778e2e

Browse files
authored
fix(cmake): improve CUDA C++ standard for compatibility with gcc-14 (#5036)
NVCC compilation errors with gcc-14 and C++11. Cases in other repos: https://gitlab.archlinux.org/archlinux/packaging/packages/cuda/-/issues/12 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Improved GPU build configuration to better support newer compiler versions (GCC/Clang 14+) and preserve user-specified C++ standards during compilation. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Jinzhe Zeng <[email protected]>
1 parent e335e3d commit 7778e2e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

source/lib/src/gpu/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,15 @@ if(USE_CUDA_TOOLKIT)
4343
message(FATAL_ERROR "CUDA version must be >= 9.0")
4444
endif()
4545

46+
# NVCC compilation errors with gcc-14 and c++11 Cases in other repos:
47+
# https://gitlab.archlinux.org/archlinux/packaging/packages/cuda/-/issues/12
48+
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "14")
49+
set_if_higher(CMAKE_CUDA_STANDARD 14)
50+
endif()
51+
4652
# CUDA 13.0+ requires C++17
4753
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "13.0")
48-
set(CMAKE_CUDA_STANDARD 17)
54+
set_if_higher(CMAKE_CUDA_STANDARD 17)
4955
message(
5056
STATUS
5157
"CUDA ${CMAKE_CUDA_COMPILER_VERSION} detected, setting C++ standard to 17"

0 commit comments

Comments
 (0)