Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
bd4eb4b
Set up static build of ODBC FlightSQL driver
amoeba Mar 24, 2026
36d5d09
Set CMAKE_MSVC_RUNTIME_LIBRARY
amoeba Mar 24, 2026
79edd5b
wip
amoeba Mar 25, 2026
dbabf18
Revert "Set CMAKE_MSVC_RUNTIME_LIBRARY"
amoeba Mar 25, 2026
5e05136
testing
amoeba Mar 26, 2026
5b17b16
last set of fixes
amoeba Mar 27, 2026
f6859cd
more testing
amoeba Mar 30, 2026
8444488
Update odbc_test_suite.cc
amoeba Mar 31, 2026
28c1079
Check ARROW_FLIGHT_TEST_LINKAGE
amoeba Mar 31, 2026
207d9a2
force static link libs
amoeba Mar 31, 2026
3ca1934
Update CMakeLists.txt
amoeba Apr 4, 2026
298afcd
Update CMakeLists.txt
amoeba Apr 4, 2026
4f66324
Update cpp_extra.yml
amoeba Apr 4, 2026
f96f04a
cleanup unneeded cmake
amoeba Apr 4, 2026
bf511a2
remove comments
amoeba Apr 7, 2026
62c1e85
formatting
amoeba Apr 7, 2026
5249de0
Simplify odbc_impl test linkage cmake directives
amoeba Apr 7, 2026
406d1e3
cleanup
amoeba Apr 7, 2026
e3f1a41
Update CMakeLists.txt
amoeba Apr 7, 2026
1248587
format
amoeba Apr 10, 2026
943f587
try to fix macos test crash
amoeba Apr 10, 2026
1938175
format
amoeba Apr 10, 2026
96478b8
add missing header
amoeba Apr 11, 2026
2309b53
testing
amoeba Apr 11, 2026
1898d6e
format
amoeba Apr 11, 2026
5b479f3
Fix rebase mistake
amoeba Apr 22, 2026
acb06e8
add workaround
amoeba Apr 22, 2026
fe092b0
update comment
amoeba Apr 22, 2026
12aa833
fix rebase issue with linking
amoeba Apr 22, 2026
27ea5b4
restore comment
amoeba Apr 22, 2026
81b6b4c
update comment
amoeba Apr 22, 2026
9ecc3fc
fix more targets
amoeba Apr 22, 2026
009c48b
more fixes
amoeba Apr 23, 2026
94b4ba1
update comments
amoeba Apr 23, 2026
a2eb217
update comments
amoeba Apr 23, 2026
3be8697
comments
amoeba Apr 23, 2026
38d0b18
guard overrides better
amoeba Apr 23, 2026
710ed57
cmake-format
amoeba Apr 23, 2026
4bc2cf6
format
amoeba Jun 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/cpp_extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,8 @@ jobs:
contents: read
packages: write
env:
ARROW_BUILD_SHARED: ON
ARROW_BUILD_STATIC: OFF
ARROW_BUILD_SHARED: OFF
ARROW_BUILD_STATIC: ON
ARROW_BUILD_TESTS: ON
ARROW_BUILD_TYPE: release
# Turn Arrow CSV off to disable `find_package(Arrow)` check on MSVC CI.
Expand All @@ -597,6 +597,10 @@ jobs:
# Build Arrow with GPR_DISABLE_ABSEIL_SYNC so grpcpp's Mutex ABI
# matches the gRPC rebuilt by the overlay triplet. Remove once fixed upstream.
ARROW_CXXFLAGS: -DGPR_DISABLE_ABSEIL_SYNC
ARROW_DEPENDENCY_USE_SHARED: OFF
ARROW_MIMALLOC: OFF
ARROW_TEST_LINKAGE: shared
ARROW_USE_STATIC_CRT: OFF
Comment on lines +600 to +603
CMAKE_GENERATOR: Ninja
CMAKE_INSTALL_PREFIX: /usr
VCPKG_BINARY_SOURCES: 'clear;nugettimeout,600;nuget,GitHub,readwrite'
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/package_odbc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,24 @@ jobs:
permissions:
packages: write
env: &odbc_msvc_env
ARROW_BUILD_SHARED: ON
ARROW_BUILD_STATIC: OFF
ARROW_BUILD_SHARED: OFF
ARROW_BUILD_STATIC: ON
ARROW_BUILD_TESTS: OFF
ARROW_BUILD_TYPE: release
# Turn Arrow CSV off to disable `find_package(Arrow)` check on MSVC CI.
# Turn Arrow CSV off to disable `find_package(Arrow)` check on MSVC CI.
# GH-49050 TODO: enable `find_package(Arrow)` check on MSVC CI.
ARROW_CSV: OFF
ARROW_DEPENDENCY_SOURCE: VCPKG
ARROW_DEPENDENCY_USE_SHARED: OFF
ARROW_FLIGHT_SQL_ODBC: ON
ARROW_FLIGHT_SQL_ODBC_INSTALLER: ON
ARROW_HOME: /usr
ARROW_MIMALLOC: OFF
ARROW_USE_STATIC_CRT: OFF
CMAKE_GENERATOR: Ninja
CMAKE_INSTALL_PREFIX: /usr
VCPKG_BINARY_SOURCES: 'clear;nugettimeout,600;nuget,GitHub,readwrite'
VCPKG_DEFAULT_TRIPLET: x64-windows
VCPKG_DEFAULT_TRIPLET: x64-windows-static-md
steps:
- name: Checkout Arrow
uses: actions/checkout@v6
Expand Down
4 changes: 2 additions & 2 deletions ci/vcpkg/amd64-windows-no-absl-sync-release.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

