IMPALA-4650: Allow protobuf to find non-system libraries and binaries This change makes PROTOBUF_GENERATE_CPP able to pick up Protobuf libraries and binaries that are found by CMake but not installed on the system LD_LIBRARY_PATH.
Change-Id: I942b3f18e25e2abc5aac167412b65abb680d3c5a Reviewed-on: http://gerrit.cloudera.org:8080/5658 Tested-by: Impala Public Jenkins Reviewed-by: Henry Robinson <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/ed0aa66e Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/ed0aa66e Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/ed0aa66e Branch: refs/heads/master Commit: ed0aa66ee1ec3dd31f451ec70432bf58c6b682c4 Parents: 4b3fdc3 Author: Henry Robinson <[email protected]> Authored: Fri Dec 2 21:29:22 2016 -0800 Committer: Henry Robinson <[email protected]> Committed: Thu Jan 12 05:18:33 2017 +0000 ---------------------------------------------------------------------- cmake_modules/FindProtobuf.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/ed0aa66e/cmake_modules/FindProtobuf.cmake ---------------------------------------------------------------------- diff --git a/cmake_modules/FindProtobuf.cmake b/cmake_modules/FindProtobuf.cmake index a1092c1..4c2ab2f 100644 --- a/cmake_modules/FindProtobuf.cmake +++ b/cmake_modules/FindProtobuf.cmake @@ -139,6 +139,7 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS TGTS) SET(ARG_BINARY_ROOT "${CMAKE_CURRENT_BINARY_DIR}") endif() GET_FILENAME_COMPONENT(ARG_BINARY_ROOT ${ARG_BINARY_ROOT} ABSOLUTE) + GET_FILENAME_COMPONENT(PROTO_LIB_DIR ${PROTOBUF_SHARED_LIBRARY} DIRECTORY) foreach(FIL ${ARG_PROTO_FILES}) get_filename_component(ABS_FIL ${FIL} ABSOLUTE) @@ -161,7 +162,9 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS TGTS) add_custom_command( OUTPUT "${PROTO_CC_OUT}" "${PROTO_H_OUT}" - COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} + COMMAND ${CMAKE_COMMAND} + -E env "LD_LIBRARY_PATH=${PROTO_LIB_DIR}:$ENV{LD_LIBRARY_PATH}" + ${PROTOBUF_PROTOC_EXECUTABLE} ARGS --plugin $<TARGET_FILE:protoc-gen-insertions> --cpp_out ${ARG_BINARY_ROOT}
