diff options
author | Walter Gray <wgray@leapmotion.com> | 2017-05-30 16:49:18 -0700 |
---|---|---|
committer | Walter Gray <wgray@leapmotion.com> | 2017-06-02 19:57:08 -0700 |
commit | 0336770801c53543f4b1f3ebfd28dfc65e331c5c (patch) | |
tree | cac1ac79295ed3ee44c4a7d156635f102d70eaa9 /examples | |
parent | faa53989cb430b5c67ab35a29255a16881d4fb4a (diff) |
add protobuf_generate function, allows use of target_sources where available
Diffstat (limited to 'examples')
-rw-r--r-- | examples/CMakeLists.txt | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 2cd2acc0..3e8e6541 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -32,22 +32,6 @@ foreach(example add_person list_people) if(protobuf_MODULE_COMPATIBLE) #Legacy Support protobuf_generate_cpp(${example}_PROTO_SRCS ${example}_PROTO_HDRS ${${example}_PROTOS}) list(APPEND ${example}_SRCS ${${example}_PROTO_SRCS} ${${example}_PROTO_HDRS}) - else() - - foreach(proto_file ${${example}_PROTOS}) - get_filename_component(proto_file_abs ${proto_file} ABSOLUTE) - get_filename_component(basename ${proto_file} NAME_WE) - set(generated_files ${basename}.pb.cc ${basename}.pb.h) - list(APPEND ${example}_SRCS ${generated_files}) - - add_custom_command( - OUTPUT ${generated_files} - COMMAND protobuf::protoc - ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} -I ${CMAKE_CURRENT_SOURCE_DIR} ${proto_file_abs} - COMMENT "Generating ${generated_files} from ${proto_file}" - VERBATIM - ) - endforeach() endif() #Executable setup @@ -58,6 +42,7 @@ foreach(example add_person list_people) target_link_libraries(${executable_name} ${PROTOBUF_LIBRARIES}) else() target_link_libraries(${executable_name} protobuf::libprotobuf) + protobuf_generate(TARGET ${executable_name}) endif() endforeach() |