# GH-49465: rebuild gRPC with native sync instead of absl::Mutex to avoid the
# Windows exit hang. See the ODBC Windows job in cpp_extra.yml
# Dynamic CRT/linkage and release-only to match that job.
# Static library linkage, dynamic CRT (/MD), release-only to match that job.
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)

set(VCPKG_C_FLAGS "/DGPR_DISABLE_ABSEIL_SYNC")
Expand Down
50 changes: 48 additions & 2 deletions cpp/src/arrow/flight/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ function(arrow_set_generated_proto_files_properties)
set(GENERATED_FILES ${ARGN})
set_source_files_properties(${GENERATED_FILES} PROPERTIES GENERATED TRUE)
if(MSVC)
# Suppress missing dll-interface warning
# Suppress warnings caused by Protobuf (dll-interface)
set_source_files_properties(${GENERATED_FILES}
PROPERTIES COMPILE_OPTIONS "/wd4251"
PROPERTIES COMPILE_OPTIONS "/wd4251;/wd4275"
SKIP_UNITY_BUILD_INCLUSION TRUE)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Disable -Wmissing-declarations
Expand Down Expand Up @@ -245,6 +245,15 @@ if(ARROW_BUILD_STATIC AND WIN32)
target_compile_definitions(arrow_flight_static PUBLIC ARROW_FLIGHT_STATIC)
endif()

# NOTE-49585: Workaround for issue found in GH-49585. See "NOTE-49585" below.
if(WIN32
AND CMAKE_BUILD_TYPE STREQUAL "Debug"
AND ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static")
foreach(LIB_TARGET ${ARROW_FLIGHT_LIBRARIES})
target_link_options(${LIB_TARGET} PRIVATE "/FORCE:MULTIPLE")
endforeach()
endif()
Comment on lines +249 to +255

foreach(LIB_TARGET ${ARROW_FLIGHT_LIBRARIES})
target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_EXPORTING)
endforeach()
Expand Down Expand Up @@ -371,6 +380,43 @@ if(ARROW_BUILD_BENCHMARKS)

endif(ARROW_BUILD_BENCHMARKS)

