2020-04-08 00:25:11 +08:00
|
|
|
# Initializes a git submodule if it hasn't been initialized before
|
2020-06-25 03:13:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
find_package(Git QUIET) # We want the library to build even if git is missing
|
2020-08-17 23:50:57 +08:00
|
|
|
if ((Git_FOUND) AND SIMDJSON_GIT AND (SIMDJSON_IS_UNDER_GIT))
|
2020-06-25 03:44:22 +08:00
|
|
|
message(STATUS "Git is available.")
|
2020-06-25 03:13:47 +08:00
|
|
|
# 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)
|
|
|
|
message(STATUS "${CMAKE_CURRENT_SOURCE_DIR}/${DIRECTORY}/.git does not exist. Initializing ${DIRECTORY} submodule ...")
|
|
|
|
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()
|
2020-04-07 07:04:37 +08:00
|
|
|
endif()
|
2020-06-25 03:13:47 +08:00
|
|
|
endfunction(initialize_submodule)
|
|
|
|
|
|
|
|
if (SIMDJSON_GOOGLE_BENCHMARKS)
|
2020-06-30 09:10:54 +08:00
|
|
|
message (STATUS "'SIMDJSON_GOOGLE_BENCHMARKS' is requested, configuring..." )
|
2020-06-25 03:13:47 +08:00
|
|
|
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()
|
|
|
|
|
|
|
|
if (SIMDJSON_COMPETITION)
|
|
|
|
initialize_submodule(cJSON)
|
|
|
|
add_library(competition-cJSON INTERFACE)
|
|
|
|
target_include_directories(competition-cJSON INTERFACE cJSON)
|
|
|
|
|
|
|
|
initialize_submodule(fastjson)
|
|
|
|
add_library(competition-fastjson INTERFACE)
|
|
|
|
target_include_directories(competition-fastjson INTERFACE fastjson/src fastjson/include)
|
|
|
|
|
|
|
|
initialize_submodule(gason)
|
|
|
|
add_library(competition-gason INTERFACE)
|
|
|
|
target_include_directories(competition-gason INTERFACE gason/src)
|
|
|
|
|
|
|
|
initialize_submodule(jsmn)
|
|
|
|
add_library(competition-jsmn INTERFACE)
|
|
|
|
target_include_directories(competition-jsmn INTERFACE jsmn)
|
|
|
|
|
|
|
|
initialize_submodule(json)
|
|
|
|
add_library(competition-json INTERFACE)
|
|
|
|
target_include_directories(competition-json INTERFACE json/single_include)
|
|
|
|
|
|
|
|
initialize_submodule(json11)
|
|
|
|
add_library(competition-json11 INTERFACE)
|
|
|
|
target_include_directories(competition-json11 INTERFACE json11)
|
|
|
|
|
|
|
|
add_library(competition-jsoncppdist INTERFACE)
|
|
|
|
target_include_directories(competition-jsoncppdist INTERFACE jsoncppdist)
|
|
|
|
|
|
|
|
initialize_submodule(rapidjson)
|
|
|
|
add_library(competition-rapidjson INTERFACE)
|
|
|
|
target_include_directories(competition-rapidjson INTERFACE rapidjson/include)
|
|
|
|
|
|
|
|
initialize_submodule(sajson)
|
|
|
|
add_library(competition-sajson INTERFACE)
|
|
|
|
target_include_directories(competition-sajson INTERFACE sajson/include)
|
|
|
|
|
|
|
|
initialize_submodule(ujson4c)
|
|
|
|
add_library(competition-ujson4c ujson4c/src/ujdecode.c)
|
|
|
|
target_include_directories(competition-ujson4c PUBLIC ujson4c/3rdparty ujson4c/src)
|
|
|
|
|
2020-11-05 01:24:42 +08:00
|
|
|
# Boost JSON is not compatible with some clang/libc++ configurations.
|
|
|
|
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
|
|
initialize_submodule(boost.json)
|
|
|
|
add_library(boostjson boost.json/src/src.cpp)
|
|
|
|
target_compile_definitions(boostjson PUBLIC BOOST_JSON_STANDALONE)
|
|
|
|
target_include_directories(boostjson PUBLIC boost.json/include)
|
|
|
|
endif()
|
2020-10-04 16:00:09 +08:00
|
|
|
|
2020-10-22 04:23:20 +08:00
|
|
|
initialize_submodule(yyjson)
|
|
|
|
add_library(yyjson yyjson/src/yyjson.c)
|
|
|
|
target_include_directories(yyjson PUBLIC yyjson/src)
|
|
|
|
|
2020-06-25 03:13:47 +08:00
|
|
|
add_library(competition-core INTERFACE)
|
2020-11-05 01:24:42 +08:00
|
|
|
# Boost JSON is not compatible with some clang/libc++ configurations.
|
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
|
|
target_link_libraries(competition-core INTERFACE competition-json competition-rapidjson competition-sajson competition-cJSON competition-jsmn yyjson)
|
|
|
|
else()
|
|
|
|
target_link_libraries(competition-core INTERFACE competition-json competition-rapidjson competition-sajson competition-cJSON competition-jsmn boostjson yyjson)
|
|
|
|
endif()
|
2020-06-25 03:13:47 +08:00
|
|
|
|
|
|
|
add_library(competition-all INTERFACE)
|
|
|
|
target_link_libraries(competition-all INTERFACE competition-core competition-jsoncppdist competition-json11 competition-fastjson competition-gason competition-ujson4c)
|
2020-04-07 07:04:37 +08:00
|
|
|
endif()
|
2020-06-25 03:13:47 +08:00
|
|
|
|
|
|
|
initialize_submodule(cxxopts)
|
2020-06-25 03:44:22 +08:00
|
|
|
message(STATUS "We acquired cxxopts and we are adding it as a library and target.")
|
2020-06-25 03:13:47 +08:00
|
|
|
add_library(cxxopts INTERFACE)
|
|
|
|
target_include_directories(cxxopts INTERFACE cxxopts/include)
|
2020-06-25 03:44:22 +08:00
|
|
|
else()
|
|
|
|
message(STATUS "Git is unavailable.")
|
2020-06-25 05:09:18 +08:00
|
|
|
if(SIMDJSON_COMPETITION)
|
2020-10-04 16:00:09 +08:00
|
|
|
message (STATUS "'SIMDJSON_COMPETITION' is requested, but we cannot download the remote repositories." )
|
2020-06-25 05:09:18 +08:00
|
|
|
endif()
|
|
|
|
if(SIMDJSON_GOOGLE_BENCHMARKS)
|
|
|
|
message (STATUS "'SIMDJSON_GOOGLE_BENCHMARKS' is requested, but we cannot download the remote repositories." )
|
|
|
|
endif()
|
2020-10-04 16:00:09 +08:00
|
|
|
endif()
|