diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 6d63b14543..b2212752c7 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -47,8 +47,13 @@ function(add_flag flag) endfunction() function(compile_proto_to_cpp PROTO_LIBRARY_NAME PB_H PB_CC PROTO) - get_target_property(Protobuf_INCLUDE_DIR protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc IMPORTED_LOCATION_RELEASE) + if (NOT Protobuf_INCLUDE_DIR) + get_target_property(Protobuf_INCLUDE_DIR protobuf::libprotobuf INTERFACE_INCLUDE_DIRECTORIES) + endif() + if (NOT Protobuf_PROTOC_EXECUTABLE) + get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc IMPORTED_LOCATION_RELEASE) + set(PROTOBUF_DEPENDS protobuf::protoc) + endif() if (NOT Protobuf_PROTOC_EXECUTABLE) message(FATAL_ERROR "Protobuf_PROTOC_EXECUTABLE is empty") @@ -80,7 +85,7 @@ function(compile_proto_to_cpp PROTO_LIBRARY_NAME PB_H PB_CC PROTO) COMMAND ${GEN_COMMAND} ARGS -I${PROJECT_SOURCE_DIR}/core -I${GEN_ARGS} --cpp_out=${SCHEMA_OUT_DIR} ${PROTO_ABS} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - DEPENDS protobuf::protoc + DEPENDS ${PROTOBUF_DEPENDS} VERBATIM )