lidavidm commented on a change in pull request #11507:
URL: https://github.com/apache/arrow/pull/11507#discussion_r743911807



##########
File path: cpp/src/arrow/flight/flight-sql/CMakeLists.txt
##########
@@ -0,0 +1,112 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+add_custom_target(arrow_flight_sql)
+
+arrow_install_all_headers("arrow/flight/flight-sql")
+
+set(FLIGHT_SQL_PROTO_PATH "${ARROW_SOURCE_DIR}/../format")
+set(FLIGHT_SQL_PROTO ${ARROW_SOURCE_DIR}/../format/FlightSql.proto)
+
+set(FLIGHT_SQL_GENERATED_PROTO_FILES 
"${CMAKE_CURRENT_BINARY_DIR}/FlightSql.pb.cc"
+                                     
"${CMAKE_CURRENT_BINARY_DIR}/FlightSql.pb.h")
+
+set(PROTO_DEPENDS ${FLIGHT_SQL_PROTO} ${ARROW_PROTOBUF_LIBPROTOBUF} 
gRPC::grpc_cpp_plugin)
+
+add_custom_command(OUTPUT ${FLIGHT_SQL_GENERATED_PROTO_FILES}
+                   COMMAND ${ARROW_PROTOBUF_PROTOC} 
"-I${FLIGHT_SQL_PROTO_PATH}"
+                           "--cpp_out=${CMAKE_CURRENT_BINARY_DIR}" 
"${FLIGHT_SQL_PROTO}"
+                   DEPENDS ${PROTO_DEPENDS} ARGS
+                   COMMAND ${ARROW_PROTOBUF_PROTOC} 
"-I${FLIGHT_SQL_PROTO_PATH}"
+                           "--grpc_out=${CMAKE_CURRENT_BINARY_DIR}"
+                           
"--plugin=protoc-gen-grpc=$<TARGET_FILE:gRPC::grpc_cpp_plugin>"
+                           "${FLIGHT_SQL_PROTO}")
+
+set_source_files_properties(${FLIGHT_SQL_GENERATED_PROTO_FILES} PROPERTIES 
GENERATED TRUE)
+
+add_custom_target(flight_sql_grpc_gen ALL DEPENDS 
${FLIGHT_SQL_GENERATED_PROTO_FILES})
+
+# <KLUDGE> -Werror / /WX cause try_compile to fail because there seems to be no
+# way to pass -isystem $GRPC_INCLUDE_DIR instead of -I$GRPC_INCLUDE_DIR
+set(CMAKE_CXX_FLAGS_BACKUP "${CMAKE_CXX_FLAGS}")
+string(REPLACE "/WX" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+string(REPLACE "-Werror " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+
+set(ARROW_FLIGHT_SQL_SRCS server.cc)
+
+add_arrow_lib(arrow_flight_sql
+              CMAKE_PACKAGE_NAME
+              ArrowFlightSql
+              PKG_CONFIG_NAME
+              arrow-flight-sql
+              OUTPUTS
+              ARROW_FLIGHT_SQL_LIBRARIES
+              SOURCES
+              ${ARROW_FLIGHT_SQL_SRCS}
+              PRECOMPILED_HEADERS
+              "$<$<COMPILE_LANGUAGE:CXX>:arrow/flight/flight-sql/pch.h>"
+              DEPENDENCIES
+              flight_sql_grpc_gen
+              SHARED_LINK_FLAGS
+              ${ARROW_VERSION_SCRIPT_FLAGS} # Defined in 
cpp/arrow/CMakeLists.txt
+              SHARED_LINK_LIBS
+              arrow_flight_shared
+              ${ARROW_FLIGHT_SQL_LINK_LIBS}
+              STATIC_LINK_LIBS
+              arrow_flight_static
+              ${ARROW_FLIGHT_SQL_LINK_LIBS})
+
+if(ARROW_TEST_LINKAGE STREQUAL "static")
+  set(ARROW_FLIGHT_SQL_TEST_LINK_LIBS
+      arrow_flight_sql_static arrow_flight_testing_static
+      ${ARROW_FLIGHT_STATIC_LINK_LIBS} ${ARROW_TEST_LINK_LIBS})
+else()
+  set(ARROW_FLIGHT_SQL_TEST_LINK_LIBS arrow_flight_sql_shared 
arrow_flight_testing_shared
+                                      ${ARROW_TEST_LINK_LIBS})
+endif()
+
+add_arrow_test(flight_sql_test
+               SOURCES
+               client_test.cc
+               server_test.cc
+               "${CMAKE_CURRENT_BINARY_DIR}/FlightSql.pb.cc"

Review comment:
       This appears to fix it for me, by avoiding linking Protobuf in multiple 
times:
   
   @rafael-telles does this work for you?
   
   ```diff
   diff --git a/cpp/src/arrow/flight/CMakeLists.txt 
b/cpp/src/arrow/flight/CMakeLists.txt
   index 309e5a968..66776424e 100644
   --- a/cpp/src/arrow/flight/CMakeLists.txt
   +++ b/cpp/src/arrow/flight/CMakeLists.txt
   @@ -27,11 +27,14 @@ endif()
    
    if(ARROW_TEST_LINKAGE STREQUAL "static")
      set(ARROW_FLIGHT_TEST_LINK_LIBS
   -      arrow_flight_static arrow_flight_testing_static 
${ARROW_FLIGHT_STATIC_LINK_LIBS}
   +      arrow_flight_static
   +      arrow_flight_testing_static
   +      ${ARROW_FLIGHT_STATIC_LINK_LIBS}
   +      gRPC::grpc++
          ${ARROW_TEST_LINK_LIBS})
    else()
      set(ARROW_FLIGHT_TEST_LINK_LIBS arrow_flight_shared 
arrow_flight_testing_shared
   -                                  ${ARROW_TEST_LINK_LIBS})
   +                                  gRPC::grpc++ ${ARROW_TEST_LINK_LIBS})
    endif()
    
    # TODO(wesm): Protobuf shared vs static linking
   @@ -165,6 +168,7 @@ add_arrow_lib(arrow_flight
                  ${ARROW_VERSION_SCRIPT_FLAGS} # Defined in 
cpp/arrow/CMakeLists.txt
                  SHARED_LINK_LIBS
                  arrow_shared
   +              SHARED_PRIVATE_LINK_LIBS
                  ${ARROW_FLIGHT_LINK_LIBS}
                  STATIC_LINK_LIBS
                  arrow_static
   diff --git a/cpp/src/arrow/flight/flight_sql/CMakeLists.txt 
b/cpp/src/arrow/flight/flight_sql/CMakeLists.txt
   index fd453ccc5..8fd852909 100644
   --- a/cpp/src/arrow/flight/flight_sql/CMakeLists.txt
   +++ b/cpp/src/arrow/flight/flight_sql/CMakeLists.txt
   @@ -36,7 +36,8 @@ 
set_source_files_properties(${FLIGHT_SQL_GENERATED_PROTO_FILES} PROPERTIES GENER
    
    add_custom_target(flight_sql_protobuf_gen ALL DEPENDS 
${FLIGHT_SQL_GENERATED_PROTO_FILES})
    
   -set(ARROW_FLIGHT_SQL_SRCS server.cc client.cc client_internal.cc)
   +set(ARROW_FLIGHT_SQL_SRCS server.cc client.cc client_internal.cc
   +                          "${CMAKE_CURRENT_BINARY_DIR}/FlightSql.pb.cc")
    
    add_arrow_lib(arrow_flight_sql
                  CMAKE_PACKAGE_NAME
   @@ -51,10 +52,13 @@ add_arrow_lib(arrow_flight_sql
                  "$<$<COMPILE_LANGUAGE:CXX>:arrow/flight/flight_sql/pch.h>"
                  DEPENDENCIES
                  flight_sql_protobuf_gen
   +              toolchain
                  SHARED_LINK_FLAGS
                  ${ARROW_VERSION_SCRIPT_FLAGS} # Defined in 
cpp/arrow/CMakeLists.txt
                  SHARED_LINK_LIBS
                  arrow_flight_shared
   +              SHARED_PRIVATE_LINK_LIBS
   +              ${ARROW_PROTOBUF_LIBPROTOBUF}
                  STATIC_LINK_LIBS
                  arrow_flight_static)
    
   @@ -75,7 +79,6 @@ target_link_libraries(flight_sql_test_app PRIVATE 
arrow_flight_sql_static
    add_arrow_test(flight_sql_client_test
                   SOURCES
                   client_test.cc
   -               "${CMAKE_CURRENT_BINARY_DIR}/FlightSql.pb.cc"
                   STATIC_LINK_LIBS
                   ${ARROW_FLIGHT_SQL_TEST_LINK_LIBS}
                   LABELS
   @@ -85,7 +88,6 @@ add_arrow_test(flight_sql_server_test
                   SOURCES
                   server_test.cc
                   client_internal.cc
   -               "${CMAKE_CURRENT_BINARY_DIR}/FlightSql.pb.cc"
                   STATIC_LINK_LIBS
                   ${ARROW_FLIGHT_SQL_TEST_LINK_LIBS}
                   LABELS
   @@ -102,8 +104,7 @@ if(ARROW_BUILD_TESTS OR ARROW_BUILD_EXAMPLES)
                     example/sqlite_statement.cc
                     example/sqlite_statement_batch_reader.cc
                     example/sqlite_server.cc
   -                 example/sqlite_tables_schema_batch_reader.cc
   -                 "${CMAKE_CURRENT_BINARY_DIR}/FlightSql.pb.cc")
   +                 example/sqlite_tables_schema_batch_reader.cc)
      target_link_libraries(flight_sql_test_server
                            PRIVATE arrow_flight_sql_static ${GFLAGS_LIBRARIES}
                                    ${SQLite3_LIBRARIES})
   diff --git a/cpp/vcpkg.json b/cpp/vcpkg.json
   index 11ce5250d..1aee71eb8 100644
   --- a/cpp/vcpkg.json
   +++ b/cpp/vcpkg.json
   @@ -17,7 +17,9 @@
        "benchmark",
        "boost-filesystem",
        "boost-multiprecision",
   +    "boost-process",
        "boost-system",
   +    "boost-uuid",
        "brotli",
        "bzip2",
        "c-ares",
   @@ -40,8 +42,5 @@
        "zlib",
        "zstd"
      ],
   -  "overrides": [
   -    { "name": "gtest", "version": "1.10.0", "port-version": 4 }
   -  ],
   -  "builtin-baseline": "b5865bfeba430cd44063fc54a45a8861195a715f"
   +  "builtin-baseline": "85b31152df8da18be5ec2b0dbd7b39b0d2404db4"
    }
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to