Skip to content

Commit f78a5dc

Browse files
committed
Workaround for C++20 bug in nlohmann/json
nlohmann/json#3907
1 parent d384077 commit f78a5dc

5 files changed

Lines changed: 29 additions & 10 deletions

File tree

include/picongpu/CMakeLists.txt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -585,20 +585,25 @@ if(PIC_HAVE_openPMD)
585585
$<TARGET_PROPERTY:toml11::toml11,INTERFACE_INCLUDE_DIRECTORIES>)
586586
target_link_libraries(picongpu-hostonly PRIVATE toml11::toml11)
587587

588+
endif()
589+
590+
foreach(target picongpu picongpu-hostonly)
588591
# This is a workaround for a missing API call in the openPMD-api,
589592
# which currently does not re-export backend version information.
590593
# https://github.com/openPMD/openPMD-api/issues/1563
591-
if(openPMD_HAVE_ADIOS2)
592-
foreach(target picongpu picongpu-hostonly)
593-
target_compile_definitions(
594-
${target}
595-
PRIVATE
596-
ADIOS2_VERSION_MAJOR=${ADIOS2_VERSION_MAJOR}
597-
ADIOS2_VERSION_MINOR=${ADIOS2_VERSION_MINOR}
598-
ADIOS2_VERSION_PATCH=${ADIOS2_VERSION_PATCH})
599-
endforeach()
594+
if(PIC_HAVE_openPMD AND openPMD_HAVE_ADIOS2)
595+
target_compile_definitions(
596+
${target}
597+
PRIVATE
598+
ADIOS2_VERSION_MAJOR=${ADIOS2_VERSION_MAJOR}
599+
ADIOS2_VERSION_MINOR=${ADIOS2_VERSION_MINOR}
600+
ADIOS2_VERSION_PATCH=${ADIOS2_VERSION_PATCH})
600601
endif()
601-
endif()
602+
603+
# Workaround for this bug https://github.com/nlohmann/json/issues/3907
604+
# We don't need ranges in <nlohmann/json.hpp>
605+
target_compile_definitions(${target} PRIVATE JSON_HAS_RANGES=0)
606+
endforeach()
602607

603608
## annotate with RPATH's
604609
if(PIC_ADD_RPATH)

share/picongpu/unit/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ add_library(argparser
112112
target_link_libraries(argparser PRIVATE ${HOST_LIBS})
113113
target_link_libraries(argparser PRIVATE pmacc::pmacc)
114114

115+
# Workaround for this bug https://github.com/nlohmann/json/issues/3907
116+
# We don't need ranges in <nlohmann/json.hpp>
117+
target_compile_definitions(argparser PRIVATE JSON_HAS_RANGES=0)
118+
115119
# Add subdirectories for tests
116120
add_subdirectory(dimensional_tests)
117121
add_subdirectory(non_dimensional_tests)

share/picongpu/unit/dimensional_tests/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ foreach(dim 2 3)
66
string(REPLACE "UT.cpp" "" testCase ${testCaseFilename})
77
set(testExe "${PROJECT_NAME}-${testCase}-${dim}D")
88
alpaka_add_executable(${testExe} ${testCaseFilepath})
9+
# Workaround for this bug https://github.com/nlohmann/json/issues/3907
10+
# We don't need ranges in <nlohmann/json.hpp>
11+
target_compile_definitions(${testExe} PRIVATE JSON_HAS_RANGES=0)
912
target_compile_definitions(${testExe} PRIVATE TEST_DIM=${dim})
1013
target_link_libraries(${testExe} PUBLIC Catch2 Catch2WithMain)
1114
target_link_libraries(${testExe} PRIVATE pmacc::pmacc)

share/picongpu/unit/non_dimensional_tests/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ foreach(testCaseFilepath ${NON_DIMENSIONAL_TESTS})
55
string(REPLACE "UT.cpp" "" testCase ${testCaseFilename})
66
set(testExe "${PROJECT_NAME}-${testCase}")
77
alpaka_add_executable(${testExe} ${testCaseFilepath})
8+
# Workaround for this bug https://github.com/nlohmann/json/issues/3907
9+
# We don't need ranges in <nlohmann/json.hpp>
10+
target_compile_definitions(${testExe} PRIVATE JSON_HAS_RANGES=0)
811
target_link_libraries(${testExe} PUBLIC Catch2 Catch2WithMain)
912
target_link_libraries(${testExe} PRIVATE pmacc::pmacc)
1013
if(${testExe} MATCHES ".*CLI.*")

test/picongpuHeaderCheck/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ alpaka_add_executable(
105105
${_TARGET_NAME}
106106
${_FILES_SOURCE})
107107

108+
# Workaround for this bug https://github.com/nlohmann/json/issues/3907
109+
# We don't need ranges in <nlohmann/json.hpp>
110+
target_compile_definitions(${_TARGET_NAME} PRIVATE JSON_HAS_RANGES=0)
111+
108112
target_link_libraries(${_TARGET_NAME} PUBLIC Catch2 Catch2WithMain)
109113
target_link_libraries(${_TARGET_NAME} PRIVATE pmacc::pmacc)
110114
target_include_directories(

0 commit comments

Comments
 (0)