gtest not found by Catkin

asked 2018-08-22 09:53:21 -0500

PacoGG gravatar image

updated 2018-09-03 06:38:25 -0500

Hi all,

Since yesterday none of my packages containin tests build. Catkin complains it cannot find gtest when using catkin_add_gtests(), since GTEST_FOUND is FALSE. You can see this in the error msg below, with the custom output I added to my CMakeLists. Up to yesterday, GTEST_FOUND was TRUE when catkin_add_gtests() was called.

This is the error I always get. In this case I'm trying to build a mockup package on a clean catkin workspace:

Errors     << silly_pkg:cmake /home/paco/catkin_ws2/logs/silly_pkg/build.cmake.002.log                                                                                                                                                                                                                                
Not searching for unused variables given on the command line.
Re-run cmake no build system arguments
-- Using CATKIN_DEVEL_PREFIX: /home/paco/catkin_ws2/devel/.private/silly_pkg
-- Using CMAKE_PREFIX_PATH: /home/paco/catkin_ws2/devel;/opt/ros/kinetic
-- This workspace overlays: /home/paco/catkin_ws2/devel;/opt/ros/kinetic
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/paco/catkin_ws2/build/silly_pkg/test_results
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.11
CMake Warning at /opt/ros/kinetic/share/catkin/cmake/test/gtest.cmake:149 (message):
  skipping gtest 'test_silly_pkg' in project 'silly_pkg' because gtest was
  not found
Call Stack (most recent call first):
  /opt/ros/kinetic/share/catkin/cmake/test/gtest.cmake:79 (_catkin_add_executable_with_google_test)
  /opt/ros/kinetic/share/catkin/cmake/test/gtest.cmake:28 (_catkin_add_google_test)
  CMakeLists.txt:28 (catkin_add_gtest)

CMake Error at /home/paco/catkin_ws2/src/silly_pkg/CMakeLists.txt:33 (target_link_libraries):
  Cannot specify link libraries for target "test_silly_pkg" which is not
  built by this project.

-- Configuring incomplete, errors occurred!
See also "/home/paco/catkin_ws2/build/silly_pkg/CMakeFiles/CMakeOutput.log".
See also "/home/paco/catkin_ws2/build/silly_pkg/CMakeFiles/CMakeError.log".
cd /home/paco/catkin_ws2/build/silly_pkg; catkin build --get-env silly_pkg | catkin env -si  /usr/bin/cmake /home/paco/catkin_ws2/src/silly_pkg --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/paco/catkin_ws2/devel/.private/silly_pkg -DCMAKE_INSTALL_PREFIX=/home/paco/catkin_ws2/install; cd -

I am using catkin 0.7.11, libgtest-dev 1.7.0 and cmake 3.5.1. I use ROS Kinetic with Ubuntu 16.04. The only thing I did yesterday was reinstalling ROS Kinetic, but the package versions are exactly the same. Did anybody have this problem? Do you have any ideas on what could be happening?

EDIT 3/09/18:

By comparing with a functional catkin+gtest workspace, I found out that the main difference is in the results of /opt/ros/kinetic/share/catkin/cmake/test/gtest.cmake. In the functional workspace, line 292 evaluates to TRUE (gtest/gmock is not a target) while in my workspace it evaluates to FALSE. This is because in my workspace running find_package(GMock QUIET) sets gmock and gtest as imported targets. Why is this different?

Thank you very much,


edit retag flag offensive close merge delete


Can you be more specific about what you mean by "reinstalling ROS Kinetic"? It's possible that some dependencies have been removed.

Geoff gravatar image Geoff  ( 2018-08-22 22:24:49 -0500 )edit

Yes. I purged ROS by sudo apt purge ros-kinetic-* and installed it again with sudo apt install ros-kinetic-desktop-full. Which necessary dependency could be missing?

PacoGG gravatar image PacoGG  ( 2018-08-23 02:50:30 -0500 )edit

Please post the source of your mockup package that is causing the error.

Geoff gravatar image Geoff  ( 2018-08-26 18:48:23 -0500 )edit

Do you mean the tests source or the program source?

PacoGG gravatar image PacoGG  ( 2018-09-03 06:19:07 -0500 )edit