I am trying to test my project, but stuck at including <gtest/gtest.h>. I coppied through git clone googletest and tried to include it, but it throw fatal error:
fatal error: gtest/gtest.h: No such file or directory .
I am using Visual studio code if it metters/
My project structure:
lab-1
|
- googletest
|
- src
| |
| - lab-1.cpp
| |
| - parser.cpp
| |
| - parser.hpp
|
- test
| |
| - CMakeLists.txt
| |
| - tests.cpp
|
- CMakeLists.txt
your textProject CMakeLists.txt:
cmake_minimum_required(VERSION 3.27)
set(This lab-1)
project(${This})
set(CMAKE_CXX_STANDARD 14)
include_directories(src)
add_executable(${This}
src/lab-1.cpp
src/parser.hpp
src/parser.cpp
)
add_subdirectory(test)
Tests CMakeLists.txt:
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)
FetchContent_MakeAvailable(googletest)
enable_testing()
add_executable(runTests
tests.cpp
../src/parser.hpp
../src/parser.cpp)
include(GoogleTest)
target_link_libraries(runTests gtest_main gmock)
gtest_discover_tests(runTests)
Send help pls
Including full path to gtest.h Playing with CMakeLists Recloning googletest repository