Skip to content

Commit 6dabfa1

Browse files
committed
Add competition libraries
1 parent 0714f5f commit 6dabfa1

File tree

5 files changed

+66
-20
lines changed

5 files changed

+66
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ objs
119119
/simdjson.h
120120
/singleheader/amalgamation_demo
121121
/singleheader/demo
122+
/tests/allparserscheckfile
122123
/tests/basictests
123124
/tests/errortests
124125
/tests/integer_tests

CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ endif()
88

99
project(simdjson
1010
DESCRIPTION "Parsing gigabytes of JSON per second"
11-
LANGUAGES CXX
11+
LANGUAGES CXX C
1212
)
1313

1414
# LTO seems to create all sorts of fun problems. Let us
@@ -60,8 +60,9 @@ add_subdirectory(src)
6060
#
6161
# Compile tools / tests / benchmarks
6262
#
63-
add_definitions(-DSIMDJSON_TEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/jsonchecker/")
64-
add_definitions(-DSIMDJSON_BENCHMARK_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/jsonexamples/")
63+
add_library(test-data INTERFACE)
64+
target_compile_definitions(test-data INTERFACE SIMDJSON_TEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/jsonchecker/")
65+
target_compile_definitions(test-data INTERFACE SIMDJSON_BENCHMARK_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/jsonexamples/")
6566

6667
enable_testing()
6768

benchmark/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ if (SIMDJSON_GOOGLE_BENCHMARKS)
1111
link_libraries(benchmark::benchmark)
1212
add_executable(bench_parse_call bench_parse_call.cpp)
1313
add_executable(bench_dom_api bench_dom_api.cpp)
14+
target_link_libraries(bench_dom_api test-data)
1415
endif()

dependencies/CMakeLists.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,39 @@ if (SIMDJSON_GOOGLE_BENCHMARKS)
2020
set(BENCHMARK_ENABLE_INSTALL OFF)
2121
add_subdirectory(benchmark)
2222
endif()
23+
24+
add_library(competition-cJSON INTERFACE)
25+
target_include_directories(competition-cJSON INTERFACE cJSON)
26+
27+
add_library(competition-fastjson INTERFACE)
28+
target_include_directories(competition-fastjson INTERFACE fastjson/src fastjson/include)
29+
30+
add_library(competition-gason INTERFACE)
31+
target_include_directories(competition-gason INTERFACE gason/src)
32+
33+
add_library(competition-jsmn INTERFACE)
34+
target_include_directories(competition-jsmn INTERFACE jsmn)
35+
36+
add_library(competition-json INTERFACE)
37+
target_include_directories(competition-json INTERFACE json/single_include)
38+
39+
add_library(competition-json11 INTERFACE)
40+
target_include_directories(competition-json11 INTERFACE json11)
41+
42+
add_library(competition-jsoncppdist INTERFACE)
43+
target_include_directories(competition-jsoncppdist INTERFACE jsoncppdist)
44+
45+
add_library(competition-rapidjson INTERFACE)
46+
target_include_directories(competition-rapidjson INTERFACE rapidjson/include)
47+
48+
add_library(competition-sajson INTERFACE)
49+
target_include_directories(competition-sajson INTERFACE sajson/include)
50+
51+
add_library(competition-ujson4c ujson4c/src/ujdecode.c)
52+
target_include_directories(competition-ujson4c PUBLIC ujson4c/3rdparty ujson4c/src)
53+
54+
add_library(competition-core INTERFACE)
55+
target_link_libraries(competition-core INTERFACE competition-json competition-rapidjson competition-sajson competition-cJSON competition-jsmn)
56+
57+
add_library(competition-all INTERFACE)
58+
target_link_libraries(competition-all INTERFACE competition-core competition-jsoncppdist competition-json11 competition-fastjson competition-gason competition-ujson4c)

tests/CMakeLists.txt

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,24 @@
22
function(add_cpp_test TEST_NAME TEST_FILE)
33
add_executable(${TEST_NAME} ${TEST_FILE})
44
add_test(${TEST_NAME} ${TEST_NAME})
5+
target_link_libraries(${TEST_NAME} test-data)
56
endfunction(add_cpp_test)
67

7-
# Sets a target to only build when you run the test, and expect failure
8-
function(add_compile_test TEST_NAME TEST_FILE EXPECT_SUCCESS)
9-
add_executable(${TEST_NAME} ${TEST_FILE})
10-
set_target_properties(${TEST_NAME} PROPERTIES
11-
EXCLUDE_FROM_ALL TRUE
12-
EXCLUDE_FROM_DEFAULT_BUILD TRUE)
13-
add_test(NAME ${TEST_NAME}
14-
COMMAND ${CMAKE_COMMAND} --build . --target ${TEST_NAME} --config $<CONFIGURATION>
15-
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
16-
if(NOT ${EXPECT_SUCCESS})
17-
set_tests_properties(${TEST_NAME} PROPERTIES WILL_FAIL TRUE)
18-
endif()
19-
endfunction(add_compile_test)
20-
218
#
229
# These test explicitly do #include "simdjson.cpp"
2310
#
2411
if (NOT MSVC) # Can't get simdjson-source to compile on Windows for some reason.
2512
add_cpp_test(numberparsingcheck numberparsingcheck.cpp)
26-
target_link_libraries(numberparsingcheck simdjson-source simdjson-windows-headers)
13+
target_link_libraries(numberparsingcheck simdjson-source test-data simdjson-windows-headers)
2714
add_cpp_test(stringparsingcheck stringparsingcheck.cpp)
28-
target_link_libraries(stringparsingcheck simdjson-source simdjson-windows-headers)
15+
target_link_libraries(stringparsingcheck simdjson-source test-data simdjson-windows-headers)
2916
endif()
3017

3118
#
3219
# All remaining tests link with simdjson proper
3320
#
3421
link_libraries(simdjson)
3522

36-
# add_executable(allparserscheckfile allparserscheckfile.cpp)
3723
add_cpp_test(basictests basictests.cpp)
3824
add_cpp_test(errortests errortests.cpp)
3925
add_cpp_test(integer_tests integer_tests.cpp)
@@ -43,7 +29,28 @@ add_cpp_test(parse_many_test parse_many_test.cpp)
4329
target_link_libraries(parse_many_test simdjson-windows-headers)
4430
add_cpp_test(pointercheck pointercheck.cpp)
4531

32+
#
33+
# Competition parse test
34+
#
35+
add_executable(allparserscheckfile allparserscheckfile.cpp)
36+
target_link_libraries(allparserscheckfile competition-all)
37+
38+
#
4639
# Compile-only tests
40+
#
41+
function(add_compile_test TEST_NAME TEST_FILE EXPECT_SUCCESS)
42+
add_executable(${TEST_NAME} ${TEST_FILE})
43+
set_target_properties(${TEST_NAME} PROPERTIES
44+
EXCLUDE_FROM_ALL TRUE
45+
EXCLUDE_FROM_DEFAULT_BUILD TRUE)
46+
add_test(NAME ${TEST_NAME}
47+
COMMAND ${CMAKE_COMMAND} --build . --target ${TEST_NAME} --config $<CONFIGURATION>
48+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
49+
if(NOT ${EXPECT_SUCCESS})
50+
set_tests_properties(${TEST_NAME} PROPERTIES WILL_FAIL TRUE)
51+
endif()
52+
endfunction(add_compile_test)
53+
4754
# Don't add the tests if we're on VS2017 or older; they don't succeed.
4855
if(NOT (MSVC AND MSVC_VERSION LESS 1920))
4956
add_compile_test(readme_examples readme_examples.cpp TRUE)

0 commit comments

Comments
 (0)