]>
Commit | Line | Data |
---|---|---|
1 | set(GTEST_ROOT "/usr/src/gtest" CACHE FILEPATH "Path to GTest CMake project") | |
2 | ||
3 | find_package(GTest) | |
4 | set(GTEST_DEPENDENCIES) | |
5 | ||
6 | if(NOT GTEST_FOUND AND EXISTS ${GTEST_ROOT}) | |
7 | include(ExternalProject) | |
8 | ExternalProject_Add(gtest PREFIX ./gtest | |
9 | SOURCE_DIR ${GTEST_ROOT} | |
10 | INSTALL_COMMAND true) | |
11 | ||
12 | link_directories(${CMAKE_CURRENT_BINARY_DIR}/gtest/src/gtest-build) | |
13 | ||
14 | set(GTEST_LIBRARIES "-lgtest") | |
15 | set(GTEST_DEPENDENCIES "gtest") | |
16 | set(GTEST_FOUND TRUE) | |
17 | find_path(GTEST_INCLUDE_DIRS NAMES gtest/gtest.h) | |
18 | ||
19 | message(STATUS "Found GTest at ${GTEST_ROOT}, headers at ${GTEST_INCLUDE_DIRS}") | |
20 | endif() | |
21 | ||
22 | if(GTEST_FOUND) | |
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}) | |
29 | endif() | |
30 | add_test(NAME AptTests | |
31 | COMMAND libapt_test | |
32 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) | |
33 | endif() |