diff --git a/CMakeLists.txt b/CMakeLists.txt index b0d5584a..2df6d218 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,8 +92,20 @@ endif() if(BUILD_TESTING) set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) - add_subdirectory(./third_party/googletest) - include(GoogleTest) + + if(NOT EXISTS third_party/googletest/CMakeLists.txt) + execute_process( + COMMAND git submodule update --init --recursive -- third_party/googletest + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + endif() + + if(EXISTS third_party/googletest/CMakeLists.txt) + add_subdirectory(./third_party/googletest) + include(GoogleTest) + else() + set(BUILD_TESTING OFF) + endif() endif() if(NOT CMAKE_PREFIX_PATH AND (NOT ("$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")))