summaryrefslogtreecommitdiffstats
path: root/Modules/FindProtobuf.cmake
diff options
context:
space:
mode:
authorMartin Joly <perso@martin-joly.fr>2016-10-07 13:37:55 (GMT)
committerBrad King <brad.king@kitware.com>2016-10-07 13:50:52 (GMT)
commit2b9dad694a43d850af5fe83dd327fc82db29a012 (patch)
tree47ee5fa75e960e0c1b9aa6bc828df3b545920a38 /Modules/FindProtobuf.cmake
parentb99bbfe88d1bb02dc903507f3e1bbe716ac04c12 (diff)
downloadCMake-2b9dad694a43d850af5fe83dd327fc82db29a012.zip
CMake-2b9dad694a43d850af5fe83dd327fc82db29a012.tar.gz
CMake-2b9dad694a43d850af5fe83dd327fc82db29a012.tar.bz2
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.
Diffstat (limited to 'Modules/FindProtobuf.cmake')
-rw-r--r--Modules/FindProtobuf.cmake16
1 files changed, 10 insertions, 6 deletions
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake
index 10c07c2..14e392a 100644
--- a/Modules/FindProtobuf.cmake
+++ b/Modules/FindProtobuf.cmake
@@ -136,9 +136,11 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS)
foreach(FIL ${ARGN})
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
get_filename_component(FIL_WE ${FIL} NAME_WE)
- get_filename_component(FIL_DIR ${FIL} DIRECTORY)
- if(FIL_DIR)
- set(FIL_WE "${FIL_DIR}/${FIL_WE}")
+ if(NOT PROTOBUF_GENERATE_CPP_APPEND_PATH)
+ get_filename_component(FIL_DIR ${FIL} DIRECTORY)
+ if(FIL_DIR)
+ set(FIL_WE "${FIL_DIR}/${FIL_WE}")
+ endif()
endif()
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc")
@@ -197,9 +199,11 @@ function(PROTOBUF_GENERATE_PYTHON SRCS)
foreach(FIL ${ARGN})
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
get_filename_component(FIL_WE ${FIL} NAME_WE)
- get_filename_component(FIL_DIR ${FIL} DIRECTORY)
- if(FIL_DIR)
- set(FIL_WE "${FIL_DIR}/${FIL_WE}")
+ if(NOT PROTOBUF_GENERATE_CPP_APPEND_PATH)
+ get_filename_component(FIL_DIR ${FIL} DIRECTORY)
+ if(FIL_DIR)
+ set(FIL_WE "${FIL_DIR}/${FIL_WE}")
+ endif()
endif()
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py")