forked from Research/WhisperCom
35 lines
1.0 KiB
CMake
35 lines
1.0 KiB
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)
|
||
|
set(PROTOC ${CMAKE_BINARY_DIR}/libs/protobuf/protoc)
|
||
|
# set(PROTOC protoc)
|
||
|
|
||
|
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="${CMAKE_SOURCE_DIR}/libs/protobuf/src" "${protoDIR}/${protoFILENAME}.proto"
|
||
|
)
|
||
|
|
||
|
ENDFOREACH(proto)
|
||
|
|
||
|
|
||
|
endfunction()
|