Merge pull request #979 from simdjson/issue977
This removes git as a dependency to our CMake
This commit is contained in:
commit
4ec56484a1
23
.drone.yml
23
.drone.yml
|
@ -273,6 +273,29 @@ steps:
|
||||||
- ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -LE "acceptance|per_implementation" # Everything we haven't run yet, run now.
|
- ASAN_OPTIONS="detect_leaks=0" ctest $CTEST_FLAGS -LE "acceptance|per_implementation" # Everything we haven't run yet, run now.
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
|
name: ninja-clang9
|
||||||
|
platform: { os: linux, arch: amd64 }
|
||||||
|
steps:
|
||||||
|
- name: Build and Test
|
||||||
|
image: conanio/clang9
|
||||||
|
user: root
|
||||||
|
environment:
|
||||||
|
CC: clang-9
|
||||||
|
CXX: clang++-9
|
||||||
|
BUILD_FLAGS: -- -j 4
|
||||||
|
CMAKE_FLAGS: -GNinja -DSIMDJSON_BUILD_STATIC=ON
|
||||||
|
CTEST_FLAGS: -j4 --output-on-failure
|
||||||
|
CXXFLAGS: -stdlib=libc++
|
||||||
|
commands:
|
||||||
|
- apt-get update -qq
|
||||||
|
- apt-get install -y cmake
|
||||||
|
- mkdir build
|
||||||
|
- cd build
|
||||||
|
- cmake $CMAKE_FLAGS ..
|
||||||
|
- cmake --build . $BUILD_FLAGS
|
||||||
|
- ctest $CTEST_FLAGS
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
name: libcpp-clang9
|
name: libcpp-clang9
|
||||||
platform: { os: linux, arch: amd64 }
|
platform: { os: linux, arch: amd64 }
|
||||||
steps:
|
steps:
|
||||||
|
|
|
@ -16,8 +16,10 @@ include(GNUInstallDirs)
|
||||||
include(cmake/simdjson-flags.cmake)
|
include(cmake/simdjson-flags.cmake)
|
||||||
include(cmake/simdjson-user-cmakecache.cmake)
|
include(cmake/simdjson-user-cmakecache.cmake)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(SIMDJSON_JUST_LIBRARY)
|
if(SIMDJSON_JUST_LIBRARY)
|
||||||
MESSAGE( STATUS "Building just the library, omitting all tests, tools and benchmarks." )
|
message( STATUS "Building just the library, omitting all tests, tools and benchmarks." )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -39,7 +41,8 @@ add_subdirectory(include)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_subdirectory(windows)
|
add_subdirectory(windows)
|
||||||
if(NOT(SIMDJSON_JUST_LIBRARY))
|
if(NOT(SIMDJSON_JUST_LIBRARY))
|
||||||
add_subdirectory(tools)
|
add_subdirectory(dependencies) ## This needs to be before tools because of cxxopts
|
||||||
|
add_subdirectory(tools) ## This needs to be before tests because of cxxopts
|
||||||
add_subdirectory(singleheader)
|
add_subdirectory(singleheader)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -47,7 +50,6 @@ endif()
|
||||||
# Compile tools / tests / benchmarks
|
# Compile tools / tests / benchmarks
|
||||||
#
|
#
|
||||||
if(NOT(SIMDJSON_JUST_LIBRARY))
|
if(NOT(SIMDJSON_JUST_LIBRARY))
|
||||||
add_subdirectory(dependencies)
|
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
add_subdirectory(examples)
|
add_subdirectory(examples)
|
||||||
add_subdirectory(benchmark)
|
add_subdirectory(benchmark)
|
||||||
|
|
|
@ -14,13 +14,13 @@ target_compile_definitions(parse_nonumberparsing PRIVATE SIMDJSON_SKIPNUMBERPARS
|
||||||
add_executable(parse_nostringparsing parse.cpp)
|
add_executable(parse_nostringparsing parse.cpp)
|
||||||
target_compile_definitions(parse_nostringparsing PRIVATE SIMDJSON_SKIPSTRINGPARSING)
|
target_compile_definitions(parse_nostringparsing PRIVATE SIMDJSON_SKIPSTRINGPARSING)
|
||||||
|
|
||||||
if (SIMDJSON_GOOGLE_BENCHMARKS)
|
if (TARGET benchmark::benchmark)
|
||||||
link_libraries(benchmark::benchmark)
|
link_libraries(benchmark::benchmark)
|
||||||
add_executable(bench_parse_call bench_parse_call.cpp)
|
add_executable(bench_parse_call bench_parse_call.cpp)
|
||||||
add_executable(bench_dom_api bench_dom_api.cpp)
|
add_executable(bench_dom_api bench_dom_api.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (SIMDJSON_COMPETITION)
|
if (TARGET competition-all)
|
||||||
add_executable(distinctuseridcompetition distinctuseridcompetition.cpp)
|
add_executable(distinctuseridcompetition distinctuseridcompetition.cpp)
|
||||||
target_link_libraries(distinctuseridcompetition competition-core)
|
target_link_libraries(distinctuseridcompetition competition-core)
|
||||||
add_executable(minifiercompetition minifiercompetition.cpp)
|
add_executable(minifiercompetition minifiercompetition.cpp)
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
|
|
||||||
# Clone the repository if it's not there
|
# Clone the repository if it's not there
|
||||||
find_package(Git QUIET)
|
find_package(Git QUIET)
|
||||||
if (Git_FOUND)
|
if (SIMDJSON_IS_UNDER_GIT AND Git_FOUND AND (GIT_VERSION_STRING VERSION_GREATER "2.1.4") AND (NOT CMAKE_GENERATOR MATCHES Ninja) ) # We use "-C" which requires a recent git
|
||||||
|
message(STATUS "Git is available and it is recent. We are enabling checkperf targets.")
|
||||||
# sync_git_repository(myrepo ...) creates two targets:
|
# sync_git_repository(myrepo ...) creates two targets:
|
||||||
# myrepo - if the repo does not exist, creates and syncs it against the origin branch
|
# myrepo - if the repo does not exist, creates and syncs it against the origin branch
|
||||||
# update_myrepo - will update the repo against the origin branch (and create if needed)
|
# update_myrepo - will update the repo against the origin branch (and create if needed)
|
||||||
|
@ -91,5 +92,10 @@ if (Git_FOUND)
|
||||||
set_property(TEST checkperf APPEND PROPERTY LABELS per_implementation)
|
set_property(TEST checkperf APPEND PROPERTY LABELS per_implementation)
|
||||||
set_property(TEST checkperf APPEND PROPERTY DEPENDS parse perfdiff ${SIMDJSON_USER_CMAKECACHE})
|
set_property(TEST checkperf APPEND PROPERTY DEPENDS parse perfdiff ${SIMDJSON_USER_CMAKECACHE})
|
||||||
set_property(TEST checkperf PROPERTY RUN_SERIAL TRUE)
|
set_property(TEST checkperf PROPERTY RUN_SERIAL TRUE)
|
||||||
|
else()
|
||||||
endif (Git_FOUND)
|
if (CMAKE_GENERATOR MATCHES Ninja)
|
||||||
|
message(STATUS "We disable the checkperf targets under Ninja.")
|
||||||
|
else()
|
||||||
|
message(STATUS "Either git is unavailable or else it is too old. We are disabling checkperf targets.")
|
||||||
|
endif()
|
||||||
|
endif ()
|
||||||
|
|
|
@ -1,4 +1,21 @@
|
||||||
option(SIMDJSON_JUST_LIBRARY "Build just the library, omit tests, tools and benchmarks" OFF)
|
|
||||||
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||||
|
message (STATUS "The simdjson repository appears to be standalone.")
|
||||||
|
option(SIMDJSON_JUST_LIBRARY "Build just the library, omit tests, tools and benchmarks" OFF)
|
||||||
|
message (STATUS "By default, we attempt to build everything.")
|
||||||
|
else()
|
||||||
|
message (STATUS "The simdjson repository appears to be used as a subdirectory.")
|
||||||
|
option(SIMDJSON_JUST_LIBRARY "Build just the library, omit tests, tools and benchmarks" ON)
|
||||||
|
message (STATUS "By default, we just build the library.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
|
||||||
|
set(SIMDJSON_IS_UNDER_GIT ON CACHE BOOL "Whether cmake is under git control")
|
||||||
|
message( STATUS "The simdjson repository appears to be under git." )
|
||||||
|
else()
|
||||||
|
set(SIMDJSON_IS_UNDER_GIT OFF CACHE BOOL "Whether cmake is under git control")
|
||||||
|
message( STATUS "The simdjson repository does not appear to be under git." )
|
||||||
|
endif()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Flags used by exes and by the simdjson library (project-wide flags)
|
# Flags used by exes and by the simdjson library (project-wide flags)
|
||||||
|
|
|
@ -1,74 +1,88 @@
|
||||||
# Initializes a git submodule if it hasn't been initialized before
|
# Initializes a git submodule if it hasn't been initialized before
|
||||||
# Does NOT attempt to update or otherwise modify git submodules that are already initialized.
|
|
||||||
function(initialize_submodule DIRECTORY)
|
|
||||||
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${DIRECTORY}/.git)
|
find_package(Git QUIET) # We want the library to build even if git is missing
|
||||||
find_package(Git QUIET REQUIRED)
|
if ((Git_FOUND) AND (SIMDJSON_IS_UNDER_GIT))
|
||||||
message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}/${DIRECTORY}/.git does not exist. Initializing ${DIRECTORY} submodule ...")
|
message(STATUS "Git is available.")
|
||||||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init ${CMAKE_CURRENT_SOURCE_DIR}/${DIRECTORY}
|
# Does NOT attempt to update or otherwise modify git submodules that are already initialized.
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
function(initialize_submodule DIRECTORY)
|
||||||
RESULT_VARIABLE GIT_EXIT_CODE)
|
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${DIRECTORY}/.git)
|
||||||
if(NOT GIT_EXIT_CODE EQUAL "0")
|
message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}/${DIRECTORY}/.git does not exist. Initializing ${DIRECTORY} submodule ...")
|
||||||
message(FATAL_ERROR "${GIT_EXECUTABLE} submodule update --init dependencies/${DIRECTORY} failed with exit code ${GIT_EXIT_CODE}, please checkout submodules")
|
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init ${CMAKE_CURRENT_SOURCE_DIR}/${DIRECTORY}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_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()
|
endif()
|
||||||
|
endfunction(initialize_submodule)
|
||||||
|
|
||||||
|
if (SIMDJSON_GOOGLE_BENCHMARKS)
|
||||||
|
option(BENCHMARK_ENABLE_TESTING OFF)
|
||||||
|
set(BENCHMARK_ENABLE_TESTING OFF)
|
||||||
|
option(BENCHMARK_ENABLE_INSTALL OFF)
|
||||||
|
set(BENCHMARK_ENABLE_INSTALL OFF)
|
||||||
|
initialize_submodule(benchmark)
|
||||||
|
add_subdirectory(benchmark)
|
||||||
endif()
|
endif()
|
||||||
endfunction(initialize_submodule)
|
|
||||||
|
|
||||||
if (SIMDJSON_GOOGLE_BENCHMARKS)
|
if (SIMDJSON_COMPETITION)
|
||||||
option(BENCHMARK_ENABLE_TESTING OFF)
|
initialize_submodule(cJSON)
|
||||||
set(BENCHMARK_ENABLE_TESTING OFF)
|
add_library(competition-cJSON INTERFACE)
|
||||||
option(BENCHMARK_ENABLE_INSTALL OFF)
|
target_include_directories(competition-cJSON INTERFACE cJSON)
|
||||||
set(BENCHMARK_ENABLE_INSTALL OFF)
|
|
||||||
initialize_submodule(benchmark)
|
|
||||||
add_subdirectory(benchmark)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (SIMDJSON_COMPETITION)
|
initialize_submodule(fastjson)
|
||||||
initialize_submodule(cJSON)
|
add_library(competition-fastjson INTERFACE)
|
||||||
add_library(competition-cJSON INTERFACE)
|
target_include_directories(competition-fastjson INTERFACE fastjson/src fastjson/include)
|
||||||
target_include_directories(competition-cJSON INTERFACE cJSON)
|
|
||||||
|
|
||||||
initialize_submodule(fastjson)
|
initialize_submodule(gason)
|
||||||
add_library(competition-fastjson INTERFACE)
|
add_library(competition-gason INTERFACE)
|
||||||
target_include_directories(competition-fastjson INTERFACE fastjson/src fastjson/include)
|
target_include_directories(competition-gason INTERFACE gason/src)
|
||||||
|
|
||||||
initialize_submodule(gason)
|
initialize_submodule(jsmn)
|
||||||
add_library(competition-gason INTERFACE)
|
add_library(competition-jsmn INTERFACE)
|
||||||
target_include_directories(competition-gason INTERFACE gason/src)
|
target_include_directories(competition-jsmn INTERFACE jsmn)
|
||||||
|
|
||||||
initialize_submodule(jsmn)
|
initialize_submodule(json)
|
||||||
add_library(competition-jsmn INTERFACE)
|
add_library(competition-json INTERFACE)
|
||||||
target_include_directories(competition-jsmn INTERFACE jsmn)
|
target_include_directories(competition-json INTERFACE json/single_include)
|
||||||
|
|
||||||
initialize_submodule(json)
|
initialize_submodule(json11)
|
||||||
add_library(competition-json INTERFACE)
|
add_library(competition-json11 INTERFACE)
|
||||||
target_include_directories(competition-json INTERFACE json/single_include)
|
target_include_directories(competition-json11 INTERFACE json11)
|
||||||
|
|
||||||
initialize_submodule(json11)
|
add_library(competition-jsoncppdist INTERFACE)
|
||||||
add_library(competition-json11 INTERFACE)
|
target_include_directories(competition-jsoncppdist INTERFACE jsoncppdist)
|
||||||
target_include_directories(competition-json11 INTERFACE json11)
|
|
||||||
|
|
||||||
add_library(competition-jsoncppdist INTERFACE)
|
initialize_submodule(rapidjson)
|
||||||
target_include_directories(competition-jsoncppdist INTERFACE jsoncppdist)
|
add_library(competition-rapidjson INTERFACE)
|
||||||
|
target_include_directories(competition-rapidjson INTERFACE rapidjson/include)
|
||||||
|
|
||||||
initialize_submodule(rapidjson)
|
initialize_submodule(sajson)
|
||||||
add_library(competition-rapidjson INTERFACE)
|
add_library(competition-sajson INTERFACE)
|
||||||
target_include_directories(competition-rapidjson INTERFACE rapidjson/include)
|
target_include_directories(competition-sajson INTERFACE sajson/include)
|
||||||
|
|
||||||
initialize_submodule(sajson)
|
initialize_submodule(ujson4c)
|
||||||
add_library(competition-sajson INTERFACE)
|
add_library(competition-ujson4c ujson4c/src/ujdecode.c)
|
||||||
target_include_directories(competition-sajson INTERFACE sajson/include)
|
target_include_directories(competition-ujson4c PUBLIC ujson4c/3rdparty ujson4c/src)
|
||||||
|
|
||||||
initialize_submodule(ujson4c)
|
add_library(competition-core INTERFACE)
|
||||||
add_library(competition-ujson4c ujson4c/src/ujdecode.c)
|
target_link_libraries(competition-core INTERFACE competition-json competition-rapidjson competition-sajson competition-cJSON competition-jsmn)
|
||||||
target_include_directories(competition-ujson4c PUBLIC ujson4c/3rdparty ujson4c/src)
|
|
||||||
|
|
||||||
add_library(competition-core INTERFACE)
|
add_library(competition-all INTERFACE)
|
||||||
target_link_libraries(competition-core INTERFACE competition-json competition-rapidjson competition-sajson competition-cJSON competition-jsmn)
|
target_link_libraries(competition-all INTERFACE competition-core competition-jsoncppdist competition-json11 competition-fastjson competition-gason competition-ujson4c)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(competition-all INTERFACE)
|
initialize_submodule(cxxopts)
|
||||||
target_link_libraries(competition-all INTERFACE competition-core competition-jsoncppdist competition-json11 competition-fastjson competition-gason competition-ujson4c)
|
message(STATUS "We acquired cxxopts and we are adding it as a library and target.")
|
||||||
endif()
|
add_library(cxxopts INTERFACE)
|
||||||
|
target_include_directories(cxxopts INTERFACE cxxopts/include)
|
||||||
initialize_submodule(cxxopts)
|
else()
|
||||||
add_library(cxxopts INTERFACE)
|
message(STATUS "Git is unavailable.")
|
||||||
target_include_directories(cxxopts INTERFACE cxxopts/include)
|
if(SIMDJSON_COMPETITION)
|
||||||
|
message (STATUS "'SIMDJSON_COMPETITION' is requested, but we cannot download the remote repositories." )
|
||||||
|
endif()
|
||||||
|
if(SIMDJSON_GOOGLE_BENCHMARKS)
|
||||||
|
message (STATUS "'SIMDJSON_GOOGLE_BENCHMARKS' is requested, but we cannot download the remote repositories." )
|
||||||
|
endif()
|
||||||
|
endif()
|
|
@ -64,7 +64,7 @@ find_program(BASH bash)
|
||||||
|
|
||||||
|
|
||||||
# Script tests
|
# Script tests
|
||||||
if (BASH AND (NOT MSVC)) # The scripts are not robust enough to run under Windows even if bash is available
|
if (BASH AND (NOT MSVC) AND (TARGET json2json)) # The scripts are not robust enough to run under Windows even if bash is available
|
||||||
#
|
#
|
||||||
# json2json test
|
# json2json test
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
link_libraries(simdjson simdjson-internal-flags simdjson-windows-headers cxxopts)
|
if(TARGET cxxopts) # we only build the tools if cxxopts is available
|
||||||
|
message(STATUS "We have cxxopts as a dependency and we are buiding the tools (e.g., json2json).")
|
||||||
add_executable(json2json json2json.cpp)
|
link_libraries(simdjson simdjson-internal-flags simdjson-windows-headers cxxopts)
|
||||||
add_executable(jsonstats jsonstats.cpp)
|
add_executable(json2json json2json.cpp)
|
||||||
add_executable(minify minify.cpp)
|
add_executable(jsonstats jsonstats.cpp)
|
||||||
|
add_executable(minify minify.cpp)
|
||||||
|
else()
|
||||||
|
message(STATUS "We are missing cxxopts as a dependency so the tools (e.g., json2json) are omitted.")
|
||||||
|
endif()
|
Loading…
Reference in New Issue