10997: PROTOBUF_GENERATE_CPP now supports proto files outside current dir
This commit is contained in:
parent
08b109a87f
commit
3982603c65
@ -73,6 +73,20 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS)
|
|||||||
return()
|
return()
|
||||||
endif(NOT ARGN)
|
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(${SRCS})
|
||||||
set(${HDRS})
|
set(${HDRS})
|
||||||
foreach(FIL ${ARGN})
|
foreach(FIL ${ARGN})
|
||||||
@ -86,7 +100,7 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS)
|
|||||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc"
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
|
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
|
||||||
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
|
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}
|
DEPENDS ${ABS_FIL}
|
||||||
COMMENT "Running C++ protocol buffer compiler on ${FIL}"
|
COMMENT "Running C++ protocol buffer compiler on ${FIL}"
|
||||||
VERBATIM )
|
VERBATIM )
|
||||||
@ -125,11 +139,17 @@ function(_protobuf_find_libraries name filename)
|
|||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Main.
|
# 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"
|
# Google's provided vcproj files generate libraries with a "lib"
|
||||||
# prefix on Windows
|
# prefix on Windows
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user