Do not search for headers anymore, if sources are already found

if GTEST/GMOCK sources are already found, only check if gtest/gtest.h
and gmock/gmock.h exist at GTEST_SRC_DIR/include and
GMOCK_SRC_DIR/include and set GTEST_INCLUDE_DIR and GMOCK_INCLUDE_DIR
accordingly.
This commit is contained in:
Christian Gruber 2019-08-29 22:34:19 +02:00
parent 84d9f1c9a5
commit 53fe478ce1

View File

@ -131,11 +131,14 @@ function(gnc_gtest_configure)
endif()
unset(GTEST_SRC_DIR CACHE)
if (GTEST_ROOT)
find_path(GTEST_INCLUDE_DIR gtest/gtest.h
HINTS ${GTEST_ROOT}/include ${GMOCK_ROOT}/gtest/include)
find_path(GTEST_SRC_DIR src/gtest-all.cc
HINTS ${GTEST_ROOT} ${GMOCK_ROOT}/gtest /usr/src/gtest)
if (GTEST_SRC_DIR AND GTEST_INCLUDE_DIR)
if (GTEST_SRC_DIR)
if (EXISTS ${GTEST_SRC_DIR}/include/gtest/gtest.h)
set(GTEST_INCLUDE_DIR ${GTEST_SRC_DIR}/include CACHE PATH "" FORCE)
else()
message(FATAL_ERROR "GTEST sources found, but it doesn't have 'gtest/gtest.h'")
endif()
set(lib_gtest_SOURCES
"${GTEST_SRC_DIR}/src/gtest_main.cc"
"${GTEST_SRC_DIR}/src/gtest-all.cc"
@ -158,8 +161,6 @@ function(gnc_gtest_configure)
message(STATUS "Checking for GMOCK")
unset(GMOCK_SRC_DIR CACHE)
if (GMOCK_ROOT)
find_path(GMOCK_INCLUDE_DIR gmock/gmock.h
HINTS ${GMOCK_ROOT}/include)
find_path(GMOCK_SRC_DIR src/gmock-all.cc
HINTS ${GMOCK_ROOT} /usr/src/gmock)
if (GMOCK_SRC_DIR)
@ -171,7 +172,12 @@ function(gnc_gtest_configure)
set(GMOCK_MAIN_SRC_DIR "${GMOCK_SRC_DIR}")
endif()
endif()
if (GMOCK_SRC_DIR AND GMOCK_INCLUDE_DIR)
if (GMOCK_SRC_DIR)
if (EXISTS ${GMOCK_SRC_DIR}/include/gmock/gmock.h)
set(GMOCK_INCLUDE_DIR ${GMOCK_SRC_DIR}/include CACHE PATH "" FORCE)
else()
message(FATAL_ERROR "GMOCK sources found, but it doesn't have 'gmock/gmock.h'")
endif()
set(GMOCK_SRC "${GMOCK_MAIN_SRC_DIR}/gmock-all.cc" PARENT_SCOPE)
set(GMOCK_LIB "${CMAKE_BINARY_DIR}/common/test-core/libgmock.a" PARENT_SCOPE)
else()