Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A CMake snippet for auto generating protobuf c++ files during make file generation
file(GLOB PROTOBUF_DEFINITION_FILES "*.proto")
set(PROTOBUF_INPUT_DIRECTORY "${PROJECT_SOURCE_DIR}")
set(PROTOBUF_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/Models/Proto/")
foreach(file ${PROTOBUF_DEFINITION_FILES})
set(PROTOBUF_ARGUMENTS "protoc --proto_path=\"${PROTOBUF_INPUT_DIRECTORY}\" --cpp_out=\"${PROTOBUF_OUTPUT_DIRECTORY}\" \"${file}\"")
execute_process(COMMAND ${PROTOBUF_OUTPUT_DIRECTORY}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE PROTOBUF_RESULT
OUTPUT_VARIABLE PROTOBUF_OUTPUT_VARIABLE)
endforeach()
file(GLOB PROTOBUF_MODELS_INCLUDES "Models/Proto/*.pb.cc" "Models/Proto/*.hpp")
@LWSS

This comment has been minimized.

Copy link

@LWSS LWSS commented May 13, 2020

COMMAND isn't being passed anything but the output directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.