diff --git a/CMakeLists.txt b/CMakeLists.txt index b9a1a327..05f914d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,8 +16,16 @@ include(GNUInstallDirs) include(cmake/simdjson-flags.cmake) include(cmake/simdjson-user-cmakecache.cmake) +if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) + set(SIMDJSON_IS_UNDER_GIT ON CACHE BOOL "Whether cmake is under git control") + message( STATUS "The simdjson repository appears to be under git." ) +else() + set(SIMDJSON_IS_UNDER_GIT OFF CACHE BOOL "Whether cmake is under git control") + message( STATUS "The simdjson repository does not appear to be under git." ) +endif() + if(SIMDJSON_JUST_LIBRARY) - MESSAGE( STATUS "Building just the library, omitting all tests, tools and benchmarks." ) + message( STATUS "Building just the library, omitting all tests, tools and benchmarks." ) endif() # diff --git a/benchmark/checkperf.cmake b/benchmark/checkperf.cmake index 650304e2..ec1aa809 100644 --- a/benchmark/checkperf.cmake +++ b/benchmark/checkperf.cmake @@ -7,7 +7,7 @@ # Clone the repository if it's not there find_package(Git QUIET) -if (Git_FOUND AND (GIT_VERSION_STRING VERSION_GREATER "2.1.4")) # We use "-C" which requires a recent git +if (SIMDJSON_IS_UNDER_GIT AND Git_FOUND AND (GIT_VERSION_STRING VERSION_GREATER "2.1.4")) # We use "-C" which requires a recent git message(STATUS "Git is available and it is recent. We are enabling checkperf targets.") # sync_git_repository(myrepo ...) creates two targets: # myrepo - if the repo does not exist, creates and syncs it against the origin branch diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt index 66034e77..c8f27e39 100644 --- a/dependencies/CMakeLists.txt +++ b/dependencies/CMakeLists.txt @@ -2,7 +2,7 @@ find_package(Git QUIET) # We want the library to build even if git is missing -if (Git_FOUND) +if ((Git_FOUND) AND (SIMDJSON_IS_UNDER_GIT)) message(STATUS "Git is available.") # Does NOT attempt to update or otherwise modify git submodules that are already initialized. function(initialize_submodule DIRECTORY)