26
26
# along with this program; if not, write to the Free Software Foundation, Inc.,
27
27
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
28
29
- ##############################################################################
29
+ # #############################################################################
30
30
#
31
31
# Targets:
32
32
#
42
42
#
43
43
# mysqlx_protobuf_generate_cpp()
44
44
#
45
- # TODO:
46
- # - Allow using external install of protobuf instead of building it from
47
- # bundled sources
48
45
#
49
46
50
-
51
47
if (TARGET ext::protobuf )
52
48
return ()
53
49
endif ()
54
50
55
51
message (STATUS "Setting up Protobuf." )
56
52
57
53
# Setup extrnal project that builds protobuf from bundled sources
54
+ add_ext (protobuf google/protobuf/api.pb.h )
58
55
59
- add_ext (protobuf )
56
+ if (NOT PROTOBUF_FOUND )
57
+ message (FATAL_ERROR "Can't build without protobuf support" )
58
+ endif ()
60
59
61
- # import targets from the external project
60
+ # import targets from the external project
62
61
# Note: The pb_ targets are created by protobuf/exports.cmake
63
-
64
62
add_ext_targets (protobuf
65
- pb -lite pb_libprotobuf-lite
66
- pb-full pb_libprotobuf
67
- protoc pb_protoc
63
+ LIBRARY protobuf -lite pb_libprotobuf-lite
64
+ LIBRARY protobuf pb_libprotobuf
65
+ EXECUTABLE protoc pb_protoc
68
66
)
69
67
70
68
71
69
# Standard PROTOBUF_GENERATE_CPP modified to our usage
72
-
73
70
function (mysqlx_protobuf_generate_cpp SRCS HDRS )
74
-
75
71
IF (NOT ARGN )
76
72
MESSAGE (SEND_ERROR
77
73
"Error: MYSQLX_PROTOBUF_GENERATE_CPP() called without any proto files" )
@@ -82,7 +78,6 @@ function(mysqlx_protobuf_generate_cpp SRCS HDRS)
82
78
SET (hdrs )
83
79
84
80
FOREACH (FIL ${ARGN} )
85
-
86
81
GET_FILENAME_COMPONENT (ABS_FIL ${FIL} ABSOLUTE )
87
82
GET_FILENAME_COMPONENT (FIL_WE ${FIL} NAME_WE )
88
83
GET_FILENAME_COMPONENT (ABS_PATH ${ABS_FIL} PATH )
@@ -92,18 +87,18 @@ function(mysqlx_protobuf_generate_cpp SRCS HDRS)
92
87
93
88
ADD_CUSTOM_COMMAND (
94
89
OUTPUT "${CMAKE_CURRENT_BINARY_DIR} /protobuf/${FIL_WE} .pb.cc"
95
- "${CMAKE_CURRENT_BINARY_DIR} /protobuf/${FIL_WE} .pb.h"
90
+ "${CMAKE_CURRENT_BINARY_DIR} /protobuf/${FIL_WE} .pb.h"
96
91
COMMAND ${CMAKE_COMMAND}
97
- -E make_directory "${CMAKE_CURRENT_BINARY_DIR} /protobuf"
92
+ -E make_directory "${CMAKE_CURRENT_BINARY_DIR} /protobuf"
98
93
COMMAND ext::protoc
99
94
ARGS --cpp_out "${CMAKE_CURRENT_BINARY_DIR} /protobuf"
100
- -I ${ABS_PATH} ${ABS_FIL}
101
- #--proto_path=${PROTOBUF_INCLUDE_DIR}
95
+ -I ${ABS_PATH} ${ABS_FIL}
96
+
97
+ # --proto_path=${PROTOBUF_INCLUDE_DIR}
102
98
DEPENDS ${ABS_FIL}
103
99
COMMENT "Running C++ protocol buffer compiler on ${FIL} "
104
100
VERBATIM
105
101
)
106
-
107
102
ENDFOREACH ()
108
103
109
104
SET_SOURCE_FILES_PROPERTIES (
@@ -113,7 +108,6 @@ function(mysqlx_protobuf_generate_cpp SRCS HDRS)
113
108
#
114
109
# Disable compile warnings in code generated by Protobuf
115
110
#
116
-
117
111
IF (UNIX )
118
112
set_source_files_properties (${srcs}
119
113
APPEND_STRING PROPERTY COMPILE_FLAGS "-w"
@@ -125,8 +119,6 @@ function(mysqlx_protobuf_generate_cpp SRCS HDRS)
125
119
)
126
120
ENDIF ()
127
121
128
-
129
122
SET (${SRCS} ${srcs} PARENT_SCOPE )
130
123
SET (${HDRS} ${hdrs} PARENT_SCOPE )
131
-
132
124
endfunction (mysqlx_protobuf_generate_cpp )
0 commit comments