Support configuration against protobuf 3.11 on Windows #91
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First of all, it is important to mention that the problem of not finding protoc on ROSOnWindowsis an upstream bug, reported in ms-iot/ROSOnWindows#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 pathC:\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 ms-iot/ROSOnWindows#218 we add toCMAKE_PROGRAM_PATH
theC:/opt/rosdeps/x64/tools/protobuf
ifC:/opt/rosdeps/x64
is part of the theCMAKE_PREFIX_PATH
. While the use of hardcoded absolute path may seems a error-prone strategy, considering thatROSOnWindows
do not support being installed in a prefix different fromC:/opt
, it is a good way of detecting reliably if the project is being configured underROSOnWindows
.