question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[package] protobuf/any: access to protobuf_generate_cpp function

See original GitHub issue

Current good practice is to use cmake_find_package generator. on an other hand, i want conan to be as discreet as possible in my CMakelists.txt. So this generator can be very helpful when no standard "Find<Package_name>.cmake exists.

For the protobuf library case, this generator hide a very important feature : the protobuf_generate_cpp function. And as a user cmake_find_package seem broken!

As a conan developer, i understand the fact that cmake guys should separate “target detection” and function utilities. but cmake is a giant… conan is not…yet.

furthermore, protobuf test_package is so sad … download a binary (not built by conan!!!) and reinvent the wheel to generate cpp file.

Do u have a plan for this kind or issue?

Thx.

Package and Environment Details (include every applicable attribute)

  • Package Name/Version: protobuf/any
  • Operating System+version: any
  • Compiler+version: GCC 8
  • Docker image: conanio/gcc8
  • Conan version: conan 1.26.0
  • Python version: Python 3.7.4

Conan profile

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=8
compiler.libcxx=libstdc++11
build_type=Release
[options]
[build_requires]
[env]
CC=gcc-8
CXX=g++-8

Steps to reproduce (Include if Applicable)

conanfile.txt

[requires]
protobuf/3.11.4
[generators]
cmake_find_package
cmake_paths

CMakefiles.txt

...
include(${CMAKE_CURRENT_BINARY_DIR}/conan_paths.cmake)
find_package(Protobuf REQUIRED)

include_directories(${CMAKE_CURRENT_BINARY_DIR})
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS foo.proto)
protobuf_generate_python(PROTO_PY foo.proto)
add_executable(bar bar.cc ${PROTO_SRCS} ${PROTO_HDRS})
target_link_libraries(bar protobuf::libprotobuf)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
dheatercommented, Aug 12, 2020

Works brilliantly for me @rockdreamer ! I submitted a PR.

1reaction
rockdreamercommented, Aug 11, 2020

I was able to build the conan-protobuf-example repo on macos by changing the ARGS line to ARGS -E env "PATH=${CONAN_BIN_DIRS}/" "LD_LIBRARY_PATH=${Protobuf_LIB_DIRS}:${CONAN_LIB_DIRS}:${Protobuf_LIB_DIRS_RELEASE}:${Protobuf_LIB_DIRS_DEBUG}:${Protobuf_LIB_DIRS_RELWITHDEBINFO}:${Protobuf_LIB_DIRS_MINSIZEREL}" "DYLD_LIBRARY_PATH=${Protobuf_LIB_DIRS}:${CONAN_LIB_DIRS}:${Protobuf_LIB_DIRS_RELEASE}:${Protobuf_LIB_DIRS_DEBUG}:${Protobuf_LIB_DIRS_RELWITHDEBINFO}:${Protobuf_LIB_DIRS_MINSIZEREL}" protoc --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_protobuf_include_path} ${_abs_file} I.e. setting the path to protoc’s position relative to the lib directory. Unsure if this is a useful thing for cmake_multi based targets or if it’s the minimum change required.

As a sidenote, I wonder what the reasoning is for not exporting bin dirs in the cmake_find_package generators? I’m trying to integrate > 50 packages right now and I find myself wanting that more and more…

Read more comments on GitHub >

github_iconTop Results From Across the Web

C++ Generated Code | Protocol Buffers - Google Developers
This page describes exactly what C++ code the protocol buffer compiler generates for any given protocol definition. Any differences between proto2 and ...
Read more >
FindProtobuf — CMake 3.25.1 Documentation
The protobuf_generate_cpp and protobuf_generate_python functions and add_executable() or add_library() calls only work properly within the same directory.
Read more >
Serialiazing your data with Protobuf - Conan Blog
The protobuf_generate_cpp function is responsible for executing the protoc and populating the PROTO_SRCS and PROTO_HDRS variables with their ...
Read more >
CMake for Proto libraires - c++ - Stack Overflow
The protobuf_generate_cpp command does not define targets, but it defines CMake variables referring to the auto-generated source files ( .cc ...
Read more >
FindProtobuf: protobof_generate_cpp() could come ... - GitLab
From 3.14 onwards the function protobuf_generate_cpp() appears to be deprecated in favour of protobuf_generate(). The old function is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found