Skip to content

Commit

Permalink
apacheGH-38339: [C++][CMake] Use transitive dependency for system Goo…
Browse files Browse the repository at this point in the history
…gleTest
  • Loading branch information
kou committed Oct 27, 2023
1 parent 6e6fd0a commit 18bf3e3
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 39 deletions.
4 changes: 2 additions & 2 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -889,8 +889,8 @@ if(NOT MSVC_TOOLCHAIN)
list(APPEND ARROW_SHARED_LINK_LIBS ${CMAKE_DL_LIBS})
endif()

set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers ${ARROW_GTEST_GTEST_MAIN}
${ARROW_GTEST_GTEST} ${ARROW_GTEST_GMOCK})
set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers ${ARROW_GTEST_GMOCK}
${ARROW_GTEST_GTEST_MAIN})

if(ARROW_BUILD_TESTS)
add_dependencies(arrow_test_dependencies ${ARROW_TEST_LINK_TOOLCHAIN})
Expand Down
3 changes: 3 additions & 0 deletions cpp/cmake_modules/FindGTestAlt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,7 @@ TEST(CXX_STANDARD, MatcherStringView) {
find_package_handle_standard_args(GTestAlt
REQUIRED_VARS GTestAlt_CXX_STANDARD_AVAILABLE)
endif()

target_link_libraries(GTest::gmock INTERFACE GTest::gtest)
target_link_libraries(GTest::gtest_main INTERFACE GTest::gtest)
endif()
3 changes: 1 addition & 2 deletions cpp/src/arrow/acero/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ if(ARROW_TESTING)
add_library(arrow_acero_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_acero_testing ${ARROW_ACERO_TEST_LINK_LIBS})
target_link_libraries(arrow_acero_testing ${ARROW_GTEST_GTEST})
target_link_libraries(arrow_acero_testing PRIVATE ${ARROW_ACERO_TEST_LINK_LIBS})
list(APPEND ARROW_ACERO_TEST_LINK_LIBS arrow_acero_testing)
endif()

Expand Down
13 changes: 2 additions & 11 deletions cpp/src/arrow/adapters/orc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,11 @@ install(FILES adapter.h options.h
# pkg-config support
arrow_add_pkg_config("arrow-orc")

if(ARROW_BUILD_STATIC)
set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_static arrow_static)
else()
set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_shared arrow_shared)
endif()

set(ORC_STATIC_TEST_LINK_LIBS orc::orc ${ARROW_LIBRARIES_FOR_STATIC_TESTS}
${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST})

add_arrow_test(adapter_test
PREFIX
"arrow-orc"
STATIC_LINK_LIBS
${ORC_STATIC_TEST_LINK_LIBS})
EXTRA_LINK_LIBS
orc::orc)

set_source_files_properties(adapter_test.cc PROPERTIES SKIP_PRECOMPILE_HEADERS ON
SKIP_UNITY_BUILD_INCLUSION ON)
4 changes: 1 addition & 3 deletions cpp/src/arrow/compute/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ add_arrow_test(internals_test
kernel_test.cc
light_array_test.cc
registry_test.cc
key_hash_test.cc
EXTRA_LINK_LIBS
${ARROW_GTEST_GMOCK})
key_hash_test.cc)

add_arrow_compute_test(expression_test SOURCES expression_test.cc)

Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/compute/kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ if(ARROW_TESTING)
add_library(arrow_compute_kernels_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(arrow_compute_kernels_testing ${ARROW_GTEST_GTEST}
${ARROW_GTEST_GMOCK})
target_link_libraries(arrow_compute_kernels_testing PRIVATE ${ARROW_GTEST_GMOCK})
endif()

add_arrow_test(scalar_cast_test
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/dataset/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ 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 ${ARROW_DATASET_TEST_LINK_LIBS})
target_link_libraries(arrow_dataset_testing ${ARROW_GTEST_GTEST})
target_link_libraries(arrow_dataset_testing PRIVATE ${ARROW_DATASET_TEST_LINK_LIBS})
list(APPEND ARROW_DATASET_TEST_LINK_LIBS arrow_dataset_testing)
endif()

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/filesystem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ if(ARROW_S3)
if(ARROW_BUILD_TESTS)
add_executable(arrow-s3fs-narrative-test s3fs_narrative_test.cc)
target_link_libraries(arrow-s3fs-narrative-test ${ARROW_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})
${GFLAGS_LIBRARIES})
add_dependencies(arrow-tests arrow-s3fs-narrative-test)
endif()

