File mysql-connector-cpp-use-system-protobuf.patch of Package mysql-connector-cpp

Index: b/cdk/CMakeLists.txt
===================================================================
--- a/cdk/CMakeLists.txt
+++ b/cdk/CMakeLists.txt
@@ -97,6 +97,7 @@ find_dependency(SSL)
 #find_dependency(Protobuf)
 find_dependency(RapidJSON)
 find_dependency(Coverage)
+#find_package(Protobuf REQUIRED)
 
 
 # TODO: These macros should not be used in public headers because they are
Index: b/cdk/protocol/mysqlx/CMakeLists.txt
===================================================================
--- a/cdk/protocol/mysqlx/CMakeLists.txt
+++ b/cdk/protocol/mysqlx/CMakeLists.txt
@@ -26,7 +26,8 @@
 # along with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
-find_dependency(Protobuf)
+#find_dependency(Protobuf)
+find_package(Protobuf REQUIRED)
 find_dependency(Compression)
 
 include(CheckIncludeFile)
@@ -39,7 +40,7 @@ add_config(HAVE_BYTEORDER_H)
 
 add_config_option(DEBUG_PROTOBUF BOOL ADVANCED DEFAULT OFF "Debug Protobuf messages")
 
-set(use_full_protobuf ${WITH_TESTS})
+set(use_full_protobuf 1)
 
 if (DEBUG_PROTOBUF)
   message("Protobuf debugging enabled")
@@ -111,6 +112,65 @@ if(NOT use_full_protobuf)
 
 endif(NOT use_full_protobuf)
 
+function(mysqlx_protobuf_generate_cpp SRCS HDRS)
+
+  IF(NOT ARGN)
+    MESSAGE(SEND_ERROR
+      "Error: MYSQLX_PROTOBUF_GENERATE_CPP() called without any proto files")
+    RETURN()
+  ENDIF()
+
+  SET(srcs)
+  SET(hdrs)
+
+  FOREACH(FIL ${ARGN})
+
+    GET_FILENAME_COMPONENT(ABS_FIL ${FIL} ABSOLUTE)
+    GET_FILENAME_COMPONENT(FIL_WE ${FIL} NAME_WE)
+    GET_FILENAME_COMPONENT(ABS_PATH ${ABS_FIL} PATH)
+
+    LIST(APPEND srcs "${CMAKE_CURRENT_BINARY_DIR}/protobuf/${FIL_WE}.pb.cc")
+    LIST(APPEND hdrs "${CMAKE_CURRENT_BINARY_DIR}/protobuf/${FIL_WE}.pb.h")
+
+    ADD_CUSTOM_COMMAND(
+      OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/protobuf/${FIL_WE}.pb.cc"
+             "${CMAKE_CURRENT_BINARY_DIR}/protobuf/${FIL_WE}.pb.h"
+      COMMAND ${CMAKE_COMMAND}
+            -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/protobuf"
+      COMMAND protobuf::protoc
+      ARGS --cpp_out "${CMAKE_CURRENT_BINARY_DIR}/protobuf"
+           -I ${ABS_PATH} ${ABS_FIL}
+      DEPENDS ${ABS_FIL} #${PROTOBUF_PROTOC_EXECUTABLE}
+      COMMENT "Running C++ protocol buffer compiler on ${FIL}"
+      VERBATIM
+    )
+
+  ENDFOREACH()
+
+  SET_SOURCE_FILES_PROPERTIES(
+    ${srcs} ${hdrs}
+    PROPERTIES GENERATED TRUE)
+
+  #
+  # Disable compile warnings in code generated by Protobuf
+  #
+
+  IF(UNIX)
+    set_source_files_properties(${srcs}
+      APPEND_STRING PROPERTY COMPILE_FLAGS "-w"
+    )
+  ELSE(WIN32)
+    set_source_files_properties(${srcs}
+      APPEND_STRING PROPERTY COMPILE_FLAGS
+      "/W1 /wd4018 /wd4996 /wd4244 /wd4267"
+    )
+  ENDIF()
+
+
+  SET(${SRCS} ${srcs} PARENT_SCOPE)
+  SET(${HDRS} ${hdrs} PARENT_SCOPE)
+
+endfunction(mysqlx_protobuf_generate_cpp)
 
 mysqlx_protobuf_generate_cpp(PB_SRCS PB_HDRS ${proto_mysqlx_defs})
 
@@ -129,11 +189,11 @@ target_include_directories(cdk_proto_mys
   ${CMAKE_CURRENT_BINARY_DIR}
 )
 
-if(use_full_protobuf)
-  target_link_libraries(cdk_proto_mysqlx PRIVATE ext::protobuf)
-else()
-  target_link_libraries(cdk_proto_mysqlx PRIVATE ext::protobuf-lite)
-endif()
+#if(use_full_protobuf)
+#  target_link_libraries(cdk_proto_mysqlx PRIVATE ext:protobuf)
+#else()
+#  target_link_libraries(cdk_proto_mysqlx PRIVATE ext::protobuf-lite)
+#endif()
 
 target_link_libraries(cdk_proto_mysqlx
   PRIVATE cdk_foundation ext::z ext::lz4 ext::zstd
Index: b/cdk/core/CMakeLists.txt
===================================================================
--- a/cdk/core/CMakeLists.txt
+++ b/cdk/core/CMakeLists.txt
@@ -45,7 +45,7 @@ add_library(cdk STATIC ${cdk_sources} ${
 
 target_link_libraries(cdk
   PUBLIC  cdk_mysqlx cdk_parser
-  PRIVATE ext::protobuf-lite  # required by codecc.cc
+#  PRIVATE ext::protobuf-lite  # required by codecc.cc
 )
 
 add_coverage(cdk)
openSUSE Build Service is sponsored by