diff options
author | André Apitzsch <andre.apitzsch@etit.tu-chemnitz.de> | 2017-07-11 13:20:36 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-07-12 17:48:22 (GMT) |
commit | c281acf80768c56bbe12a9f017a856d8e966f084 (patch) | |
tree | f704a8dc8b1328f0b02ff2a3eaa1174863afaf89 /Modules/FindProtobuf.cmake | |
parent | 107a92ea9a784d283b8d6d35a8c9bd93db8cd06d (diff) | |
download | CMake-c281acf80768c56bbe12a9f017a856d8e966f084.zip CMake-c281acf80768c56bbe12a9f017a856d8e966f084.tar.gz CMake-c281acf80768c56bbe12a9f017a856d8e966f084.tar.bz2 |
FindProtobuf: add target for protoc
Diffstat (limited to 'Modules/FindProtobuf.cmake')
-rw-r--r-- | Modules/FindProtobuf.cmake | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index 33262f3..90f7a2e 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -48,6 +48,8 @@ # The protobuf lite library. # ``protobuf::libprotoc`` # The protoc library. +# ``protobuf::protoc`` +# The protoc compiler. # # The following cache variables are also available to set or use: # @@ -172,9 +174,9 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS) add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc" "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h" - COMMAND ${Protobuf_PROTOC_EXECUTABLE} + COMMAND protobuf::protoc ARGS "--cpp_out=${DLL_EXPORT_DECL}${CMAKE_CURRENT_BINARY_DIR}" ${_protobuf_include_path} ${ABS_FIL} - DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE} + DEPENDS ${ABS_FIL} protobuf::protoc COMMENT "Running C++ protocol buffer compiler on ${FIL}" VERBATIM ) endforeach() @@ -232,8 +234,8 @@ function(PROTOBUF_GENERATE_PYTHON SRCS) list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py") add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py" - COMMAND ${Protobuf_PROTOC_EXECUTABLE} --python_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL} - DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE} + COMMAND protobuf::protoc --python_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL} + DEPENDS ${ABS_FIL} protobuf::protoc COMMENT "Running Python protocol buffer compiler on ${FIL}" VERBATIM ) endforeach() @@ -501,6 +503,16 @@ if(Protobuf_INCLUDE_DIR) endif() endif() endif() + + if(Protobuf_PROTOC_EXECUTABLE) + if(NOT TARGET protobuf::protoc) + add_executable(protobuf::protoc IMPORTED) + if(EXISTS "${Protobuf_PROTOC_EXECUTABLE}") + set_target_properties(protobuf::protoc PROPERTIES + IMPORTED_LOCATION "${Protobuf_PROTOC_EXECUTABLE}") + endif() + endif() + endif() endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) |