Expand Down
1 change: 0 additions & 1 deletion cpp/src/arrow/flight/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ list(APPEND
Boost::headers
Boost::filesystem
Boost::system
${ARROW_GTEST_GTEST}
${ARROW_GTEST_GMOCK})
list(APPEND ARROW_FLIGHT_TEST_LINK_LIBS gRPC::grpc++)

Expand Down
7 changes: 2 additions & 5 deletions cpp/src/arrow/flight/integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ if(ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static" AND ARROW_BUILD_STATIC)
else()
set(ARROW_FLIGHT_INTEGRATION_TEST_LINK_LIBS arrow_flight_sql_shared)
endif()
list(APPEND
ARROW_FLIGHT_INTEGRATION_TEST_LINK_LIBS
${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES}
${ARROW_GTEST_GTEST})
list(APPEND ARROW_FLIGHT_INTEGRATION_TEST_LINK_LIBS ${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES})

add_executable(flight-test-integration-server test_integration_server.cc
test_integration.cc)
Expand Down
9 changes: 5 additions & 4 deletions cpp/src/arrow/gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ if(ARROW_BUILD_TESTS)
endif()

if(ARROW_BUILD_BENCHMARKS)
add_arrow_benchmark(cuda_benchmark PREFIX "arrow-gpu")
target_link_libraries(arrow-gpu-cuda-benchmark
PUBLIC ${ARROW_CUDA_LIBRARY} ${ARROW_GTEST_GTEST}
${ARROW_BENCHMARK_LINK_LIBS})
add_arrow_benchmark(cuda_benchmark
PREFIX
"arrow-gpu"
EXTRA_LINK_LIBS
${ARROW_CUDA_LIBRARY})
add_dependencies(arrow_cuda-benchmarks arrow-gpu-cuda-benchmark)
endif()
11 changes: 5 additions & 6 deletions cpp/src/parquet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,19 @@ else()
set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_shared arrow_shared)
endif()

set(PARQUET_MIN_TEST_LIBS ${ARROW_GTEST_GMOCK} ${ARROW_GTEST_GTEST}
${ARROW_GTEST_GTEST_MAIN} Boost::headers)
set(PARQUET_MIN_TEST_LIBS ${ARROW_GTEST_GMOCK} ${ARROW_GTEST_GTEST_MAIN} Boost::headers)

if(APPLE)
list(APPEND PARQUET_MIN_TEST_LIBS ${CMAKE_DL_LIBS})
elseif(NOT MSVC)
list(APPEND PARQUET_MIN_TEST_LIBS pthread ${CMAKE_DL_LIBS})
endif()

set(PARQUET_SHARED_TEST_LINK_LIBS arrow_testing_shared ${PARQUET_MIN_TEST_LIBS}
parquet_shared thrift::thrift)
set(PARQUET_SHARED_TEST_LINK_LIBS arrow_testing_shared parquet_shared thrift::thrift
${PARQUET_MIN_TEST_LIBS})

set(PARQUET_STATIC_TEST_LINK_LIBS ${PARQUET_MIN_TEST_LIBS} parquet_static thrift::thrift
${ARROW_LIBRARIES_FOR_STATIC_TESTS})
set(PARQUET_STATIC_TEST_LINK_LIBS ${ARROW_LIBRARIES_FOR_STATIC_TESTS} parquet_static
thrift::thrift ${PARQUET_MIN_TEST_LIBS})

#
# Generated Thrift sources
Expand Down

0 comments on commit 18bf3e3

Please sign in to comment.