1 set(GTEST_ROOT "/usr/src/gtest" CACHE FILEPATH "Path to GTest CMake project")
4 set(GTEST_DEPENDENCIES)
6 if(NOT GTEST_FOUND AND EXISTS ${GTEST_ROOT})
7 include(ExternalProject)
8 ExternalProject_Add(gtest PREFIX ./gtest
9 SOURCE_DIR ${GTEST_ROOT}
12 link_directories(${CMAKE_CURRENT_BINARY_DIR}/gtest/src/gtest-build)
14 set(GTEST_LIBRARIES "-lgtest")
15 set(GTEST_DEPENDENCIES "gtest")
17 find_path(GTEST_INCLUDE_DIRS NAMES gtest/gtest.h)
19 message(STATUS "Found GTest at ${GTEST_ROOT}, headers at ${GTEST_INCLUDE_DIRS}")
23 file(GLOB files gtest_runner.cc *-helpers.cc *_test.cc)
24 add_executable(libapt_test ${files})
25 target_include_directories(libapt_test PRIVATE ${GTEST_INCLUDE_DIRS})
26 target_link_libraries(libapt_test ${GTEST_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} apt-private apt-inst)
27 if (GTEST_DEPENDENCIES)
28 add_dependencies(libapt_test ${GTEST_DEPENDENCIES})
30 add_test(NAME AptTests
32 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})