diff --git a/src/struct_pb/tests/CMakeLists.txt b/src/struct_pb/tests/CMakeLists.txt index a845733ca..8f7f1a52d 100644 --- a/src/struct_pb/tests/CMakeLists.txt +++ b/src/struct_pb/tests/CMakeLists.txt @@ -20,19 +20,22 @@ endif() set(TEST_PROTO main.cpp) if (Protobuf_FOUND) - add_definitions(-DSTRUCT_PB_WITH_PROTO) - message(STATUS "Found Protobuf: ${Protobuf_VERSION}") - include_directories(${Protobuf_INCLUDE_DIRS}) - include_directories(${CMAKE_CURRENT_BINARY_DIR}) - set(PROTO_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/) - file(GLOB PROTO_FILES ${PROTO_SRC_DIR}/*.proto) + if(${Protobuf_VERSION} GREATER_EQUAL 3.21) + message(STATUS "Gen proto files") + add_definitions(-DSTRUCT_PB_WITH_PROTO) + message(STATUS "Found Protobuf: ${Protobuf_VERSION}") + include_directories(${Protobuf_INCLUDE_DIRS}) + include_directories(${CMAKE_CURRENT_BINARY_DIR}) + set(PROTO_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/) + file(GLOB PROTO_FILES ${PROTO_SRC_DIR}/*.proto) - protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES}) - # message(STATUS "Proto source files: ${PROTO_SRCS}") - # message(STATUS "Proto header files: ${PROTO_HDRS}") - add_executable(struct_pb_test ${PROTO_SRCS} ${TEST_PROTO}) - target_link_libraries(struct_pb_test PRIVATE protobuf::libprotobuf) - add_test(NAME struct_pb_test COMMAND struct_pb_test) + protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES}) + # message(STATUS "Proto source files: ${PROTO_SRCS}") + # message(STATUS "Proto header files: ${PROTO_HDRS}") + add_executable(struct_pb_test ${PROTO_SRCS} ${TEST_PROTO}) + target_link_libraries(struct_pb_test PRIVATE protobuf::libprotobuf) + add_test(NAME struct_pb_test COMMAND struct_pb_test) + endif() else() add_executable(struct_pb_test ${TEST_PROTO}) add_test(NAME struct_pb_test COMMAND struct_pb_test)