MOD: Modifies cmake include for protobuf
- sets the protoc path in CMakeLists.txt file so it can also be used in top level projects - sets the proto source file path so it can be used in top level projects - uses cmake variable PROTO_SRC_PATH defined in CMakeLists for the custom command in the protobuf.cmake file
This commit is contained in:
parent
f3a46ef218
commit
c0e5c73716
@ -65,6 +65,8 @@ IF(NOT TARGET protobuf)
|
||||
SET(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "disable shared libraries")
|
||||
#SET(WITH_PROTOC ON CACHE BOOL "enable building of protoc")
|
||||
add_subdirectory(libs/protobuf EXCLUDE_FROM_ALL)
|
||||
set(PROTOC ${CMAKE_CURRENT_BINARY_DIR}/libs/protobuf/protoc CACHE INTERNAL "" )
|
||||
set(PROTO_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}/libs/protobuf/src CACHE INTERNAL "" )
|
||||
ENDIF()
|
||||
|
||||
# we are building with c++20
|
||||
|
@ -13,8 +13,6 @@ function(protobuf_generate_cpp)
|
||||
${ARGN})
|
||||
|
||||
FILE(GLOB PROTO_FILES ${protobuf_PROTO_PATH}/*.proto)
|
||||
set(PROTOC ${CMAKE_BINARY_DIR}/libs/protobuf/protoc)
|
||||
# set(PROTOC protoc)
|
||||
|
||||
FOREACH(proto ${PROTO_FILES})
|
||||
FILE(TO_NATIVE_PATH ${proto} proto_native)
|
||||
@ -25,7 +23,7 @@ function(protobuf_generate_cpp)
|
||||
add_custom_command(
|
||||
OUTPUT "${protoDIR}/${protoFILENAME}.pb.cc"
|
||||
DEPENDS "${protoDIR}/${protoFILENAME}.proto"
|
||||
COMMAND ${PROTOC} --cpp_out=${protoDIR} --proto_path=${protoDIR} --proto_path="${CMAKE_SOURCE_DIR}/libs/protobuf/src" "${protoDIR}/${protoFILENAME}.proto"
|
||||
COMMAND ${PROTOC} --cpp_out=${protoDIR} --proto_path=${protoDIR} --proto_path=${PROTO_SRC_PATH} "${protoDIR}/${protoFILENAME}.proto"
|
||||
)
|
||||
|
||||
ENDFOREACH(proto)
|
||||
|
Loading…
Reference in New Issue
Block a user