Skip to content

Commit

Permalink
build(cmake): Fix protobuf error during build when using Velox as a s…
Browse files Browse the repository at this point in the history
…ubproject (#12128)

Summary:
Error message:

```
.../cmake-build-debug/_deps/velox-src/velox/dwio/dwrf/common/wrap/dwrf-proto-wrapper.cpp:37:10: fatal error: velox/dwio/dwrf/proto/dwrf_proto.pb.cc: No such file or directory
   37 | #include "velox/dwio/dwrf/proto/dwrf_proto.pb.cc"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated
```

This is because the generated `protoc` command relies on the root CMake project path so the command will be messed up when Velox is used as a module of nother CMake project.

The patch fixes the issue.

Pull Request resolved: #12128

Reviewed By: sdruzkin

Differential Revision: D68448949

Pulled By: kagamiori

fbshipit-source-id: b45269fcc5f4dd4f3f3343720367d3c9a20757f5
  • Loading branch information
zhztheplayer authored and facebook-github-bot committed Jan 21, 2025
1 parent b7d30ba commit bb745c1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions velox/dwio/dwrf/proto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ set(PROTO_OUTPUT_FILES ${PROTO_HDRS} ${PROTO_SRCS})
set_source_files_properties(${PROTO_OUTPUT_FILES} PROPERTIES GENERATED TRUE)

# Ensure that the option --proto_path is not given an empty argument
foreach(PROTO_PATH ${CMAKE_SOURCE_DIR} ${Protobuf_INCLUDE_DIRS})
foreach(PROTO_PATH ${PROJECT_SOURCE_DIR} ${Protobuf_INCLUDE_DIRS})
list(APPEND PROTO_PATH_ARGS --proto_path=${PROTO_PATH})
endforeach()

add_custom_command(
OUTPUT ${PROTO_OUTPUT_FILES}
COMMAND protobuf::protoc ${PROTO_PATH_ARGS} --cpp_out ${CMAKE_BINARY_DIR}
COMMAND protobuf::protoc ${PROTO_PATH_ARGS} --cpp_out ${PROJECT_BINARY_DIR}
${PROTO_FILES_FULL}
DEPENDS protobuf::protoc
COMMENT "Running PROTO compiler"
Expand Down

0 comments on commit bb745c1

Please sign in to comment.