FindProtobuf: Fix protobuf_generate_*() to handle subdirs

The change in commit v3.7.0-rc1~513^2 (FindProtobuf: fix
protobuf_generate_*() to handle proto files in subdirs, 2016-06-09)
incorrectly adds subdirectories to the path of the generated files when
`*.proto` files are passed to `protobuf_generate_*` with subdirectories.
This behavior is not correct when `PROTOBUF_GENERATE_CPP_APPEND_PATH` is
True (default behavior) as `protoc` will generate output file in the
current build directory.
This commit is contained in:
Martin Joly 2016-10-07 15:37:55 +02:00 committed by Brad King
parent b99bbfe88d
commit 2b9dad694a
1 changed files with 10 additions and 6 deletions

View File

@ -136,9 +136,11 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS)
foreach(FIL ${ARGN}) foreach(FIL ${ARGN})
get_filename_component(ABS_FIL ${FIL} ABSOLUTE) get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
get_filename_component(FIL_WE ${FIL} NAME_WE) get_filename_component(FIL_WE ${FIL} NAME_WE)
get_filename_component(FIL_DIR ${FIL} DIRECTORY) if(NOT PROTOBUF_GENERATE_CPP_APPEND_PATH)
if(FIL_DIR) get_filename_component(FIL_DIR ${FIL} DIRECTORY)
set(FIL_WE "${FIL_DIR}/${FIL_WE}") if(FIL_DIR)
set(FIL_WE "${FIL_DIR}/${FIL_WE}")
endif()
endif() endif()
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc") list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc")
@ -197,9 +199,11 @@ function(PROTOBUF_GENERATE_PYTHON SRCS)
foreach(FIL ${ARGN}) foreach(FIL ${ARGN})
get_filename_component(ABS_FIL ${FIL} ABSOLUTE) get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
get_filename_component(FIL_WE ${FIL} NAME_WE) get_filename_component(FIL_WE ${FIL} NAME_WE)
get_filename_component(FIL_DIR ${FIL} DIRECTORY) if(NOT PROTOBUF_GENERATE_CPP_APPEND_PATH)
if(FIL_DIR) get_filename_component(FIL_DIR ${FIL} DIRECTORY)
set(FIL_WE "${FIL_DIR}/${FIL_WE}") if(FIL_DIR)
set(FIL_WE "${FIL_DIR}/${FIL_WE}")
endif()
endif() endif()
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py") list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py")