I want to find GTest
via:
find_package(GTest REQUIRED)
But it is not found:
Error:Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
I know from this link that GTest
should be distributed via standard CMake.
Can you tell me what I did wrong?
find_package
does not look in CMake's installation directory. It only evaluates thePATH
andCMAKE_PREFIX_VARIABLES
. Just add the path to CMake's GTest to the latter variable, clear your CMake cache and re-run CMake.If you have gtest installed you can just do:
If you're on Ubuntu, you should read
/usr/share/doc/libgtest-dev/README.Debian
. It says:So you should compile and install your own version of the
gtest
library with the exactly same Compiler Options, and set theGTEST_LIBRARY
orGTEST_ROOT
variable accordingly.For example, I did the following:
Then I added the following lines in my
CMakeLists.txt
: