build: initialize GTest submodule in CMake
Try to initialize the GTest Git submodule from the CMake code if it has not been. If that fails, turn off `BUILD_TESTING`. We do not want to require recursive clones or initializing submodules for users by default. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
parent
e8494b56d1
commit
94979eff97
|
@ -92,8 +92,20 @@ endif()
|
||||||
if(BUILD_TESTING)
|
if(BUILD_TESTING)
|
||||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||||
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
|
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
|
||||||
|
|
||||||
|
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)
|
add_subdirectory(./third_party/googletest)
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
|
else()
|
||||||
|
set(BUILD_TESTING OFF)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT CMAKE_PREFIX_PATH AND (NOT ("$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")))
|
if(NOT CMAKE_PREFIX_PATH AND (NOT ("$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")))
|
||||||
|
|
Loading…
Reference in New Issue