Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit 5c60566

Browse files
committed
Fix build with embedded protobuf library
1 parent 56497c6 commit 5c60566

File tree

7 files changed

+140
-48
lines changed

7 files changed

+140
-48
lines changed

CMakeLists.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall")
6767
# Configure the use of QT4
6868
find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork REQUIRED QUIET)
6969

70-
if (ENABLE_PROTOBUF)
71-
# add protocol buffers (make sure to find the static version)
72-
set(CMAKE_FIND_LIBRARY_SUFFIXES_OLD ${CMAKE_FIND_LIBRARY_SUFFIXES})
73-
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
74-
find_package(Protobuf REQUIRED)
75-
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_OLD})
76-
set(CMAKE_FIND_LIBRARY_SUFFIXES_OLD)
77-
endif (ENABLE_PROTOBUF)
78-
7970
#add libusb and pthreads
8071
find_package(libusb-1.0 REQUIRED)
8172
find_package(Threads REQUIRED)

dependencies/CMakeLists.txt

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,103 @@
1+
add_subdirectory(build/getoptPlusPlus)
2+
add_subdirectory(build/hidapi)
3+
add_subdirectory(build/jsoncpp)
4+
add_subdirectory(build/serial)
5+
add_subdirectory(build/tinkerforge)
16

2-
add_subdirectory(build)
7+
if(ENABLE_PROTOBUF)
8+
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared protobuf library")
9+
add_subdirectory(external/protobuf)
10+
11+
if(CMAKE_CROSSCOMPILING)
12+
# when crosscompiling import the protoc executable targets from a file generated by a native build
13+
option(IMPORT_PROTOC "Protoc export file (protoc_export.cmake) from a native build" "IMPORT_PROTOC-FILE_NOT_FOUND")
14+
include(${IMPORT_PROTOC})
15+
else()
16+
# export the protoc compiler so it can be used when cross compiling
17+
export(TARGETS protoc_compiler FILE "${CMAKE_BINARY_DIR}/protoc_export.cmake")
18+
endif()
19+
20+
# define the include for the protobuf library at the parent scope
21+
set(PROTOBUF_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/external/protobuf/src")
22+
set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS} PARENT_SCOPE)
23+
24+
# define the protoc executable at the parent scope
25+
get_property(PROTOBUF_PROTOC_EXECUTABLE TARGET protoc_compiler PROPERTY LOCATION)
26+
set(PROTOBUF_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE} PARENT_SCOPE)
27+
message(STATUS "Using protobuf compiler: " ${PROTOBUF_PROTOC_EXECUTABLE})
28+
29+
#=============================================================================
30+
# Copyright 2009 Kitware, Inc.
31+
# Copyright 2009-2011 Philip Lowman <[email protected]>
32+
# Copyright 2008 Esben Mose Hansen, Ange Optimization ApS
33+
#
34+
# Distributed under the OSI-approved BSD License (the "License");
35+
# see accompanying file Copyright.txt for details.
36+
#
37+
# This software is distributed WITHOUT ANY WARRANTY; without even the
38+
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
39+
# See the License for more information.
40+
#=============================================================================
41+
# (To distribute this file outside of CMake, substitute the full
42+
# License text for the above reference.)
43+
function(PROTOBUF_GENERATE_CPP SRCS HDRS)
44+
if(NOT ARGN)
45+
message(SEND_ERROR "Error: PROTOBUF_GENERATE_CPP() called without any proto files")
46+
return()
47+
endif()
48+
49+
if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
50+
# Create an include path for each file specified
51+
foreach(FIL ${ARGN})
52+
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
53+
get_filename_component(ABS_PATH ${ABS_FIL} PATH)
54+
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
55+
if(${_contains_already} EQUAL -1)
56+
list(APPEND _protobuf_include_path -I ${ABS_PATH})
57+
endif()
58+
endforeach()
59+
else()
60+
set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
61+
endif()
62+
63+
if(DEFINED PROTOBUF_IMPORT_DIRS)
64+
foreach(DIR ${PROTOBUF_IMPORT_DIRS})
65+
get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
66+
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
67+
if(${_contains_already} EQUAL -1)
68+
list(APPEND _protobuf_include_path -I ${ABS_PATH})
69+
endif()
70+
endforeach()
71+
endif()
72+
73+
if(CMAKE_CROSSCOMPILING)
74+
set(PROTOC_DEPENDENCY ${PROTOBUF_PROTOC_EXECUTABLE})
75+
else()
76+
set(PROTOC_DEPENDENCY protoc_compiler)
77+
endif()
78+
79+
set(${SRCS})
80+
set(${HDRS})
81+
foreach(FIL ${ARGN})
82+
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
83+
get_filename_component(FIL_WE ${FIL} NAME_WE)
84+
85+
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc")
86+
list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h")
87+
88+
add_custom_command(
89+
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc"
90+
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
91+
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
92+
ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}
93+
DEPENDS ${ABS_FIL} ${PROTOC_DEPENDENCY}
94+
COMMENT "Running C++ protocol buffer compiler on ${FIL}"
95+
VERBATIM
96+
)
97+
endforeach()
98+
99+
set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
100+
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
101+
set(${HDRS} ${${HDRS}} PARENT_SCOPE)
102+
endfunction()
103+
endif()

