ros-controls / ros_control

Generic and simple controls framework for ROS
http://wiki.ros.org/ros_control
BSD 3-Clause "New" or "Revised" License
478 stars 306 forks source link

Handle building without GMock #485

Closed cottsay closed 3 years ago

cottsay commented 3 years ago

These macros will not fail if GMock is not available at build time, and will not produce a target under these circumstances. However, the subsequent CMake lines are assuming that the target will exist, and cause CMake to fail if not.

This change makes the packages tolerant to the absence of GMock at build time.

Example failure:

CMake Warning at /ros1/install/share/catkin/cmake/test/gtest.cmake:160 (message):
  skipping gmock 'controller_base_test' in project 'controller_interface'
  because gmock was not found
Call Stack (most recent call first):
  /ros1/install/share/catkin/cmake/test/gtest.cmake:89 (_catkin_add_executable_with_google_test)
  /ros1/install/share/catkin/cmake/test/gtest.cmake:63 (_catkin_add_google_test)
  CMakeLists.txt:33 (catkin_add_gmock)

CMake Error at CMakeLists.txt:34 (target_link_libraries):
  Cannot specify link libraries for target "controller_base_test" which is
  not built by this project.
bmagyar commented 3 years ago

I've seen this technique before but I wonder why it's preferred. You are essentially auto-disabling tests if they can't be compiled. Gmock and gtest have multiple ways to be looked up on any system, last time I checked there were 4 different methods in catkin to do this. So I'd say the title is a little misleading and would ask why you want to do this...