catkin
catkin copied to clipboard
GoogleTest target collisions when built as subproject
When a project using catkin is included as a subproject to a non catkin project, collisions for GoogleTest targets (GMock and GTest) can occur. catkin does not test if these targets already exist before trying to import them leading to traces similar to this:
CMake Error at /usr/share/cmake-3.16/Modules/ExternalProject.cmake:3182 (add_custom_target):
add_custom_target cannot create target "GMock" because another target with
the same name already exists. The existing target is a custom target
created in source directory "/mnt/p/Dev/CLionProjects/uasgroundrisk". See
documentation for policy CMP0002 for more details.
This can be fixed by checking for existing targets before importing them.