You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
1.4 KiB

  1. find_path(GTEST_ROOT src/gtest.cc
  2. /usr/src/googletest/googletest
  3. /usr/src/gtest
  4. )
  5. find_package(GTest)
  6. set(GTEST_DEPENDENCIES)
  7. if(NOT GTEST_FOUND AND EXISTS ${GTEST_ROOT})
  8. include(ExternalProject)
  9. ExternalProject_Add(gtest PREFIX ./gtest
  10. SOURCE_DIR ${GTEST_ROOT}
  11. INSTALL_COMMAND true)
  12. link_directories(${CMAKE_CURRENT_BINARY_DIR}/gtest/src/gtest-build)
  13. set(GTEST_LIBRARIES "-lgtest")
  14. set(GTEST_DEPENDENCIES "gtest")
  15. set(GTEST_FOUND TRUE)
  16. find_path(GTEST_INCLUDE_DIRS NAMES gtest/gtest.h)
  17. message(STATUS "Found GTest at ${GTEST_ROOT}, headers at ${GTEST_INCLUDE_DIRS}")
  18. endif()
  19. if(GTEST_FOUND)
  20. # Definition of the C++ files used to build the test binary - note that this
  21. # is expanded at CMake time, so you have to rerun cmake if you add or remove
  22. # a file (you can just run cmake . in the build directory)
  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()