GobySoft / goby3

The Goby Underwater Autonomy Project Version 3
Other
22 stars 11 forks source link

Unify Protobuf CMake modules across projects #58

Closed rgov closed 4 years ago

rgov commented 5 years ago

cgsn-mooring's FindProtobufLocal.cmake varies slightly from Goby3's FindProtobufGoby.cmake, though they both define the same functions.

One consequence of this is that if you add Goby3 sources to a build with add_subdirectory(), the re-defined functions will replace the parent project's definitions.

CMake has an official built-in FindProtobuf module as well that has been significantly overhauled. It supports the PROTOC_OUT_DIR option now which might do some of what you want.

rgov commented 5 years ago

I confirmed that the generate_protobuf_cpp function is the only one that is redefined when including Goby3 as a subproject. (See this CMake issue on redefinitions of macros and functions.)

Renaming the function to goby_generate_protobuf_cpp worked around the issue for me.

tsaubergine commented 5 years ago

I don't think I can do --dccl_out and --cpp_out in the same command with the official CMake FindProtobuf module. I will leave this open for renaming the function to goby_generate_protobuf_cpp, though.

mathstuf commented 5 years ago

Protobuf upstream also has their own protobuf-config shipping with CMake functions in it. It has a unified API rather than a per-language call though.

https://github.com/protocolbuffers/protobuf/blob/1509e8e3b3d10a2a903f60d6281e30e51b8ecba5/cmake/protobuf-config.cmake.in#L10

mathstuf commented 5 years ago

I think it started showing up in 3.4 if that matters.

tsaubergine commented 5 years ago

Cool, thanks. May be helpful for the future. For now I need to support protobuf as old as 2.6.1 and CMake as old as 3.5.1