CMakeLists.txt 810 Bytes
Newer Older
1 2 3 4 5

file(GLOB PROTOS ${CMAKE_CURRENT_SOURCE_DIR}/*.proto)

foreach( proto_file ${PROTOS} )
    FILE(TO_NATIVE_PATH ${proto_file} proto_native)
6
    #generate cpp and h files from proto file
7 8
    EXECUTE_PROCESS(COMMAND ${Protobuf_PROTOC_EXECUTABLE} --proto_path=${CMAKE_CURRENT_SOURCE_DIR} --cpp_out=${CMAKE_CURRENT_SOURCE_DIR} ${proto_native}
            RESULT_VARIABLE rv)
9 10 11 12 13
    if(rv)
        MESSAGE("Generation of data model returned ${rv} for proto ${proto_native}")
    else(rv)
        MESSAGE("Generated .cc and .h for proto file: ${proto_native}")
    endif(rv)
14 15 16 17 18
endforeach( proto_file)

file(GLOB PROTO_SRC *.cc)
file(GLOB PROTO_HDR *.h)

19
# Lists of generated .cc and .h files should be visible in superordinate CMakeFile
20 21
set(PROTO_SRC ${PROTO_SRC} PARENT_SCOPE)
set(PROTO_HDR ${PROTO_HDR} PARENT_SCOPE)
22

23