diff options
author | Philip Lowman <philip@yhbt.com> | 2011-06-07 05:07:41 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2011-06-14 13:25:16 (GMT) |
commit | 3982603c65f5db4f9c42eee3ac8b324f3ff93c7a (patch) | |
tree | 0ee5bcb56f5a9d81284fc726239c5c328bcc4443 /Modules/FindProtobuf.cmake | |
parent | 08b109a87f43406f70a125552a2e0aaf54d3b782 (diff) | |
download | CMake-3982603c65f5db4f9c42eee3ac8b324f3ff93c7a.zip CMake-3982603c65f5db4f9c42eee3ac8b324f3ff93c7a.tar.gz CMake-3982603c65f5db4f9c42eee3ac8b324f3ff93c7a.tar.bz2 |
10997: PROTOBUF_GENERATE_CPP now supports proto files outside current dir
Diffstat (limited to 'Modules/FindProtobuf.cmake')
-rw-r--r-- | Modules/FindProtobuf.cmake | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index 88ef7cd..38f5a75 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -73,6 +73,20 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS) return() endif(NOT ARGN) + if(PROTOBUF_GENERATE_CPP_APPEND_PATH) + # Create an include path for each file specified + foreach(FIL ${ARGN}) + get_filename_component(ABS_FIL ${FIL} ABSOLUTE) + get_filename_component(ABS_PATH ${ABS_FIL} PATH) + list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) + if(${_contains_already} EQUAL -1) + list(APPEND _protobuf_include_path -I ${ABS_PATH}) + endif() + endforeach() + else() + set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR}) + endif() + set(${SRCS}) set(${HDRS}) foreach(FIL ${ARGN}) @@ -86,7 +100,7 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS) OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc" "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h" COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} - ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} --proto_path ${CMAKE_CURRENT_SOURCE_DIR} ${ABS_FIL} + ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL} DEPENDS ${ABS_FIL} COMMENT "Running C++ protocol buffer compiler on ${FIL}" VERBATIM ) @@ -125,11 +139,17 @@ function(_protobuf_find_libraries name filename) endif() endfunction() - # # Main. # +# By default have PROTOBUF_GENERATE_CPP macro pass -I to protoc +# for each directory where a proto file is referenced. +if(NOT DEFINED PROTOBUF_GENERATE_CPP_APPEND_PATH) + set(PROTOBUF_GENERATE_CPP_APPEND_PATH TRUE) +endif() + + # Google's provided vcproj files generate libraries with a "lib" # prefix on Windows if(MSVC) |