# - Try to find GTEST # # The following variables are optionally searched for defaults # GTEST_ROOT_DIR: Base directory where all GTEST components are found # # The following are set after configuration is done: # GTEST_FOUND # GTEST_INCLUDE_DIRS # GTEST_LIBRARIES # GTEST_LIBRARYRARY_DIRS
include(FindPackageHandleStandardArgs)
set(GTEST_ROOT_DIR "" CACHE PATH "Folder contains Google gtest")
# Link runTests with what we want to test and the GTest and pthread library add_executable(runTests tests.cpp) target_link_libraries(runTests ${GTEST_LIBRARIES}${BOOST_THREAD_LIBRARY}) #target_link_libraries(runTests gtest pthread)
compile
1 2
mkdir build && cd build && cmake-gui .. make -j8
run
1
./runTests
link (optional)
use -lgtest as linker flag and optionally, if you did not write your own test mainroutine, the explicit -lgtest_main flag.