Allow build without download (#1334)

* Add option for downloading dependencies

* Format the boost json import code

Co-authored-by: friendlyanon <friendlyanon@users.noreply.github.com>
This commit is contained in:
friendlyanon 2020-12-14 01:07:29 +01:00 committed by GitHub
parent 6b02b06581
commit 91b07ba075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 13 deletions

View File

@ -1,7 +1,14 @@
include(CMakeDependentOption)
include(import.cmake) include(import.cmake)
option(SIMDJSON_COMPETITION "Compile competitive benchmarks" ON) option(SIMDJSON_ALLOW_DOWNLOADS
option(SIMDJSON_GOOGLE_BENCHMARKS "compile the Google Benchmark benchmarks" ON) "Allow dependencies to be downloaded during configure time"
ON)
cmake_dependent_option(SIMDJSON_COMPETITION "Compile competitive benchmarks" ON
SIMDJSON_ALLOW_DOWNLOADS OFF)
cmake_dependent_option(SIMDJSON_GOOGLE_BENCHMARKS "compile the Google Benchmark benchmarks" ON
SIMDJSON_ALLOW_DOWNLOADS OFF)
if(SIMDJSON_GOOGLE_BENCHMARKS) if(SIMDJSON_GOOGLE_BENCHMARKS)
set_off(BENCHMARK_ENABLE_TESTING) set_off(BENCHMARK_ENABLE_TESTING)
@ -16,9 +23,17 @@ endif()
function(competition_scope_) function(competition_scope_)
# boost json in standalone mode requires C++17 string_view # boost json in standalone mode requires C++17 string_view
include(CheckCXXSourceCompiles) include(CheckCXXSourceCompiles)
check_cxx_source_compiles("#include <string_view>\n#if __cpp_lib_string_view < 201606\n#error no string view support\n#endif\nint main(){}" USE_BOOST_JSON) check_cxx_source_compiles([[
#include <string_view>
#if __cpp_lib_string_view < 201606
# error no string view support
#endif
int main() {}
]] USE_BOOST_JSON)
if(USE_BOOST_JSON) if(USE_BOOST_JSON)
import_dependency(boostjson boostorg/json ee8d72d8502b409b5561200299cad30ccdb91415) import_dependency(boostjson boostorg/json ee8d72d)
add_library(boostjson STATIC "${boostjson_SOURCE_DIR}/src/src.cpp") add_library(boostjson STATIC "${boostjson_SOURCE_DIR}/src/src.cpp")
target_compile_definitions(boostjson PUBLIC BOOST_JSON_STANDALONE) target_compile_definitions(boostjson PUBLIC BOOST_JSON_STANDALONE)
target_include_directories(boostjson SYSTEM PUBLIC target_include_directories(boostjson SYSTEM PUBLIC
@ -102,9 +117,14 @@ if(SIMDJSON_COMPETITION)
competition_scope_() competition_scope_()
endif() endif()
cmake_dependent_option(SIMDJSON_CXXOPTS "Download cxxopts (necessary for tools)" ON
SIMDJSON_ALLOW_DOWNLOADS OFF)
if(SIMDJSON_CXXOPTS)
set_off(CXXOPTS_BUILD_EXAMPLES) set_off(CXXOPTS_BUILD_EXAMPLES)
set_off(CXXOPTS_BUILD_TESTS) set_off(CXXOPTS_BUILD_TESTS)
set_off(CXXOPTS_ENABLE_INSTALL) set_off(CXXOPTS_ENABLE_INSTALL)
import_dependency(cxxopts jarro2783/cxxopts 794c975) import_dependency(cxxopts jarro2783/cxxopts 794c975)
add_dependency(cxxopts) add_dependency(cxxopts)
endif()