Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
58 lines
2.1 KiB
CMake
58 lines
2.1 KiB
CMake
# Special PROTOBUF_GENERATE_CPP which allows to set the output folder:
|
|
# From https://stackoverflow.com/users/1600278/akira-okumura
|
|
|
|
function(MY_PROTOBUF_GENERATE_CPP PATH SRCS HDRS)
|
|
if(NOT ARGN)
|
|
message(SEND_ERROR "Error: PROTOBUF_GENERATE_CPP() called without any proto files")
|
|
return()
|
|
endif()
|
|
|
|
if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
|
|
# Create an include path for each file specified
|
|
foreach(FIL ${ARGN})
|
|
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
|
|
get_filename_component(ABS_PATH ${ABS_FIL} PATH)
|
|
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
|
|
if(${_contains_already} EQUAL -1)
|
|
list(APPEND _protobuf_include_path -I ${ABS_PATH})
|
|
endif()
|
|
endforeach()
|
|
else()
|
|
set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
|
|
endif()
|
|
|
|
if(DEFINED PROTOBUF_IMPORT_DIRS)
|
|
foreach(DIR ${PROTOBUF_IMPORT_DIRS})
|
|
get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
|
|
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
|
|
if(${_contains_already} EQUAL -1)
|
|
list(APPEND _protobuf_include_path -I ${ABS_PATH})
|
|
endif()
|
|
endforeach()
|
|
endif()
|
|
|
|
set(${SRCS})
|
|
set(${HDRS})
|
|
foreach(FIL ${ARGN})
|
|
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
|
|
get_filename_component(FIL_WE ${FIL} NAME_WE)
|
|
|
|
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${PATH}/${FIL_WE}.pb.cc")
|
|
list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${PATH}/${FIL_WE}.pb.h")
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${PATH})
|
|
|
|
add_custom_command(
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${PATH}/${FIL_WE}.pb.cc"
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${PATH}/${FIL_WE}.pb.h"
|
|
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
|
|
ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR}/${PATH} ${_protobuf_include_path} ${ABS_FIL}
|
|
DEPENDS ${ABS_FIL}
|
|
COMMENT "Running C++ protocol buffer compiler on ${FIL}"
|
|
VERBATIM )
|
|
endforeach()
|
|
|
|
set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
|
|
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
|
|
set(${HDRS} ${${HDRS}} PARENT_SCOPE)
|
|
endfunction() |