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