[PATCH] D135712: [CMake] Fix FindGRPC cmake module to allow different layering

Steven Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 12 12:40:14 PDT 2022


steven_wu added inline comments.


================
Comment at: cmake/Modules/FindGRPC.cmake:111
 # They may be relative to the source dir or absolute (for generated protos).
-function(generate_protos LibraryName ProtoFile)
+macro(generate_protos_source GeneratedSource ProtoFile)
   cmake_parse_arguments(PARSE_ARGV 2 PROTO "GRPC" "" "DEPENDS")
----------------
sammccall wrote:
> sammccall wrote:
> > changing from function to macro means all the local variables here are done in the parent scope, which is hard to reason about.
> > 
> > I think the only reason you're doing that here is to return the filename in the `ProtoSource` variable, in which case `set(${GeneratedSource} ${GeneratedProtoSource} PARENT_SCOPE)` should do the job from a function.
> nit: the plural is in the wrong place: rather `generate_proto_sources`?
> this generates the multiple sources for a single proto, rather than the other way around.
> 
> (I'm not sure why the original was plural, but this makes it somehow more confusing)
The reason why it is a macro is I don't know any elegant way to pass all the DEPEND down to `add_*_library`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135712/new/

https://reviews.llvm.org/D135712



More information about the llvm-commits mailing list