WhisperCom/cmake/Modules/protobuf.cmake
Christina Sander c0e5c73716
MOD: Modifies cmake include for protobuf
- sets the protoc path in CMakeLists.txt file so it can also be used in top level projects
 - sets the proto source file path so it can be used in top level projects
 - uses cmake variable PROTO_SRC_PATH defined in CMakeLists for the custom command in the protobuf.cmake file
2023-08-31 11:07:31 +02:00

33 lines
948 B
CMake

function(protobuf_generate_cpp)
set(OPTIONS)
set(SINGLE_VALUE_KEYWORDS
PROTO_PATH
CPP_PATH
HPP_PATH
)
set(MULTI_VALUE_KEYWORDS)
cmake_parse_arguments(protobuf
"${OPTIONS}"
"${SINGLE_VALUE_KEYWORDS}"
"${MULTI_VALUE_KEYWORDS}"
${ARGN})
FILE(GLOB PROTO_FILES ${protobuf_PROTO_PATH}/*.proto)
FOREACH(proto ${PROTO_FILES})
FILE(TO_NATIVE_PATH ${proto} proto_native)
get_filename_component(protoFILENAME ${proto} NAME_WLE )
get_filename_component(protoDIR ${proto} DIRECTORY)
add_custom_command(
OUTPUT "${protoDIR}/${protoFILENAME}.pb.cc"
DEPENDS "${protoDIR}/${protoFILENAME}.proto"
COMMAND ${PROTOC} --cpp_out=${protoDIR} --proto_path=${protoDIR} --proto_path=${PROTO_SRC_PATH} "${protoDIR}/${protoFILENAME}.proto"
)
ENDFOREACH(proto)
endfunction()