Skip to content

Commit 9e1addd

Browse files
authored
Merge pull request #5367 from franzpoeschel/fix-toml-json-version-mismatches
toml11/nlohmann-json: avoid symbol clashes with different versions in upstream dependencies
2 parents a5ff770 + 04ae1be commit 9e1addd

File tree

169 files changed

+30886
-33010
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+30886
-33010
lines changed

include/picongpu/CMakeLists.txt

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -580,22 +580,30 @@ if(PIC_HAVE_openPMD)
580580
PRIVATE $<TARGET_PROPERTY:toml11::toml11,INTERFACE_INCLUDE_DIRECTORIES>
581581
)
582582
target_link_libraries(picongpu-hostonly PRIVATE toml11::toml11)
583+
endif()
583584

585+
foreach(target picongpu picongpu-hostonly)
584586
# This is a workaround for a missing API call in the openPMD-api,
585587
# which currently does not re-export backend version information.
586588
# https://github.com/openPMD/openPMD-api/issues/1563
587-
if(openPMD_HAVE_ADIOS2)
588-
foreach(target picongpu picongpu-hostonly)
589-
target_compile_definitions(
590-
${target}
591-
PRIVATE
592-
ADIOS2_VERSION_MAJOR=${ADIOS2_VERSION_MAJOR}
593-
ADIOS2_VERSION_MINOR=${ADIOS2_VERSION_MINOR}
594-
ADIOS2_VERSION_PATCH=${ADIOS2_VERSION_PATCH}
595-
)
596-
endforeach()
589+
if(PIC_HAVE_openPMD AND openPMD_HAVE_ADIOS2)
590+
target_compile_definitions(
591+
${target}
592+
PRIVATE
593+
ADIOS2_VERSION_MAJOR=${ADIOS2_VERSION_MAJOR}
594+
ADIOS2_VERSION_MINOR=${ADIOS2_VERSION_MINOR}
595+
ADIOS2_VERSION_PATCH=${ADIOS2_VERSION_PATCH}
596+
)
597597
endif()
598-
endif()
598+
599+
# Workaround for this bug https://github.com/nlohmann/json/issues/3907
600+
# We don't need ranges in <nlohmann/json.hpp>
601+
target_compile_definitions(${target} PRIVATE JSON_HAS_RANGES=0)
602+
603+
# Automatic detection of std::source_location availability fails
604+
# on Clang 12 through 14
605+
target_compile_definitions(${target} PRIVATE TOML11_DISABLE_SOURCE_LOCATION)
606+
endforeach()
599607

600608
## annotate with RPATH's
601609
if(PIC_ADD_RPATH)

