cmake_modules
cmake_modules copied to clipboard
FindUUID module causes linking errors
In ROS Melodic the FindUUID module causes addition of an obviously invalid -lUUID::UUID flag to linker options when cmake_modules is added as a <build_depend> (even if libuuid itself is not used at all in the code).
Compilation/linking error looks like this:
/usr/bin/ld: cannot find -lUUID::UUID
In our case simple removal of the file (/opt/ros/melodic/share/cmake_modules/cmake/Modules/FindUUID.cmake) solved the problem, but I'm not sure if it's a solution or a workaround.
Can you provide a minimal reproducible case for this? There are definitely packages in Melodic that use cmake_modules and do not have this issue that build on the buildfarm. I think it's likely to do with something on your particular system.
It looks like it's trying to use the cmake style exported targets and not handling it correctly, based on the UUID::UUID.
I stopped poking around the code that suffered from this issue, but I've recently found this, seemingly related, issue: https://bitbucket.org/ignitionrobotics/ign-cmake/issues/40/cmake-cannot-parse-ignition-math4-ignition
Looks like a classic case of global namespace pollution. Perhaps it's possible to find a "better" ordering of:
find_package(catkin)
find_package(gazebo)
catkin_package()
target_link_libraries()
in CMakeLists.txt, one that would prevent the variable overloading.