Introduce googletest library
The library will be either found in the system or downloaded via FetchContent.
This commit is contained in:
@@ -2507,6 +2507,21 @@ if(ENABLE_TESTS)
|
|||||||
# meta-target: each test is supposed to add_dependencies(tests ${NEWTEST})
|
# meta-target: each test is supposed to add_dependencies(tests ${NEWTEST})
|
||||||
# then, it is possible to build and execute all tests using "ninja tests && ctest"
|
# then, it is possible to build and execute all tests using "ninja tests && ctest"
|
||||||
add_custom_target(tests)
|
add_custom_target(tests)
|
||||||
|
find_package(GTest)
|
||||||
|
if (NOT GTest_FOUND)
|
||||||
|
message(STATUS "GTest package not found, will download googletest automatically. To prevent that install google test on your system (libgtest-dev)")
|
||||||
|
include(FetchContent)
|
||||||
|
FetchContent_Declare(
|
||||||
|
googletest
|
||||||
|
GIT_REPOSITORY https://github.com/google/googletest.git
|
||||||
|
GIT_TAG 58d77fa8070e8cec2dc1ed015d66b454c8d78850 # 1.12.1
|
||||||
|
)
|
||||||
|
set(BUILD_GMOCK OFF)
|
||||||
|
set(INSTALL_GTEST OFF)
|
||||||
|
FetchContent_MakeAvailable(googletest)
|
||||||
|
add_library(GTest::gtest ALIAS gtest)
|
||||||
|
add_library(GTest::gtest_main ALIAS gtest_main)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(common)
|
add_subdirectory(common)
|
||||||
|
|||||||
+3
-2
@@ -8,8 +8,9 @@ explaining how to test with cmake and ctest; it is a suggested read, and the
|
|||||||
following just lists the main points of how to compile the tests and how to add
|
following just lists the main points of how to compile the tests and how to add
|
||||||
new ones.
|
new ones.
|
||||||
|
|
||||||
At the time of writing, only the NR RLC tests have been integrated. The author
|
GoogleTest is a C++ unit testing framework that has been added as an external dependency. While using GoogleTest is not a requirement it can simplify writing unit tests.
|
||||||
hopes that more tests follow suit.
|
See [primer](http://google.github.io/googletest/primer.html) for a quick introduction. To add it to your test executable link against
|
||||||
|
`GTest::gtest` or `GTest::gtest_main`.
|
||||||
|
|
||||||
# How to compile tests
|
# How to compile tests
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user