mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
deps: switch to CPM (#2257)
* deps: switch to CPM * missing file * setting the dependencies on URL download * using fixed version of cxxopts
This commit is contained in:
@@ -287,6 +287,7 @@ enable_testing()
|
||||
add_custom_target(all_tests)
|
||||
|
||||
add_subdirectory(windows)
|
||||
include(cmake/CPM.cmake)
|
||||
add_subdirectory(dependencies) ## This needs to be before tools because of cxxopts
|
||||
add_subdirectory(tools) ## This needs to be before tests because of cxxopts
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
|
||||
|
||||
set(CPM_DOWNLOAD_VERSION 0.40.2)
|
||||
set(CPM_HASH_SUM "c8cdc32c03816538ce22781ed72964dc864b2a34a310d3b7104812a5ca2d835d")
|
||||
|
||||
if(CPM_SOURCE_CACHE)
|
||||
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
|
||||
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
else()
|
||||
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
endif()
|
||||
|
||||
# Expand relative path. This is important if the provided path contains a tilde (~)
|
||||
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
|
||||
|
||||
file(DOWNLOAD
|
||||
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
|
||||
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
|
||||
)
|
||||
|
||||
include(${CPM_DOWNLOAD_LOCATION})
|
||||
Vendored
+76
-37
@@ -1,5 +1,4 @@
|
||||
include(CMakeDependentOption)
|
||||
include(import.cmake)
|
||||
|
||||
option(SIMDJSON_ALLOW_DOWNLOADS
|
||||
"Allow dependencies to be downloaded during configure time"
|
||||
@@ -11,17 +10,21 @@ cmake_dependent_option(SIMDJSON_GOOGLE_BENCHMARKS "compile the Google Benchmark
|
||||
SIMDJSON_ALLOW_DOWNLOADS OFF)
|
||||
|
||||
if(SIMDJSON_GOOGLE_BENCHMARKS)
|
||||
set_off(BENCHMARK_ENABLE_TESTING)
|
||||
set_off(BENCHMARK_ENABLE_INSTALL)
|
||||
set_off(BENCHMARK_ENABLE_WERROR)
|
||||
|
||||
import_dependency(google_benchmarks google/benchmark v1.7.1)
|
||||
add_dependency(google_benchmarks)
|
||||
CPMAddPackage(
|
||||
NAME google_benchmarks
|
||||
URL https://github.com/google/benchmark/archive/refs/tags/v1.7.1.zip
|
||||
OPTIONS
|
||||
"BENCHMARK_ENABLE_TESTING OFF"
|
||||
"BENCHMARK_ENABLE_INSTALL OFF"
|
||||
"BENCHMARK_ENABLE_WERROR OFF"
|
||||
)
|
||||
endif()
|
||||
|
||||
# The bulk of our benchmarking and testing data has been moved simdjson/simdjson-data
|
||||
import_dependency(simdjson-data simdjson/simdjson-data a5b13babe65c1bba7186b41b43d4cbdc20a5c470)
|
||||
add_dependency(simdjson-data)
|
||||
CPMAddPackage(
|
||||
NAME simdjson-data
|
||||
URL https://github.com/simdjson/simdjson-data/archive/a5b13babe65c1bba7186b41b43d4cbdc20a5c470.zip
|
||||
)
|
||||
|
||||
option(SIMDJSON_USE_BOOST_JSON "Try to include BOOST_JSON, this may break your binaries under some systems." OFF)
|
||||
# This prevents variables declared with set() from unnecessarily escaping and
|
||||
# should not be called more than once
|
||||
@@ -38,20 +41,30 @@ function(competition_scope_)
|
||||
int main() {}
|
||||
]] SIMDJSON_FOUND_STRING_VIEW)
|
||||
if(SIMDJSON_FOUND_STRING_VIEW AND SIMDJSON_USE_BOOST_JSON)
|
||||
import_dependency(boostjson boostorg/json ee8d72d)
|
||||
CPMAddPackage(
|
||||
NAME boostjson
|
||||
URL https://github.com/boostorg/json/archive/ee8d72d8502b409b5561200299cad30ccdb91415.zip
|
||||
)
|
||||
add_library(boostjson STATIC "${boostjson_SOURCE_DIR}/src/src.cpp")
|
||||
target_compile_definitions(boostjson PUBLIC BOOST_JSON_STANDALONE)
|
||||
target_include_directories(boostjson SYSTEM PUBLIC
|
||||
"${boostjson_SOURCE_DIR}/include")
|
||||
target_compile_definitions(boostjson INTERFACE SIMDJSON_COMPETITION_BOOSTJSON)
|
||||
endif()
|
||||
|
||||
import_dependency(cjson DaveGamble/cJSON c69134d)
|
||||
CPMAddPackage(
|
||||
NAME cjson
|
||||
URL https://github.com/DaveGamble/cJSON/archive/c69134d01746dcf551dd7724b4edb12f922eb0d1.zip
|
||||
DOWNLOAD_ONLY YES
|
||||
)
|
||||
add_library(cjson STATIC "${cjson_SOURCE_DIR}/cJSON.c")
|
||||
target_include_directories(cjson SYSTEM PUBLIC "${cjson_SOURCE_DIR}")
|
||||
target_compile_definitions(cjson INTERFACE SIMDJSON_COMPETITION_CJSON)
|
||||
|
||||
import_dependency(fastjson mikeando/fastjson 485f994)
|
||||
CPMAddPackage(
|
||||
NAME fastjson
|
||||
URL https://github.com/mikeando/fastjson/archive/485f994a61a64ac73fa6a40d4d639b99b463563b.zip
|
||||
DOWNLOAD_ONLY YES
|
||||
)
|
||||
add_library(fastjson STATIC
|
||||
"${fastjson_SOURCE_DIR}/src/fastjson.cpp"
|
||||
"${fastjson_SOURCE_DIR}/src/fastjson2.cpp"
|
||||
@@ -60,28 +73,36 @@ int main() {}
|
||||
"${fastjson_SOURCE_DIR}/include")
|
||||
target_compile_definitions(fastjson INTERFACE SIMDJSON_COMPETITION_FASTJSON)
|
||||
|
||||
import_dependency(gason vivkin/gason 7aee524)
|
||||
CPMAddPackage(
|
||||
NAME gason
|
||||
URL https://github.com/vivkin/gason/archive/7aee524189da1c1ecd19f67981e3d903dae25470.zip
|
||||
DOWNLOAD_ONLY YES
|
||||
)
|
||||
add_library(gason STATIC "${gason_SOURCE_DIR}/src/gason.cpp")
|
||||
target_include_directories(gason SYSTEM PUBLIC "${gason_SOURCE_DIR}/src")
|
||||
target_compile_definitions(gason INTERFACE SIMDJSON_COMPETITION_GASON)
|
||||
|
||||
import_dependency(jsmn zserge/jsmn 18e9fe4)
|
||||
CPMAddPackage(
|
||||
NAME jsmn
|
||||
URL https://github.com/zserge/jsmn/archive/18e9fe42cbfe21d65076f5c77ae2be379ad1270f.zip
|
||||
DOWNLOAD_ONLY YES
|
||||
)
|
||||
add_library(jsmn STATIC "${jsmn_SOURCE_DIR}/jsmn.c")
|
||||
target_include_directories(jsmn SYSTEM PUBLIC "${jsmn_SOURCE_DIR}")
|
||||
target_compile_definitions(jsmn INTERFACE SIMDJSON_COMPETITION_JSMN)
|
||||
|
||||
message(STATUS "Importing json (nlohmann/json@v3.10.5)")
|
||||
set(nlohmann_json_SOURCE_DIR "${dep_root}/json")
|
||||
if(NOT EXISTS "${nlohmann_json_SOURCE_DIR}")
|
||||
file(DOWNLOAD
|
||||
"https://github.com/nlohmann/json/releases/download/v3.10.5/json.hpp"
|
||||
"${nlohmann_json_SOURCE_DIR}/nlohmann/json.hpp")
|
||||
endif()
|
||||
add_library(nlohmann_json INTERFACE)
|
||||
target_include_directories(nlohmann_json SYSTEM INTERFACE "${nlohmann_json_SOURCE_DIR}")
|
||||
target_compile_definitions(nlohmann_json INTERFACE SIMDJSON_COMPETITION_NLOHMANN_JSON)
|
||||
CPMAddPackage(
|
||||
NAME nlohmann_json
|
||||
URL https://github.com/nlohmann/json/archive/refs/tags/v3.10.5.zip
|
||||
)
|
||||
|
||||
import_dependency(json11 dropbox/json11 ec4e452)
|
||||
set_property(TARGET nlohmann_json APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS SIMDJSON_COMPETITION_NLOHMANN_JSON)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME json11
|
||||
URL https://github.com/dropbox/json11/archive/ec4e45219af1d7cde3d58b49ed762376fccf1ace.zip
|
||||
DOWNLOAD_ONLY YES
|
||||
)
|
||||
add_library(json11 STATIC "${json11_SOURCE_DIR}/json11.cpp")
|
||||
target_include_directories(json11 SYSTEM PUBLIC "${json11_SOURCE_DIR}")
|
||||
target_compile_definitions(json11 INTERFACE SIMDJSON_COMPETITION_JSON11)
|
||||
@@ -91,7 +112,11 @@ int main() {}
|
||||
target_include_directories(jsoncpp SYSTEM PUBLIC "${jsoncpp_SOURCE_DIR}")
|
||||
target_compile_definitions(jsoncpp INTERFACE SIMDJSON_COMPETITION_JSONCPP)
|
||||
|
||||
import_dependency(rapidjson Tencent/rapidjson f54b0e4)
|
||||
CPMAddPackage(
|
||||
NAME rapidjson
|
||||
URL https://github.com/Tencent/rapidjson/archive/f54b0e47a08782a6131cc3d60f94d038fa6e0a51.zip
|
||||
DOWNLOAD_ONLY YES
|
||||
)
|
||||
add_library(rapidjson INTERFACE)
|
||||
target_compile_definitions(rapidjson INTERFACE RAPIDJSON_HAS_STDSTRING)
|
||||
include (TestBigEndian)
|
||||
@@ -110,14 +135,22 @@ int main() {}
|
||||
target_compile_definitions(rapidjson INTERFACE SIMDJSON_COMPETITION_RAPIDJSON)
|
||||
endif()
|
||||
|
||||
import_dependency(sajson chadaustin/sajson 2dcfd35)
|
||||
CPMAddPackage(
|
||||
NAME sajson
|
||||
URL https://github.com/chadaustin/sajson/archive/2dcfd350586375f9910f74821d4f07d67ae455ba.zip
|
||||
DOWNLOAD_ONLY YES
|
||||
)
|
||||
add_library(sajson INTERFACE)
|
||||
target_compile_definitions(sajson INTERFACE SAJSON_UNSORTED_OBJECT_KEYS)
|
||||
target_include_directories(sajson SYSTEM INTERFACE
|
||||
"${sajson_SOURCE_DIR}/include")
|
||||
target_compile_definitions(sajson INTERFACE SIMDJSON_COMPETITION_SAJSON)
|
||||
|
||||
import_dependency(ujson4c esnme/ujson4c e14f3fd)
|
||||
CPMAddPackage(
|
||||
NAME ujson4c
|
||||
URL https://github.com/esnme/ujson4c/archive/e14f3fd5207fe30d1bdea723f260609e69d1abfa.zip
|
||||
DOWNLOAD_ONLY YES
|
||||
)
|
||||
add_library(ujson4c STATIC
|
||||
"${ujson4c_SOURCE_DIR}/src/ujdecode.c"
|
||||
"${ujson4c_SOURCE_DIR}/3rdparty/ultrajsondec.c")
|
||||
@@ -126,7 +159,11 @@ int main() {}
|
||||
"${ujson4c_SOURCE_DIR}/3rdparty")
|
||||
target_compile_definitions(ujson4c INTERFACE SIMDJSON_COMPETITION_UJSON4C)
|
||||
|
||||
import_dependency(yyjson ibireme/yyjson c385651)
|
||||
CPMAddPackage(
|
||||
NAME yyjson
|
||||
URL https://github.com/ibireme/yyjson/archive/c3856514de0a67d7b66939bf3ed491a2d6e61277.zip
|
||||
DOWNLOAD_ONLY YES
|
||||
)
|
||||
add_library(yyjson STATIC "${yyjson_SOURCE_DIR}/src/yyjson.c")
|
||||
target_include_directories(yyjson SYSTEM PUBLIC "${yyjson_SOURCE_DIR}/src")
|
||||
target_compile_definitions(yyjson INTERFACE SIMDJSON_COMPETITION_YYJSON)
|
||||
@@ -151,10 +188,12 @@ cmake_dependent_option(SIMDJSON_CXXOPTS "Download cxxopts (necessary for tools)"
|
||||
SIMDJSON_ALLOW_DOWNLOADS OFF)
|
||||
|
||||
if(SIMDJSON_CXXOPTS)
|
||||
set_off(CXXOPTS_BUILD_EXAMPLES)
|
||||
set_off(CXXOPTS_BUILD_TESTS)
|
||||
set_off(CXXOPTS_ENABLE_INSTALL)
|
||||
|
||||
import_dependency(cxxopts jarro2783/cxxopts 5965670)
|
||||
add_dependency(cxxopts)
|
||||
CPMAddPackage(
|
||||
NAME cxxopts
|
||||
URL https://github.com/jarro2783/cxxopts/archive/59656709c0c58fcd0ed18b38e02938dbe05284c5.zip
|
||||
OPTIONS
|
||||
"CXXOPTS_BUILD_EXAMPLES OFF"
|
||||
"CXXOPTS_BUILD_TESTS OFF"
|
||||
"CXXOPTS_ENABLE_INSTALL OFF"
|
||||
)
|
||||
endif()
|
||||
|
||||
Vendored
-48
@@ -1,48 +0,0 @@
|
||||
set(dep_root "${simdjson_SOURCE_DIR}/dependencies/.cache")
|
||||
if(DEFINED ENV{simdjson_DEPENDENCY_CACHE_DIR})
|
||||
set(dep_root "$ENV{simdjson_DEPENDENCY_CACHE_DIR}")
|
||||
endif()
|
||||
|
||||
function(import_dependency NAME GITHUB_REPO COMMIT)
|
||||
message(STATUS "Importing ${NAME} (${GITHUB_REPO}@${COMMIT})")
|
||||
set(target "${dep_root}/${NAME}")
|
||||
|
||||
# If the folder exists in the cache, then we assume that everything is as
|
||||
# should be and do nothing
|
||||
if(EXISTS "${target}")
|
||||
set("${NAME}_SOURCE_DIR" "${target}" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(zip_url "https://github.com/${GITHUB_REPO}/archive/${COMMIT}.zip")
|
||||
set(archive "${dep_root}/archive.zip")
|
||||
set(dest "${dep_root}/_extract")
|
||||
|
||||
file(DOWNLOAD "${zip_url}" "${archive}")
|
||||
file(MAKE_DIRECTORY "${dest}")
|
||||
execute_process(
|
||||
WORKING_DIRECTORY "${dest}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E tar xf "${archive}")
|
||||
file(REMOVE "${archive}")
|
||||
|
||||
# GitHub archives only ever have one folder component at the root, so this
|
||||
# will always match that single folder
|
||||
file(GLOB dir LIST_DIRECTORIES YES "${dest}/*")
|
||||
|
||||
file(RENAME "${dir}" "${target}")
|
||||
|
||||
set("${NAME}_SOURCE_DIR" "${target}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Delegates to the dependency
|
||||
macro(add_dependency NAME)
|
||||
if(NOT DEFINED "${NAME}_SOURCE_DIR")
|
||||
message(FATAL_ERROR "Missing ${NAME}_SOURCE_DIR variable")
|
||||
endif()
|
||||
|
||||
add_subdirectory("${${NAME}_SOURCE_DIR}" "${PROJECT_BINARY_DIR}/_deps/${NAME}" EXCLUDE_FROM_ALL)
|
||||
endmacro()
|
||||
|
||||
function(set_off NAME)
|
||||
set("${NAME}" OFF CACHE INTERNAL "")
|
||||
endfunction()
|
||||
Reference in New Issue
Block a user