mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
c806e955c4
* Initial work on JSON builder * moving the files back to ondemand for now. * tweak * more later * update * minor edits * dropping vs arm (missing support) * adding tests. we still specialized write_string_escaped * tweaking * fix typo * tweaking the approach * minor fix * missing store * another missing store * Attempt at fixing failing serialization tests. (#2292) * Fixing appeand_float typo (#2294) * applying a couple of fixes * updating single header * fix for pre C++17 if constexpr * Fixing unused argument problem and updating the singleheader file * various pedantic fixes * Sketch of builder * reordering. * simplify * Adding draft of static reflection based deserialization * Updating simdjson singleheader * patching the automated deserialization. * automated * Adding support for smart pointers of user defined types. * Adding specialization for smart pointers for basic types. I think it is highly likely that this can be done in a more generic way. * Referncing a later version of rapidjson that fixed the issue related with assignment attempt of a const variable for GenericStringRef class. * guarding the tests * adding documentation for string_builder * saving * rename to 'append' * saving * non-functional benchmarks (#2342) * non-functional benchmarks * Fix typo * various fixes * tweaking --------- Co-authored-by: Daniel Lemire <dlemire@lemire.me> Co-authored-by: Francisco Geiman Thiesen <franciscogthiesen@gmail.com> * tuning * various minor fixes * minor tweak * minor simplification * updating amal * adding a cast * update * fancy casting * removing dead code * Pushing latest changes. CITM benchmark is still not working. * Still not working, but now I am getting only 10 errors. * add static reflection benchmark to 'large random' benchmark and allows (#2349) deserialization (with static reflection) from objects and arrays. Co-authored-by: Daniel Lemire <dlemire@lemire.me> * Removing std::map from CitmCatalog definition, since that is not currently supported. * Added free to rust bench, segfault is still happening.. * The syntax changed: ^E became ^^E. (#2350) * The syntax changed: ^E became ^^E. * guarding --------- Co-authored-by: Daniel Lemire <dlemire@lemire.me> * Adding support for string_view_keyed_map types. * Adding concepts as a conditional include. * updating single-header * Adding concepts to ondemand deps * rust benchmark is finally working * Fixing small typo in docs. * adding docker config and instructions so that our users can test the static reflection (#2358) * adding docker config and instructions so that our users can test the static reflection * completing the instructions * pruning white spaces --------- Co-authored-by: Daniel Lemire <dlemire@lemire.me> * minor optimizations on the JSON builder branch * avoiding undef behaviour * saving * somewhat nicer builder * make it possible to run just one benchmark * adding linux perf * fixing minor issue * updating swar * Adding real world compilation benchmark (#2379) * Adding compilation benchmark for json parsing with and without reflection * Moving it to the benchmark folder, also reducing a bit the number of iterations. * Removing script from root folder. * Reducing number of iterations * Update benchmark/benchmark_reflection_usage_compilation.sh Co-authored-by: Daniel Lemire <daniel@lemire.me> * Update benchmark/benchmark_reflection_usage_compilation.sh Co-authored-by: Daniel Lemire <daniel@lemire.me> * Update benchmark/benchmark_reflection_usage_compilation.sh Co-authored-by: Daniel Lemire <daniel@lemire.me> * Making the script more customizable and also test whether the compiler being used supports reflection before actually running the benchmark --------- Co-authored-by: Daniel Lemire <daniel@lemire.me> * Using define_static_string from https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3491r2.html (#2389) * Applying changes needed after latest reflection paper updates. * Working, but no template for yet. * Updating single-header to incldue the use of define_static_string. * copying over master --------- Co-authored-by: Daniel Lemire <dlemire@lemire.me> Co-authored-by: Francisco Geiman Thiesen <franciscogthiesen@gmail.com>
192 lines
7.1 KiB
CMake
192 lines
7.1 KiB
CMake
include(CMakeDependentOption)
|
|
|
|
option(SIMDJSON_ALLOW_DOWNLOADS
|
|
"Allow dependencies to be downloaded during configure time"
|
|
ON)
|
|
|
|
cmake_dependent_option(SIMDJSON_COMPETITION "Compile competitive benchmarks" ON
|
|
SIMDJSON_ALLOW_DOWNLOADS OFF)
|
|
cmake_dependent_option(SIMDJSON_GOOGLE_BENCHMARKS "compile the Google Benchmark benchmarks" ON
|
|
"SIMDJSON_ALLOW_DOWNLOADS OR MINGW" OFF)
|
|
|
|
if(SIMDJSON_GOOGLE_BENCHMARKS)
|
|
CPMAddPackage(
|
|
NAME google_benchmarks
|
|
URL https://github.com/google/benchmark/archive/refs/tags/v1.9.4.zip
|
|
OPTIONS
|
|
"BENCHMARK_ENABLE_TESTING OFF"
|
|
"BENCHMARK_ENABLE_INSTALL OFF"
|
|
"BENCHMARK_ENABLE_WERROR OFF"
|
|
)
|
|
endif()
|
|
|
|
CPMAddPackage(
|
|
NAME simdjson-data
|
|
URL https://github.com/simdjson/simdjson-data/archive/351949906abde446f0314bf79606fb5d884f5be7.zip
|
|
)
|
|
|
|
option(SIMDJSON_USE_BOOST_JSON "Try to include BOOST_JSON, this may break your binaries under some systems." OFF)
|
|
# This prevents variables declared with set() from unnecessarily escaping and
|
|
# should not be called more than once
|
|
function(competition_scope_)
|
|
# boost json in standalone mode requires C++17 string_view
|
|
include(CheckCXXSourceCompiles)
|
|
check_cxx_source_compiles([[
|
|
#include <string_view>
|
|
|
|
#if __cpp_lib_string_view < 201606
|
|
# error no string view support
|
|
#endif
|
|
|
|
int main() {}
|
|
]] SIMDJSON_FOUND_STRING_VIEW)
|
|
if(SIMDJSON_FOUND_STRING_VIEW AND SIMDJSON_USE_BOOST_JSON)
|
|
CPMAddPackage(
|
|
NAME boostjson
|
|
URL https://github.com/boostorg/json/archive/ee8d72d8502b409b5561200299cad30ccdb91415.zip
|
|
)
|
|
add_library(boostjson STATIC "${boostjson_SOURCE_DIR}/src/src.cpp")
|
|
target_compile_definitions(boostjson PUBLIC BOOST_JSON_STANDALONE)
|
|
target_include_directories(boostjson SYSTEM PUBLIC
|
|
"${boostjson_SOURCE_DIR}/include")
|
|
target_compile_definitions(boostjson INTERFACE SIMDJSON_COMPETITION_BOOSTJSON)
|
|
endif()
|
|
CPMAddPackage(
|
|
NAME cjson
|
|
URL https://github.com/DaveGamble/cJSON/archive/c69134d01746dcf551dd7724b4edb12f922eb0d1.zip
|
|
DOWNLOAD_ONLY YES
|
|
)
|
|
add_library(cjson STATIC "${cjson_SOURCE_DIR}/cJSON.c")
|
|
target_include_directories(cjson SYSTEM PUBLIC "${cjson_SOURCE_DIR}")
|
|
target_compile_definitions(cjson INTERFACE SIMDJSON_COMPETITION_CJSON)
|
|
|
|
CPMAddPackage(
|
|
NAME fastjson
|
|
URL https://github.com/mikeando/fastjson/archive/485f994a61a64ac73fa6a40d4d639b99b463563b.zip
|
|
DOWNLOAD_ONLY YES
|
|
)
|
|
add_library(fastjson STATIC
|
|
"${fastjson_SOURCE_DIR}/src/fastjson.cpp"
|
|
"${fastjson_SOURCE_DIR}/src/fastjson2.cpp"
|
|
"${fastjson_SOURCE_DIR}/src/fastjson_dom.cpp")
|
|
target_include_directories(fastjson SYSTEM PUBLIC
|
|
"${fastjson_SOURCE_DIR}/include")
|
|
target_compile_definitions(fastjson INTERFACE SIMDJSON_COMPETITION_FASTJSON)
|
|
|
|
CPMAddPackage(
|
|
NAME gason
|
|
URL https://github.com/vivkin/gason/archive/7aee524189da1c1ecd19f67981e3d903dae25470.zip
|
|
DOWNLOAD_ONLY YES
|
|
)
|
|
add_library(gason STATIC "${gason_SOURCE_DIR}/src/gason.cpp")
|
|
target_include_directories(gason SYSTEM PUBLIC "${gason_SOURCE_DIR}/src")
|
|
target_compile_definitions(gason INTERFACE SIMDJSON_COMPETITION_GASON)
|
|
|
|
CPMAddPackage(
|
|
NAME jsmn
|
|
URL https://github.com/zserge/jsmn/archive/18e9fe42cbfe21d65076f5c77ae2be379ad1270f.zip
|
|
DOWNLOAD_ONLY YES
|
|
)
|
|
add_library(jsmn STATIC "${jsmn_SOURCE_DIR}/jsmn.c")
|
|
target_include_directories(jsmn SYSTEM PUBLIC "${jsmn_SOURCE_DIR}")
|
|
target_compile_definitions(jsmn INTERFACE SIMDJSON_COMPETITION_JSMN)
|
|
|
|
CPMAddPackage(
|
|
NAME nlohmann_json
|
|
URL https://github.com/nlohmann/json/archive/refs/tags/v3.12.0.zip
|
|
)
|
|
|
|
set_property(TARGET nlohmann_json APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS SIMDJSON_COMPETITION_NLOHMANN_JSON)
|
|
|
|
|
|
set(jsoncpp_SOURCE_DIR "${simdjson_SOURCE_DIR}/dependencies/jsoncppdist")
|
|
add_library(jsoncpp STATIC "${jsoncpp_SOURCE_DIR}/jsoncpp.cpp")
|
|
target_include_directories(jsoncpp SYSTEM PUBLIC "${jsoncpp_SOURCE_DIR}")
|
|
target_compile_definitions(jsoncpp INTERFACE SIMDJSON_COMPETITION_JSONCPP)
|
|
|
|
CPMAddPackage(
|
|
NAME rapidjson
|
|
URL https://github.com/Tencent/rapidjson/archive/805d7ed5dfe97a39b8b0816fd5eeed8731dc4936.zip
|
|
DOWNLOAD_ONLY YES
|
|
)
|
|
add_library(rapidjson INTERFACE)
|
|
target_compile_definitions(rapidjson INTERFACE RAPIDJSON_HAS_STDSTRING)
|
|
include (TestBigEndian)
|
|
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
|
|
if(IS_BIG_ENDIAN)
|
|
target_compile_definitions(rapidjson INTERFACE RAPIDJSON_ENDIAN=1)
|
|
else()
|
|
target_compile_definitions(rapidjson INTERFACE RAPIDJSON_ENDIAN=0)
|
|
endif()
|
|
target_compile_definitions(rapidjson INTERFACE RAPIDJSON_HAS_STDSTRING)
|
|
target_include_directories(rapidjson SYSTEM INTERFACE
|
|
"${rapidjson_SOURCE_DIR}/include")
|
|
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14)
|
|
message(STATUS "Disabling rapidjson")
|
|
else()
|
|
target_compile_definitions(rapidjson INTERFACE SIMDJSON_COMPETITION_RAPIDJSON)
|
|
endif()
|
|
|
|
CPMAddPackage(
|
|
NAME sajson
|
|
URL https://github.com/chadaustin/sajson/archive/2dcfd350586375f9910f74821d4f07d67ae455ba.zip
|
|
DOWNLOAD_ONLY YES
|
|
)
|
|
add_library(sajson INTERFACE)
|
|
target_compile_definitions(sajson INTERFACE SAJSON_UNSORTED_OBJECT_KEYS)
|
|
target_include_directories(sajson SYSTEM INTERFACE
|
|
"${sajson_SOURCE_DIR}/include")
|
|
target_compile_definitions(sajson INTERFACE SIMDJSON_COMPETITION_SAJSON)
|
|
|
|
CPMAddPackage(
|
|
NAME ujson4c
|
|
URL https://github.com/esnme/ujson4c/archive/e14f3fd5207fe30d1bdea723f260609e69d1abfa.zip
|
|
DOWNLOAD_ONLY YES
|
|
)
|
|
add_library(ujson4c STATIC
|
|
"${ujson4c_SOURCE_DIR}/src/ujdecode.c"
|
|
"${ujson4c_SOURCE_DIR}/3rdparty/ultrajsondec.c")
|
|
target_include_directories(ujson4c SYSTEM PUBLIC
|
|
"${ujson4c_SOURCE_DIR}/src"
|
|
"${ujson4c_SOURCE_DIR}/3rdparty")
|
|
target_compile_definitions(ujson4c INTERFACE SIMDJSON_COMPETITION_UJSON4C)
|
|
|
|
CPMAddPackage(
|
|
NAME yyjson
|
|
URL https://github.com/ibireme/yyjson/archive/c3856514de0a67d7b66939bf3ed491a2d6e61277.zip
|
|
DOWNLOAD_ONLY YES
|
|
)
|
|
add_library(yyjson STATIC "${yyjson_SOURCE_DIR}/src/yyjson.c")
|
|
target_include_directories(yyjson SYSTEM PUBLIC "${yyjson_SOURCE_DIR}/src")
|
|
target_compile_definitions(yyjson INTERFACE SIMDJSON_COMPETITION_YYJSON)
|
|
|
|
add_library(competition-core INTERFACE)
|
|
target_link_libraries(competition-core INTERFACE nlohmann_json rapidjson sajson cjson jsmn yyjson)
|
|
|
|
if(TARGET boostjson)
|
|
target_compile_definitions(boostjson INTERFACE HAS_BOOST_JSON)
|
|
target_link_libraries(competition-core INTERFACE boostjson)
|
|
endif()
|
|
|
|
add_library(competition-all INTERFACE)
|
|
target_link_libraries(competition-all INTERFACE competition-core jsoncpp fastjson gason ujson4c)
|
|
endfunction()
|
|
|
|
if(SIMDJSON_COMPETITION)
|
|
competition_scope_()
|
|
endif()
|
|
|
|
cmake_dependent_option(SIMDJSON_CXXOPTS "Download cxxopts (necessary for tools)" ON
|
|
SIMDJSON_ALLOW_DOWNLOADS OFF)
|
|
|
|
if(SIMDJSON_CXXOPTS)
|
|
CPMAddPackage(
|
|
NAME cxxopts
|
|
URL https://github.com/jarro2783/cxxopts/archive/59656709c0c58fcd0ed18b38e02938dbe05284c5.zip
|
|
OPTIONS
|
|
"CXXOPTS_BUILD_EXAMPLES OFF"
|
|
"CXXOPTS_BUILD_TESTS OFF"
|
|
"CXXOPTS_ENABLE_INSTALL OFF"
|
|
)
|
|
endif()
|