This is not necessary. The default languages are C and CXX - see the CMake documentation: https://cmake.org/cmake/help/latest/command/project.html

Also catkin already exports the gtest dependency (https://github.com/ros/catkin/blob/afb0e2a2ae8c0c34c17a2df7b8e1219792246bf1/package.xml#L34-L35). So since your package build depends on catkin that already ensures that gtest is available.

Also based on the build output gtest is certainly installed:

-- Found gtest sources under '/usr/src/googletest': gtests will be built

My best guess is that the add_subdirectory() call including a separate CMake project which finds catkin itselfmight be the culprit. I would suggest to make sure thatfind_package(catkin REQUIRED)` is called before that in the main CMake file.

1 Like