有人可以帮我用google mock编译google测试框架吗?目前,我有这个cmake文件:
cmake_minimum_required(VERSION 3.2)
if (CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories(BEFORE SYSTEM
"${gtest_SOURCE_DIR}/include" "${gmock_SOURCE_DIR}/include")
else()
target_include_directories(gmock_main SYSTEM BEFORE INTERFACE
"${gtest_SOURCE_DIR}/include" "${gmock_SOURCE_DIR}/include")
endif()
set(CMAKE_CXX_STANDARD 11)
# Locate GTest
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
# Link runTests with what we want to test and the GTest and pthread library
add_executable(runTests tests.cpp)
target_link_libraries(runTests gmock_main)
target_link_libraries(runTests ${GTEST_LIBRARIES} pthread)
目前我收到此错误:无法为目标" gmock_main"指定包含目录这不是由这个项目建造的。
我知道这是因为上面第7行,但是如果我删除整个if-else语句我得到这个错误:致命错误:gmock / gmock.h:没有这样的文件或目录 编译终止。
如果有人能帮助我,我真的很感激。