This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 656065b2c9d GH-55279: [C++] Fix build errors with
ARROW_BUILD_{SHARED,STATIC,TESTS}=ON on Windows (#55294)
656065b2c9d is described below
commit 656065b2c9d4b060edef56773d9d20f1d5a6e1ad
Author: Sutou Kouhei <[email protected]>
AuthorDate: Mon Nov 2 18:00:01 2026 +0900
GH-55279: [C++] Fix build errors with ARROW_BUILD_{SHARED,STATIC,TESTS}=ON
on Windows (#55294)
### Rationale for this change
We can't build Arrow C++ with `ARROW_BUILD_SHARED=ON`,
`ARROW_BUILD_STATIC=ON` and `ARROW_BUILD_TESTS=ON` on Windows. Tests are linked
with shared libraries by default (`ARROW_TEST_LINKAGE=shared`) but some targets
use `ARROW_BUILD_STATIC` to choose static libraries/definitions:
* `arrow_compute_testing` is an object library and it sets
`ARROW_STATIC`/`ARROW_COMPUTE_STATIC` as public compile definitions with
`ARROW_BUILD_STATIC`. So tests that use `arrow_compute_testing` are compiled
with `ARROW_STATIC`/`ARROW_COMPUTE_STATIC` even when they are linked with
shared libraries.
* `arrow-compute-grouper-benchmark` links `arrow_compute_static` with
`ARROW_BUILD_STATIC`. So it's linked with both of `arrow_static` and
`arrow_shared`.
`parquet_static` can't be built with Parquet encryption on Windows too. It
doesn't link OpenSSL. We don't use a shared object library for shared and
static libraries on Windows. So `parquet_static` can't find OpenSSL headers.
`parquet/arrow/reader.cc` uses OpenTelemetry headers via
`arrow/util/tracing_internal.h` but `parquet_static` doesn't link OpenTelemetry.
Our CI doesn't detect them because we don't have any Windows job that uses
`ARROW_BUILD_SHARED=ON` and `ARROW_BUILD_STATIC=ON`.
There are similar problems that aren't detected by our CI:
* Parquet benchmarks use `parquet_shared` with static test libraries when
`ARROW_BUILD_SHARED=ON`, `ARROW_BUILD_STATIC=ON` and
`ARROW_TEST_LINKAGE=static`. So they're linked with both of `arrow_static` and
`arrow_shared`.
* `parquet_testing` is an object library that doesn't have
`ARROW_STATIC`/`PARQUET_STATIC`. So `parquet/test_util.cc` is compiled without
them even when tests are linked with static libraries on Windows.
### What changes are included in this PR?
* Use `ARROW_BUILD_STATIC=ON` in the Windows CI job to detect this case.
* Link OpenSSL to `parquet_static` when Parquet encryption is enabled.
* Link OpenTelemetry to `parquet_static` when OpenTelemetry is enabled.
* Use static libraries instead of object libraries for
`arrow_compute_core_testing`, `arrow_compute_kernels_testing`,
`arrow_acero_testing`, `arrow_dataset_testing` and `parquet_testing`. They link
libraries for `ARROW_TEST_LINKAGE` as `PUBLIC`. So they're compiled with the
same compile definitions (e.g. `ARROW_STATIC` on Windows) as tests. We don't
need to set `ARROW_STATIC`/`ARROW_COMPUTE_STATIC` manually. Their sources are
compiled only once.
* Split `arrow_compute_testing` to `arrow_compute_core_testing` (helpers)
and `arrow_compute_testing_main` (`main()` in `test_env.cc`).
* `arrow_compute_testing_main` is an interface library. If we use a
static library for it, `main()` in `GTest::gmock_main` may be used instead of
`main()` in `test_env.cc`. Interface library sources are compiled as sources of
each test executable, so `main()` in `test_env.cc` is always used.
* `arrow_compute_testing_main` doesn't link any Arrow library. So it can
be used by tests that use different linkage from `ARROW_TEST_LINKAGE` such as
Flight SQL tests (`ARROW_FLIGHT_TEST_LINKAGE`).
* `arrow_compute_testing_main` must not be linked as `PUBLIC` from static
testing libraries. If it's linked as `PUBLIC`, `test_env.cc` is also compiled
into these static libraries. So tests link it explicitly.
* Use testing libraries instead of `ARROW_ACERO_TEST_LINK_LIBS`,
`ARROW_DATASET_TEST_LINK_LIBS` and `PARQUET_TEST_LINK_LIBS` in tests and
benchmarks. Testing libraries already link libraries for `ARROW_TEST_LINKAGE`.
* Use `ARROW_TEST_LINKAGE` instead of `ARROW_BUILD_STATIC` to choose a
compute library for `arrow-compute-grouper-benchmark`.
* Use `ARROW_TEST_LINKAGE` instead of `ARROW_BUILD_SHARED` to choose a
Parquet library for Parquet benchmarks.
Note that the ORC adapter test still uses `ARROW_BUILD_STATIC` to choose
libraries. It uses liborc directly and links `orc::orc`. If it's linked with
`arrow_shared`, ORC's protobuf messages are registered twice (by `libarrow` and
the test). We'll work on it separately if we need it.
### Are these changes tested?
Yes.
### Are there any user-facing changes?
No.
### Was AI used for this PR?
In accordance to the [AI generation
guidelines](https://arrow.apache.org/docs/dev/developers/overview.html#ai-generated-code),
please disclose below whether and how AI was used in this PR.
**PR code and description written by:**
- [x] Human
- [x] AI
**Reviewed before submission by:**
- [x] Human
- [x] AI
- [ ] Not reviewed
* GitHub Issue: #55279
Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
---
.github/workflows/cpp_windows.yml | 2 +-
cpp/src/arrow/acero/CMakeLists.txt | 45 +++++++----------
cpp/src/arrow/c/CMakeLists.txt | 5 +-
cpp/src/arrow/compute/CMakeLists.txt | 46 ++++++++++-------
cpp/src/arrow/compute/kernels/CMakeLists.txt | 33 ++++++------
cpp/src/arrow/compute/row/CMakeLists.txt | 2 +-
cpp/src/arrow/compute/test_util_internal.cc | 2 +-
cpp/src/arrow/dataset/CMakeLists.txt | 34 ++++++-------
cpp/src/arrow/engine/CMakeLists.txt | 2 +-
cpp/src/arrow/flight/sql/CMakeLists.txt | 2 +-
cpp/src/parquet/CMakeLists.txt | 75 ++++++++++++----------------
11 files changed, 115 insertions(+), 133 deletions(-)
diff --git a/.github/workflows/cpp_windows.yml
b/.github/workflows/cpp_windows.yml
index 315ad66cb74..bea657c53df 100644
--- a/.github/workflows/cpp_windows.yml
+++ b/.github/workflows/cpp_windows.yml
@@ -46,7 +46,7 @@ jobs:
ARROW_BOOST_USE_SHARED: OFF
ARROW_BUILD_BENCHMARKS: ON
ARROW_BUILD_SHARED: ON
- ARROW_BUILD_STATIC: OFF
+ ARROW_BUILD_STATIC: ON
ARROW_BUILD_TESTS: ON
ARROW_DATASET: ON
ARROW_FILESYSTEM: ON
diff --git a/cpp/src/arrow/acero/CMakeLists.txt
b/cpp/src/arrow/acero/CMakeLists.txt
index dc18afa9797..af990b32175 100644
--- a/cpp/src/arrow/acero/CMakeLists.txt
+++ b/cpp/src/arrow/acero/CMakeLists.txt
@@ -107,37 +107,27 @@ if(ARROW_BUILD_STATIC AND WIN32)
target_compile_definitions(arrow_acero_static PUBLIC ARROW_ACERO_STATIC)
endif()
-if(ARROW_TEST_LINKAGE STREQUAL "static")
- set(ARROW_ACERO_TEST_LINK_LIBS arrow_acero_static
${ARROW_TEST_STATIC_LINK_LIBS})
-else()
- set(ARROW_ACERO_TEST_LINK_LIBS arrow_acero_shared
${ARROW_TEST_SHARED_LINK_LIBS})
-endif()
-
foreach(LIB_TARGET ${ARROW_ACERO_LIBRARIES})
target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_ACERO_EXPORTING)
endforeach()
-# Define arrow_acero_testing object library for common test files
+# Define arrow_acero_testing static library for common test files.
if(ARROW_TESTING)
# test_nodes.cc isn't used by all tests but link to it for simple
# CMakeLists.txt.
- add_library(arrow_acero_testing OBJECT test_nodes.cc test_util_internal.cc)
- # Even though this is still just an object library we still need to "link"
our
- # dependencies so that include paths are configured correctly
- target_link_libraries(arrow_acero_testing PRIVATE
${ARROW_ACERO_TEST_LINK_LIBS})
+ add_library(arrow_acero_testing STATIC test_nodes.cc test_util_internal.cc)
+ if(ARROW_TEST_LINKAGE STREQUAL "static")
+ target_link_libraries(arrow_acero_testing PUBLIC arrow_acero_static
+
${ARROW_TEST_STATIC_LINK_LIBS})
+ else()
+ target_link_libraries(arrow_acero_testing PUBLIC arrow_acero_shared
+
${ARROW_TEST_SHARED_LINK_LIBS})
+ endif()
+ target_link_libraries(arrow_acero_testing PUBLIC arrow_compute_core_testing)
# Only for test_nodes.cc.
if(ARROW_WITH_OPENTELEMETRY)
target_link_libraries(arrow_acero_testing PRIVATE
${ARROW_OPENTELEMETRY_LIBS})
endif()
- # arrow_compute_testing will register the kernels for Gtest. In order to
register the kernels
- # for Google benchmark we use a custom main function used on
add_arrow_compute_benchmark.
- set(ARROW_ACERO_BENCHMARKS_TEST_LINK_LIBS
- ${ARROW_ACERO_TEST_LINK_LIBS} arrow_acero_testing
arrow_compute_core_testing)
- list(APPEND ARROW_ACERO_TEST_LINK_LIBS arrow_acero_testing
arrow_compute_testing)
-endif()
-# Only for hash_aggregate_test.cc.
-if(ARROW_USE_BOOST)
- list(APPEND ARROW_ACERO_TEST_LINK_LIBS Boost::headers)
endif()
# Adding unit tests part of the "dataset" portion of the test suite
@@ -163,9 +153,16 @@ function(add_arrow_acero_test REL_TEST_NAME)
set(LABELS "arrow_acero")
endif()
+ # arrow_compute_testing_main registers the extra kernels.
+ set(EXTRA_LINK_LIBS arrow_acero_testing arrow_compute_testing_main)
+ # Only for hash_aggregate_test.cc.
+ if(ARROW_USE_BOOST)
+ list(APPEND EXTRA_LINK_LIBS Boost::headers)
+ endif()
+
add_arrow_test(${REL_TEST_NAME}
EXTRA_LINK_LIBS
- ${ARROW_ACERO_TEST_LINK_LIBS}
+ ${EXTRA_LINK_LIBS}
PREFIX
${PREFIX}
LABELS
@@ -214,11 +211,7 @@ function(add_arrow_acero_benchmark REL_BENCHMARK_NAME)
set(LABELS "arrow_acero")
endif()
- if(ARROW_TEST_LINKAGE STREQUAL "static")
- set(EXTRA_LINK_LIBS arrow_acero_static
${ARROW_ACERO_BENCHMARKS_TEST_LINK_LIBS})
- else()
- set(EXTRA_LINK_LIBS arrow_acero_shared
${ARROW_ACERO_BENCHMARKS_TEST_LINK_LIBS})
- endif()
+ set(EXTRA_LINK_LIBS arrow_acero_testing)
if(ARG_EXTRA_LINK_LIBS)
list(APPEND EXTRA_LINK_LIBS ${ARG_EXTRA_LINK_LIBS})
endif()
diff --git a/cpp/src/arrow/c/CMakeLists.txt b/cpp/src/arrow/c/CMakeLists.txt
index a7f722aacc9..da87aa047f3 100644
--- a/cpp/src/arrow/c/CMakeLists.txt
+++ b/cpp/src/arrow/c/CMakeLists.txt
@@ -26,10 +26,11 @@ endif()
if(ARROW_COMPUTE)
if(ARROW_TEST_LINKAGE STREQUAL "static")
- list(APPEND ARROW_TEST_LINK_LIBS arrow_compute_static
arrow_compute_testing)
+ list(APPEND ARROW_TEST_LINK_LIBS arrow_compute_static)
else()
- list(APPEND ARROW_TEST_LINK_LIBS arrow_compute_shared
arrow_compute_testing)
+ list(APPEND ARROW_TEST_LINK_LIBS arrow_compute_shared)
endif()
+ list(APPEND ARROW_TEST_LINK_LIBS arrow_compute_testing_main)
endif()
add_arrow_test(bridge_test
diff --git a/cpp/src/arrow/compute/CMakeLists.txt
b/cpp/src/arrow/compute/CMakeLists.txt
index bfddb66358a..ecbad4621d3 100644
--- a/cpp/src/arrow/compute/CMakeLists.txt
+++ b/cpp/src/arrow/compute/CMakeLists.txt
@@ -28,28 +28,35 @@ else()
set(ARROW_COMPUTE_TEST_LINK_LIBS arrow_compute_shared
${ARROW_TEST_SHARED_LINK_LIBS})
endif()
-# Define arrow_compute_core_testing object library for common test files
requiring
+# Define arrow_compute_core_testing static library for common test files
requiring
# only core compute. No extra kernels are required.
+#
+# It links libraries for ARROW_TEST_LINKAGE. So it uses the same compile
+# definitions (e.g. ARROW_STATIC on Windows) as tests.
if(ARROW_TESTING)
- add_library(arrow_compute_core_testing OBJECT test_util_internal.cc)
- # Even though this is still just an object library we still need to "link"
our
- # dependencies so that include paths are configured correctly
- target_link_libraries(arrow_compute_core_testing PUBLIC ${ARROW_GTEST_GMOCK})
+ add_library(arrow_compute_core_testing STATIC test_util_internal.cc)
+ if(ARROW_TEST_LINKAGE STREQUAL "static")
+ target_link_libraries(arrow_compute_core_testing
+ PUBLIC ${ARROW_TEST_STATIC_LINK_LIBS})
+ else()
+ target_link_libraries(arrow_compute_core_testing
+ PUBLIC ${ARROW_TEST_SHARED_LINK_LIBS})
+ endif()
endif()
-# Define arrow_compute_testing object library for test files requiring extra
kernels.
+# Define arrow_compute_testing_main interface library that provides main()
+# initializing extra kernels.
+#
+# test_env.cc is compiled as a source of each test executable. If we use
+# a static library, main() in GTest::gmock_main may be used instead.
+#
+# This doesn't link any Apache Arrow C++ library. So this can be used
+# by tests that use different linkage from ARROW_TEST_LINKAGE such as
+# Flight SQL tests.
if(ARROW_TESTING AND ARROW_COMPUTE)
- set(ARROW_COMPUTE_TESTING_SRCS test_env.cc)
- add_library(arrow_compute_testing OBJECT ${ARROW_COMPUTE_TESTING_SRCS})
- # Even though this is still just an object library we still need to "link"
- # arrow_compute_core_testing so that is also included correctly
- target_link_libraries(arrow_compute_testing
- PUBLIC $<TARGET_OBJECTS:arrow_compute_core_testing>
- PUBLIC ${ARROW_GTEST_GTEST})
- if(ARROW_BUILD_STATIC AND WIN32)
- target_compile_definitions(arrow_compute_testing PUBLIC
ARROW_COMPUTE_STATIC
- ARROW_STATIC)
- endif()
+ add_library(arrow_compute_testing_main INTERFACE)
+ target_sources(arrow_compute_testing_main INTERFACE test_env.cc)
+ target_link_libraries(arrow_compute_testing_main INTERFACE
${ARROW_GTEST_GTEST})
endif()
set(ARROW_COMPUTE_TEST_PREFIX "arrow-compute")
@@ -170,7 +177,7 @@ add_arrow_compute_test(expression_test
SOURCES
expression_test.cc
EXTRA_LINK_LIBS
- arrow_compute_testing)
+ arrow_compute_testing_main)
add_arrow_compute_test(row_test
SOURCES
@@ -183,7 +190,8 @@ add_arrow_compute_test(row_test
row/row_test.cc
util_internal_test.cc
EXTRA_LINK_LIBS
- arrow_compute_testing)
+ arrow_compute_core_testing
+ arrow_compute_testing_main)
add_arrow_compute_benchmark(function_benchmark)
diff --git a/cpp/src/arrow/compute/kernels/CMakeLists.txt
b/cpp/src/arrow/compute/kernels/CMakeLists.txt
index d07356aa630..c8d9ceed6a2 100644
--- a/cpp/src/arrow/compute/kernels/CMakeLists.txt
+++ b/cpp/src/arrow/compute/kernels/CMakeLists.txt
@@ -20,12 +20,10 @@ arrow_install_all_headers("arrow/compute/kernels")
# ----------------------------------------------------------------------
# Tests that don't require the full kernel library
-# Define arrow_compute_kernels_testing object library for common test files
+# Define arrow_compute_kernels_testing static library for common test files.
if(ARROW_TESTING)
- add_library(arrow_compute_kernels_testing OBJECT test_util_internal.cc)
- # Even though this is still just an object library we still need to "link"
our
- # dependencies so that include paths are configured correctly
- target_link_libraries(arrow_compute_kernels_testing PUBLIC
${ARROW_GTEST_GMOCK})
+ add_library(arrow_compute_kernels_testing STATIC test_util_internal.cc)
+ target_link_libraries(arrow_compute_kernels_testing PUBLIC
arrow_compute_core_testing)
endif()
add_arrow_test(scalar_cast_test
@@ -33,14 +31,13 @@ add_arrow_test(scalar_cast_test
SOURCES
scalar_cast_test.cc
EXTRA_LINK_LIBS
- arrow_compute_kernels_testing
- arrow_compute_core_testing)
+ arrow_compute_kernels_testing)
# ----------------------------------------------------------------------
# Scalar kernels
set(ARROW_COMPUTE_SCALAR_TYPE_TEST_LINK_LIBS arrow_compute_kernels_testing
- arrow_compute_testing)
+ arrow_compute_testing_main)
if(ARROW_WITH_UTF8PROC)
list(APPEND ARROW_COMPUTE_SCALAR_TYPE_TEST_LINK_LIBS utf8proc::utf8proc)
endif()
@@ -57,14 +54,14 @@ add_arrow_compute_test(scalar_if_else_test
scalar_if_else_test.cc
EXTRA_LINK_LIBS
arrow_compute_kernels_testing
- arrow_compute_testing)
+ arrow_compute_testing_main)
add_arrow_compute_test(scalar_temporal_test
SOURCES
scalar_temporal_test.cc
EXTRA_LINK_LIBS
arrow_compute_kernels_testing
- arrow_compute_testing)
+ arrow_compute_testing_main)
add_arrow_compute_test(scalar_math_test
SOURCES
@@ -73,7 +70,7 @@ add_arrow_compute_test(scalar_math_test
scalar_round_arithmetic_test.cc
EXTRA_LINK_LIBS
arrow_compute_kernels_testing
- arrow_compute_testing)
+ arrow_compute_testing_main)
add_arrow_compute_test(scalar_utility_test
SOURCES
@@ -82,7 +79,7 @@ add_arrow_compute_test(scalar_utility_test
scalar_validity_test.cc
EXTRA_LINK_LIBS
arrow_compute_kernels_testing
- arrow_compute_testing)
+ arrow_compute_testing_main)
add_arrow_benchmark(scalar_cast_benchmark PREFIX "arrow-compute")
# The following benchmarks require compute kernels initialization.
@@ -112,35 +109,35 @@ add_arrow_compute_test(vector_test
select_k_test.cc
EXTRA_LINK_LIBS
arrow_compute_kernels_testing
- arrow_compute_testing)
+ arrow_compute_testing_main)
add_arrow_compute_test(vector_sort_test
SOURCES
vector_sort_test.cc
EXTRA_LINK_LIBS
arrow_compute_kernels_testing
- arrow_compute_testing)
+ arrow_compute_testing_main)
add_arrow_compute_test(vector_search_sorted_test
SOURCES
vector_search_sorted_test.cc
EXTRA_LINK_LIBS
arrow_compute_kernels_testing
- arrow_compute_testing)
+ arrow_compute_testing_main)
add_arrow_compute_test(vector_selection_test
SOURCES
vector_selection_test.cc
EXTRA_LINK_LIBS
arrow_compute_kernels_testing
- arrow_compute_testing)
+ arrow_compute_testing_main)
add_arrow_compute_test(vector_swizzle_test
SOURCES
vector_swizzle_test.cc
EXTRA_LINK_LIBS
arrow_compute_kernels_testing
- arrow_compute_testing)
+ arrow_compute_testing_main)
add_arrow_benchmark(vector_hash_benchmark PREFIX "arrow-compute")
# The following benchmarks require compute kernels initialization.
@@ -161,7 +158,7 @@ add_arrow_compute_test(aggregate_test
aggregate_test.cc
EXTRA_LINK_LIBS
arrow_compute_kernels_testing
- arrow_compute_testing
+ arrow_compute_testing_main
Boost::headers)
# ----------------------------------------------------------------------
diff --git a/cpp/src/arrow/compute/row/CMakeLists.txt
b/cpp/src/arrow/compute/row/CMakeLists.txt
index 542dc314806..6ad74cbe9fd 100644
--- a/cpp/src/arrow/compute/row/CMakeLists.txt
+++ b/cpp/src/arrow/compute/row/CMakeLists.txt
@@ -22,7 +22,7 @@ arrow_install_all_headers("arrow/compute/row")
if(ARROW_BUILD_BENCHMARKS AND ARROW_COMPUTE)
add_arrow_benchmark(grouper_benchmark PREFIX "arrow-compute")
- if(ARROW_BUILD_STATIC)
+ if(ARROW_TEST_LINKAGE STREQUAL "static")
target_link_libraries(arrow-compute-grouper-benchmark PUBLIC
arrow_compute_static)
else()
target_link_libraries(arrow-compute-grouper-benchmark PUBLIC
arrow_compute_shared)
diff --git a/cpp/src/arrow/compute/test_util_internal.cc
b/cpp/src/arrow/compute/test_util_internal.cc
index 219028943cb..74ca7241e02 100644
--- a/cpp/src/arrow/compute/test_util_internal.cc
+++ b/cpp/src/arrow/compute/test_util_internal.cc
@@ -31,8 +31,8 @@
namespace arrow::compute {
+using ::arrow::internal::MapVector;
using compute::ExecBatch;
-using internal::MapVector;
ExecBatch ExecBatchFromJSON(const std::vector<TypeHolder>& types,
std::string_view json) {
auto fields = ::arrow::internal::MapVector(
diff --git a/cpp/src/arrow/dataset/CMakeLists.txt
b/cpp/src/arrow/dataset/CMakeLists.txt
index 321b74331e3..cfb2c9ba78d 100644
--- a/cpp/src/arrow/dataset/CMakeLists.txt
+++ b/cpp/src/arrow/dataset/CMakeLists.txt
@@ -111,25 +111,21 @@ if(ARROW_BUILD_STATIC AND WIN32)
target_compile_definitions(arrow_dataset_static PUBLIC ARROW_DS_STATIC)
endif()
-if(ARROW_TEST_LINKAGE STREQUAL "static")
- set(ARROW_DATASET_TEST_LINK_LIBS arrow_dataset_static arrow_acero_testing
- arrow_compute_testing
${ARROW_TEST_STATIC_LINK_LIBS})
-else()
- set(ARROW_DATASET_TEST_LINK_LIBS arrow_dataset_shared arrow_acero_testing
- arrow_compute_testing
${ARROW_TEST_SHARED_LINK_LIBS})
-endif()
-
foreach(LIB_TARGET ${ARROW_DATASET_LIBRARIES})
target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_DS_EXPORTING)
endforeach()
-# Define arrow_dataset_testing object library for common test files
+# Define arrow_dataset_testing static library for common test files.
if(ARROW_TESTING)
- add_library(arrow_dataset_testing OBJECT test_util_internal.cc)
- # Even though this is still just an object library we still need to "link"
our
- # dependencies so that include paths are configured correctly
- target_link_libraries(arrow_dataset_testing PRIVATE
${ARROW_DATASET_TEST_LINK_LIBS})
- list(APPEND ARROW_DATASET_TEST_LINK_LIBS arrow_dataset_testing)
+ add_library(arrow_dataset_testing STATIC test_util_internal.cc)
+ if(ARROW_TEST_LINKAGE STREQUAL "static")
+ target_link_libraries(arrow_dataset_testing PUBLIC arrow_dataset_static
+
${ARROW_TEST_STATIC_LINK_LIBS})
+ else()
+ target_link_libraries(arrow_dataset_testing PUBLIC arrow_dataset_shared
+
${ARROW_TEST_SHARED_LINK_LIBS})
+ endif()
+ target_link_libraries(arrow_dataset_testing PUBLIC arrow_acero_testing)
endif()
# Adding unit tests part of the "dataset" portion of the test suite
@@ -149,10 +145,9 @@ function(ADD_ARROW_DATASET_TEST REL_TEST_NAME)
set(PREFIX "arrow-dataset")
endif()
+ set(EXTRA_LINK_LIBS arrow_dataset_testing arrow_compute_testing_main)
if(ARG_EXTRA_LINK_LIBS)
- set(EXTRA_LINK_LIBS ${ARG_EXTRA_LINK_LIBS})
- else()
- set(EXTRA_LINK_LIBS ${ARROW_DATASET_TEST_LINK_LIBS})
+ list(APPEND EXTRA_LINK_LIBS ${ARG_EXTRA_LINK_LIBS})
endif()
if(ARG_LABELS)
@@ -186,12 +181,11 @@ if(ARROW_CSV)
endif()
if(ARROW_JSON)
- add_arrow_dataset_test(file_json_test EXTRA_LINK_LIBS
${ARROW_DATASET_TEST_LINK_LIBS}
- arrow::simdjson)
+ add_arrow_dataset_test(file_json_test EXTRA_LINK_LIBS arrow::simdjson)
endif()
if(ARROW_ORC)
- add_arrow_dataset_test(file_orc_test EXTRA_LINK_LIBS
${ARROW_DATASET_TEST_LINK_LIBS})
+ add_arrow_dataset_test(file_orc_test)
endif()
if(ARROW_PARQUET)
diff --git a/cpp/src/arrow/engine/CMakeLists.txt
b/cpp/src/arrow/engine/CMakeLists.txt
index 221adaaca8b..cd7a0dfe325 100644
--- a/cpp/src/arrow/engine/CMakeLists.txt
+++ b/cpp/src/arrow/engine/CMakeLists.txt
@@ -90,7 +90,7 @@ add_arrow_test(substrait_test
substrait/test_util.cc
EXTRA_LINK_LIBS
${ARROW_SUBSTRAIT_TEST_LINK_LIBS}
- arrow_compute_testing
+ arrow_compute_testing_main
PREFIX
"arrow-substrait"
LABELS
diff --git a/cpp/src/arrow/flight/sql/CMakeLists.txt
b/cpp/src/arrow/flight/sql/CMakeLists.txt
index 6e01672248d..f13396bfd3f 100644
--- a/cpp/src/arrow/flight/sql/CMakeLists.txt
+++ b/cpp/src/arrow/flight/sql/CMakeLists.txt
@@ -140,7 +140,7 @@ if(ARROW_BUILD_TESTS OR ARROW_BUILD_EXAMPLES)
else()
list(APPEND ARROW_FLIGHT_SQL_TEST_LIBS arrow_substrait_shared)
endif()
- list(APPEND ARROW_FLIGHT_SQL_TEST_EXTRA_LINK_LIBS arrow_compute_testing)
+ list(APPEND ARROW_FLIGHT_SQL_TEST_EXTRA_LINK_LIBS
arrow_compute_testing_main)
if(ARROW_BUILD_EXAMPLES)
add_executable(acero-flight-sql-server ${ARROW_FLIGHT_SQL_ACERO_SRCS}
diff --git a/cpp/src/parquet/CMakeLists.txt b/cpp/src/parquet/CMakeLists.txt
index 6affbde88b4..3830919e40f 100644
--- a/cpp/src/parquet/CMakeLists.txt
+++ b/cpp/src/parquet/CMakeLists.txt
@@ -41,23 +41,14 @@ function(ADD_PARQUET_TEST REL_TEST_NAME)
"${multi_value_args}"
${ARGN})
- set(TEST_ARGUMENTS PREFIX "parquet" LABELS "parquet-tests")
-
- if(ARROW_TEST_LINKAGE STREQUAL "static")
- add_test_case(${REL_TEST_NAME}
- STATIC_LINK_LIBS
- parquet_static
- ${PARQUET_TEST_LINK_LIBS}
- ${TEST_ARGUMENTS}
- ${ARG_UNPARSED_ARGUMENTS})
- else()
- add_test_case(${REL_TEST_NAME}
- STATIC_LINK_LIBS
- parquet_shared
- ${PARQUET_TEST_LINK_LIBS}
- ${TEST_ARGUMENTS}
- ${ARG_UNPARSED_ARGUMENTS})
- endif()
+ add_test_case(${REL_TEST_NAME}
+ STATIC_LINK_LIBS
+ parquet_testing
+ PREFIX
+ "parquet"
+ LABELS
+ "parquet-tests"
+ ${ARG_UNPARSED_ARGUMENTS})
endfunction()
function(ADD_PARQUET_FUZZ_TARGET REL_FUZZING_NAME)
@@ -108,7 +99,8 @@ function(ADD_PARQUET_BENCHMARK REL_TEST_NAME)
${PREFIX}
LABELS
"parquet-benchmarks"
- ${PARQUET_BENCHMARK_LINK_OPTION}
+ EXTRA_LINK_LIBS
+ parquet_testing
${ARG_UNPARSED_ARGUMENTS})
endfunction()
@@ -124,16 +116,6 @@ else()
set(PARQUET_STATIC_INSTALL_INTERFACE_LIBS)
endif()
-set(PARQUET_TEST_LINK_LIBS ${ARROW_TEST_LINK_LIBS} thrift::thrift)
-if(APPLE)
- list(APPEND PARQUET_TEST_LINK_LIBS ${CMAKE_DL_LIBS})
-elseif(NOT MSVC)
- if(ARROW_ENABLE_THREADING)
- list(APPEND PARQUET_TEST_LINK_LIBS Threads::Threads)
- endif()
- list(APPEND PARQUET_TEST_LINK_LIBS ${CMAKE_DL_LIBS})
-endif()
-
#
# Generated Thrift sources
set(PARQUET_THRIFT_SOURCE_DIR "${ARROW_SOURCE_DIR}/src/generated/")
@@ -251,6 +233,7 @@ list(APPEND PARQUET_STATIC_LINK_LIBS ${ARROW_XSIMD})
if(PARQUET_REQUIRE_ENCRYPTION)
list(APPEND PARQUET_SHARED_PRIVATE_LINK_LIBS ${ARROW_OPENSSL_LIBS})
+ list(APPEND PARQUET_STATIC_LINK_LIBS ${ARROW_OPENSSL_LIBS})
set(PARQUET_SRCS ${PARQUET_SRCS} encryption/encryption_internal.cc
encryption/openssl_internal.cc)
# Encryption key management
@@ -289,6 +272,7 @@ endif()
if(ARROW_WITH_OPENTELEMETRY)
list(APPEND PARQUET_SHARED_PRIVATE_LINK_LIBS ${ARROW_OPENTELEMETRY_LIBS})
+ list(APPEND PARQUET_STATIC_LINK_LIBS ${ARROW_OPENTELEMETRY_LIBS})
endif()
if(CXX_LINKER_SUPPORTS_VERSION_SCRIPT)
@@ -322,25 +306,30 @@ if(WIN32 AND NOT (ARROW_TEST_LINKAGE STREQUAL "static"))
add_library(parquet_test_support STATIC
"${PARQUET_THRIFT_SOURCE_DIR}/parquet_types.cpp")
target_link_libraries(parquet_test_support thrift::thrift)
- list(PREPEND PARQUET_TEST_LINK_LIBS parquet_test_support)
list(APPEND PARQUET_LIBRARIES parquet_test_support)
endif()
if(ARROW_TESTING)
- add_library(parquet_testing OBJECT test_util.cc)
- # Even though this is still just an object library we still need to
- # "link" our dependencies so that include paths are configured
- # correctly
- target_link_libraries(parquet_testing PUBLIC ${ARROW_GTEST_GMOCK})
- list(APPEND PARQUET_TEST_LINK_LIBS parquet_testing simdjson::simdjson)
-endif()
-
-if(NOT ARROW_BUILD_SHARED)
- set(PARQUET_BENCHMARK_LINK_OPTION STATIC_LINK_LIBS parquet_static
- ${PARQUET_TEST_LINK_LIBS}
benchmark::benchmark_main)
-else()
- set(PARQUET_BENCHMARK_LINK_OPTION EXTRA_LINK_LIBS parquet_shared
- ${PARQUET_TEST_LINK_LIBS})
+ # Define parquet_testing static library for common test files.
+ add_library(parquet_testing STATIC test_util.cc)
+ if(ARROW_TEST_LINKAGE STREQUAL "static")
+ target_link_libraries(parquet_testing PUBLIC parquet_static)
+ else()
+ target_link_libraries(parquet_testing PUBLIC parquet_shared)
+ endif()
+ if(TARGET parquet_test_support)
+ target_link_libraries(parquet_testing PUBLIC parquet_test_support)
+ endif()
+ target_link_libraries(parquet_testing PUBLIC ${ARROW_TEST_LINK_LIBS}
thrift::thrift
+ simdjson::simdjson)
+ if(APPLE)
+ target_link_libraries(parquet_testing PUBLIC ${CMAKE_DL_LIBS})
+ elseif(NOT MSVC)
+ if(ARROW_ENABLE_THREADING)
+ target_link_libraries(parquet_testing PUBLIC Threads::Threads)
+ endif()
+ target_link_libraries(parquet_testing PUBLIC ${CMAKE_DL_LIBS})
+ endif()
endif()
if(ARROW_BUILD_STATIC AND WIN32)