From e710e6dbaa1f30ca04ccc40123fbab623c063cfd Mon Sep 17 00:00:00 2001 From: David Li Date: Tue, 28 Jul 2026 12:07:47 +0900 Subject: [PATCH 1/2] build(c): don't allow combined static/shared build on Windows Closes #4581. --- c/cmake_modules/DefineOptions.cmake | 16 ++++++++++++++-- ci/linux-packages/debian/rules | 2 ++ ci/linux-packages/yum/apache-arrow-adbc.spec.in | 2 ++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/c/cmake_modules/DefineOptions.cmake b/c/cmake_modules/DefineOptions.cmake index 50bade29d3..4fa7b9537b 100644 --- a/c/cmake_modules/DefineOptions.cmake +++ b/c/cmake_modules/DefineOptions.cmake @@ -81,6 +81,9 @@ macro(define_option_string name description default) endif() endmacro() +# On Windows, we can't build both static and shared (they both generate a .lib), so disable static build +set(_STATIC_BUILD_DEFAULT NOT WIN32) + # Top level cmake dir if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") #---------------------------------------------------------------------- @@ -94,7 +97,7 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") define_option_string(ADBC_GO_BUILD_TAGS "Build tags to append when compiling ADBC Go libraries" "") - define_option(ADBC_BUILD_STATIC "Build static libraries" ON) + define_option(ADBC_BUILD_STATIC "Build static libraries" _STATIC_BUILD_DEFAULT) define_option(ADBC_BUILD_SHARED "Build shared libraries" ON) @@ -250,8 +253,17 @@ macro(validate_config) endif() endif() endforeach() - endforeach() + + # https://github.com/apache/arrow-adbc/issues/4581 + # Don't allow building both static and shared libraries on Windows + # They both generate a .lib file, and so you get one or the other at random + if(WIN32 + AND ADBC_BUILD_STATIC + AND ADBC_BUILD_SHARED) + message(FATAL_ERROR "Cannot enable both ADBC_BUILD_STATIC and ADBC_BUILD_SHARED on Windows" + ) + endif() endmacro() macro(config_summary_message) diff --git a/ci/linux-packages/debian/rules b/ci/linux-packages/debian/rules index 239dae79eb..9bd274149c 100755 --- a/ci/linux-packages/debian/rules +++ b/ci/linux-packages/debian/rules @@ -39,6 +39,8 @@ override_dh_auto_configure: --buildsystem=cmake+ninja \ -- \ -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \ + -DADBC_BUILD_SHARED=ON \ + -DADBC_BUILD_STATIC=ON \ -DADBC_DRIVER_FLIGHTSQL=ON \ -DADBC_DRIVER_MANAGER=ON \ -DADBC_DRIVER_POSTGRESQL=ON \ diff --git a/ci/linux-packages/yum/apache-arrow-adbc.spec.in b/ci/linux-packages/yum/apache-arrow-adbc.spec.in index cc6df2c8b3..eea668eb7c 100644 --- a/ci/linux-packages/yum/apache-arrow-adbc.spec.in +++ b/ci/linux-packages/yum/apache-arrow-adbc.spec.in @@ -64,6 +64,8 @@ cd c %adbc_cmake \ -DCMAKE_BUILD_TYPE=${cmake_build_type} \ -G"Unix Makefiles" \ + -DADBC_BUILD_SHARED=ON \ + -DADBC_BUILD_STATIC=ON \ -DADBC_DRIVER_FLIGHTSQL=ON \ -DADBC_DRIVER_MANAGER=ON \ -DADBC_DRIVER_POSTGRESQL=ON \ From 6f48dfa177ee2913a95fb70ec758e5c1686f19e7 Mon Sep 17 00:00:00 2001 From: David Li Date: Tue, 28 Jul 2026 18:34:42 +0900 Subject: [PATCH 2/2] doh --- c/cmake_modules/DefineOptions.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/c/cmake_modules/DefineOptions.cmake b/c/cmake_modules/DefineOptions.cmake index 4fa7b9537b..517f860850 100644 --- a/c/cmake_modules/DefineOptions.cmake +++ b/c/cmake_modules/DefineOptions.cmake @@ -82,7 +82,12 @@ macro(define_option_string name description default) endmacro() # On Windows, we can't build both static and shared (they both generate a .lib), so disable static build -set(_STATIC_BUILD_DEFAULT NOT WIN32) +if(WIN32) + set(_STATIC_BUILD_DEFAULT OFF) +else() + set(_STATIC_BUILD_DEFAULT ON) +endif() +message(STATUS "Default static build: ${_STATIC_BUILD_DEFAULT}") # Top level cmake dir if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") @@ -97,7 +102,7 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") define_option_string(ADBC_GO_BUILD_TAGS "Build tags to append when compiling ADBC Go libraries" "") - define_option(ADBC_BUILD_STATIC "Build static libraries" _STATIC_BUILD_DEFAULT) + define_option(ADBC_BUILD_STATIC "Build static libraries" "${_STATIC_BUILD_DEFAULT}") define_option(ADBC_BUILD_SHARED "Build shared libraries" ON)