Locate the Google C++ Testing Framework.
This module defines the following IMPORTED
targets:
GTest::GTest
gtest
library, if found; adds Thread::Thread automaticallyGTest::Main
gtest_main
library, if foundThis module will set the following variables in your project:
GTEST_FOUND
GTEST_INCLUDE_DIRS
The library variables below are set as normal variables. These contain debug/optimized keywords when a debugging library is found.
GTEST_LIBRARIES
gtest
library; note it also requires linking with an appropriate thread libraryGTEST_MAIN_LIBRARIES
gtest_main
libraryGTEST_BOTH_LIBRARIES
gtest
and gtest_main
The following cache variables may also be set:
GTEST_ROOT
GTEST_MSVC_SEARCH
MD
or MT
(the default) to enable searching a GTest build treeenable_testing() find_package(GTest REQUIRED) add_executable(foo foo.cc) target_link_libraries(foo GTest::GTest GTest::Main) add_test(AllTestsInFoo foo)
If you would like each Google test to show up in CTest as a test you may use the following macro:
GTEST_ADD_TESTS(executable extra_args files...)
executable
extra_args
""
for none)files...
AUTO
to find them from executable targetHowever, note that this macro will slow down your tests by running an executable for each test and test fixture. You will also have to re-run CMake after adding or removing tests or test fixtures.
Example usage:
set(FooTestArgs --foo 1 --bar 2) add_executable(FooTest FooUnitTest.cc) GTEST_ADD_TESTS(FooTest "${FooTestArgs}" AUTO)
© 2000–2016 Kitware, Inc.
© 2000–2011 Insight Software Consortium
Licensed under the BSD 3-clause License.
https://cmake.org/cmake/help/v3.5/module/FindGTest.html