GTest

hunter_add_package(GTest)
find_package(GTest CONFIG REQUIRED)

target_link_libraries(foo GTest::gtest_main) # GTest::gtest will be linked automatically
target_link_libraries(boo GTest::gtest)

Bugs

  • Cygwin GCC build failed with c++11 flag

GMock

  • Available since Hunter v0.12.42

For package versions 1.8.0-hunter-p1 and higher the package also includes GMock. When finding the GMock package GTest is automatically included. Note that package version 1.8.0-hunter-p1 does not support the MinGW and Visual Studio 2005 toolchains, so GMock is not available in these cases.

hunter_add_package(GTest)
find_package(GTest CONFIG REQUIRED)

# GMock::gmock and GTest::gtest will be linked automatically
target_link_libraries(foo GTest::gmock_main)