ros-industrial / abb_libegm

A C++ library for interfacing with ABB robot controllers supporting Externally Guided Motion (689-1)
BSD 3-Clause "New" or "Revised" License
93 stars 53 forks source link

Support configuration against protobuf 3.11 on Windows #91

Closed traversaro closed 4 years ago

traversaro commented 4 years ago

First of all, it is important to mention that the problem of not finding protoc on ROSOnWindowsis an upstream bug, reported in https://github.com/ms-iot/ROSOnWindows/issues/218 .

Until now, the use of the HINTS parameter in find_package make the CMake use the installed protobuf-config.cmake instead of the CMake's provided FindProtobuf.cmake that was used on non-WIN32. Note that the actual value of the parameter passed to HINTS does not matter, actually on my ROSOnWindows setup ${_CMAKE_INSTALL_DIR}/tools/protobuf was actually the non-existing path C:\opt\python27amd64\Scripts\tools\protobuf.

Unfortunately, the variables and macros exported by the protobuf 3.11's protobuf-config.cmake are not compatible with the one used in the project, so the configuration was not working correctly when using a modern protobuf such as the one installed by vcpkg.

To have a CMake that is able to configure with protobuf and CMake installed in Ubuntu 16.04, againtt the protobuf installed by ROSOnWindows and also the latest protobuf installed by vcpkg, we use also on Windows the default signature of find_package, and as a workaround for https://github.com/ms-iot/ROSOnWindows/issues/218 we add to CMAKE_PROGRAM_PATH the C:/opt/rosdeps/x64/tools/protobuf if C:/opt/rosdeps/x64 is part of the the CMAKE_PREFIX_PATH . While the use of hardcoded absolute path may seems a error-prone strategy, considering that ROSOnWindows do not support being installed in a prefix different from C:/opt, it is a good way of detecting reliably if the project is being configured under ROSOnWindows .

gavanderhoorn commented 4 years ago

Thanks @traversaro :+1:

gavanderhoorn commented 4 years ago

While the use of hardcoded absolute path may seems a error-prone strategy, considering that ROSOnWindows do not support being installed in a prefix different from C:/opt, it is a good way of detecting reliably if the project is being configured under ROSOnWindows .

Yes, I agree.

It's a work-around, but let's see what upstream does.