I have never encountered a problem with testing my code using gtest a few months ago until recently I encountered a problem where all of a sudden the "gtest/gtest.h"
header file can no longer be found. I am using putty to hold all my files and directories and the googletest directory is located in the same filepath as the unit test I am compiling to generate the executable. The gtest GitHub was recently updated so I'm not sure if that might have caused it. I have used git submodule add <gtest URL>
and the it says that googletest already exists. I have always built my files using cmake3 .
, but now I keep getting errors regarding the TEST()
functions within the unit test file. I assume this is because the gtest directory cannot be found. I also tried using cmake .
to build but that results in a ton of untrackable errors with the gtest.h header file itself. Apparently it seems that building with cmake .
can track the gtest.h header file while building with cmake3 .
cannot. I still have no clue on how to solve this error.
Here is my CMakeLists.txt file:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
ADD_SUBDIRECTORY(googletest)
SET(CMAKE_CXX_STANDARD 11)
ADD_EXECUTABLE(test
unit_test.cpp
)
TARGET_LINK_LIBRARIES(test gtest)
TARGET_COMPILE_DEFINITIONS(test PRIVATE gtest_disable_pthreads=ON)
Aucun commentaire:
Enregistrer un commentaire