Compare commits

...

5 Commits

Author SHA1 Message Date
Niels Lohmann
dede2cf6a2 🚧 add nvcc
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2025-05-27 19:02:47 +02:00
Niels Lohmann
5b52e5d8ff 🚧 add nvcc
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2025-05-27 18:03:08 +02:00
Niels Lohmann
e7f18308b4 🚧 add nvcc
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2025-05-27 16:50:55 +02:00
Niels Lohmann
281d1e929b Detect used C++ standard library (#4793) 2025-05-23 17:59:52 +02:00
Kuan-Fu, Wu
7421ac31a7 doc: Fix JSON Pointer example to use direct initialization (#4468)
Changed the example code in the documentation from copy initialization
to direct initialization for `json::json_pointer`.
This prevents compilation errors caused by the constructor being explicit.
2025-05-22 12:39:39 +02:00
7 changed files with 69 additions and 7 deletions

View File

@@ -266,6 +266,20 @@ jobs:
- name: Build
run: cmake --build build
ci_nvcc:
runs-on: ubuntu-latest
container: nvidia/cuda:12.9.0-devel-ubuntu24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get latest CMake and ninja
uses: lukka/get-cmake@ea004816823209b8d1211e47b216185caee12cc5 # v4.02
- name: Run CMake
run: CXX=nvcc cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
- name: Build
run: cmake --build build --parallel 10
- name: Test
run: cd build ; ctest -j 10 --output-on-failure
ci_test_documentation:
runs-on: ubuntu-latest
strategy:

View File

@@ -0,0 +1,31 @@
/*
* Detect used C++ Standard Library
*
* This file is compiled and run via try_run in download_test_data.cmake.
*/
#include <cstdio>
// see https://en.cppreference.com/w/cpp/header/ciso646
#if __cplusplus >= 202002L
#include <version>
#else
#include <ciso646>
#endif
int main()
{
#if defined(_LIBCPP_VERSION)
std::printf("LLVM C++ Standard Library (libc++), _LIBCPP_VERSION=%d", _LIBCPP_VERSION);
#elif defined(__GLIBCXX__)
std::printf("GNU C++ Standard Library (libstdc++), __GLIBCXX__=%d", __GLIBCXX__);
#elif defined(_MSVC_STL_VERSION)
std::printf("Microsoft C++ Standard Library (MSVC STL), _MSVC_STL_VERSION=%d", _MSVC_STL_VERSION);
#elif defined(_LIBCUDACXX_VERSION)
std::printf("NVIDIA C++ Standard Library (libcudacxx), _LIBCUDACXX_VERSION=%d", _LIBCUDACXX_VERSION);
#elif defined(EASTL_VERSION)
std::printf("Electronic Arts Standard Template Library (EASTL), EASTL_VERSION=%d", EASTL_VERSION);
#else
std::printf("unknown");
#endif
}

View File

@@ -54,3 +54,18 @@ else()
endif()
string(REGEX REPLACE "[ ]*\n" "; " CXX_VERSION_RESULT "${CXX_VERSION_RESULT}")
message(STATUS "Compiler: ${CXX_VERSION_RESULT}")
# determine used C++ standard library (for debug and support purposes)
if(NOT DEFINED LIBCPP_VERSION_OUTPUT_CACHED)
try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR
"${CMAKE_BINARY_DIR}" SOURCES "${CMAKE_SOURCE_DIR}/cmake/detect_libcpp_version.cpp"
RUN_OUTPUT_VARIABLE LIBCPP_VERSION_OUTPUT COMPILE_OUTPUT_VARIABLE LIBCPP_VERSION_COMPILE_OUTPUT
)
if(NOT LIBCPP_VERSION_OUTPUT)
set(LIBCPP_VERSION_OUTPUT "Unknown")
message(AUTHOR_WARNING "Failed to compile cmake/detect_libcpp_version to detect the used C++ standard library. This does not affect the library or the test cases. Please still create an issue at https://github.com/nlohmann/json to investigate this.\n${LIBCPP_VERSION_COMPILE_OUTPUT}")
endif()
set(LIBCPP_VERSION_OUTPUT_CACHED "${LIBCPP_VERSION_OUTPUT}" CACHE STRING "Detected C++ standard library version")
endif()
message(STATUS "C++ standard library: ${LIBCPP_VERSION_OUTPUT_CACHED}")

View File

@@ -42,7 +42,7 @@ Note `/` does not identify the root (i.e., the whole document), but an object en
JSON Pointers can be created from a string:
```cpp
json::json_pointer p = "/nested/one";
json::json_pointer p("/nested/one");
```
Furthermore, a user-defined string literal can be used to achieve the same result:

View File

@@ -75,8 +75,8 @@ target_compile_options(test_main PUBLIC
# https://github.com/nlohmann/json/pull/3229
$<$<CXX_COMPILER_ID:Intel>:-diag-disable=2196>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-deprecated;-Wno-float-equal>
$<$<CXX_COMPILER_ID:GNU>:-Wno-deprecated-declarations>
$<$<CXX_COMPILER_ID:GNU>:-Wno-deprecated-declarations;-Wno-deprecated;-Wno-float-equal>
$<$<CXX_COMPILER_ID:Clang>:-Wno-deprecated-declarations;-Wno-deprecated;-Wno-float-equal>
$<$<CXX_COMPILER_ID:Intel>:-diag-disable=1786>)
target_include_directories(test_main PUBLIC
thirdparty/doctest

View File

@@ -12,8 +12,8 @@ target_compile_options(abi_compat_common INTERFACE
# https://github.com/nlohmann/json/pull/3229
$<$<CXX_COMPILER_ID:Intel>:-diag-disable=2196>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-deprecated;-Wno-float-equal>
$<$<CXX_COMPILER_ID:GNU>:-Wno-deprecated-declarations>
$<$<CXX_COMPILER_ID:GNU>:-Wno-deprecated-declarations;-Wno-deprecated;-Wno-float-equal>
$<$<CXX_COMPILER_ID:Clang>:-Wno-deprecated-declarations;-Wno-deprecated;-Wno-float-equal>
$<$<CXX_COMPILER_ID:Intel>:-diag-disable=1786>)
target_include_directories(abi_compat_common SYSTEM INTERFACE
../thirdparty/doctest

View File

@@ -1914,10 +1914,12 @@ TEST_CASE("MessagePack with std::byte")
SECTION("empty vector")
{
const std::vector<std::byte> empty_data;
CHECK_THROWS_WITH_AS([&]() {
CHECK_THROWS_WITH_AS([&]()
{
[[maybe_unused]] auto result = json::from_msgpack(empty_data);
return true;
}(),
}
(),
"[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing MessagePack value: unexpected end of input",
json::parse_error&);
}