From 0714f5fc672412d890d23f5679705c32e4928b6a Mon Sep 17 00:00:00 2001 From: John Keiser Date: Mon, 6 Apr 2020 16:04:37 -0700 Subject: [PATCH] Create dependencies/CMakeLists.txt --- CMakeLists.txt | 14 +------------- dependencies/CMakeLists.txt | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 dependencies/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index b294297e..c7d95310 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,23 +65,11 @@ add_definitions(-DSIMDJSON_BENCHMARK_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/jsone enable_testing() +add_subdirectory(dependencies) add_subdirectory(tools) add_subdirectory(tests) add_subdirectory(benchmark) -if (SIMDJSON_GOOGLE_BENCHMARKS) - if(NOT EXISTS dependencies/benchmark/CMakeLists.txt) - # message(STATUS "Unable to find dependencies/benchmark/CMakeLists.txt") - execute_process(COMMAND git submodule update --init -- dependencies/benchmark - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - endif() - option(BENCHMARK_ENABLE_TESTING OFF) - set(BENCHMARK_ENABLE_TESTING OFF) - option(BENCHMARK_ENABLE_INSTALL OFF) - set(BENCHMARK_ENABLE_INSTALL OFF) - add_subdirectory(dependencies/benchmark) -endif() - # for fuzzing, read the comments in the fuzz/CMakeLists.txt file option(ENABLE_FUZZING "enable building the fuzzers" ON) if(ENABLE_FUZZING) diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt new file mode 100644 index 00000000..2bef03f4 --- /dev/null +++ b/dependencies/CMakeLists.txt @@ -0,0 +1,22 @@ +# Init submodules so they can be used +find_package(Git QUIET) +if(GIT_FOUND) + option(SIMDJSON_GIT_SUBMODULE "Check submodules during build" ON) + if(SIMDJSON_GIT_SUBMODULE) + message(STATUS "Updating submodules") + execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_EXIT_CODE) + if(NOT GIT_EXIT_CODE EQUAL "0") + message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") + endif() + endif() +endif() + +if (SIMDJSON_GOOGLE_BENCHMARKS) + option(BENCHMARK_ENABLE_TESTING OFF) + set(BENCHMARK_ENABLE_TESTING OFF) + option(BENCHMARK_ENABLE_INSTALL OFF) + set(BENCHMARK_ENABLE_INSTALL OFF) + add_subdirectory(benchmark) +endif()