diff options
author | Markus Heß <hessi88@googlemail.com> | 2017-09-12 10:00:04 +0200 |
---|---|---|
committer | Markus Heß <hessi88@googlemail.com> | 2017-09-12 10:00:04 +0200 |
commit | 444aecd35a1b3e5eb50baab9025cd5f565ec71c6 (patch) | |
tree | c8a0f1cf5d16b14326f74896569b67914892d6bd | |
parent | 174c82d8cef27be5cb9d8491dd1e26d27898870b (diff) | |
download | protobuf-444aecd35a1b3e5eb50baab9025cd5f565ec71c6.tar.gz protobuf-444aecd35a1b3e5eb50baab9025cd5f565ec71c6.tar.bz2 protobuf-444aecd35a1b3e5eb50baab9025cd5f565ec71c6.zip |
fix protobuf_generate function
-rw-r--r-- | cmake/protobuf-config.cmake.in | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/cmake/protobuf-config.cmake.in b/cmake/protobuf-config.cmake.in index 83213547..11a9b75a 100644 --- a/cmake/protobuf-config.cmake.in +++ b/cmake/protobuf-config.cmake.in @@ -9,14 +9,17 @@ include("${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake") function(protobuf_generate) include(CMakeParseArguments) + + set(_options APPEND_PATH) set(_singleargs LANGUAGE OUT_VAR) if(COMMAND target_sources) list(APPEND _singleargs TARGET) endif() + set(_multiargs PROTOS IMPORT_DIRS GENERATE_EXTENSIONS) - cmake_parse_arguments(protobuf_generate "APPEND_PATH" "${_singleargs}" "PROTOS IMPORT_DIRS GENERATE_EXTENSIONS" "${ARGN}") + cmake_parse_arguments(protobuf_generate "${_options}" "${_singleargs}" "${_multiargs}" "${ARGN}") - if(protobuf_generate_PROTOS AND NOT protobuf_generate_TARGET) + if(NOT protobuf_generate_PROTOS AND NOT protobuf_generate_TARGET) message(SEND_ERROR "Error: protobuf_generate called without any targets or source files") return() endif() @@ -78,14 +81,16 @@ function(protobuf_generate) return() endif() - set(_generated_srcs) + set(_generated_srcs_all) foreach(_proto ${protobuf_generate_PROTOS}) get_filename_component(_abs_file ${_proto} ABSOLUTE) get_filename_component(_basename ${_proto} NAME_WE) - foreach(_ext ${_output_extensions}) + set(_generated_srcs) + foreach(_ext ${protobuf_GENERATE_EXTENSIONS}) list(APPEND _generated_srcs "${CMAKE_CURRENT_BINARY_DIR}/${_basename}${_ext}") endforeach() + list(APPEND _generated_srcs_all ${_generated_srcs}) add_custom_command( OUTPUT ${_generated_srcs} @@ -96,12 +101,12 @@ function(protobuf_generate) VERBATIM ) endforeach() - set_source_files_properties(${_generated_srcs} PROPERTIES GENERATED TRUE) + set_source_files_properties(${_generated_srcs_all} PROPERTIES GENERATED TRUE) if(protobuf_generate_OUT_VAR) - set(${protobuf_generate_OUT_VAR} ${_generated_srcs} PARENT_SCOPE) + set(${protobuf_generate_OUT_VAR} ${_generated_srcs_all} PARENT_SCOPE) endif() if(protobuf_generate_TARGET) - target_sources(${protobuf_generate_TARGET} PUBLIC ${_generated_srcs}) + target_sources(${protobuf_generate_TARGET} PUBLIC ${_generated_srcs_all}) endif() endfunction() |