From 4e91be95323fa869a82ea59e733a706a5fd3867b Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 2 Oct 2017 08:04:24 -0400 Subject: FindProtobuf: Refactor custom command output listing Reduce duplication by storing the custom command outputs in variables. Also, since custom command outputs are automatically marked as generated we do not need to do so explicitly. --- Modules/FindProtobuf.cmake | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index 90f7a2e..c1444a1 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -168,12 +168,14 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS) endif() endif() - list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc") - list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h") + set(_protobuf_protoc_src "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc") + set(_protobuf_protoc_hdr "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h") + list(APPEND ${SRCS} "${_protobuf_protoc_src}") + list(APPEND ${HDRS} "${_protobuf_protoc_hdr}") add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc" - "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h" + OUTPUT "${_protobuf_protoc_src}" + "${_protobuf_protoc_hdr}" COMMAND protobuf::protoc ARGS "--cpp_out=${DLL_EXPORT_DECL}${CMAKE_CURRENT_BINARY_DIR}" ${_protobuf_include_path} ${ABS_FIL} DEPENDS ${ABS_FIL} protobuf::protoc @@ -181,9 +183,8 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS) VERBATIM ) endforeach() - set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE) - set(${SRCS} ${${SRCS}} PARENT_SCOPE) - set(${HDRS} ${${HDRS}} PARENT_SCOPE) + set(${SRCS} "${${SRCS}}" PARENT_SCOPE) + set(${HDRS} "${${HDRS}}" PARENT_SCOPE) endfunction() function(PROTOBUF_GENERATE_PYTHON SRCS) -- cgit v0.12