WhisperCom/cmake/Modules/protobuf.cmake

33 lines
948 B
CMake
Raw Normal View History

2023-06-15 15:04:15 +02:00
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"
2023-06-15 15:04:15 +02:00
)
ENDFOREACH(proto)
endfunction()