@@ -29,19 +29,19 @@ set(PROTO_DEPENDS ${FLIGHT_SQL_PROTO} ${ARROW_PROTOBUF_LIBPROTOBUF})
2929
3030add_custom_command (OUTPUT ${FLIGHT_SQL_GENERATED_PROTO_FILES}
3131 COMMAND ${ARROW_PROTOBUF_PROTOC} "-I${FLIGHT_SQL_PROTO_PATH} "
32- "--cpp_out=${CMAKE_CURRENT_BINARY_DIR } " "${FLIGHT_SQL_PROTO} "
32+ "--cpp_out=dllexport_decl=ARROW_FLIGHT_SQL_EXPORT:${CMAKE_CURRENT_BINARY_DIR } "
33+ "${FLIGHT_SQL_PROTO} "
3334 DEPENDS ${PROTO_DEPENDS} )
3435
3536set_source_files_properties (${FLIGHT_SQL_GENERATED_PROTO_FILES} PROPERTIES GENERATED TRUE )
36-
3737add_custom_target (flight_sql_protobuf_gen ALL DEPENDS ${FLIGHT_SQL_GENERATED_PROTO_FILES} )
3838
3939set (ARROW_FLIGHT_SQL_SRCS
4040 server.cc
4141 sql_info_internal.cc
4242 column_metadata.cc
4343 client.cc
44- " ${ CMAKE_CURRENT_BINARY_DIR } /FlightSql.pb.cc" )
44+ protocol_internal.cc )
4545
4646add_arrow_lib (arrow_flight_sql
4747 CMAKE_PACKAGE_NAME
@@ -63,6 +63,14 @@ add_arrow_lib(arrow_flight_sql
6363 PRIVATE_INCLUDES
6464 "${Protobuf_INCLUDE_DIRS} " )
6565
66+ if (MSVC )
67+ # Suppress warnings caused by Protobuf (casts)
68+ set_source_files_properties (protocol_internal.cc PROPERTIES COMPILE_FLAGS "/wd4267" )
69+ endif ()
70+ foreach (LIB_TARGET ${ARROW_FLIGHT_SQL_LIBRARIES} )
71+ target_compile_definitions (${LIB_TARGET} PRIVATE ARROW_FLIGHT_SQL_EXPORTING )
72+ endforeach ()
73+
6674if (ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static" AND ARROW_BUILD_STATIC)
6775 set (ARROW_FLIGHT_SQL_TEST_LINK_LIBS arrow_flight_sql_static)
6876else ()
@@ -81,11 +89,18 @@ if(ARROW_BUILD_TESTS OR ARROW_BUILD_EXAMPLES)
8189 example/sqlite_statement_batch_reader.cc
8290 example/sqlite_server.cc
8391 example/sqlite_tables_schema_batch_reader.cc)
92+ set (ARROW_FLIGHT_SQL_TEST_SRCS server_test.cc)
93+ if (NOT MSVC AND NOT MINGW)
94+ # ARROW-16902: getting Protobuf generated code to have all the
95+ # proper dllexport/dllimport declarations is difficult, since
96+ # protoc does not insert them everywhere needed to satisfy both
97+ # MinGW and MSVC, and the Protobuf team recommends against it
98+ list (APPEND ARROW_FLIGHT_SQL_TEST_SRCS client_test.cc)
99+ endif ()
84100
85101 add_arrow_test (flight_sql_test
86102 SOURCES
87- client_test.cc
88- server_test.cc
103+ ${ARROW_FLIGHT_SQL_TEST_SRCS}
89104 ${ARROW_FLIGHT_SQL_TEST_SERVER_SRCS}
90105 STATIC_LINK_LIBS
91106 ${ARROW_FLIGHT_SQL_TEST_LINK_LIBS}
@@ -102,4 +117,10 @@ if(ARROW_BUILD_TESTS OR ARROW_BUILD_EXAMPLES)
102117 add_executable (flight-sql-test-app test_app_cli.cc )
103118 target_link_libraries (flight-sql-test-app PRIVATE ${ARROW_FLIGHT_SQL_TEST_LINK_LIBS}
104119 ${GFLAGS_LIBRARIES} )
120+
121+ if (ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static" AND ARROW_BUILD_STATIC)
122+ target_compile_definitions (flight_sql_test
123+ flight-sql-test-server flight-sql-test-app
124+ PUBLIC ARROW_FLIGHT_STATIC ARROW_FLIGHT_SQL_STATIC )
125+ endif ()
105126endif ()
0 commit comments