Skip to content

Commit 54b7291

Browse files
committed
Reference simdjson by name, don't specify include files individually
1 parent 1e30b6e commit 54b7291

File tree

7 files changed

+43
-139
lines changed

7 files changed

+43
-139
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ commands:
5959
- run: make all
6060
- run: make test
6161

62-
cmake_test: # this version builds, install, test and then verifyi from the installation
62+
cmake_test: # this version builds, install, test and then verify from the installation
6363
steps:
6464
- run: apt-get update -qq
6565
- run: apt-get install -y cmake

CMakeLists.txt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ set(CMAKE_MACOSX_RPATH OFF)
2424
set(CMAKE_THREAD_PREFER_PTHREAD ON)
2525
set(THREADS_PREFER_PTHREAD_FLAG ON)
2626

27-
set(SIMDJSON_LIB_NAME simdjson)
2827
set(PROJECT_VERSION_MAJOR 0)
2928
set(PROJECT_VERSION_MINOR 3)
3029
set(PROJECT_VERSION_PATCH 1)
@@ -50,22 +49,27 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake")
5049
find_package(CTargets)
5150
find_package(Options)
5251

53-
# We used to have install(DIRECTORY include/${SIMDJSON_LIB_NAME} DESTINATION include)
54-
# alone.
55-
# However, this fails because we also need the root level simdjson.h file.
56-
install(DIRECTORY include/${SIMDJSON_LIB_NAME} DESTINATION include)
57-
install(FILES include/${SIMDJSON_LIB_NAME}.h DESTINATION include)
52+
#
53+
# Create the top level simdjson library (must be done at this level to use both src/ and include/
54+
# directories)
55+
#
56+
add_subdirectory(include)
57+
add_subdirectory(src)
58+
59+
#
60+
# Compile tools / tests / benchmarks
61+
#
5862
set (TEST_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/jsonchecker/")
5963
set (BENCHMARK_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/jsonexamples/")
6064
add_definitions(-DSIMDJSON_TEST_DATA_DIR="${TEST_DATA_DIR}")
6165
add_definitions(-DSIMDJSON_BENCHMARK_DATA_DIR="${TEST_DATA_DIR}")
6266
enable_testing()
63-
include(include/CMakeLists.txt)
64-
add_subdirectory(src)
67+
6568
add_subdirectory(tools)
6669
add_subdirectory(tests)
6770
add_subdirectory(benchmark)
6871

72+
6973
if (SIMDJSON_GOOGLE_BENCHMARKS)
7074
if(NOT EXISTS dependencies/benchmark/CMakeLists.txt)
7175
# message(STATUS "Unable to find dependencies/benchmark/CMakeLists.txt")

benchmark/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
target_include_directories(${SIMDJSON_LIB_NAME}
2-
INTERFACE
3-
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/benchmark>
4-
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/benchmark/linux>
5-
)
6-
1+
include_directories( . linux )
72
add_cpp_benchmark(parse)
83
add_cpp_benchmark(statisticalmodel)
94
add_cpp_benchmark(parse_stream)

fuzz/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ macro(implement_fuzzer sourcefile)
4444
if (SIMDJSON_FUZZ_LINKMAIN)
4545
target_sources(${name} PRIVATE main.cpp)
4646
endif ()
47-
target_link_libraries(${name} PRIVATE ${SIMDJSON_LIB_NAME})
47+
target_link_libraries(${name} PRIVATE simdjson)
4848
if (SIMDJSON_FUZZ_LDFLAGS)
4949
target_link_libraries(${name} PRIVATE ${SIMDJSON_FUZZ_LDFLAGS})
5050
endif ()

include/CMakeLists.txt

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,2 @@
1-
set(SIMDJSON_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
2-
set(SIMDJSON_INCLUDE
3-
${SIMDJSON_INCLUDE_DIR}/simdjson.h
4-
${SIMDJSON_INCLUDE_DIR}/simdjson/common_defs.h
5-
${SIMDJSON_INCLUDE_DIR}/simdjson/compiler_check.h
6-
${SIMDJSON_INCLUDE_DIR}/simdjson/document_stream.h
7-
${SIMDJSON_INCLUDE_DIR}/simdjson/document.h
8-
${SIMDJSON_INCLUDE_DIR}/simdjson/error.h
9-
${SIMDJSON_INCLUDE_DIR}/simdjson/implementation.h
10-
${SIMDJSON_INCLUDE_DIR}/simdjson/inline/document_stream.h
11-
${SIMDJSON_INCLUDE_DIR}/simdjson/inline/document.h
12-
${SIMDJSON_INCLUDE_DIR}/simdjson/inline/error.h
13-
${SIMDJSON_INCLUDE_DIR}/simdjson/inline/padded_string.h
14-
${SIMDJSON_INCLUDE_DIR}/simdjson/inline/parsedjson_iterator.h
15-
${SIMDJSON_INCLUDE_DIR}/simdjson/internal/jsonformatutils.h
16-
${SIMDJSON_INCLUDE_DIR}/simdjson/jsonioutil.h
17-
${SIMDJSON_INCLUDE_DIR}/simdjson/jsonparser.h
18-
${SIMDJSON_INCLUDE_DIR}/simdjson/nonstd/string_view.hpp
19-
${SIMDJSON_INCLUDE_DIR}/simdjson/padded_string.h
20-
${SIMDJSON_INCLUDE_DIR}/simdjson/parsedjson.h
21-
${SIMDJSON_INCLUDE_DIR}/simdjson/parsedjson_iterator.h
22-
${SIMDJSON_INCLUDE_DIR}/simdjson/portability.h
23-
${SIMDJSON_INCLUDE_DIR}/simdjson/simdjson_version.h
24-
${SIMDJSON_INCLUDE_DIR}/simdjson/simdjson.h
25-
)
1+
install(DIRECTORY simdjson DESTINATION include FILES_MATCHING PATTERN *.h)
2+
install(FILES simdjson.h DESTINATION include)

src/CMakeLists.txt

Lines changed: 24 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,47 @@
1-
if(${CMAKE_C_COMPILER_ID} MATCHES "Intel") # icc / icpc
2-
# prevent shared libraries from depending on Intel provided libraries
3-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-intel")
4-
endif()
5-
61
include(GNUInstallDirs)
72

8-
# we default on a shared library.
93
if(SIMDJSON_BUILD_STATIC)
10-
set(SIMDJSON_LIB_TYPE STATIC)
114
MESSAGE( STATUS "Building a static library." )
5+
add_library(simdjson STATIC "")
126
else()
13-
MESSAGE( STATUS "Building a dynamic library (default)." )
14-
set(SIMDJSON_LIB_TYPE SHARED)
7+
MESSAGE( STATUS "Building a dynamic library." )
8+
add_library(simdjson SHARED "")
159
endif()
1610

17-
MESSAGE( STATUS "SIMDJSON_LIB_TYPE: " ${SIMDJSON_LIB_TYPE})
18-
19-
# Bring in include files
20-
include(../include/CMakeLists.txt)
11+
target_sources(simdjson PRIVATE simdjson.cpp)
12+
target_include_directories(simdjson PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
13+
target_include_directories(simdjson PRIVATE .)
2114

22-
set(SIMDJSON_SRC_DIR $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
23-
24-
set(SIMDJSON_SRC
25-
simdjson.cpp
26-
)
27-
28-
# Load headers and sources
29-
set(SIMDJSON_SRC_HEADERS
30-
error.cpp
31-
implementation.cpp
32-
isadetection.h
33-
simdprune_tables.h
34-
stage1_find_marks.cpp
35-
stage2_build_tape.cpp
36-
arm64/bitmanipulation.h
37-
arm64/bitmask.h
38-
arm64/implementation.h
39-
arm64/intrinsics.h
40-
arm64/numberparsing.h
41-
arm64/simd.h
42-
arm64/stage1_find_marks.h
43-
arm64/stage2_build_tape.h
44-
arm64/stringparsing.h
45-
fallback/implementation.h
46-
fallback/stage1_find_marks.h
47-
fallback/stage2_build_tape.h
48-
generic/atomparsing.h
49-
generic/json_scanner.h
50-
generic/json_string_scanner.h
51-
generic/json_structural_indexer.h
52-
generic/numberparsing.h
53-
generic/stage2_build_tape.h
54-
generic/stage2_streaming_build_tape.h
55-
generic/stringparsing.h
56-
generic/utf8_fastvalidate_algorithm.h
57-
generic/utf8_lookup_algorithm.h
58-
generic/utf8_lookup2_algorithm.h
59-
generic/utf8_range_algorithm.h
60-
generic/utf8_zwegner_algorithm.h
61-
haswell/bitmanipulation.h
62-
haswell/bitmask.h
63-
haswell/implementation.h
64-
haswell/intrinsics.h
65-
haswell/numberparsing.h
66-
haswell/simd.h
67-
haswell/stage1_find_marks.h
68-
haswell/stage2_build_tape.h
69-
haswell/stringparsing.h
70-
document_parser_callbacks.h
71-
westmere/bitmanipulation.h
72-
westmere/bitmask.h
73-
westmere/implementation.h
74-
westmere/intrinsics.h
75-
westmere/numberparsing.h
76-
westmere/simd.h
77-
westmere/stage1_find_marks.h
78-
westmere/stage2_build_tape.h
79-
westmere/stringparsing.h
80-
)
81-
set_source_files_properties(${SIMDJSON_SRC_HEADERS} PROPERTIES HEADER_FILE_ONLY TRUE)
15+
if(${CMAKE_C_COMPILER_ID} MATCHES "Intel") # icc / icpc
16+
# prevent shared libraries from depending on Intel provided libraries
17+
target_link_options(simdjson PUBLIC "-static-intel")
18+
endif()
8219

83-
add_library(${SIMDJSON_LIB_NAME} ${SIMDJSON_LIB_TYPE} ${SIMDJSON_SRC} ${SIMDJSON_INCLUDE} ${SIMDJSON_SRC_HEADERS})
20+
if(SIMDJSON_ENABLE_THREADS)
21+
find_package(Threads REQUIRED)
22+
target_link_libraries(simdjson PRIVATE Threads::Threads)
23+
endif()
8424

85-
target_include_directories(${SIMDJSON_LIB_NAME}
86-
PUBLIC
87-
$<BUILD_INTERFACE:${SIMDJSON_SRC_DIR}>
88-
$<BUILD_INTERFACE:${SIMDJSON_INCLUDE_DIR}>
89-
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
90-
)
25+
# Installation
9126

92-
install(TARGETS ${SIMDJSON_LIB_NAME}
93-
EXPORT ${SIMDJSON_LIB_NAME}-config
27+
install(TARGETS simdjson
28+
EXPORT simdjson-config
9429
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
9530
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
9631
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
9732
)
9833

99-
install(EXPORT ${SIMDJSON_LIB_NAME}-config
100-
FILE ${SIMDJSON_LIB_NAME}-config.cmake
101-
NAMESPACE ${SIMDJSON_LIB_NAME}::
102-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${SIMDJSON_LIB_NAME}
34+
install(EXPORT simdjson-config
35+
FILE simdjson-config.cmake
36+
NAMESPACE simdjson::
37+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/simdjson
10338
)
10439

10540
if(NOT MSVC)
10641
## We output the library at the root of the current directory where cmake is invoked
10742
## This is handy but Visual Studio will happily ignore us
108-
set_target_properties(${SIMDJSON_LIB_NAME} PROPERTIES
109-
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
110-
VERSION ${SIMDJSON_LIB_VERSION}
111-
SOVERSION ${SIMDJSON_LIB_SOVERSION})
43+
set_target_properties(simdjson PROPERTIES
44+
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
11245
MESSAGE( STATUS "Library output directory (does not apply to Visual Studio): " ${CMAKE_BINARY_DIR})
11346
endif()
11447

@@ -121,12 +54,7 @@ if(MSVC AND (SIMDJSON_LIB_TYPE STREQUAL "SHARED"))
12154
MESSAGE( STATUS "To build a Windows DLL using Visual Studio, you may need cmake 3.4 or better." )
12255
endif()
12356
MESSAGE( STATUS "Building a Windows DLL using Visual Studio, exporting all symbols automatically." )
124-
set_target_properties(${SIMDJSON_LIB_NAME}
57+
set_target_properties(simdjson
12558
PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS 1)
12659
endif()
12760

128-
if(SIMDJSON_ENABLE_THREADS)
129-
find_package(Threads REQUIRED)
130-
target_link_libraries( ${SIMDJSON_LIB_NAME} Threads::Threads)
131-
endif()
132-

tests/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
if(MSVC)
2-
target_include_directories(${SIMDJSON_LIB_NAME}
2+
target_include_directories(simdjson
33
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/windows>
44
)
55
endif()
@@ -24,7 +24,7 @@ target_compile_definitions(errortests PRIVATE JSON_TEST_PATH="${PROJECT_SOURCE_D
2424

2525
## This causes problems
2626
# add_executable(singleheader ./singleheadertest.cpp ${PROJECT_SOURCE_DIR}/singleheader/simdjson.cpp)
27-
# target_link_libraries(singleheader ${SIMDJSON_LIB_NAME})
27+
# target_link_libraries(singleheader simdjson)
2828
# add_test(singleheader singleheader)
2929

3030
if(MSVC)

0 commit comments

Comments
 (0)