-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
080aec5
commit 8943c44
Showing
6 changed files
with
129 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# PROTOBUF_C_FOUND - System has libprotobuf-c | ||
# PROTOBUF_C_INCLUDE_DIRS - The libprotobuf-c include directories | ||
# PROTOBUF_C_LIBRARIES - The libraries needed to use libprotobuf-c | ||
# PROTOBUF_C_DEFINITIONS - Compiler switches required for using libprotobuf-c | ||
|
||
function(PROTOBUF_C_GENERATE SRCS HDRS) | ||
if(NOT ARGN) | ||
message(SEND_ERROR "Error: PROTOBUFC_GENERATE() called without any proto files") | ||
return() | ||
endif() | ||
|
||
if(PROTOBUF_C_GENERATE_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() | ||
|
||
if(DEFINED PROTOBUFC_IMPORT_DIRS) | ||
foreach(DIR ${PROTOBUF_IMPORT_DIRS}) | ||
get_filename_component(ABS_PATH ${DIR} ABSOLUTE) | ||
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) | ||
if(${_contains_already} EQUAL -1) | ||
list(APPEND _protobuf_include_path -I ${ABS_PATH}) | ||
endif() | ||
endforeach() | ||
endif() | ||
|
||
set(${SRCS}) | ||
set(${HDRS}) | ||
foreach(FIL ${ARGN}) | ||
get_filename_component(ABS_FIL ${FIL} ABSOLUTE) | ||
get_filename_component(FIL_WE ${FIL} NAME_WE) | ||
|
||
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb-c.c") | ||
list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb-c.h") | ||
|
||
add_custom_command( | ||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb-c.c" | ||
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb-c.h" | ||
COMMAND ${PROTOBUFC_PROTOC_EXECUTABLE} | ||
ARGS --c_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL} | ||
DEPENDS ${ABS_FIL} | ||
COMMENT "Running C protocol buffer compiler on ${FIL}" | ||
VERBATIM ) | ||
endforeach() | ||
|
||
set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE) | ||
set(${SRCS} ${${SRCS}} PARENT_SCOPE) | ||
set(${HDRS} ${${HDRS}} PARENT_SCOPE) | ||
endfunction() | ||
|
||
# Find the protoc Executable | ||
find_program(PROTOBUFC_PROTOC_EXECUTABLE | ||
NAMES protoc-c | ||
DOC "protoc-c compiler" | ||
) | ||
|
||
find_package(PkgConfig QUIET) | ||
if(PKG_CONFIG_FOUND) | ||
pkg_check_modules(PC_PROTOBUF_C QUIET protobuf-c) | ||
set(PROTOBUF_C_DEFINITIONS ${PC_PROTOBUF_C_CFLAGS_OTHER}) | ||
endif() | ||
|
||
find_path(PROTOBUF_C_INCLUDE_DIR protobuf-c/protobuf-c.h | ||
HINTS ${PC_PROTOBUF_C_INCLUDEDIR} ${PC_PROTOBUF_C_INCLUDE_DIRS} | ||
PATH_SUFFIXES protobuf-c) | ||
|
||
find_library(PROTOBUF_C_LIBRARY NAMES protobuf-c | ||
HINTS ${PC_PROTOBUF_C_LIBDIR} ${PC_PROTOBUF_C_LIBRARY_DIRS}) | ||
|
||
set(PROTOBUF_C_LIBRARIES ${PROTOBUF_C_LIBRARY} ) | ||
set(PROTOBUF_C_INCLUDE_DIRS ${PROTOBUF_C_INCLUDE_DIR}) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(protobuf-c DEFAULT_MSG | ||
PROTOBUF_C_LIBRARY PROTOBUF_C_INCLUDE_DIR) | ||
|
||
mark_as_advanced(PROTOBUF_C_INCLUDE_DIR YANG_LIBRARY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## load in pkg-config support | ||
find_package(PkgConfig QUIET) | ||
if(PKG_CONFIG_FOUND) | ||
## use pkg-config to get hints for 0mq locations | ||
pkg_check_modules(PC_ZeroMQ QUIET zmq) | ||
set(PROTOBUF_C_DEFINITIONS ${PC_PROTOBUF_C_CFLAGS_OTHER}) | ||
endif() | ||
|
||
## use the hint from above to find where 'zmq.hpp' is located | ||
find_path(ZeroMQ_INCLUDE_DIR | ||
NAMES zmq.hpp | ||
HINTS ${PC_ZeroMQ_INCLUDEDIR} ${PC_ZeroMQ_INCLUDE_DIRS} | ||
) | ||
|
||
## use the hint from about to find the location of libzmq | ||
find_library(ZeroMQ_LIBRARY | ||
NAMES zmq | ||
HINTS ${PC_ZeroMQ_C_LIBDIR} ${PC_ZeroMQ_C_LIBRARY_DIRS} | ||
) |
22 changes: 22 additions & 0 deletions
22
mjpg-streamer-experimental/plugins/output_zmqserver/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
include(FindZeroMQ) | ||
include(FindProtobuf-c) | ||
|
||
MJPG_STREAMER_PLUGIN_OPTION(output_zmqserver "ZMQ Server output plugin" | ||
ONLYIF ZeroMQ_LIBRARY PROTOBUF_C_LIBRARY) | ||
|
||
if (NOT ZeroMQ_LIBRARY) | ||
message(WARNING Optional dependency ZeroMQ not found) | ||
endif() | ||
|
||
if (NOT PROTOBUF_C_LIBRARY) | ||
message(WARNING Optional dependency Protobuf-c not found) | ||
endif() | ||
|
||
if (PLUGIN_OUTPUT_ZMQSERVER) | ||
protobuf_c_generate(PROTO_SRC PROTO_HEADER package.proto) | ||
include_directories(${ZeroMQ_INCLUDE_DIR}) | ||
include_directories(${PROTOBUF_C_INCLUDE_DIR}) | ||
include_directories(${CMAKE_CURRENT_BINARY_DIR}) | ||
MJPG_STREAMER_PLUGIN_COMPILE(output_zmqserver ${PROTO_SRC} output_zmqserver.c) | ||
target_link_libraries(output_zmqserver ${ZeroMQ_LIBRARY} ${PROTOBUF_C_LIBRARY}) | ||
endif() |
28 changes: 0 additions & 28 deletions
28
mjpg-streamer-experimental/plugins/output_zmqserver/Makefile
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
mjpg-streamer-experimental/plugins/output_zmqserver/package.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
syntax = "proto2"; | ||
package pb; | ||
|
||
message Package { | ||
|