tests: cmake: fix building with system gtest

Issues #980 #983
This commit is contained in:
redfish 2016-08-29 13:56:34 -04:00
parent 4a9e94944c
commit 640a934d5f
6 changed files with 10 additions and 9 deletions

View file

@ -79,7 +79,6 @@ Packaging for your favorite distribution would be a welcome contribution!
* pkg-config
* libunbound `>=1.4.16` (note: Unbound is not a dependency, libunbound is)
* libevent `>=2.0`
* libgtest `>=1.5`
* Boost `>=1.58`
* BerkeleyDB `>=4.8` (note: on Ubuntu this means installing libdb-dev and libdb++-dev)
* libunwind (optional, for stack trace on exception)
@ -87,6 +86,7 @@ Packaging for your favorite distribution would be a welcome contribution!
* ldns `>=1.6.17` (optional, for statically-linked binaries)
* expat `>=1.1` (optional, for statically-linked binaries)
* bison or yacc (optional, for statically-linked binaries)
* GTest `>=1.5` (optional, for running test suite) (NOTE: `libgtest-dev` package in Ubuntu ships without binaries and requires a manual build; `gtest` on Arch includes binaries)
* Doxygen (optional, for generating documentation)
* graphviz (optional, for generating documentation)

View file

@ -42,21 +42,22 @@ find_package(GTest)
if (GTest_FOUND)
include_directories(SYSTEM ${GTEST_INCLUDE_DIRS})
else ()
message(STATUS "GTest not found on the system: will use GTest bundled with this source")
add_subdirectory(gtest)
include_directories(SYSTEM "${gtest_SOURCE_DIR}/include" "${gtest_SOURCE_DIR}")
# Emulate the FindGTest module's variable.
set(GTEST_MAIN_LIBRARIES gtest_main)
set(GTEST_LIBRARIES gtest)
# Ignore some warnings when building gtest binaries.
if(NOT MSVC)
set_property(TARGET gtest gtest_main
set_property(TARGET gtest
APPEND_STRING
PROPERTY
COMPILE_FLAGS " -Wno-undef -Wno-sign-compare")
endif()
set_property(TARGET gtest gtest_main
set_property(TARGET gtest
PROPERTY
FOLDER "${folder}")
endif ()

View file

@ -42,7 +42,7 @@ target_link_libraries(transfers
crypto
common
epee
${GTEST_MAIN_LIBRARIES}
${GTEST_LIBRARIES}
${Boost_LIBRARIES})
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_transfers")

View file

@ -40,7 +40,7 @@ add_executable(libwallet_api_tests
target_link_libraries(libwallet_api_tests
LINK_PRIVATE
wallet
${GTEST_MAIN_LIBRARIES}
${GTEST_LIBRARIES}
${EXTRA_LIBRARIES})
set_property(TARGET libwallet_api_tests

View file

@ -40,7 +40,7 @@ target_link_libraries(net_load_tests_clt
otshell_utils
p2p
cryptonote_core
${GTEST_MAIN_LIBRARIES}
${GTEST_LIBRARIES}
${Boost_CHRONO_LIBRARY}
${Boost_DATE_TIME_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
@ -62,7 +62,7 @@ target_link_libraries(net_load_tests_srv
otshell_utils
p2p
cryptonote_core
${GTEST_MAIN_LIBRARIES}
${GTEST_LIBRARIES}
${Boost_CHRONO_LIBRARY}
${Boost_DATE_TIME_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}

View file

@ -69,7 +69,7 @@ target_link_libraries(unit_tests
rpc
wallet
p2p
${GTEST_MAIN_LIBRARIES}
${GTEST_LIBRARIES}
${Boost_CHRONO_LIBRARY}
${Boost_REGEX_LIBRARY}
${Boost_SYSTEM_LIBRARY}