1 find_path(GTEST_ROOT src/gtest.cc
2 /usr/src/googletest/googletest
6 set(GTEST_DEPENDENCIES)
8 if(NOT GTEST_FOUND AND EXISTS ${GTEST_ROOT})
9 include(ExternalProject)
10 ExternalProject_Add(gtest PREFIX ./gtest
11 SOURCE_DIR ${GTEST_ROOT}
14 link_directories(${CMAKE_CURRENT_BINARY_DIR}/gtest/src/gtest-build)
16 set(GTEST_LIBRARIES "-lgtest")
17 set(GTEST_DEPENDENCIES "gtest")
19 find_path(GTEST_INCLUDE_DIRS NAMES gtest/gtest.h)
21 message(STATUS "Found GTest at ${GTEST_ROOT}, headers at ${GTEST_INCLUDE_DIRS}")
25 file(GLOB files gtest_runner.cc *-helpers.cc *_test.cc)
26 add_executable(libapt_test ${files})
27 target_include_directories(libapt_test PRIVATE ${GTEST_INCLUDE_DIRS})
28 target_link_libraries(libapt_test ${GTEST_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} apt-private apt-inst)
29 if (GTEST_DEPENDENCIES)
30 add_dependencies(libapt_test ${GTEST_DEPENDENCIES})
32 add_test(NAME AptTests
34 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})