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 [1]. 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 [2], 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 and unzip

(2) Build gtest:

cd gtest-1.7.0

mkdir build

cd build

cmake ..


(3) Install gtest library

sudo cp -r ../include/gtest /usr/local/include/

sudo cp lib*.a /usr/local/lib


  1. cmake find_package not working on Mac OS X

  2. InstallingGoolgeTestForMac

Yang Song

Ph.D. Student in Robotics