From d395707098e247c8d2eb4511fec216706dc4f3e4 Mon Sep 17 00:00:00 2001 From: Dima Korolev Date: Sat, 17 Feb 2024 10:25:53 +0100 Subject: [PATCH 1/2] Added support for the `CURRENT_WITH_LEVELDB` env var. --- cmake/CMakeLists.txt | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f3bfadde..2070ce6b 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -4,12 +4,17 @@ cmake_minimum_required(VERSION 3.14.1) project(cmake_trivial_2023 C CXX) -set (CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 17) find_package(Threads REQUIRED) -# Settings for `googletest`. It builds faste without `gmock`. -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -option(BUILD_GMOCK OFF) +if(NOT DEFINED ENV{CURRENT_WITH_LEVELDB}) + message(STATUS "Disabling gmock.") + # Settings for `googletest`. It builds faste without `gmock`. + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + option(BUILD_GMOCK OFF) +else() + message(STATUS "Using Current with LevelDB.") +endif() # The helper to clone a dependency, or use it from a sibling dir if available. function(UseOrGitClone dep remote branch) @@ -36,9 +41,18 @@ function(UseOrGitClone dep remote branch) endfunction() UseOrGitClone(current https://github.com/c5t/current stable) -UseOrGitClone(googletest https://github.com/c5t/googletest v1.14) -set(C5T_LIBRARIES "Threads::Threads" "C5T") +if(NOT DEFINED ENV{CURRENT_WITH_LEVELDB}) + UseOrGitClone(googletest https://github.com/c5t/googletest v1.14) +else() + UseOrGitClone(googletest https://github.com/c5t/leveldb main) +endif() + +if(NOT DEFINED ENV{CURRENT_WITH_LEVELDB}) + set(C5T_LIBRARIES "Threads::Threads" "C5T") +else() + set(C5T_LIBRARIES "Threads::Threads" "C5T" "leveldb") +endif() # Declare shared libraries as shared library targets. Do not link them against anything external. file(GLOB_RECURSE BINARY_SOURCE_FILES "src/dlib_*.cc") From 1176e635959ae87a560073d5aee972524d7ff28e Mon Sep 17 00:00:00 2001 From: Dima Korolev Date: Sat, 17 Feb 2024 10:30:36 +0100 Subject: [PATCH 2/2] Typo fix and added recursive submodules cloning. --- cmake/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 2070ce6b..82b1087c 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -32,7 +32,7 @@ function(UseOrGitClone dep remote branch) message(STATUS "Using `${dep}` from `CMAKE_CURRENT_SOURCE_DIR/../${dep}': Configured.") else() message(STATUS "Cloning `${dep}` from `${remote}:${branch}` ...") - execute_process(OUTPUT_QUIET ERROR_QUIET COMMAND git clone --depth 1 -b ${branch} ${remote}) + execute_process(OUTPUT_QUIET ERROR_QUIET COMMAND git clone --depth 1 --recurse-submodules --shallow-submodules -b ${branch} ${remote}) file(TOUCH .gitignore) file(APPEND .gitignore "${dep}/\n") add_subdirectory("${CMAKE_SOURCE_DIR}/${dep}" ${dep}) @@ -45,7 +45,7 @@ UseOrGitClone(current https://github.com/c5t/current stable) if(NOT DEFINED ENV{CURRENT_WITH_LEVELDB}) UseOrGitClone(googletest https://github.com/c5t/googletest v1.14) else() - UseOrGitClone(googletest https://github.com/c5t/leveldb main) + UseOrGitClone(leveldb https://github.com/c5t/leveldb main) endif() if(NOT DEFINED ENV{CURRENT_WITH_LEVELDB})