In the quickstart of google test (https://google.github.io/googletest/quickstart-cmake.html) I found the following code to download the google test dependencies from Github:
cmake_minimum_required(VERSION 3.14)
project(my_project)
# GoogleTest requires at least C++14
set(CMAKE_CXX_STANDARD 14)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
)
FetchContent_MakeAvailable(googletest)
enable_testing()
add_executable(
hello_test
hello_test.cc
)
target_link_libraries(
hello_test
gtest_main
)
include(GoogleTest)
gtest_discover_tests(hello_test)
This works for google test, and in the test file hello_test.cc I can include #include "gtest/gtest.h"
successfully.
However, I would like to include also Gmock: #include "gmock/gmock.h"
but it cannot find it.
How can I include gmock downloading the dependencies like gtest?
#include "gtest.gtest.h"
? This filename is not typical for the Google Test header. The#include "gtest/gtest.h"
and#include "gmock/gmock.h"
are the usual ones. – Coze