Open jboomer opened 2 years ago
I have the similar issue with scotch subproject. Changing mesonbuild/cmake/generator.py
Line 69 to return arg
works for me.
Thanks, but that change doesn't work as the protoc
and grpc_cpp_plugin
are built by grpc itself, so they are not in the path. From a comment in generator.py:
Most generator expressions are simply ignored for
simplicety, however some are required for some common
use cases.
I guess this is a more advanced use case that is not really supported. I guess the way to use grpc in a meson project would be to compile it outside of the project and use pkg-config
to link it.
It's also possible to port grpc to meson and submit it to the WrapDB for others to use. Then you're not at the mercy of the quality of Meson's imperfect heuristics while trying to translate foreign build systems, and as a side benefit, you do not need cmake to be installed when building.
That being said, our cmake expert may be able to improve those heuristics to get this use case working, in which case, great!
The main problem here is that protoc uses an executable that was not imported from a dependency and is declared inside the project. So basically:
add_executable(grpc_cpp_plugin
src/compiler/cpp_plugin.cc
)
add_custom_command(
OUTPUT "${_gRPC_PROTO_GENS_DIR}/${RELFIL_WE}.grpc.pb.cc"
# more stuff...
COMMAND ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}
ARGS --plugin=protoc-gen-grpc=${_gRPC_CPP_PLUGIN}
# more stuff...
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE_LOCATION} ${ABS_FIL} ${_gRPC_PROTOBUF_PROTOC} grpc_cpp_plugin
# more stuff
)
I think I found a valid use case for exe.full_path()
:) Now I just have to figure out how to teach the CMake backend how to make it work...
@WaldonChen, did you open an issue about that. Your fix is more a hack and likely only works by accident.
@eli-schwartz : I'm neither an expert in cmake nor meson and that project looks positively daunting :) . Just evaluating solutions for now, compiling it outside the project would be ok although if it can work as a cmake subproject that would be awesome. From what I could see so far the mentioned issue is really the only roadblock, the rest seems to compile fine.
@jboomer Implementing the missing feature in the CMake subproject is possible on the Meson side but might take a bit because it is not really straightforward.
I opened an issue about my hack: https://github.com/mesonbuild/meson/issues/10328
Describe the bug Trying to compile grpc as a cmake subproject. Unfortunately this fails during the step where it compiles some proto files itself. Particularly, this seems to happen because the
TARGET_FILE
expression which is supposed to resolve to the path of theprotoc
compiler and thegrpc_cpp_plugin
executable do not get filled in.meson.build :
Failed build step:
In the above step, the path to
protoc
seems to be missing as well as the path to thegrpc_cpp_plugin
. Highlighted below where they should be:In the protobuf.cmake and CMakeLists.txt these are generated like:
and
respectively.
To Reproduce Use the meson build above with an executable that uses the dependencies.
Expected behavior
protoc
andgrpcc_cpp_plugin
are found and grpc compilessystem parameters
meson --version
0.62.1ninja --version
if it's a Ninja build 1.10.2