@@ -200,94 +200,8 @@ endif()
200200###
201201### Protobuf + gRPC
202202###
203- set (PROTOFILES
204- protos/occ.proto)
205-
206- # NOTE: we want the files to end up in a subdirectory "protos" in the build dir,
207- # but the Protobuf and gRPC generator functions don't support custom output
208- # directories.
209- # As a workaround, we rewrite CMAKE_CURRENT_BINARY_DIR for Protobuf/gRPC
210- # and then restore it to its real CMake-managed value.
211- file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /protos)
212- set (CMAKE_CURRENT_BINARY_DIR_OLD ${CMAKE_CURRENT_BINARY_DIR} )
213- set (CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} /protos)
214-
215- # Protobuf+gRPC generator wrapper
216- function (PROTOBUF_GENERATE_GRPC_CPP SRCS HDRS)
217- if (NOT ARGN)
218- message (SEND_ERROR "Error: PROTOBUF_GENERATE_GRPC_CPP() called without any proto files" )
219- return ()
220- endif ()
221-
222- if (PROTOBUF_GENERATE_CPP_APPEND_PATH) # This variable is common for all types of output.
223- # Create an include path for each file specified
224- foreach (FIL ${ARGN} )
225- get_filename_component (ABS_FIL ${FIL} ABSOLUTE )
226- get_filename_component (ABS_PATH ${ABS_FIL} PATH )
227- list (FIND _protobuf_include_path ${ABS_PATH} _contains_already)
228- if (${_contains_already} EQUAL -1)
229- list (APPEND _protobuf_include_path -I ${ABS_PATH} )
230- endif ()
231- endforeach ()
232- else ()
233- set (_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR} )
234- endif ()
235-
236- if (DEFINED PROTOBUF_IMPORT_DIRS)
237- foreach (DIR ${PROTOBUF_IMPORT_DIRS} )
238- get_filename_component (ABS_PATH ${DIR} ABSOLUTE )
239- list (FIND _protobuf_include_path ${ABS_PATH} _contains_already)
240- if (${_contains_already} EQUAL -1)
241- list (APPEND _protobuf_include_path -I ${ABS_PATH} )
242- endif ()
243- endforeach ()
244- endif ()
245203
246- set (${SRCS} )
247- set (${HDRS} )
248- foreach (FIL ${ARGN} )
249- get_filename_component (ABS_FIL ${FIL} ABSOLUTE )
250- get_filename_component (FIL_WE ${FIL} NAME_WE )
251-
252- list (APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR} /${FIL_WE} .pb.cc" )
253- list (APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR} /${FIL_WE} .pb.h" )
254- list (APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR} /${FIL_WE} .grpc.pb.cc" )
255- list (APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR} /${FIL_WE} .grpc.pb.h" )
256-
257- # protoc cpp generator
258- add_custom_command (
259- OUTPUT "${CMAKE_CURRENT_BINARY_DIR} /${FIL_WE} .pb.cc"
260- "${CMAKE_CURRENT_BINARY_DIR} /${FIL_WE} .pb.h"
261- COMMAND protobuf::protoc
262- ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}
263- DEPENDS ${ABS_FIL}
264- COMMENT "Running C++ protocol buffer compiler on ${FIL} "
265- VERBATIM )
266-
267- if (APPLE )
268- set (libenv DYLD_LIBRARY_PATH=$<TARGET_FILE_DIR:gRPC::grpc++>:$<TARGET_FILE_DIR:protobuf::libprotobuf>)
269- endif ()
270- # protoc grpc cpp generator
271- add_custom_command (
272- OUTPUT "${CMAKE_CURRENT_BINARY_DIR} /${FIL_WE} .grpc.pb.cc"
273- "${CMAKE_CURRENT_BINARY_DIR} /${FIL_WE} .grpc.pb.h"
274- COMMAND ${libenv} $<TARGET_FILE:protobuf::protoc>
275- ARGS --grpc_out=${CMAKE_CURRENT_BINARY_DIR}
276- --plugin=protoc-gen-grpc=${gRPC_CPP_PLUGIN_EXECUTABLE}
277- ${_protobuf_include_path} ${ABS_FIL}
278- DEPENDS ${ABS_FIL} protobuf::protoc
279- COMMENT "Running gRPC C++ protocol buffer compiler on ${FIL} "
280- VERBATIM )
281- endforeach ()
282-
283- set_source_files_properties (${${SRCS} } ${${HDRS} } PROPERTIES GENERATED TRUE )
284- set (${SRCS} ${${SRCS} } PARENT_SCOPE)
285- set (${HDRS} ${${HDRS} } PARENT_SCOPE)
286- endfunction ()
287-
288- protobuf_generate_grpc_cpp(GRPC_SOURCES GRPC_HEADERS ${PROTOFILES} )
289-
290- set (CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR_OLD} )
204+ add_subdirectory (protos)
291205
292206###
293207### Build target OCCLIBRARY
@@ -332,12 +246,9 @@ if (UNIX AND NOT APPLE)
332246 "LINKER:--no-as-needed" )
333247endif ()
334248
335-
336249target_link_libraries (${OCCLIBRARY}
337250 PUBLIC
338- gRPC::grpc++
339- gRPC::grpc++_reflection
340- protobuf::libprotobuf
251+ Occ-proto
341252 Boost::program_options)
342253
343254generate_export_header(${OCCLIBRARY} )
@@ -430,9 +341,7 @@ add_library(${OCCPLUGIN} SHARED
430341
431342target_link_libraries (${OCCPLUGIN} PUBLIC
432343 FairMQ::FairMQ
433- gRPC::grpc++
434- gRPC::grpc++_reflection
435- protobuf::libprotobuf
344+ Occ-proto
436345 Boost::program_options)
437346
438347target_include_directories (${OCCPLUGIN}
0 commit comments