. Файлы. Я, как я мог бы выяснить, следует искать в каталоге сборки - но я не могу подтвердить это.
Код: Выделить всё
+ project_root
+ CMakeLists.txt
+ library
+ CMakeLists.txt
+ util.cpp
+ tests
+ CMakeLists.txt
+ main.cpp
+ test_component.cpp
+ application
+ CMakeLists.txt
+ main.cpp
< /code>
выше - показанная структура проекта. И ниже приведен cmakelists.txt для тестов. < /P>
cmake_minimum_required(VERSION 3.22)
project(my-tests)
include_directories(${CMAKE_SOURCE_DIR}/library/include)
add_executable(
test_app
main.cpp
test_component.cpp
)
target_link_libraries(
test_app
# Link with Google Test
gtest
gtest_main
pthread
)
target_compile_options(
test_app
PRIVATE
--coverage
)
target_link_options(
test_app
PRIVATE
--coverage
)
include(GoogleTest)
gtest_discover_tests(test_app)
< /code>
и последнее, но не в последнюю очередь вывод, который указывает, что информация о покрытии не была найдена. < /p>
No coverage info files for CMake project /home/myuser/Projects/organization/demo-project. No coverage data will be analyzed for this project.
Подробнее здесь: https://stackoverflow.com/questions/796 ... cc-project