Protobuf message on subdirestory CMake Linux c++

49 views Asked by At

need to generate and connect the message.proto file to the unit tests. CMake throws an error:fatal error: protobuf/message.pb.h: not found #include <protobuf/message.pb.h> CMakeLists.txt:

cmake_minimum_required(VERSION 3.16.3)
cmake_policy(SET CMP0016 NEW)

project(protobuf_parser VERSION 1.0.0 DESCRIPTION "Разбор потока length-prefixed Protobuf сообщений на C++")

include_directories(${CMAKE_SOURCE_DIR}/src)

enable_testing()
add_subdirectory(test)

CMakeLists.txt /src/protobuf:

include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${Protobuf_INCLUDE_DIRS})
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS message.proto)

add_library(protobuf ${PROTO_SRCS} ${PROTO_HDRS})
target_link_libraries(protobuf INTERFACE ${Protobuf_LIBRARIES})

CMakeLists.txt /test:

cmake_minimum_required(VERSION 3.16)

include_directories(${CMAKE_CURRENT_BINARY_DIR})

add_executable(Example Test_Helpers.cpp)
target_link_libraries(Example PUBLIC
    gtest_main
    protobuf_parser
    protobuf ${PROTOBUF_LIBRARY}
    )
add_test(
    NAME Example
    COMMAND Example
    )

I searched for information on the Internet, but I couldn't find it

0

There are 0 answers