aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmake
diff options
context:
space:
mode:
authorGravatar Christian von Arnim <christian.vonarnim@gmail.com>2018-05-14 09:03:42 +0200
committerGravatar Christian von Arnim <christian.vonarnim@gmail.com>2018-05-14 09:22:34 +0200
commitb9c0c5f526206f2d9b56522089f3abd0c329429a (patch)
tree527ce9c80e89f150215266b711d286f96b1cdf7c /cmake
parente8ae76fbde910720faa1708b6910f6ba7275e8aa (diff)
cmake: Add parameter PROTOC_OUT_DIR to protobuf_generate
Diffstat (limited to 'cmake')
-rw-r--r--cmake/protobuf-config.cmake.in10
1 files changed, 7 insertions, 3 deletions
diff --git a/cmake/protobuf-config.cmake.in b/cmake/protobuf-config.cmake.in
index 0e2380a8..a40b7fd1 100644
--- a/cmake/protobuf-config.cmake.in
+++ b/cmake/protobuf-config.cmake.in
@@ -11,7 +11,7 @@ function(protobuf_generate)
include(CMakeParseArguments)
set(_options APPEND_PATH)
- set(_singleargs LANGUAGE OUT_VAR EXPORT_MACRO)
+ set(_singleargs LANGUAGE OUT_VAR EXPORT_MACRO PROTOC_OUT_DIR)
if(COMMAND target_sources)
list(APPEND _singleargs TARGET)
endif()
@@ -34,6 +34,10 @@ function(protobuf_generate)
endif()
string(TOLOWER ${protobuf_generate_LANGUAGE} protobuf_generate_LANGUAGE)
+ if(NOT protobuf_generate_PROTOC_OUT_DIR)
+ set(protobuf_generate_PROTOC_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
+ endif()
+
if(protobuf_generate_EXPORT_MACRO AND protobuf_generate_LANGUAGE STREQUAL cpp)
set(_dll_export_decl "dllexport_decl=${protobuf_generate_EXPORT_MACRO}:")
endif()
@@ -92,14 +96,14 @@ function(protobuf_generate)
set(_generated_srcs)
foreach(_ext ${protobuf_generate_GENERATE_EXTENSIONS})
- list(APPEND _generated_srcs "${CMAKE_CURRENT_BINARY_DIR}/${_basename}${_ext}")
+ list(APPEND _generated_srcs "${protobuf_generate_PROTOC_OUT_DIR}/${_basename}${_ext}")
endforeach()
list(APPEND _generated_srcs_all ${_generated_srcs})
add_custom_command(
OUTPUT ${_generated_srcs}
COMMAND protobuf::protoc
- ARGS --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${_abs_file}
+ ARGS --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_protobuf_include_path} ${_abs_file}
DEPENDS ${ABS_FIL} protobuf::protoc
COMMENT "Running ${protobuf_generate_LANGUAGE} protocol buffer compiler on ${_proto}"
VERBATIM )