diff options
author | Brad King <brad.king@kitware.com> | 2011-06-14 17:23:43 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2011-06-14 17:23:43 (GMT) |
commit | 9c569bea2d4ed9e7290ac7582ce9463af26b1dc3 (patch) | |
tree | 3fbbdcad500c45d8b99ec5209621ec13c281a126 /Modules | |
parent | 414c35ebb21c566b0880689afb3768bf90cef50f (diff) | |
parent | 3982603c65f5db4f9c42eee3ac8b324f3ff93c7a (diff) | |
download | CMake-9c569bea2d4ed9e7290ac7582ce9463af26b1dc3.zip CMake-9c569bea2d4ed9e7290ac7582ce9463af26b1dc3.tar.gz CMake-9c569bea2d4ed9e7290ac7582ce9463af26b1dc3.tar.bz2 |
Merge topic '10997_PROTOBDUF_GENERATE_CPP_returns_wrong_path'
3982603 10997: PROTOBUF_GENERATE_CPP now supports proto files outside current dir
Diffstat (limited to 'Modules')
-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) |