diff options
author | Julian Andres Klode <jak@debian.org> | 2016-08-07 18:22:14 +0200 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2016-08-10 16:11:43 +0200 |
commit | 06c2b40b9b9094f4f6391bd1d17cfc3725313070 (patch) | |
tree | 08f853ea0f6cf803c9ef91dbb90de55814833ac1 /test/libapt/CMakeLists.txt | |
parent | 173fa882cf3396ab6d2a9be53c6ea23eda225a1d (diff) |
CMake: Add unit tests
Add support for our GTest based unit tests. By default, CMake will
look in /usr/src/gtest for the external GTest project, but this can
be overriden by defining GTEST_ROOT when invoking cmake.
Gbp-Dch: ignore
Diffstat (limited to 'test/libapt/CMakeLists.txt')
-rw-r--r-- | test/libapt/CMakeLists.txt | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/libapt/CMakeLists.txt b/test/libapt/CMakeLists.txt new file mode 100644 index 000000000..7f9990526 --- /dev/null +++ b/test/libapt/CMakeLists.txt @@ -0,0 +1,22 @@ +include(ExternalProject) + +set(GTEST_ROOT "/usr/src/gtest" CACHE FILEPATH "Path to GTest CMake project") + +message(STATUS "Found GTest at ${GTEST_ROOT}") + +if (EXISTS ${GTEST_ROOT}) + +ExternalProject_Add(gtest PREFIX ./gtest + SOURCE_DIR ${GTEST_ROOT} + INSTALL_COMMAND true) + +link_directories(${CMAKE_CURRENT_BINARY_DIR}/gtest/src/gtest-build) +FILE(GLOB files gtest_runner.cc *-helpers.cc *_test.cc) +add_executable(libapt_test ${files}) +target_link_libraries(libapt_test -lgtest ${CMAKE_THREAD_LIBS_INIT} apt-private apt-inst) +add_dependencies(libapt_test gtest) +add_test(NAME AptTests + COMMAND libapt_test + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + +endif() |