-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2cf783b
Showing
7 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "dependencies/simdjson"] | ||
path = dependencies/simdjson | ||
url = https://github.com/simdjson/simdjson.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
cmake_minimum_required(VERSION 3.9) # CMP0069 NEW | ||
|
||
project(simdjson | ||
DESCRIPTION "simdjson demo" | ||
LANGUAGES CXX | ||
) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
set(CMAKE_MACOSX_RPATH OFF) | ||
set(CMAKE_THREAD_PREFER_PTHREAD ON) | ||
set(THREADS_PREFER_PTHREAD_FLAG ON) | ||
|
||
set(PROJECT_VERSION_MAJOR 0) | ||
set(PROJECT_VERSION_MINOR 0) | ||
set(PROJECT_VERSION_PATCH 1) | ||
add_subdirectory(dependencies) | ||
add_subdirectory(src) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Simple demo to show that we can use simdjson as a CMake dependency. | ||
|
||
``` | ||
mkdir build && cd build && cmake .. && cmake --build . && ./src/test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function(initialize_submodule DIRECTORY) | ||
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${DIRECTORY}/.git) | ||
find_package(Git QUIET REQUIRED) | ||
message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}/${DIRECTORY}/.git does not exist. Initializing ${DIRECTORY} submodule ...") | ||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init ${DIRECTORY} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
RESULT_VARIABLE GIT_EXIT_CODE) | ||
if(NOT GIT_EXIT_CODE EQUAL "0") | ||
message(FATAL_ERROR "${GIT_EXECUTABLE} submodule update --init dependencies/${DIRECTORY} failed with exit code ${GIT_EXIT_CODE}, please checkout submodules") | ||
endif() | ||
endif() | ||
endfunction(initialize_submodule) | ||
|
||
initialize_submodule(simdjson) | ||
add_library(simdjsondep INTERFACE) | ||
target_include_directories(simdjsondep INTERFACE simdjson/include) | ||
add_subdirectory(simdjson EXCLUDE_FROM_ALL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
add_executable(test test.cpp) | ||
|
||
target_link_libraries(test simdjson) | ||
target_link_libraries(test simdjsondep) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "simdjson.h" | ||
int main(int argc, char* argv[]) { | ||
if(argc < 2) { | ||
std::cout << "provide the filename of a JSON file" << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
try { | ||
simdjson::dom::parser parser; | ||
simdjson::dom::element doc = parser.load(argv[1]); | ||
std::cout << "found valid JSON" << std::endl; | ||
return EXIT_SUCCESS; | ||
} catch (simdjson::simdjson_error &e) { | ||
std::cout << "Exception! Bad JSON?" << std::endl; | ||
std::cout << e.what() << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
} |