chores: Fetch googletest via CMake (#4252)

This commit is contained in:
Raphael Coeffic
2023-10-27 19:26:22 +10:00
committed by GitHub
parent c85b444a14
commit 44981ad1f5
6 changed files with 33 additions and 35 deletions
-25
View File
@@ -1,25 +0,0 @@
set(GTEST_ROOT /usr CACHE STRING "Base path to Google Test headers and source.")
find_path(GTEST_INCDIR gtest/gtest.h HINTS "${GTEST_ROOT}/include" DOC "Path to Google Test header files folder ('gtest/gtest.h').")
find_path(GTEST_SRCDIR src/gtest-all.cc HINTS "${GTEST_ROOT}" "${GTEST_ROOT}/src/gtest" DOC "Path of Google Test 'src' folder.")
if(NOT GTEST_INCDIR OR NOT GTEST_SRCDIR)
message(STATUS "Googletest will be downloaded")
set(GTEST_VERSION 1.8.1)
set(GTEST_SRCDIR "${RADIO_SRC_DIR}/tests/googletest-release-${GTEST_VERSION}/googletest")
set(GTEST_INCDIR "${GTEST_SRCDIR}/include")
set(GTEST_URL "https://github.com/google/googletest/archive/release-${GTEST_VERSION}.tar.gz")
set(GTEST_ARCHIVE "${RADIO_SRC_DIR}/tests/gtest-${GTEST_VERSION}.tar.gz")
if (NOT EXISTS "${GTEST_SRCDIR}")
file(DOWNLOAD "${GTEST_URL}" ${GTEST_ARCHIVE} SHOW_PROGRESS)
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar -xf ${GTEST_ARCHIVE}
WORKING_DIRECTORY ${RADIO_SRC_DIR}/tests)
execute_process(
COMMAND ${CMAKE_COMMAND} -E remove -f ${GTEST_ARCHIVE})
endif()
endif()
+15
View File
@@ -0,0 +1,15 @@
# Fetch gtest source code from Github
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG f8d7d77c06936315286eb55f8de22cd23c188571 # v1.14.0
)
FetchContent_MakeAvailable(googletest)
include_directories(
${googletest_SOURCE_DIR}/googletest/include
)
+1 -1
View File
@@ -40,7 +40,7 @@ if(WIN32)
endif()
# google tests
include(DownloadGTest)
include(FetchGtest)
add_custom_target(tests-radio
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/gtests-radio