# NOTE-49585: Workaround for issue found in GH-49585. When building Flight
# targets with the combination of:
#
# - WIN32
# - Debug
# - /MD linkage
#
# You get linker errors like this:
#
# absl_synchronization.lib(mutex.cc.obj) : error LNK2005: "private: void __cdecl absl::lts_20250814::Mutex::Dtor(void)" (?Dtor
# @Mutex@lts_20250814@absl@@AEAAXXZ) already defined in arrow_flight_static.lib(grpc_client.obj) [C:\path\to\arrow\cpp\static-debug-build\src\arrow\flight\sql\arrow-flight-sql-test.vcxproj]
# C:\path\to\arrow\cpp\static-debug-build\debug\Debug\arrow-flight-sql-test.exe :
# fatal error LNK1169: one or more multiply defined symbols found [C:\path\to\arrow\cpp\static-debug-build\src\arrow\flight\sql\arrow-flight-sql-test.vcxproj]
# Building Custom Rule C:/path/to/arrow/cpp/src/arrow/flight/CMakeLists.txt
# test_server.cc
# absl_synchronization.lib(mutex.cc.obj) : error LNK2005: "private: void __cdecl absl::lts_20250814::Mutex::Dtor(void)" (?Dtor
# @Mutex@lts_20250814@absl@@AEAAXXZ) already defined in arrow_flight_static.lib(protocol_grpc_internal.obj) [C:\path\to\arrow\cpp\static-debug-build\src\arrow\flight\flight-test-server.vcxproj]
# C:\path\to\arrow\cpp\static-debug-build\debug\Debug\flight-test-server.exe : fatal error
# LNK1169: one or more multiply defined symbols found [C:\path\to\arrow\cpp\static-debug-build\src\arrow\flight\flight-test-server.vcxproj]
#
# If you build in Release mode w/ /MD linkage you don't get these errors.
if(WIN32
AND CMAKE_BUILD_TYPE STREQUAL "Debug"
AND ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static")
set(FLIGHT_TEST_EXES
arrow-flight-internals-test
arrow-flight-test
flight-test-server
arrow-flight-perf-server
arrow-flight-benchmark)
foreach(test_exe ${FLIGHT_TEST_EXES})
if(TARGET ${test_exe})
target_link_options(${test_exe} PRIVATE "/FORCE:MULTIPLE")
endif()
endforeach()
endif()
Comment on lines +404 to +418

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lidavidm @raulcd @kou do any of you have any thoughts on this workaround I came up with using Claude? I can dig in more if any of you want.

It makes sense that the duplicate symbol could show up twice with how the build is set up and I can see why this only shows up in Debug builds: https://github.com/abseil/abseil-cpp/blob/master/absl/synchronization/mutex.h#L1197.

The /FORCE:MULTIPLE workaround seems like a heavy fix.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happens despite linking everything statically? Ugh, I guess it is what it is. (Also: is it just me, or do the preprocessor condition and the comment there contradict each other? The symbol is only defined when not building DLL)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gentle ping @lidavidm @raulcd @kou Do you think this PR can be merged?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I see the full command line when the link error happens?

if(ARROW_FLIGHT_SQL)
add_subdirectory(sql)

Expand Down
26 changes: 26 additions & 0 deletions cpp/src/arrow/flight/sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,26 @@ if(ARROW_BUILD_STATIC AND WIN32)
target_compile_definitions(arrow_flight_sql_static PUBLIC ARROW_FLIGHT_SQL_STATIC)
endif()

# NOTE-49585: Workaround for issue found in GH-49585. See "NOTE-49585" in
# ../CMakeLists.txt.
if(WIN32
AND CMAKE_BUILD_TYPE STREQUAL "Debug"
AND ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static")
foreach(LIB_TARGET ${ARROW_FLIGHT_SQL_LIBRARIES})
target_link_options(${LIB_TARGET} PRIVATE "/FORCE:MULTIPLE")
endforeach()
endif()
Comment on lines +98 to +104

if(MSVC)
# Suppress warnings caused by Protobuf (casts)
set_source_files_properties(protocol_internal.cc PROPERTIES COMPILE_OPTIONS "/wd4267")
endif()
foreach(LIB_TARGET ${ARROW_FLIGHT_SQL_LIBRARIES})
target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_SQL_EXPORTING)
if(MSVC)
# Suppress warnings caused by Protobuf (dll-interface)
target_compile_options(${LIB_TARGET} PRIVATE "/wd4275")
endif()
endforeach()

if(ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static" AND ARROW_BUILD_STATIC)
Expand Down Expand Up @@ -177,6 +191,18 @@ if(ARROW_BUILD_TESTS OR ARROW_BUILD_EXAMPLES)
ARROW_FLIGHT_SQL_STATIC)
endforeach()
endif()

# NOTE-49585: Workaround for issue found in GH-49585. See "NOTE-49585" in
# ../CMakeLists.txt.
if(WIN32
AND CMAKE_BUILD_TYPE STREQUAL "Debug"
AND ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static")
foreach(TEST_TARGET arrow-flight-sql-test flight-sql-test-server flight-sql-test-app)
if(TARGET ${TEST_TARGET})
target_link_options(${TEST_TARGET} PRIVATE "/FORCE:MULTIPLE")
endif()
endforeach()
endif()
Comment on lines +197 to +205
endif()

if(ARROW_FLIGHT_SQL_ODBC)
Expand Down
52 changes: 33 additions & 19 deletions cpp/src/arrow/flight/sql/odbc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,34 @@ if(WIN32)
list(APPEND ARROW_FLIGHT_SQL_ODBC_SRCS odbc.def install/versioninfo.rc)
endif()

# On Windows, dynmaic build for ODBC is supported.
# On unix systems, static build for ODBC is supported, all libraries are linked statically on unix.
set(ARROW_FLIGHT_SQL_ODBC_DEPENDENCIES "")
# Initialize install interface libs (only set in Windows static build)
set(ARROW_FLIGHT_SQL_ODBC_SHARED_INSTALL_INTERFACE_LIBS "")
set(ARROW_FLIGHT_SQL_ODBC_STATIC_INSTALL_INTERFACE_LIBS "")
set(ARROW_FLIGHT_SQL_ODBC_SHARED_PRIVATE_LINK_LIBS "")

if(WIN32)
set(ARROW_FLIGHT_SQL_ODBC_DEPENDENCIES arrow_flight_sql)
set(ARROW_FLIGHT_SQL_ODBC_SHARED_LINK_LIBS arrow_flight_sql_shared arrow_odbc_spi_impl)
set(ARROW_FLIGHT_SQL_ODBC_STATIC_LINK_LIBS arrow_flight_sql_static)
list(APPEND ARROW_FLIGHT_SQL_ODBC_SHARED_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_shared)
list(APPEND ARROW_FLIGHT_SQL_ODBC_STATIC_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_static)
if(ARROW_BUILD_STATIC)
# Static Arrow deps on Windows — self-contained ODBC DLL
set(ARROW_FLIGHT_SQL_ODBC_SHARED_LINK_LIBS arrow_flight_sql_static
arrow_odbc_spi_impl)
set(ARROW_FLIGHT_SQL_ODBC_STATIC_LINK_LIBS arrow_flight_sql_static)
list(APPEND ARROW_FLIGHT_SQL_ODBC_SHARED_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_static)
list(APPEND ARROW_FLIGHT_SQL_ODBC_STATIC_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_static)
else()
set(ARROW_FLIGHT_SQL_ODBC_SHARED_LINK_LIBS arrow_flight_sql_shared
arrow_odbc_spi_impl)
set(ARROW_FLIGHT_SQL_ODBC_STATIC_LINK_LIBS arrow_flight_sql_static)
list(APPEND ARROW_FLIGHT_SQL_ODBC_SHARED_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_shared)
list(APPEND ARROW_FLIGHT_SQL_ODBC_STATIC_INSTALL_INTERFACE_LIBS
ArrowFlight::arrow_flight_sql_static)
endif()
list(APPEND ARROW_FLIGHT_SQL_ODBC_SHARED_PRIVATE_LINK_LIBS ODBC::ODBC ${ODBCINST})
else()
# Unix
# Unix/macOS: driver dynamically links arrow_flight_sql so the driver and test
# binary share the same grpc/arrow_flight runtime.
set(ARROW_FLIGHT_SQL_ODBC_SHARED_LINK_LIBS arrow_odbc_spi_impl)
set(ARROW_FLIGHT_SQL_ODBC_STATIC_LINK_LIBS ODBC::ODBC ${ODBCINST})
endif()
Expand All @@ -91,8 +102,6 @@ add_arrow_lib(arrow_flight_sql_odbc
${ARROW_FLIGHT_SQL_ODBC_SRCS}
DEFINITIONS
UNICODE
DEPENDENCIES
${ARROW_FLIGHT_SQL_ODBC_DEPENDENCIES}
SHARED_LINK_FLAGS
${ARROW_VERSION_SCRIPT_FLAGS} # Defined in cpp/arrow/CMakeLists.txt
SHARED_LINK_LIBS
Expand All @@ -106,6 +115,16 @@ add_arrow_lib(arrow_flight_sql_odbc
SHARED_PRIVATE_LINK_LIBS
${ARROW_FLIGHT_SQL_ODBC_SHARED_PRIVATE_LINK_LIBS})

# NOTE-49585: Workaround for issue found in GH-49585. See "NOTE-49585" in
# ../../CMakeLists.txt.
if(WIN32
AND CMAKE_BUILD_TYPE STREQUAL "Debug"
AND ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static")
foreach(LIB_TARGET ${ARROW_FLIGHT_SQL_ODBC_LIBRARIES})
target_link_options(${LIB_TARGET} PRIVATE "/FORCE:MULTIPLE")
endforeach()
endif()
Comment on lines +120 to +126

foreach(LIB_TARGET ${ARROW_FLIGHT_SQL_ODBC_LIBRARIES})
target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_SQL_ODBC_EXPORTING)
endforeach()
Expand All @@ -130,15 +149,10 @@ if(ARROW_FLIGHT_SQL_ODBC_INSTALLER)
set(CPACK_PACKAGE_CONTACT "dev@arrow.apache.org")

if(WIN32)
# Install ODBC and its Arrow dependencies
install(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
DESTINATION bin
COMPONENT ArrowFlightSQLODBC)
install(TARGETS arrow_shared
arrow_compute_shared
arrow_flight_shared
arrow_flight_sql_shared
arrow_flight_sql_odbc_shared
install(TARGETS arrow_flight_sql_odbc_shared
RUNTIME_DEPENDENCIES
PRE_EXCLUDE_REGEXES
"api-ms-.*"
Expand Down
46 changes: 37 additions & 9 deletions cpp/src/arrow/flight/sql/odbc/odbc_impl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,15 @@ endif()
if(WIN32)
find_package(ODBC REQUIRED)
target_include_directories(arrow_odbc_spi_impl PUBLIC ${ODBC_INCLUDE_DIR})
target_link_libraries(arrow_odbc_spi_impl
PUBLIC arrow_flight_sql_shared arrow_compute_shared Boost::locale
${ODBCINST})
if(ARROW_BUILD_STATIC)
target_link_libraries(arrow_odbc_spi_impl
PUBLIC arrow_flight_sql_static arrow_compute_static
Boost::locale ${ODBCINST})
else()
target_link_libraries(arrow_odbc_spi_impl
PUBLIC arrow_flight_sql_shared arrow_compute_shared
Boost::locale ${ODBCINST})
endif()
else()
# Unix
target_include_directories(arrow_odbc_spi_impl SYSTEM BEFORE PUBLIC ${ODBC_INCLUDE_DIR})
Expand Down Expand Up @@ -163,11 +169,19 @@ target_link_libraries(arrow_odbc_spi_impl_cli arrow_odbc_spi_impl)

# On Windows, dynamic linking ODBC is supported.
# On unix systems, static linking ODBC is supported, thus the library linking is static.
if(WIN32)
set(ODBC_SPI_IMPL_TEST_LINK_LIBS arrow_flight_testing_shared)
# Use STATIC_LINK_LIBS when Flight tests require static linkage to avoid mixing static/shared Arrow
if(WIN32 AND ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static")
set(ODBC_SPI_IMPL_TEST_STATIC_LIBS arrow_odbc_spi_impl arrow_flight_testing_static
${ARROW_TEST_STATIC_LINK_LIBS})
set(ODBC_SPI_IMPL_TEST_EXTRA_LIBS "")
elseif(WIN32)
set(ODBC_SPI_IMPL_TEST_STATIC_LIBS "")
set(ODBC_SPI_IMPL_TEST_EXTRA_LIBS arrow_odbc_spi_impl arrow_flight_testing_shared)
else()
# unix
set(ODBC_SPI_IMPL_TEST_LINK_LIBS arrow_flight_testing_static)
# Unix - always static
set(ODBC_SPI_IMPL_TEST_STATIC_LIBS arrow_odbc_spi_impl arrow_flight_testing_static
${ARROW_TEST_STATIC_LINK_LIBS})
set(ODBC_SPI_IMPL_TEST_EXTRA_LIBS "")
endif()

add_arrow_test(odbc_spi_impl_test
Expand All @@ -187,5 +201,19 @@ add_arrow_test(odbc_spi_impl_test
record_batch_transformer_test.cc
util_test.cc
EXTRA_LINK_LIBS
arrow_odbc_spi_impl
${ODBC_SPI_IMPL_TEST_LINK_LIBS})
${ODBC_SPI_IMPL_TEST_EXTRA_LIBS}
STATIC_LINK_LIBS
${ODBC_SPI_IMPL_TEST_STATIC_LIBS})

# NOTE-49585: Workaround for issue found in GH-49585. See "NOTE-49585" in
# ../../../CMakeLists.txt.
if(WIN32
AND CMAKE_BUILD_TYPE STREQUAL "Debug"
AND ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static")
if(TARGET arrow_odbc_spi_impl_cli)
target_link_options(arrow_odbc_spi_impl_cli PRIVATE "/FORCE:MULTIPLE")
endif()
if(TARGET arrow-odbc-spi-impl-test)
target_link_options(arrow-odbc-spi-impl-test PRIVATE "/FORCE:MULTIPLE")
endif()
endif()
Comment on lines +210 to +219
36 changes: 23 additions & 13 deletions cpp/src/arrow/flight/sql/odbc/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ set(ARROW_FLIGHT_SQL_ODBC_TEST_SRCS
# GH-46889: move protobuf_test_util to a more common location
../../../../engine/substrait/protobuf_test_util.cc)

# GH-49651 Link ODBC tests statically on Linux and dynamically on macOS/Windows
if(WIN32 OR APPLE)
# GH-49651 Link ODBC tests statically on Linux and dynamically on macOS.
if(APPLE OR (WIN32 AND ARROW_TEST_LINKAGE STREQUAL "shared"))
set(ARROW_FLIGHT_SQL_ODBC_TEST_LINK_LIBS arrow_flight_sql_odbc_shared
${ARROW_TEST_SHARED_LINK_LIBS})
else()
Expand All @@ -56,24 +56,26 @@ endif()
set(ARROW_FLIGHT_SQL_ODBC_TEST_LIBS ${ODBCINST} ${ODBC_LIBRARIES} ${SQLite3_LIBRARIES})

# On Windows, dynamic linking ODBC is supported, tests link libraries dynamically.
# On unix systems, static linking ODBC is supported, thus tests link libraries statically.
# On Windows with static Arrow, use STATIC_LINK_LIBS to avoid mixing static/shared.
# On Unix/macOS, tests link libraries statically.
set(ARROW_FLIGHT_SQL_ODBC_TEST_EXTRA_LINK_LIBS "")
set(ARROW_FLIGHT_SQL_ODBC_TEST_STATIC_LINK_LIBS "")
if(WIN32)
# arrow_odbc_spi_impl is required on Windows due to dynamic linking
if(WIN32 AND ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static")
# Static Windows tests
list(APPEND
ARROW_FLIGHT_SQL_ODBC_TEST_STATIC_LINK_LIBS
arrow_odbc_spi_impl
${ARROW_FLIGHT_SQL_ODBC_TEST_LIBS}
${ARROW_FLIGHT_SQL_ODBC_TEST_LINK_LIBS}
${ARROW_TEST_STATIC_LINK_LIBS})
elseif(WIN32)
Comment on lines +63 to +71
# Dynamic Windows tests
list(APPEND ARROW_FLIGHT_SQL_ODBC_TEST_EXTRA_LINK_LIBS arrow_odbc_spi_impl
${ARROW_FLIGHT_SQL_ODBC_TEST_LIBS})
else()
# Unix
# Unix/macOS
list(APPEND ARROW_FLIGHT_SQL_ODBC_TEST_STATIC_LINK_LIBS
${ARROW_FLIGHT_SQL_ODBC_TEST_LIBS} ${ARROW_FLIGHT_SQL_ODBC_TEST_LINK_LIBS})

if(NOT APPLE)
# Links static dependencies on Linux to support ARROW_TEST_LINKAGE=static
list(APPEND ARROW_FLIGHT_SQL_ODBC_TEST_STATIC_LINK_LIBS arrow_odbc_spi_impl
${ARROW_PROTOBUF_LIBPROTOBUF})
endif()

endif()

add_arrow_test(flight_sql_odbc_test
Expand All @@ -92,3 +94,11 @@ target_link_libraries(arrow-flight-sql-odbc-test PRIVATE ODBC::ODBC)

# Disable unity build due to sqlite_sql_info.cc conflict with sql.h and sqlext.h headers.
set_target_properties(arrow-flight-sql-odbc-test PROPERTIES UNITY_BUILD OFF)

if(WIN32
AND CMAKE_BUILD_TYPE STREQUAL "Debug"
AND ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static")
if(TARGET arrow-flight-sql-odbc-test)
target_link_options(arrow-flight-sql-odbc-test PRIVATE "/FORCE:MULTIPLE")
endif()
endif()
Comment on lines +98 to +104
Loading
Loading