本来以为像之前链接boost一样,加个链接路径就好了,没想到报找不到gtest的符号,搞了半天,没弄明白啥原因。
网上也没搜到好方法,只能把gtest的源码加到项目里,然后在链接了。
CMake配置如下:
set(googleTestDir "C:/Users/z00199662/CLionProjects/MyCppProject/googletest-master")
#Add the google test subdirectory
add_subdirectory(${googleTestDir})
#include googletest/include dir
include_directories(${googleTestDir}/googletest/include)
#include the googlemock/include dir
include_directories(${googleTestDir}/googlemock/include)
# Link with GoogleTest
target_link_libraries(MyCppProject gtest gtest_main)
#Link with GoogleMock
target_link_libraries(MyCppProject gmock gmock_main)