protobug generation optional

This commit is contained in:
Philippe G
2022-01-04 17:02:31 -08:00
parent bf24735422
commit d81e95c94a
11 changed files with 1255 additions and 10 deletions

View File

@@ -24,17 +24,25 @@ if(UNIX AND NOT APPLE)
list(APPEND EXTRA_LIBS dns_sd)
# TODO: migrate from this to native linux mDNS
endif()
set(NANOPB_OPTIONS "-I${CMAKE_CURRENT_SOURCE_DIR}")
set(PROTOS protobuf/authentication.proto protobuf/mercury.proto protobuf/keyexchange.proto protobuf/spirc.proto protobuf/metadata.proto)
message(${PROTOS})
message("building protobuf")
message(${CMAKE_CURRENT_SOURCE_DIR})
nanopb_generate_cpp(PROTO_SRCS PROTO_HDRS RELPATH ${CMAKE_CURRENT_SOURCE_DIR} ${PROTOS})
add_custom_target(generate_proto_sources DEPENDS ${PROTO_SRCS} ${PROTO_HDRS})
set_source_files_properties(${PROTO_SRCS} ${PROTO_HDRS}
PROPERTIES GENERATED TRUE)
if (GENERATE_PROTOS)
file(GLOB SOURCES "src/*.cpp" "src/*.c")
set(NANOPB_OPTIONS "-I${CMAKE_CURRENT_SOURCE_DIR}")
set(PROTOS protobuf/authentication.proto protobuf/mercury.proto protobuf/keyexchange.proto protobuf/spirc.proto protobuf/metadata.proto)
message(${PROTOS})
message("building protobuf")
message(${CMAKE_CURRENT_SOURCE_DIR})
nanopb_generate_cpp(PROTO_SRCS PROTO_HDRS RELPATH ${CMAKE_CURRENT_SOURCE_DIR} ${PROTOS})
add_custom_target(generate_proto_sources DEPENDS ${PROTO_SRCS} ${PROTO_HDRS})
set_source_files_properties(${PROTO_SRCS} ${PROTO_HDRS} PROPERTIES GENERATED TRUE)
set(GENERATED_INCLUDES ${CMAKE_CURRENT_BINARY_DIR})
else()
file(GLOB SOURCES "src/*.cpp" "src/*.c" "protobuf/*.c")
message("BEWARE => NOT GENERATING PROTOBUF")
set(GENERATED_INCLUDES ".")
endif()
add_library(cspot STATIC ${SOURCES} ${PROTO_SRCS})
# PUBLIC to propagate includes from bell to cspot dependents
target_link_libraries(cspot PUBLIC ${EXTRA_LIBS})
target_include_directories(cspot PUBLIC "include" ${CMAKE_CURRENT_BINARY_DIR} ${NANOPB_INCLUDE_DIRS})
target_include_directories(cspot PUBLIC "include" ${GENERATED_INCLUDES} ${NANOPB_INCLUDE_DIRS})