Skip to content

Commit c974997

Browse files
committed
CMake: CUDA 12.0 and 12.1 nlohmann_json compiler error workaround
1 parent 1efca04 commit c974997

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

cmake/dependencies/nlohmann_json.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ if(NOT nlohmann_json_POPULATED)
1717
FetchContent_Populate(nlohmann_json)
1818
# Add the project as a subdirectory
1919
add_subdirectory(${nlohmann_json_SOURCE_DIR} ${nlohmann_json_BINARY_DIR} EXCLUDE_FROM_ALL)
20+
21+
# If we are using linux and CUDA 12.0 or 12.1, add an interface definition of JSON_HAS_RANGES to 0 to the nlohmann target to workaround an nvcc bug. See https://github.com/nlohmann/json/issues/3907
22+
if(NOT MSVC AND CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0 AND CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 12.2)
23+
target_compile_definitions(nlohmann_json INTERFACE $<$<COMPILE_LANGUAGE:CUDA>:JSON_HAS_RANGES=0>)
24+
endif()
25+
2026
endif()
2127

2228
# Mark some CACHE vars advanced for a cleaner GUI

0 commit comments

Comments
 (0)