From 6dabfa176ab402ba287a063db6c1c164615adad6 Mon Sep 17 00:00:00 2001 From: John Keiser Date: Mon, 6 Apr 2020 17:18:37 -0700 Subject: [PATCH] Add competition libraries --- .gitignore | 1 + CMakeLists.txt | 7 +++-- benchmark/CMakeLists.txt | 1 + dependencies/CMakeLists.txt | 36 ++++++++++++++++++++++ tests/CMakeLists.txt | 61 +++++++++++++++++++++---------------- 5 files changed, 76 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 5dfa3ec6..d0c90473 100644 --- a/.gitignore +++ b/.gitignore @@ -119,6 +119,7 @@ objs /simdjson.h /singleheader/amalgamation_demo /singleheader/demo +/tests/allparserscheckfile /tests/basictests /tests/errortests /tests/integer_tests diff --git a/CMakeLists.txt b/CMakeLists.txt index c7d95310..59be9917 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ endif() project(simdjson DESCRIPTION "Parsing gigabytes of JSON per second" - LANGUAGES CXX + LANGUAGES CXX C ) # LTO seems to create all sorts of fun problems. Let us @@ -60,8 +60,9 @@ add_subdirectory(src) # # Compile tools / tests / benchmarks # -add_definitions(-DSIMDJSON_TEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/jsonchecker/") -add_definitions(-DSIMDJSON_BENCHMARK_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/jsonexamples/") +add_library(test-data INTERFACE) +target_compile_definitions(test-data INTERFACE SIMDJSON_TEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/jsonchecker/") +target_compile_definitions(test-data INTERFACE SIMDJSON_BENCHMARK_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/jsonexamples/") enable_testing() diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index a9be1807..89359b18 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -11,4 +11,5 @@ if (SIMDJSON_GOOGLE_BENCHMARKS) link_libraries(benchmark::benchmark) add_executable(bench_parse_call bench_parse_call.cpp) add_executable(bench_dom_api bench_dom_api.cpp) + target_link_libraries(bench_dom_api test-data) endif() \ No newline at end of file diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt index 2bef03f4..8f5f9486 100644 --- a/dependencies/CMakeLists.txt +++ b/dependencies/CMakeLists.txt @@ -20,3 +20,39 @@ if (SIMDJSON_GOOGLE_BENCHMARKS) set(BENCHMARK_ENABLE_INSTALL OFF) add_subdirectory(benchmark) endif() + +add_library(competition-cJSON INTERFACE) +target_include_directories(competition-cJSON INTERFACE cJSON) + +add_library(competition-fastjson INTERFACE) +target_include_directories(competition-fastjson INTERFACE fastjson/src fastjson/include) + +add_library(competition-gason INTERFACE) +target_include_directories(competition-gason INTERFACE gason/src) + +add_library(competition-jsmn INTERFACE) +target_include_directories(competition-jsmn INTERFACE jsmn) + +add_library(competition-json INTERFACE) +target_include_directories(competition-json INTERFACE json/single_include) + +add_library(competition-json11 INTERFACE) +target_include_directories(competition-json11 INTERFACE json11) + +add_library(competition-jsoncppdist INTERFACE) +target_include_directories(competition-jsoncppdist INTERFACE jsoncppdist) + +add_library(competition-rapidjson INTERFACE) +target_include_directories(competition-rapidjson INTERFACE rapidjson/include) + +add_library(competition-sajson INTERFACE) +target_include_directories(competition-sajson INTERFACE sajson/include) + +add_library(competition-ujson4c ujson4c/src/ujdecode.c) +target_include_directories(competition-ujson4c PUBLIC ujson4c/3rdparty ujson4c/src) + +add_library(competition-core INTERFACE) +target_link_libraries(competition-core INTERFACE competition-json competition-rapidjson competition-sajson competition-cJSON competition-jsmn) + +add_library(competition-all INTERFACE) +target_link_libraries(competition-all INTERFACE competition-core competition-jsoncppdist competition-json11 competition-fastjson competition-gason competition-ujson4c) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2587d9af..9d589dcf 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,9 +2,42 @@ function(add_cpp_test TEST_NAME TEST_FILE) add_executable(${TEST_NAME} ${TEST_FILE}) add_test(${TEST_NAME} ${TEST_NAME}) + target_link_libraries(${TEST_NAME} test-data) endfunction(add_cpp_test) -# Sets a target to only build when you run the test, and expect failure +# +# These test explicitly do #include "simdjson.cpp" +# +if (NOT MSVC) # Can't get simdjson-source to compile on Windows for some reason. + add_cpp_test(numberparsingcheck numberparsingcheck.cpp) + target_link_libraries(numberparsingcheck simdjson-source test-data simdjson-windows-headers) + add_cpp_test(stringparsingcheck stringparsingcheck.cpp) + target_link_libraries(stringparsingcheck simdjson-source test-data simdjson-windows-headers) +endif() + +# +# All remaining tests link with simdjson proper +# +link_libraries(simdjson) + +add_cpp_test(basictests basictests.cpp) +add_cpp_test(errortests errortests.cpp) +add_cpp_test(integer_tests integer_tests.cpp) +add_cpp_test(jsoncheck jsoncheck.cpp) +target_link_libraries(jsoncheck simdjson-windows-headers) +add_cpp_test(parse_many_test parse_many_test.cpp) +target_link_libraries(parse_many_test simdjson-windows-headers) +add_cpp_test(pointercheck pointercheck.cpp) + +# +# Competition parse test +# +add_executable(allparserscheckfile allparserscheckfile.cpp) +target_link_libraries(allparserscheckfile competition-all) + +# +# Compile-only tests +# function(add_compile_test TEST_NAME TEST_FILE EXPECT_SUCCESS) add_executable(${TEST_NAME} ${TEST_FILE}) set_target_properties(${TEST_NAME} PROPERTIES @@ -18,32 +51,6 @@ function(add_compile_test TEST_NAME TEST_FILE EXPECT_SUCCESS) endif() endfunction(add_compile_test) -# -# These test explicitly do #include "simdjson.cpp" -# -if (NOT MSVC) # Can't get simdjson-source to compile on Windows for some reason. - add_cpp_test(numberparsingcheck numberparsingcheck.cpp) - target_link_libraries(numberparsingcheck simdjson-source simdjson-windows-headers) - add_cpp_test(stringparsingcheck stringparsingcheck.cpp) - target_link_libraries(stringparsingcheck simdjson-source simdjson-windows-headers) -endif() - -# -# All remaining tests link with simdjson proper -# -link_libraries(simdjson) - -# add_executable(allparserscheckfile allparserscheckfile.cpp) -add_cpp_test(basictests basictests.cpp) -add_cpp_test(errortests errortests.cpp) -add_cpp_test(integer_tests integer_tests.cpp) -add_cpp_test(jsoncheck jsoncheck.cpp) -target_link_libraries(jsoncheck simdjson-windows-headers) -add_cpp_test(parse_many_test parse_many_test.cpp) -target_link_libraries(parse_many_test simdjson-windows-headers) -add_cpp_test(pointercheck pointercheck.cpp) - -# Compile-only tests # Don't add the tests if we're on VS2017 or older; they don't succeed. if(NOT (MSVC AND MSVC_VERSION LESS 1920)) add_compile_test(readme_examples readme_examples.cpp TRUE)