After following the steps of installing Google Test described in my article Use Gtest in Ros Program on my mac book, I compile the test program using CMake. However, the CMake reports an error of
Could NOT find GTest (missing: GTEST_INCLUDE_DIR).
Problem: CMake find_package could not find GTest
When I seek for a solution, I was on the wrong track by reading . After struggling for a while, I figured out that the root reason is I did not install gtest properly on Mac OS.
By referring Tonatiuh’s guide , I solve the problem by copying the gtest directory in the source folder to the path /usr/local/include/.
Namely, the complete procedure to install gtest on mac os is:
(1) Download gtest gtest-1.7.0.zip and unzip
(2) Build gtest:
cd gtest-1.7.0 mkdir build cd build cmake .. make
(3) Install gtest library
sudo cp -r ../include/gtest /usr/local/include/ sudo cp lib*.a /usr/local/lib