dependencies/build/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

dependencies/external/protobuf

libsrc/protoserver/CMakeLists.txt

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,51 @@ set(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/protoserver)
44
set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/protoserver)
55

66
include_directories(
7-
${CMAKE_CURRENT_BINARY_DIR}
8-
${PROTOBUF_INCLUDE_DIRS})
7+
${CMAKE_CURRENT_BINARY_DIR}
8+
${PROTOBUF_INCLUDE_DIRS}
9+
)
910

1011
# Group the headers that go through the MOC compiler
1112
set(ProtoServer_QT_HEADERS
12-
${CURRENT_HEADER_DIR}/ProtoServer.h
13-
${CURRENT_HEADER_DIR}/ProtoConnection.h
14-
${CURRENT_SOURCE_DIR}/ProtoClientConnection.h
15-
${CURRENT_HEADER_DIR}/ProtoConnectionWrapper.h
13+
${CURRENT_HEADER_DIR}/ProtoServer.h
14+
${CURRENT_HEADER_DIR}/ProtoConnection.h
15+
${CURRENT_SOURCE_DIR}/ProtoClientConnection.h
16+
${CURRENT_HEADER_DIR}/ProtoConnectionWrapper.h
1617
)
1718

1819
set(ProtoServer_HEADERS
1920
)
2021

2122
set(ProtoServer_SOURCES
22-
${CURRENT_SOURCE_DIR}/ProtoServer.cpp
23-
${CURRENT_SOURCE_DIR}/ProtoClientConnection.cpp
24-
${CURRENT_SOURCE_DIR}/ProtoConnection.cpp
25-
${CURRENT_SOURCE_DIR}/ProtoConnectionWrapper.cpp
23+
${CURRENT_SOURCE_DIR}/ProtoServer.cpp
24+
${CURRENT_SOURCE_DIR}/ProtoClientConnection.cpp
25+
${CURRENT_SOURCE_DIR}/ProtoConnection.cpp
26+
${CURRENT_SOURCE_DIR}/ProtoConnectionWrapper.cpp
2627
)
2728

2829
set(ProtoServer_PROTOS
29-
${CURRENT_SOURCE_DIR}/message.proto
30+
${CURRENT_SOURCE_DIR}/message.proto
3031
)
3132

3233
protobuf_generate_cpp(ProtoServer_PROTO_SRCS ProtoServer_PROTO_HDRS
33-
${ProtoServer_PROTOS}
34+
${ProtoServer_PROTOS}
3435
)
3536

3637
qt4_wrap_cpp(ProtoServer_HEADERS_MOC ${ProtoServer_QT_HEADERS})
3738

3839
add_library(protoserver
39-
${ProtoServer_HEADERS}
40-
${ProtoServer_QT_HEADERS}
41-
${ProtoServer_SOURCES}
42-
${ProtoServer_HEADERS_MOC}
43-
${ProtoServer_PROTOS}
44-
${ProtoServer_PROTO_SRCS}
45-
${ProtoServer_PROTO_HDRS}
40+
${ProtoServer_HEADERS}
41+
${ProtoServer_QT_HEADERS}
42+
${ProtoServer_SOURCES}
43+
${ProtoServer_HEADERS_MOC}
44+
${ProtoServer_PROTOS}
45+
${ProtoServer_PROTO_SRCS}
46+
${ProtoServer_PROTO_HDRS}
4647
)
4748

4849
target_link_libraries(protoserver
49-
hyperion
50-
hyperion-utils
51-
${PROTOBUF_LIBRARIES}
52-
${QT_LIBRARIES})
50+
hyperion
51+
hyperion-utils
52+
protobuf
53+
${QT_LIBRARIES}
54+
)

src/CMakeLists.txt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
add_subdirectory(hyperiond)
22
add_subdirectory(hyperion-remote)
33

4-
# Add the 'Video 4 Linux' grabber if it is enabled
5-
if(ENABLE_V4L2)
6-
add_subdirectory(hyperion-v4l2)
7-
endif(ENABLE_V4L2)
4+
# The following clients depend on the protobuf library
5+
if(ENABLE_PROTOBUF)
6+
# Add the 'Video 4 Linux' grabber if it is enabled
7+
if(ENABLE_V4L2)
8+
add_subdirectory(hyperion-v4l2)
9+
endif()
810

9-
# Add the X11 grabber if it is enabled
10-
if(ENABLE_X11)
11-
add_subdirectory(hyperion-x11)
12-
endif(ENABLE_X11)
11+
# Add the X11 grabber if it is enabled
12+
if(ENABLE_X11)
13+
add_subdirectory(hyperion-x11)
14+
endif()
15+
endif()

src/hyperion-x11/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ include_directories(
1414
${CMAKE_CURRENT_BINARY_DIR}/../../libsrc/protoserver
1515
${QT_INCLUDES}
1616
${X11_INCLUDES}
17+
${PROTOBUF_INCLUDE_DIRS}
1718
)
1819

1920
set(Hyperion_X11_QT_HEADERS

0 commit comments

Comments
 (0)