share/picongpu/unit/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ add_library(
106106
target_link_libraries(argparser PRIVATE ${HOST_LIBS})
107107
target_link_libraries(argparser PRIVATE pmacc::pmacc)
108108

109+
# Workaround for this bug https://github.com/nlohmann/json/issues/3907
110+
# We don't need ranges in <nlohmann/json.hpp>
111+
target_compile_definitions(argparser PRIVATE JSON_HAS_RANGES=0)
112+
109113
# Add subdirectories for tests
110114
add_subdirectory(dimensional_tests)
111115
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
@@ -8,6 +8,9 @@ foreach(dim 2 3)
88
alpaka_add_executable(${testExe} ${testCaseFilepath})
99
target_include_directories(${testExe} PRIVATE BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../include")
1010
target_include_directories(${testExe} PRIVATE BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/include")
11+
# Workaround for this bug https://github.com/nlohmann/json/issues/3907
12+
# We don't need ranges in <nlohmann/json.hpp>
13+
target_compile_definitions(${testExe} PRIVATE JSON_HAS_RANGES=0)
1114
target_compile_definitions(${testExe} PRIVATE TEST_DIM=${dim})
1215
target_link_libraries(${testExe} PUBLIC Catch2 Catch2WithMain)
1316
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
@@ -6,6 +6,9 @@ foreach(testCaseFilepath ${NON_DIMENSIONAL_TESTS})
66
set(testExe "${PROJECT_NAME}-${testCase}")
77
alpaka_add_executable(${testExe} ${testCaseFilepath})
88
target_include_directories(${testExe} PRIVATE BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/../../../../include")
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_link_libraries(${testExe} PUBLIC Catch2 Catch2WithMain)
1013
target_link_libraries(${testExe} PRIVATE pmacc::pmacc)
1114
if(${testExe} MATCHES ".*CLI.*")

test/picongpuHeaderCheck/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ alpaka_add_executable(
9696
${_FILES_SOURCE}
9797
)
9898

99+
# Workaround for this bug https://github.com/nlohmann/json/issues/3907
100+
# We don't need ranges in <nlohmann/json.hpp>
101+
target_compile_definitions(${_TARGET_NAME} PRIVATE JSON_HAS_RANGES=0)
102+
99103
target_link_libraries(${_TARGET_NAME} PUBLIC Catch2 Catch2WithMain)
100104
target_link_libraries(${_TARGET_NAME} PRIVATE pmacc::pmacc)
101105
target_include_directories(

thirdParty/nlohmann_json/CMakeLists.txt

Lines changed: 81 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
cmake_minimum_required(VERSION 3.1)
1+
cmake_minimum_required(VERSION 3.5...4.0)
22

33
##
44
## PROJECT
55
## name and version
66
##
7-
project(nlohmann_json VERSION 3.9.1 LANGUAGES CXX)
7+
project(nlohmann_json VERSION 3.12.0 LANGUAGES CXX)
8+
9+
##
10+
## MAIN_PROJECT CHECK
11+
## determine if nlohmann_json is built as a subproject (using add_subdirectory) or if it is the main project
12+
##
13+
set(MAIN_PROJECT OFF)
14+
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
15+
set(MAIN_PROJECT ON)
16+
endif()
817

918
##
1019
## INCLUDE
1120
##
1221
##
22+
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
1323
include(ExternalProject)
1424

1525
##
@@ -21,26 +31,47 @@ if (POLICY CMP0077)
2131
cmake_policy(SET CMP0077 NEW)
2232
endif ()
2333

24-
option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ON)
25-
option(JSON_Install "Install CMake targets during install step." ON)
26-
option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF)
27-
option(JSON_ImplicitConversions "Enable implicit conversions." ON)
34+
# VERSION_GREATER_EQUAL is not available in CMake 3.1
35+
if(${MAIN_PROJECT} AND (${CMAKE_VERSION} VERSION_EQUAL 3.13 OR ${CMAKE_VERSION} VERSION_GREATER 3.13))
36+
set(JSON_BuildTests_INIT ON)
37+
else()
38+
set(JSON_BuildTests_INIT OFF)
39+
endif()
40+
option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ${JSON_BuildTests_INIT})
41+
option(JSON_CI "Enable CI build targets." OFF)
42+
option(JSON_Diagnostics "Use extended diagnostic messages." OFF)
43+
option(JSON_Diagnostic_Positions "Enable diagnostic positions." OFF)
44+
option(JSON_GlobalUDLs "Place user-defined string literals in the global namespace." ON)
45+
option(JSON_ImplicitConversions "Enable implicit conversions." ON)
46+
option(JSON_DisableEnumSerialization "Disable default integer enum serialization." OFF)
47+
option(JSON_LegacyDiscardedValueComparison "Enable legacy discarded value comparison." OFF)
48+
option(JSON_Install "Install CMake targets during install step." ${MAIN_PROJECT})
49+
option(JSON_MultipleHeaders "Use non-amalgamated version of the library." ON)
50+
option(JSON_SystemInclude "Include as system headers (skip for clang-tidy)." OFF)
51+
52+
if (JSON_CI)
53+
include(ci)
54+
endif ()
2855

2956
##
3057
## CONFIGURATION
3158
##
3259
include(GNUInstallDirs)
3360

34-
set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME})
35-
set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE INTERNAL "")
61+
if (NOT DEFINED NLOHMANN_JSON_TARGET_NAME)
62+
# Allow overriding the target name when using FetchContent / add_subdirectory.
63+
set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME})
64+
endif()
65+
66+
set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}" CACHE INTERNAL "")
3667
set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
3768
set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
3869
set(NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE "cmake/config.cmake.in")
3970
set(NLOHMANN_JSON_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
4071
set(NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
4172
set(NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Config.cmake")
4273
set(NLOHMANN_JSON_CMAKE_PROJECT_TARGETS_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Targets.cmake")
43-
set(NLOHMANN_JSON_PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
74+
set(NLOHMANN_JSON_PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/pkgconfig")
4475

4576
if (JSON_MultipleHeaders)
4677
set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/include/")
@@ -51,7 +82,31 @@ else()
5182
endif()
5283

5384
if (NOT JSON_ImplicitConversions)
54-
message(STATUS "Implicit conversions are disabled")
85+
message(STATUS "Implicit conversions are disabled (JSON_USE_IMPLICIT_CONVERSIONS=0)")
86+
endif()
87+
88+
if (JSON_DisableEnumSerialization)
89+
message(STATUS "Enum integer serialization is disabled (JSON_DISABLE_ENUM_SERIALIZATION=0)")
90+
endif()
91+
92+
if (JSON_LegacyDiscardedValueComparison)
93+
message(STATUS "Legacy discarded value comparison enabled (JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON=1)")
94+
endif()
95+
96+
if (JSON_Diagnostics)
97+
message(STATUS "Diagnostics enabled (JSON_DIAGNOSTICS=1)")
98+
endif()
99+
100+
if (JSON_Diagnostic_Positions)
101+
message(STATUS "Diagnostic positions enabled (JSON_DIAGNOSTIC_POSITIONS=1)")
102+
endif()
103+
104+
if (NOT JSON_GlobalUDLs)
105+
message(STATUS "User-defined string literals are not put in the global namespace (JSON_USE_GLOBAL_UDLS=0)")
106+
endif()
107+
108+
if (JSON_SystemInclude)
109+
set(NLOHMANN_JSON_SYSTEM_INCLUDE "SYSTEM")
55110
endif()
56111

57112
##
@@ -69,14 +124,19 @@ endif()
69124
target_compile_definitions(
70125
${NLOHMANN_JSON_TARGET_NAME}
71126
INTERFACE
72-
JSON_USE_IMPLICIT_CONVERSIONS=$<BOOL:${JSON_ImplicitConversions}>
127+
$<$<NOT:$<BOOL:${JSON_GlobalUDLs}>>:JSON_USE_GLOBAL_UDLS=0>
128+
$<$<NOT:$<BOOL:${JSON_ImplicitConversions}>>:JSON_USE_IMPLICIT_CONVERSIONS=0>
129+
$<$<BOOL:${JSON_DisableEnumSerialization}>:JSON_DISABLE_ENUM_SERIALIZATION=1>
130+
$<$<BOOL:${JSON_Diagnostics}>:JSON_DIAGNOSTICS=1>
131+
$<$<BOOL:${JSON_Diagnostic_Positions}>:JSON_DIAGNOSTIC_POSITIONS=1>
132+
$<$<BOOL:${JSON_LegacyDiscardedValueComparison}>:JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON=1>
73133
)
74134

75135
target_include_directories(
76136
${NLOHMANN_JSON_TARGET_NAME}
77-
INTERFACE
137+
${NLOHMANN_JSON_SYSTEM_INCLUDE} INTERFACE
78138
$<BUILD_INTERFACE:${NLOHMANN_JSON_INCLUDE_BUILD_DIR}>
79-
$<INSTALL_INTERFACE:include>
139+
$<INSTALL_INTERFACE:${NLOHMANN_JSON_INCLUDE_INSTALL_DIR}>
80140
)
81141

82142
## add debug view definition file for msvc (natvis)
@@ -93,19 +153,19 @@ endif()
93153

94154
# Install a pkg-config file, so other tools can find this.
95155
CONFIGURE_FILE(
96-
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkg-config.pc.in"
97-
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
156+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkg-config.pc.in"
157+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
158+
@ONLY
98159
)
99160

100161
##
101162
## TESTS
102163
## create and configure the unit test target
103164
##
104-
include(CTest) #adds option BUILD_TESTING (default ON)
105-
106-
if(BUILD_TESTING AND JSON_BuildTests)
165+
if (JSON_BuildTests)
166+
include(CTest)
107167
enable_testing()
108-
add_subdirectory(test)
168+
add_subdirectory(tests)
109169
endif()
110170

111171
##
@@ -141,7 +201,7 @@ if(JSON_Install)
141201
FILES ${NLOHMANN_NATVIS_FILE}
142202
DESTINATION .
143203
)
144-
endif()
204+
endif()
145205
export(
146206
TARGETS ${NLOHMANN_JSON_TARGET_NAME}
147207
NAMESPACE ${PROJECT_NAME}::
@@ -161,4 +221,5 @@ endif()
161221
FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
162222
DESTINATION ${NLOHMANN_JSON_PKGCONFIG_INSTALL_DIR}
163223
)
224+
include(CPack)
164225
endif()

thirdParty/nlohmann_json/LICENSE.MIT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2013-2020 Niels Lohmann
3+
Copyright (c) 2013-2025 Niels Lohmann
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)