Remove support for GoogleTest/GoogleMock <= v1.8.0

This simplifies function gnc_gtest_configure(), since GoogleTest and
GoogleMock are combined in one source directory.

Additionally variable GMOCK_ROOT is not necessary anymore and is
removed.
This commit is contained in:
Christian Gruber 2019-09-04 22:06:32 +02:00
parent 3c93f18115
commit 97a81980e5
3 changed files with 12 additions and 33 deletions

View File

@ -880,7 +880,6 @@ add_custom_target(distcheck DEPENDS dist
-D CMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-D CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-D GTEST_ROOT=${GTEST_ROOT}
-D GMOCK_ROOT=${GMOCK_ROOT}
-P ${CMAKE_SOURCE_DIR}/common/cmake_modules/MakeDistCheck.cmake
)

View File

@ -126,16 +126,10 @@ function(gnc_gtest_configure)
if (NOT DEFINED ${GTEST_ROOT})
set(GTEST_ROOT $ENV{GTEST_ROOT})
endif()
if (NOT DEFINED ${GMOCK_ROOT})
set(GMOCK_ROOT $ENV{GMOCK_ROOT})
endif()
unset(GTEST_SRC_DIR CACHE)
if (GTEST_ROOT)
find_path(GTEST_SRC_DIR src/gtest-all.cc NO_CMAKE_SYSTEM_PATH
PATHS ${GTEST_ROOT} PATH_SUFFIXES googletest)
elseif (GMOCK_ROOT)
find_path(GTEST_SRC_DIR src/gtest-all.cc NO_CMAKE_SYSTEM_PATH
PATHS ${GMOCK_ROOT}/../googletest ${GMOCK_ROOT}/gtest)
PATHS ${GTEST_ROOT}/googletest)
endif()
if (GTEST_SRC_DIR)
if (EXISTS ${GTEST_SRC_DIR}/include/gtest/gtest.h)
@ -144,11 +138,11 @@ function(gnc_gtest_configure)
message(FATAL_ERROR "GTEST sources found, but it doesn't have 'gtest/gtest.h'")
endif()
else()
if (GTEST_ROOT OR GMOCK_ROOT)
message(FATAL_ERROR "GTEST sources not found in GTEST_ROOT or GMOCK_ROOT")
if (GTEST_ROOT)
message(FATAL_ERROR "GTEST sources not found in GTEST_ROOT")
endif()
find_path(GTEST_SRC_DIR src/gtest-all.cc
PATHS /usr/src PATH_SUFFIXES googletest/googletest gtest)
PATHS /usr/src/googletest/googletest)
if (GTEST_SRC_DIR)
find_path(GTEST_INCLUDE_DIR gtest/gtest.h NO_CMAKE_SYSTEM_PATH
PATHS ${GTEST_SRC_DIR}/include)
@ -164,7 +158,7 @@ function(gnc_gtest_configure)
find_library(GTEST_SHARED_LIB gtest)
find_library(GTEST_MAIN_LIB gtest_main)
if (NOT (GTEST_SHARED_LIB AND GTEST_MAIN_LIB AND GTEST_INCLUDE_DIR))
message(FATAL_ERROR "GTEST not found. Please install it or set GTEST_ROOT or GMOCK_ROOT")
message(FATAL_ERROR "GTEST not found. Please install it or set GTEST_ROOT")
endif()
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON)
@ -173,12 +167,9 @@ function(gnc_gtest_configure)
message(STATUS "Checking for GMOCK")
unset(GMOCK_SRC_DIR CACHE)
if (GMOCK_ROOT)
if (GTEST_ROOT)
find_path(GMOCK_SRC_DIR src/gmock-all.cc NO_CMAKE_SYSTEM_PATH
PATHS ${GMOCK_ROOT})
elseif (GTEST_ROOT)
find_path(GMOCK_SRC_DIR src/gmock-all.cc NO_CMAKE_SYSTEM_PATH
PATHS ${GTEST_ROOT}/googlemock ${GTEST_ROOT}/../googlemock)
PATHS ${GTEST_ROOT}/googlemock)
endif()
if (GMOCK_SRC_DIR)
if (EXISTS ${GMOCK_SRC_DIR}/include/gmock/gmock.h)
@ -187,18 +178,11 @@ function(gnc_gtest_configure)
message(FATAL_ERROR "GMOCK sources found, but it doesn't have 'gmock/gmock.h'")
endif()
else()
if (GMOCK_ROOT OR GTEST_ROOT)
message(FATAL_ERROR "GMOCK sources not found in GMOCK_ROOT or GTEST_ROOT")
if (GTEST_ROOT)
message(FATAL_ERROR "GMOCK sources not found in GTEST_ROOT")
endif()
find_path(GMOCK_SRC_DIR src/gmock-all.cc
PATHS /usr/src PATH_SUFFIXES googletest/googlemock gmock)
if (NOT GMOCK_SRC_DIR)
find_path(GMOCK_SRC_DIR gmock-all.cc
PATHS /usr/src PATH_SUFFIXES gmock)
if (GMOCK_SRC_DIR)
set(GMOCK_MAIN_SRC_DIR "${GMOCK_SRC_DIR}")
endif()
endif()
PATHS /usr/src/googletest/googlemock)
if (GMOCK_SRC_DIR)
find_path(GMOCK_INCLUDE_DIR gmock/gmock.h NO_CMAKE_SYSTEM_PATH
PATHS ${GMOCK_SRC_DIR}/include)
@ -206,10 +190,7 @@ function(gnc_gtest_configure)
endif()
find_path(GMOCK_INCLUDE_DIR gmock/gmock.h)
if (GMOCK_SRC_DIR)
if (NOT GMOCK_MAIN_SRC_DIR)
set(GMOCK_MAIN_SRC_DIR "${GMOCK_SRC_DIR}/src")
endif()
set(GMOCK_SRC "${GMOCK_MAIN_SRC_DIR}/gmock-all.cc" PARENT_SCOPE)
set(GMOCK_SRC "${GMOCK_SRC_DIR}/src/gmock-all.cc" PARENT_SCOPE)
set(GMOCK_LIB "${CMAKE_BINARY_DIR}/common/test-core/libgmock.a" PARENT_SCOPE)
else()
find_library(GMOCK_SHARED_LIB gmock)
@ -217,7 +198,7 @@ function(gnc_gtest_configure)
if (GMOCK_MAIN_LIB AND GMOCK_SHARED_LIB AND GMOCK_INCLUDE_DIR)
set(GMOCK_LIB "${GMOCK_SHARED_LIB};${GMOCK_MAIN_LIB}" PARENT_SCOPE)
else()
message(FATAL_ERROR "GMOCK not found. Please install it or set GMOCK_ROOT")
message(FATAL_ERROR "GMOCK not found. Please install it or set GTEST_ROOT")
endif()
endif()
set(GMOCK_FOUND YES PARENT_SCOPE)

View File

@ -46,7 +46,6 @@ function(run_dist_check PACKAGE_PREFIX EXT)
-D CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
-D CMAKE_INSTALL_PREFIX=../${INSTALL_DIR}
-D GTEST_ROOT=${GTEST_ROOT}
-D GMOCK_ROOT=${GMOCK_ROOT}
../${PACKAGE_PREFIX}
WORKING_DIRECTORY ${BUILD_DIR}
ERROR_MSG "CMake configure command failed."