|
|
|
@ -1,4 +1,38 @@
@@ -1,4 +1,38 @@
|
|
|
|
|
find_program(PROTOC protoc) |
|
|
|
|
if(NOT CMAKE_SCRIPT_MODE_FILE) |
|
|
|
|
|
|
|
|
|
set(PROTOBUF_DIR ${CMAKE_CURRENT_LIST_DIR}/protobuf) |
|
|
|
|
|
|
|
|
|
set(PROTOBUF_BUILD ${PROJECT_BINARY_DIR}/protobuf-build) |
|
|
|
|
set(PROTOBUF_BINARY ${PROJECT_BINARY_DIR}/protobuf-binary) |
|
|
|
|
set(PROTOBUF_SRC ${PROJECT_BINARY_DIR}/protobuf-src) |
|
|
|
|
|
|
|
|
|
configure_file(${CMAKE_CURRENT_LIST_DIR}/protobuf-CMakeLists.cmake ${PROTOBUF_BUILD}/CMakeLists.txt) |
|
|
|
|
if(NOT CMAKE_GENERATOR) |
|
|
|
|
set(CMAKE_GENERATOR "Ninja") |
|
|
|
|
endif() |
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . |
|
|
|
|
RESULT_VARIABLE result |
|
|
|
|
WORKING_DIRECTORY ${PROTOBUF_BUILD} ) |
|
|
|
|
if(result) |
|
|
|
|
message(FATAL_ERROR "CMake step for protobuf failed: ${result}") |
|
|
|
|
endif() |
|
|
|
|
# execute_process(COMMAND ${CMAKE_COMMAND} --build . |
|
|
|
|
# RESULT_VARIABLE result |
|
|
|
|
# WORKING_DIRECTORY ${PROTOBUF_BUILD}) |
|
|
|
|
# if(result) |
|
|
|
|
# message(FATAL_ERROR "Build step for protobuf failed: ${result}") |
|
|
|
|
# endif() |
|
|
|
|
|
|
|
|
|
set(PROTOC ${PROTOBUF_BINARY}/protoc) |
|
|
|
|
|
|
|
|
|
add_custom_command(OUTPUT ${PROTOC} |
|
|
|
|
COMMENT "Building protoc binary" |
|
|
|
|
COMMAND ${CMAKE_COMMAND} --build . |
|
|
|
|
USES_TERMINAL |
|
|
|
|
WORKING_DIRECTORY ${PROTOBUF_BUILD}) |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
# find_program(PROTOC protoc PATHS ${CMAKE_CURRENT_LIST_DIR}/protobuf/cmake/build/) |
|
|
|
|
|
|
|
|
|
function(proto_generate_cpp PROTO_FILE PB_OUT HDR_VAR SRC_VAR) |
|
|
|
|
get_filename_component(PROTO_FILE_NAME ${PROTO_FILE} NAME_WE) |
|
|
|
@ -14,7 +48,7 @@ function(proto_generate_cpp PROTO_FILE PB_OUT HDR_VAR SRC_VAR)
@@ -14,7 +48,7 @@ function(proto_generate_cpp PROTO_FILE PB_OUT HDR_VAR SRC_VAR)
|
|
|
|
|
--cpp_out=${PB_OUT} |
|
|
|
|
--proto_path ${PROTO_FILE_DIR} |
|
|
|
|
${PROTO_FILE_PATH} |
|
|
|
|
DEPENDS ${PROTO_FILE_PATH} |
|
|
|
|
DEPENDS ${PROTO_FILE_PATH} ${PROTOC} |
|
|
|
|
COMMENT "Generating nanopb sources for ${PROTO_FILE}") |
|
|
|
|
set_property(SOURCE ${PROTO_HDR} ${PROTO_SRC} PROPERTY GENERATED TRUE) |
|
|
|
|
set_property(DIRECTORY . APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${PROTO_HDR} ${PROTO_SRC}) |
|
|
|
|