diff --git a/cpp/src/arrow/flight/sql/CMakeLists.txt b/cpp/src/arrow/flight/sql/CMakeLists.txt index 5dbadd1234bb7..d0cac8c4691f4 100644 --- a/cpp/src/arrow/flight/sql/CMakeLists.txt +++ b/cpp/src/arrow/flight/sql/CMakeLists.txt @@ -36,8 +36,8 @@ add_custom_command(OUTPUT ${FLIGHT_SQL_GENERATED_PROTO_FILES} set_source_files_properties(${FLIGHT_SQL_GENERATED_PROTO_FILES} PROPERTIES GENERATED TRUE) if(MSVC) # Suppress warnings caused by Protobuf (casts, dll-interface) - set_source_files_properties(${FLIGHT_SQL_GENERATED_PROTO_FILES} - PROPERTIES COMPILE_FLAGS "/wd4251 /wd4267") + set_source_files_properties(${FLIGHT_SQL_GENERATED_PROTO_FILES} PROPERTIES COMPILE_FLAGS + "/wd4267") endif() add_custom_target(flight_sql_protobuf_gen ALL DEPENDS ${FLIGHT_SQL_GENERATED_PROTO_FILES}) @@ -47,7 +47,7 @@ set(ARROW_FLIGHT_SQL_SRCS sql_info_internal.cc column_metadata.cc client.cc - "${CMAKE_CURRENT_BINARY_DIR}/FlightSql.pb.cc") + protocol_internal.cc) add_arrow_lib(arrow_flight_sql CMAKE_PACKAGE_NAME diff --git a/cpp/src/arrow/flight/sql/client.cc b/cpp/src/arrow/flight/sql/client.cc index 3ce220491f173..10ff1eea6f4cb 100644 --- a/cpp/src/arrow/flight/sql/client.cc +++ b/cpp/src/arrow/flight/sql/client.cc @@ -23,7 +23,7 @@ #include #include "arrow/buffer.h" -#include "arrow/flight/sql/FlightSql.pb.h" +#include "arrow/flight/sql/protocol_internal.h" #include "arrow/flight/types.h" #include "arrow/io/memory.h" #include "arrow/ipc/reader.h" diff --git a/cpp/src/arrow/flight/sql/client_test.cc b/cpp/src/arrow/flight/sql/client_test.cc index c25a3e02b8c60..54c2b73af0f5a 100644 --- a/cpp/src/arrow/flight/sql/client_test.cc +++ b/cpp/src/arrow/flight/sql/client_test.cc @@ -26,11 +26,17 @@ #include +// XXX(ARROW-16902): Protobuf doesn't insert dllimport declarations in +// all the right places for MinGW (causing an error "redeclared +// without dllimport attribute"). Instead, just omit them and rely on +// symbols being found implicitly. +#if defined(__MINGW32__) +#define ARROW_FLIGHT_SQL_STATIC +#endif // Must come before Protobuf include -#include "arrow/flight/sql/visibility.h" +#include "arrow/flight/sql/protocol_internal.h" #include "arrow/buffer.h" -#include "arrow/flight/sql/FlightSql.pb.h" #include "arrow/flight/sql/api.h" #include "arrow/testing/gtest_util.h" diff --git a/cpp/src/arrow/flight/sql/protocol_internal.cc b/cpp/src/arrow/flight/sql/protocol_internal.cc new file mode 100644 index 0000000000000..0d5e3c4c60b8d --- /dev/null +++ b/cpp/src/arrow/flight/sql/protocol_internal.cc @@ -0,0 +1,23 @@ +// 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 + +#include "arrow/flight/sql/protocol_internal.h" + +// NOTE(lidavidm): Normally this is forbidden, but on Windows to get +// the dllexport/dllimport macro in the right places, we need to +// ensure our header gets included (and Protobuf will not insert the +// include for you) +#include "arrow/flight/sql/FlightSql.pb.cc" // NOLINT diff --git a/cpp/src/arrow/flight/sql/protocol_internal.h b/cpp/src/arrow/flight/sql/protocol_internal.h new file mode 100644 index 0000000000000..ce50ad2f61b1e --- /dev/null +++ b/cpp/src/arrow/flight/sql/protocol_internal.h @@ -0,0 +1,26 @@ +// 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 + +#pragma once + +// This addresses platform-specific defines, e.g. on Windows +#include "arrow/flight/platform.h" // IWYU pragma: keep + +// This header holds the Flight SQL definitions. + +#include "arrow/flight/sql/visibility.h" + +#include "arrow/flight/sql/FlightSql.pb.h" // IWYU pragma: export diff --git a/cpp/src/arrow/flight/sql/server.cc b/cpp/src/arrow/flight/sql/server.cc index c82146de86da3..0ebe647ba1490 100644 --- a/cpp/src/arrow/flight/sql/server.cc +++ b/cpp/src/arrow/flight/sql/server.cc @@ -27,7 +27,7 @@ #include "arrow/buffer.h" #include "arrow/builder.h" -#include "arrow/flight/sql/FlightSql.pb.h" +#include "arrow/flight/sql/protocol_internal.h" #include "arrow/flight/sql/sql_info_internal.h" #include "arrow/type.h" #include "arrow/util/checked_cast.h"