Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion ci/docker/alpine-linux-3.16-cpp.dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,6 +37,7 @@ RUN apk add \
glog-dev \
gmock \
grpc-dev \
gtest-dev \
libxml2-dev \
llvm13-dev \
llvm13-static \
Expand DownExpand Up@@ -95,7 +96,6 @@ ENV ARROW_ACERO=ON \
ARROW_WITH_ZSTD=ON \
AWSSDK_SOURCE=BUNDLED \
google_cloud_cpp_storage_SOURCE=BUNDLED \
GTest_SOURCE=BUNDLED \
ORC_SOURCE=BUNDLED \
PATH=/usr/lib/ccache/:$PATH \
xsimd_SOURCE=BUNDLED
4 changes: 2 additions & 2 deletions cpp/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -839,8 +839,8 @@ if(NOT MSVC_TOOLCHAIN)
list(APPEND ARROW_SHARED_LINK_LIBS ${CMAKE_DL_LIBS})
endif()

set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers GTest::gtest_main GTest::gtest
GTest::gmock)
set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers ${ARROW_GTEST_GTEST_MAIN}

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.

IMHO this is a regression as using variables instead of targets is an anti-pattern but I currently don't see a cleaner approach either.

I think we should rethink the entire dependency management once we have bumped the cmake version to 3.16 as we will have much better tools available. (this is of course out of scope for this PR)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

${ARROW_GTEST_GTEST} ${ARROW_GTEST_GMOCK})

if(ARROW_BUILD_TESTS)
add_dependencies(arrow_test_dependencies ${ARROW_TEST_LINK_TOOLCHAIN})
Expand Down
61 changes: 61 additions & 0 deletions cpp/cmake_modules/FindGTestAlt.cmake
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

if(GTestAlt_FOUND)
return()
endif()

set(find_package_args)
if(GTestAlt_FIND_VERSION)
list(APPEND find_package_args ${GTestAlt_FIND_VERSION})
endif()
if(GTestAlt_FIND_QUIETLY)
list(APPEND find_package_args QUIET)
endif()
if(CMAKE_VERSION VERSION_LESS 3.23)
list(APPEND find_package_args CONFIG)
endif()
# We can't find shred library version of GoogleTest on Windows with
# Conda's gtest package because it doesn't provide GTestConfig.cmake
# provided by GoogleTest and CMake's built-in FindGTtest.cmake
# doesn't support gtest_dll.dll.
find_package(GTest ${find_package_args})

set(GTestAlt_FOUND ${GTest_FOUND})
if(GTestAlt_FOUND)
set(KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
set(GTestAlt_CXX_STANDARD_TEST_SOURCE
"${CMAKE_CURRENT_BINARY_DIR}/gtest_cxx_standard_test.cc")
file(WRITE ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
"
#include <string_view>
#include <gtest/gtest.h>

TEST(CXX_STANDARD, MatcherStringView) {
testing::Matcher matcher(std::string_view(\"hello\"));
}
")
try_compile(GTestAlt_CXX_STANDARD_AVAILABLE ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
LINK_LIBRARIES GTest::gtest_main)
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE})
if(NOT GTestAlt_CXX_STANDARD_AVAILABLE)
message(STATUS "GTest can't be used with ${CMAKE_CXX_STANDARD}")
set(GTestAlt_FOUND FALSE)
endif()
endif()
46 changes: 18 additions & 28 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line numberDiff line numberDiff line change
Expand Up@@ -2190,54 +2190,38 @@ macro(build_gtest)
# The include directory must exist before it is referenced by a target.
file(MAKE_DIRECTORY "${GTEST_INCLUDE_DIR}")

add_library(GTest::gtest SHARED IMPORTED)
set_target_properties(GTest::gtest
add_library(arrow::GTest::gtest SHARED IMPORTED)
set_target_properties(arrow::GTest::gtest
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_SHARED_LIB}"
INTERFACE_COMPILE_DEFINITIONS
"GTEST_LINKED_AS_SHARED_LIBRARY=1"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::gtest_main SHARED IMPORTED)
set_target_properties(GTest::gtest_main
add_library(arrow::GTest::gtest_main SHARED IMPORTED)
set_target_properties(arrow::GTest::gtest_main
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_MAIN_SHARED_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::gmock SHARED IMPORTED)
set_target_properties(GTest::gmock
add_library(arrow::GTest::gmock SHARED IMPORTED)
set_target_properties(arrow::GTest::gmock
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GMOCK_SHARED_LIB}"
INTERFACE_COMPILE_DEFINITIONS
"GMOCK_LINKED_AS_SHARED_LIBRARY=1"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")
add_dependencies(toolchain-tests googletest_ep)
add_dependencies(GTest::gtest googletest_ep)
add_dependencies(GTest::gtest_main googletest_ep)
add_dependencies(GTest::gmock googletest_ep)
add_dependencies(arrow::GTest::gtest googletest_ep)
add_dependencies(arrow::GTest::gtest_main googletest_ep)
add_dependencies(arrow::GTest::gmock googletest_ep)
endmacro()

if(ARROW_TESTING)
if(CMAKE_VERSION VERSION_LESS 3.23)
set(GTEST_USE_CONFIG TRUE)
else()
set(GTEST_USE_CONFIG FALSE)
endif()
# We can't find shred library version of GoogleTest on Windows with
# Conda's gtest package because it doesn't provide GTestConfig.cmake
# provided by GoogleTest and CMake's built-in FindGTtest.cmake
# doesn't support gtest_dll.dll.
resolve_dependency(GTest
HAVE_ALT
TRUE
REQUIRED_VERSION
1.10.0
USE_CONFIG
${GTEST_USE_CONFIG})
1.10.0)

if(GTest_SOURCE STREQUAL "SYSTEM")
get_target_property(gtest_cxx_standard GTest::gtest INTERFACE_COMPILE_FEATURES)
if((${gtest_cxx_standard} STREQUAL "cxx_std_11") OR (${gtest_cxx_standard} STREQUAL
"cxx_std_14"))
message(FATAL_ERROR "System GTest is built with a C++ standard lower than 17. Use bundled GTest via passing in CMake flag
-DGTest_SOURCE=\"BUNDLED\"")
endif()

find_package(PkgConfig QUIET)
pkg_check_modules(gtest_PC
gtest
Expand All@@ -2254,10 +2238,16 @@ if(ARROW_TESTING)

string(APPEND ARROW_TESTING_PC_LIBS " $<TARGET_FILE:GTest::gtest>")
endif()
set(ARROW_GTEST_GMOCK GTest::gmock)
set(ARROW_GTEST_GTEST GTest::gtest)
set(ARROW_GTEST_GTEST_MAIN GTest::gtest_main)
else()
# TODO: How to solve BUNDLED case? Do we install bundled GoogleTest?
# string(APPEND ARROW_TESTING_PC_CFLAGS " -I${GTEST_INCLUDE_DIR}")
# string(APPEND ARROW_TESTING_PC_LIBS " -lgtest")
set(ARROW_GTEST_GMOCK arrow::GTest::gmock)
set(ARROW_GTEST_GTEST arrow::GTest::gtest)
set(ARROW_GTEST_GTEST_MAIN arrow::GTest::gtest_main)
endif()
endif()

Expand Down
8 changes: 3 additions & 5 deletions cpp/src/arrow/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -717,18 +717,16 @@ if(ARROW_TESTING)
arrow::flatbuffers
rapidjson::rapidjson
arrow_shared
GTest::gtest
${ARROW_GTEST_GTEST}
SHARED_INSTALL_INTERFACE_LIBS
Arrow::arrow_shared
GTest::gtest
STATIC_LINK_LIBS
arrow::flatbuffers
rapidjson::rapidjson
arrow_static
GTest::gtest
${ARROW_GTEST_GTEST}
STATIC_INSTALL_INTERFACE_LIBS
Arrow::arrow_static
GTest::gtest)
Arrow::arrow_static)

add_custom_target(arrow_testing)
add_dependencies(arrow_testing ${ARROW_TESTING_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/adapters/orc/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,7 @@ else()
endif()

set(ORC_STATIC_TEST_LINK_LIBS orc::liborc ${ARROW_LIBRARIES_FOR_STATIC_TESTS}
GTest::gtest_main GTest::gtest)
${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST})

add_arrow_test(adapter_test
PREFIX
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/filesystem/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,7 +81,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} GTest::gtest)
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})
add_dependencies(arrow-tests arrow-s3fs-narrative-test)
endif()

Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/flight/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,8 +67,8 @@ list(APPEND
Boost::headers
Boost::filesystem
Boost::system
GTest::gtest
GTest::gmock)
${ARROW_GTEST_GTEST}
${ARROW_GTEST_GMOCK})
list(APPEND ARROW_FLIGHT_TEST_LINK_LIBS gRPC::grpc++)

# TODO(wesm): Protobuf shared vs static linking
Expand DownExpand Up@@ -308,7 +308,7 @@ if(ARROW_TESTING)
test_definitions.cc
test_util.cc
DEPENDENCIES
GTest::gtest
${ARROW_GTEST_GTEST}
flight_grpc_gen
arrow_dependencies
SHARED_LINK_LIBS
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/flight/integration_tests/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@ list(APPEND
ARROW_FLIGHT_INTEGRATION_TEST_LINK_LIBS
${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES}
GTest::gtest)
${ARROW_GTEST_GTEST})

add_executable(flight-test-integration-server test_integration_server.cc
test_integration.cc)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/gpu/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ endif()
if(ARROW_BUILD_BENCHMARKS)
add_arrow_benchmark(cuda_benchmark PREFIX "arrow-gpu")
target_link_libraries(arrow-gpu-cuda-benchmark
PUBLIC ${ARROW_CUDA_LIBRARY} GTest::gtest
PUBLIC ${ARROW_CUDA_LIBRARY} ${ARROW_GTEST_GTEST}
${ARROW_BENCHMARK_LINK_LIBS})
add_dependencies(arrow_cuda-benchmarks arrow-gpu-cuda-benchmark)
endif()
2 changes: 1 addition & 1 deletion cpp/src/arrow/testing/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ if(ARROW_BUILD_TESTS)
elseif(ARROW_BUILD_INTEGRATION)
add_executable(arrow-json-integration-test json_integration_test.cc)
target_link_libraries(arrow-json-integration-test ${ARROW_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::gtest)
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})

add_dependencies(arrow-json-integration-test arrow arrow_testing)
add_dependencies(arrow-integration arrow-json-integration-test)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/parquet/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -114,7 +114,7 @@ else()
set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_shared arrow_shared)
endif()

set(PARQUET_MIN_TEST_LIBS GTest::gtest_main GTest::gtest Boost::headers)
set(PARQUET_MIN_TEST_LIBS ${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST} Boost::headers)

if(APPLE)
set(PARQUET_MIN_TEST_LIBS ${PARQUET_MIN_TEST_LIBS} ${CMAKE_DL_LIBS})
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion ci/docker/alpine-linux-3.16-cpp.dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,6 +37,7 @@ RUN apk add \
glog-dev \
gmock \
grpc-dev \
gtest-dev \
libxml2-dev \
llvm13-dev \
llvm13-static \
Expand DownExpand Up@@ -95,7 +96,6 @@ ENV ARROW_ACERO=ON \
ARROW_WITH_ZSTD=ON \
AWSSDK_SOURCE=BUNDLED \
google_cloud_cpp_storage_SOURCE=BUNDLED \
GTest_SOURCE=BUNDLED \
ORC_SOURCE=BUNDLED \
PATH=/usr/lib/ccache/:$PATH \
xsimd_SOURCE=BUNDLED
4 changes: 2 additions & 2 deletions cpp/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -839,8 +839,8 @@ if(NOT MSVC_TOOLCHAIN)
list(APPEND ARROW_SHARED_LINK_LIBS ${CMAKE_DL_LIBS})
endif()

set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers GTest::gtest_main GTest::gtest
GTest::gmock)
set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers ${ARROW_GTEST_GTEST_MAIN}

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.

IMHO this is a regression as using variables instead of targets is an anti-pattern but I currently don't see a cleaner approach either.

I think we should rethink the entire dependency management once we have bumped the cmake version to 3.16 as we will have much better tools available. (this is of course out of scope for this PR)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

${ARROW_GTEST_GTEST} ${ARROW_GTEST_GMOCK})

if(ARROW_BUILD_TESTS)
add_dependencies(arrow_test_dependencies ${ARROW_TEST_LINK_TOOLCHAIN})
Expand Down
61 changes: 61 additions & 0 deletions cpp/cmake_modules/FindGTestAlt.cmake
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

if(GTestAlt_FOUND)
return()
endif()

set(find_package_args)
if(GTestAlt_FIND_VERSION)
list(APPEND find_package_args ${GTestAlt_FIND_VERSION})
endif()
if(GTestAlt_FIND_QUIETLY)
list(APPEND find_package_args QUIET)
endif()
if(CMAKE_VERSION VERSION_LESS 3.23)
list(APPEND find_package_args CONFIG)
endif()
# We can't find shred library version of GoogleTest on Windows with
# Conda's gtest package because it doesn't provide GTestConfig.cmake
# provided by GoogleTest and CMake's built-in FindGTtest.cmake
# doesn't support gtest_dll.dll.
find_package(GTest ${find_package_args})

set(GTestAlt_FOUND ${GTest_FOUND})
if(GTestAlt_FOUND)
set(KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
set(GTestAlt_CXX_STANDARD_TEST_SOURCE
"${CMAKE_CURRENT_BINARY_DIR}/gtest_cxx_standard_test.cc")
file(WRITE ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
"
#include <string_view>
#include <gtest/gtest.h>

TEST(CXX_STANDARD, MatcherStringView) {
testing::Matcher matcher(std::string_view(\"hello\"));
}
")
try_compile(GTestAlt_CXX_STANDARD_AVAILABLE ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
LINK_LIBRARIES GTest::gtest_main)
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE})
if(NOT GTestAlt_CXX_STANDARD_AVAILABLE)
message(STATUS "GTest can't be used with ${CMAKE_CXX_STANDARD}")
set(GTestAlt_FOUND FALSE)
endif()
endif()
46 changes: 18 additions & 28 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line numberDiff line numberDiff line change
Expand Up@@ -2190,54 +2190,38 @@ macro(build_gtest)
# The include directory must exist before it is referenced by a target.
file(MAKE_DIRECTORY "${GTEST_INCLUDE_DIR}")

add_library(GTest::gtest SHARED IMPORTED)
set_target_properties(GTest::gtest
add_library(arrow::GTest::gtest SHARED IMPORTED)
set_target_properties(arrow::GTest::gtest
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_SHARED_LIB}"
INTERFACE_COMPILE_DEFINITIONS
"GTEST_LINKED_AS_SHARED_LIBRARY=1"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::gtest_main SHARED IMPORTED)
set_target_properties(GTest::gtest_main
add_library(arrow::GTest::gtest_main SHARED IMPORTED)
set_target_properties(arrow::GTest::gtest_main
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_MAIN_SHARED_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::gmock SHARED IMPORTED)
set_target_properties(GTest::gmock
add_library(arrow::GTest::gmock SHARED IMPORTED)
set_target_properties(arrow::GTest::gmock
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GMOCK_SHARED_LIB}"
INTERFACE_COMPILE_DEFINITIONS
"GMOCK_LINKED_AS_SHARED_LIBRARY=1"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")
add_dependencies(toolchain-tests googletest_ep)
add_dependencies(GTest::gtest googletest_ep)
add_dependencies(GTest::gtest_main googletest_ep)
add_dependencies(GTest::gmock googletest_ep)
add_dependencies(arrow::GTest::gtest googletest_ep)
add_dependencies(arrow::GTest::gtest_main googletest_ep)
add_dependencies(arrow::GTest::gmock googletest_ep)
endmacro()

if(ARROW_TESTING)
if(CMAKE_VERSION VERSION_LESS 3.23)
set(GTEST_USE_CONFIG TRUE)
else()
set(GTEST_USE_CONFIG FALSE)
endif()
# We can't find shred library version of GoogleTest on Windows with
# Conda's gtest package because it doesn't provide GTestConfig.cmake
# provided by GoogleTest and CMake's built-in FindGTtest.cmake
# doesn't support gtest_dll.dll.
resolve_dependency(GTest
HAVE_ALT
TRUE
REQUIRED_VERSION
1.10.0
USE_CONFIG
${GTEST_USE_CONFIG})
1.10.0)

if(GTest_SOURCE STREQUAL "SYSTEM")
get_target_property(gtest_cxx_standard GTest::gtest INTERFACE_COMPILE_FEATURES)
if((${gtest_cxx_standard} STREQUAL "cxx_std_11") OR (${gtest_cxx_standard} STREQUAL
"cxx_std_14"))
message(FATAL_ERROR "System GTest is built with a C++ standard lower than 17. Use bundled GTest via passing in CMake flag
-DGTest_SOURCE=\"BUNDLED\"")
endif()

find_package(PkgConfig QUIET)
pkg_check_modules(gtest_PC
gtest
Expand All@@ -2254,10 +2238,16 @@ if(ARROW_TESTING)

string(APPEND ARROW_TESTING_PC_LIBS " $<TARGET_FILE:GTest::gtest>")
endif()
set(ARROW_GTEST_GMOCK GTest::gmock)
set(ARROW_GTEST_GTEST GTest::gtest)
set(ARROW_GTEST_GTEST_MAIN GTest::gtest_main)
else()
# TODO: How to solve BUNDLED case? Do we install bundled GoogleTest?
# string(APPEND ARROW_TESTING_PC_CFLAGS " -I${GTEST_INCLUDE_DIR}")
# string(APPEND ARROW_TESTING_PC_LIBS " -lgtest")
set(ARROW_GTEST_GMOCK arrow::GTest::gmock)
set(ARROW_GTEST_GTEST arrow::GTest::gtest)
set(ARROW_GTEST_GTEST_MAIN arrow::GTest::gtest_main)
endif()
endif()

Expand Down
8 changes: 3 additions & 5 deletions cpp/src/arrow/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -717,18 +717,16 @@ if(ARROW_TESTING)
arrow::flatbuffers
rapidjson::rapidjson
arrow_shared
GTest::gtest
${ARROW_GTEST_GTEST}
SHARED_INSTALL_INTERFACE_LIBS
Arrow::arrow_shared
GTest::gtest
STATIC_LINK_LIBS
arrow::flatbuffers
rapidjson::rapidjson
arrow_static
GTest::gtest
${ARROW_GTEST_GTEST}
STATIC_INSTALL_INTERFACE_LIBS
Arrow::arrow_static
GTest::gtest)
Arrow::arrow_static)

add_custom_target(arrow_testing)
add_dependencies(arrow_testing ${ARROW_TESTING_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/adapters/orc/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,7 @@ else()
endif()

set(ORC_STATIC_TEST_LINK_LIBS orc::liborc ${ARROW_LIBRARIES_FOR_STATIC_TESTS}
GTest::gtest_main GTest::gtest)
${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST})

add_arrow_test(adapter_test
PREFIX
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/filesystem/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,7 +81,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} GTest::gtest)
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})
add_dependencies(arrow-tests arrow-s3fs-narrative-test)
endif()

Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/flight/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,8 +67,8 @@ list(APPEND
Boost::headers
Boost::filesystem
Boost::system
GTest::gtest
GTest::gmock)
${ARROW_GTEST_GTEST}
${ARROW_GTEST_GMOCK})
list(APPEND ARROW_FLIGHT_TEST_LINK_LIBS gRPC::grpc++)

# TODO(wesm): Protobuf shared vs static linking
Expand DownExpand Up@@ -308,7 +308,7 @@ if(ARROW_TESTING)
test_definitions.cc
test_util.cc
DEPENDENCIES
GTest::gtest
${ARROW_GTEST_GTEST}
flight_grpc_gen
arrow_dependencies
SHARED_LINK_LIBS
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/flight/integration_tests/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@ list(APPEND
ARROW_FLIGHT_INTEGRATION_TEST_LINK_LIBS
${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES}
GTest::gtest)
${ARROW_GTEST_GTEST})

add_executable(flight-test-integration-server test_integration_server.cc
test_integration.cc)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/gpu/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ endif()
if(ARROW_BUILD_BENCHMARKS)
add_arrow_benchmark(cuda_benchmark PREFIX "arrow-gpu")
target_link_libraries(arrow-gpu-cuda-benchmark
PUBLIC ${ARROW_CUDA_LIBRARY} GTest::gtest
PUBLIC ${ARROW_CUDA_LIBRARY} ${ARROW_GTEST_GTEST}
${ARROW_BENCHMARK_LINK_LIBS})
add_dependencies(arrow_cuda-benchmarks arrow-gpu-cuda-benchmark)
endif()
2 changes: 1 addition & 1 deletion cpp/src/arrow/testing/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ if(ARROW_BUILD_TESTS)
elseif(ARROW_BUILD_INTEGRATION)
add_executable(arrow-json-integration-test json_integration_test.cc)
target_link_libraries(arrow-json-integration-test ${ARROW_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::gtest)
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})

add_dependencies(arrow-json-integration-test arrow arrow_testing)
add_dependencies(arrow-integration arrow-json-integration-test)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/parquet/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -114,7 +114,7 @@ else()
set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_shared arrow_shared)
endif()

set(PARQUET_MIN_TEST_LIBS GTest::gtest_main GTest::gtest Boost::headers)
set(PARQUET_MIN_TEST_LIBS ${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST} Boost::headers)

if(APPLE)
set(PARQUET_MIN_TEST_LIBS ${PARQUET_MIN_TEST_LIBS} ${CMAKE_DL_LIBS})
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion ci/docker/alpine-linux-3.16-cpp.dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,6 +37,7 @@ RUN apk add \
glog-dev \
gmock \
grpc-dev \
gtest-dev \
libxml2-dev \
llvm13-dev \
llvm13-static \
Expand DownExpand Up@@ -95,7 +96,6 @@ ENV ARROW_ACERO=ON \
ARROW_WITH_ZSTD=ON \
AWSSDK_SOURCE=BUNDLED \
google_cloud_cpp_storage_SOURCE=BUNDLED \
GTest_SOURCE=BUNDLED \
ORC_SOURCE=BUNDLED \
PATH=/usr/lib/ccache/:$PATH \
xsimd_SOURCE=BUNDLED
4 changes: 2 additions & 2 deletions cpp/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -839,8 +839,8 @@ if(NOT MSVC_TOOLCHAIN)
list(APPEND ARROW_SHARED_LINK_LIBS ${CMAKE_DL_LIBS})
endif()

set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers GTest::gtest_main GTest::gtest
GTest::gmock)
set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers ${ARROW_GTEST_GTEST_MAIN}

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.

IMHO this is a regression as using variables instead of targets is an anti-pattern but I currently don't see a cleaner approach either.

I think we should rethink the entire dependency management once we have bumped the cmake version to 3.16 as we will have much better tools available. (this is of course out of scope for this PR)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

${ARROW_GTEST_GTEST} ${ARROW_GTEST_GMOCK})

if(ARROW_BUILD_TESTS)
add_dependencies(arrow_test_dependencies ${ARROW_TEST_LINK_TOOLCHAIN})
Expand Down
61 changes: 61 additions & 0 deletions cpp/cmake_modules/FindGTestAlt.cmake
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

if(GTestAlt_FOUND)
return()
endif()

set(find_package_args)
if(GTestAlt_FIND_VERSION)
list(APPEND find_package_args ${GTestAlt_FIND_VERSION})
endif()
if(GTestAlt_FIND_QUIETLY)
list(APPEND find_package_args QUIET)
endif()
if(CMAKE_VERSION VERSION_LESS 3.23)
list(APPEND find_package_args CONFIG)
endif()
# We can't find shred library version of GoogleTest on Windows with
# Conda's gtest package because it doesn't provide GTestConfig.cmake
# provided by GoogleTest and CMake's built-in FindGTtest.cmake
# doesn't support gtest_dll.dll.
find_package(GTest ${find_package_args})

set(GTestAlt_FOUND ${GTest_FOUND})
if(GTestAlt_FOUND)
set(KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
set(GTestAlt_CXX_STANDARD_TEST_SOURCE
"${CMAKE_CURRENT_BINARY_DIR}/gtest_cxx_standard_test.cc")
file(WRITE ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
"
#include <string_view>
#include <gtest/gtest.h>

TEST(CXX_STANDARD, MatcherStringView) {
testing::Matcher matcher(std::string_view(\"hello\"));
}
")
try_compile(GTestAlt_CXX_STANDARD_AVAILABLE ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
LINK_LIBRARIES GTest::gtest_main)
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE})
if(NOT GTestAlt_CXX_STANDARD_AVAILABLE)
message(STATUS "GTest can't be used with ${CMAKE_CXX_STANDARD}")
set(GTestAlt_FOUND FALSE)
endif()
endif()
46 changes: 18 additions & 28 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line numberDiff line numberDiff line change
Expand Up@@ -2190,54 +2190,38 @@ macro(build_gtest)
# The include directory must exist before it is referenced by a target.
file(MAKE_DIRECTORY "${GTEST_INCLUDE_DIR}")

add_library(GTest::gtest SHARED IMPORTED)
set_target_properties(GTest::gtest
add_library(arrow::GTest::gtest SHARED IMPORTED)
set_target_properties(arrow::GTest::gtest
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_SHARED_LIB}"
INTERFACE_COMPILE_DEFINITIONS
"GTEST_LINKED_AS_SHARED_LIBRARY=1"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::gtest_main SHARED IMPORTED)
set_target_properties(GTest::gtest_main
add_library(arrow::GTest::gtest_main SHARED IMPORTED)
set_target_properties(arrow::GTest::gtest_main
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_MAIN_SHARED_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::gmock SHARED IMPORTED)
set_target_properties(GTest::gmock
add_library(arrow::GTest::gmock SHARED IMPORTED)
set_target_properties(arrow::GTest::gmock
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GMOCK_SHARED_LIB}"
INTERFACE_COMPILE_DEFINITIONS
"GMOCK_LINKED_AS_SHARED_LIBRARY=1"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")
add_dependencies(toolchain-tests googletest_ep)
add_dependencies(GTest::gtest googletest_ep)
add_dependencies(GTest::gtest_main googletest_ep)
add_dependencies(GTest::gmock googletest_ep)
add_dependencies(arrow::GTest::gtest googletest_ep)
add_dependencies(arrow::GTest::gtest_main googletest_ep)
add_dependencies(arrow::GTest::gmock googletest_ep)
endmacro()

if(ARROW_TESTING)
if(CMAKE_VERSION VERSION_LESS 3.23)
set(GTEST_USE_CONFIG TRUE)
else()
set(GTEST_USE_CONFIG FALSE)
endif()
# We can't find shred library version of GoogleTest on Windows with
# Conda's gtest package because it doesn't provide GTestConfig.cmake
# provided by GoogleTest and CMake's built-in FindGTtest.cmake
# doesn't support gtest_dll.dll.
resolve_dependency(GTest
HAVE_ALT
TRUE
REQUIRED_VERSION
1.10.0
USE_CONFIG
${GTEST_USE_CONFIG})
1.10.0)

if(GTest_SOURCE STREQUAL "SYSTEM")
get_target_property(gtest_cxx_standard GTest::gtest INTERFACE_COMPILE_FEATURES)
if((${gtest_cxx_standard} STREQUAL "cxx_std_11") OR (${gtest_cxx_standard} STREQUAL
"cxx_std_14"))
message(FATAL_ERROR "System GTest is built with a C++ standard lower than 17. Use bundled GTest via passing in CMake flag
-DGTest_SOURCE=\"BUNDLED\"")
endif()

find_package(PkgConfig QUIET)
pkg_check_modules(gtest_PC
gtest
Expand All@@ -2254,10 +2238,16 @@ if(ARROW_TESTING)

string(APPEND ARROW_TESTING_PC_LIBS " $<TARGET_FILE:GTest::gtest>")
endif()
set(ARROW_GTEST_GMOCK GTest::gmock)
set(ARROW_GTEST_GTEST GTest::gtest)
set(ARROW_GTEST_GTEST_MAIN GTest::gtest_main)
else()
# TODO: How to solve BUNDLED case? Do we install bundled GoogleTest?
# string(APPEND ARROW_TESTING_PC_CFLAGS " -I${GTEST_INCLUDE_DIR}")
# string(APPEND ARROW_TESTING_PC_LIBS " -lgtest")
set(ARROW_GTEST_GMOCK arrow::GTest::gmock)
set(ARROW_GTEST_GTEST arrow::GTest::gtest)
set(ARROW_GTEST_GTEST_MAIN arrow::GTest::gtest_main)
endif()
endif()

Expand Down
8 changes: 3 additions & 5 deletions cpp/src/arrow/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -717,18 +717,16 @@ if(ARROW_TESTING)
arrow::flatbuffers
rapidjson::rapidjson
arrow_shared
GTest::gtest
${ARROW_GTEST_GTEST}
SHARED_INSTALL_INTERFACE_LIBS
Arrow::arrow_shared
GTest::gtest
STATIC_LINK_LIBS
arrow::flatbuffers
rapidjson::rapidjson
arrow_static
GTest::gtest
${ARROW_GTEST_GTEST}
STATIC_INSTALL_INTERFACE_LIBS
Arrow::arrow_static
GTest::gtest)
Arrow::arrow_static)

add_custom_target(arrow_testing)
add_dependencies(arrow_testing ${ARROW_TESTING_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/adapters/orc/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,7 @@ else()
endif()

set(ORC_STATIC_TEST_LINK_LIBS orc::liborc ${ARROW_LIBRARIES_FOR_STATIC_TESTS}
GTest::gtest_main GTest::gtest)
${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST})

add_arrow_test(adapter_test
PREFIX
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/filesystem/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,7 +81,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} GTest::gtest)
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})
add_dependencies(arrow-tests arrow-s3fs-narrative-test)
endif()

Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/flight/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,8 +67,8 @@ list(APPEND
Boost::headers
Boost::filesystem
Boost::system
GTest::gtest
GTest::gmock)
${ARROW_GTEST_GTEST}
${ARROW_GTEST_GMOCK})
list(APPEND ARROW_FLIGHT_TEST_LINK_LIBS gRPC::grpc++)

# TODO(wesm): Protobuf shared vs static linking
Expand DownExpand Up@@ -308,7 +308,7 @@ if(ARROW_TESTING)
test_definitions.cc
test_util.cc
DEPENDENCIES
GTest::gtest
${ARROW_GTEST_GTEST}
flight_grpc_gen
arrow_dependencies
SHARED_LINK_LIBS
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/flight/integration_tests/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@ list(APPEND
ARROW_FLIGHT_INTEGRATION_TEST_LINK_LIBS
${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES}
GTest::gtest)
${ARROW_GTEST_GTEST})

add_executable(flight-test-integration-server test_integration_server.cc
test_integration.cc)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/gpu/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ endif()
if(ARROW_BUILD_BENCHMARKS)
add_arrow_benchmark(cuda_benchmark PREFIX "arrow-gpu")
target_link_libraries(arrow-gpu-cuda-benchmark
PUBLIC ${ARROW_CUDA_LIBRARY} GTest::gtest
PUBLIC ${ARROW_CUDA_LIBRARY} ${ARROW_GTEST_GTEST}
${ARROW_BENCHMARK_LINK_LIBS})
add_dependencies(arrow_cuda-benchmarks arrow-gpu-cuda-benchmark)
endif()
2 changes: 1 addition & 1 deletion cpp/src/arrow/testing/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ if(ARROW_BUILD_TESTS)
elseif(ARROW_BUILD_INTEGRATION)
add_executable(arrow-json-integration-test json_integration_test.cc)
target_link_libraries(arrow-json-integration-test ${ARROW_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::gtest)
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})

add_dependencies(arrow-json-integration-test arrow arrow_testing)
add_dependencies(arrow-integration arrow-json-integration-test)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/parquet/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -114,7 +114,7 @@ else()
set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_shared arrow_shared)
endif()

set(PARQUET_MIN_TEST_LIBS GTest::gtest_main GTest::gtest Boost::headers)
set(PARQUET_MIN_TEST_LIBS ${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST} Boost::headers)

if(APPLE)
set(PARQUET_MIN_TEST_LIBS ${PARQUET_MIN_TEST_LIBS} ${CMAKE_DL_LIBS})
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion ci/docker/alpine-linux-3.16-cpp.dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,6 +37,7 @@ RUN apk add \
glog-dev \
gmock \
grpc-dev \
gtest-dev \
libxml2-dev \
llvm13-dev \
llvm13-static \
Expand DownExpand Up@@ -95,7 +96,6 @@ ENV ARROW_ACERO=ON \
ARROW_WITH_ZSTD=ON \
AWSSDK_SOURCE=BUNDLED \
google_cloud_cpp_storage_SOURCE=BUNDLED \
GTest_SOURCE=BUNDLED \
ORC_SOURCE=BUNDLED \
PATH=/usr/lib/ccache/:$PATH \
xsimd_SOURCE=BUNDLED
4 changes: 2 additions & 2 deletions cpp/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -839,8 +839,8 @@ if(NOT MSVC_TOOLCHAIN)
list(APPEND ARROW_SHARED_LINK_LIBS ${CMAKE_DL_LIBS})
endif()

set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers GTest::gtest_main GTest::gtest
GTest::gmock)
set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers ${ARROW_GTEST_GTEST_MAIN}

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.

IMHO this is a regression as using variables instead of targets is an anti-pattern but I currently don't see a cleaner approach either.

I think we should rethink the entire dependency management once we have bumped the cmake version to 3.16 as we will have much better tools available. (this is of course out of scope for this PR)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

${ARROW_GTEST_GTEST} ${ARROW_GTEST_GMOCK})

if(ARROW_BUILD_TESTS)
add_dependencies(arrow_test_dependencies ${ARROW_TEST_LINK_TOOLCHAIN})
Expand Down
61 changes: 61 additions & 0 deletions cpp/cmake_modules/FindGTestAlt.cmake
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

if(GTestAlt_FOUND)
return()
endif()

set(find_package_args)
if(GTestAlt_FIND_VERSION)
list(APPEND find_package_args ${GTestAlt_FIND_VERSION})
endif()
if(GTestAlt_FIND_QUIETLY)
list(APPEND find_package_args QUIET)
endif()
if(CMAKE_VERSION VERSION_LESS 3.23)
list(APPEND find_package_args CONFIG)
endif()
# We can't find shred library version of GoogleTest on Windows with
# Conda's gtest package because it doesn't provide GTestConfig.cmake
# provided by GoogleTest and CMake's built-in FindGTtest.cmake
# doesn't support gtest_dll.dll.
find_package(GTest ${find_package_args})

set(GTestAlt_FOUND ${GTest_FOUND})
if(GTestAlt_FOUND)
set(KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
set(GTestAlt_CXX_STANDARD_TEST_SOURCE
"${CMAKE_CURRENT_BINARY_DIR}/gtest_cxx_standard_test.cc")
file(WRITE ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
"
#include <string_view>
#include <gtest/gtest.h>

TEST(CXX_STANDARD, MatcherStringView) {
testing::Matcher matcher(std::string_view(\"hello\"));
}
")
try_compile(GTestAlt_CXX_STANDARD_AVAILABLE ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
LINK_LIBRARIES GTest::gtest_main)
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE})
if(NOT GTestAlt_CXX_STANDARD_AVAILABLE)
message(STATUS "GTest can't be used with ${CMAKE_CXX_STANDARD}")
set(GTestAlt_FOUND FALSE)
endif()
endif()
46 changes: 18 additions & 28 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line numberDiff line numberDiff line change
Expand Up@@ -2190,54 +2190,38 @@ macro(build_gtest)
# The include directory must exist before it is referenced by a target.
file(MAKE_DIRECTORY "${GTEST_INCLUDE_DIR}")

add_library(GTest::gtest SHARED IMPORTED)
set_target_properties(GTest::gtest
add_library(arrow::GTest::gtest SHARED IMPORTED)
set_target_properties(arrow::GTest::gtest
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_SHARED_LIB}"
INTERFACE_COMPILE_DEFINITIONS
"GTEST_LINKED_AS_SHARED_LIBRARY=1"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::gtest_main SHARED IMPORTED)
set_target_properties(GTest::gtest_main
add_library(arrow::GTest::gtest_main SHARED IMPORTED)
set_target_properties(arrow::GTest::gtest_main
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_MAIN_SHARED_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::gmock SHARED IMPORTED)
set_target_properties(GTest::gmock
add_library(arrow::GTest::gmock SHARED IMPORTED)
set_target_properties(arrow::GTest::gmock
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GMOCK_SHARED_LIB}"
INTERFACE_COMPILE_DEFINITIONS
"GMOCK_LINKED_AS_SHARED_LIBRARY=1"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")
add_dependencies(toolchain-tests googletest_ep)
add_dependencies(GTest::gtest googletest_ep)
add_dependencies(GTest::gtest_main googletest_ep)
add_dependencies(GTest::gmock googletest_ep)
add_dependencies(arrow::GTest::gtest googletest_ep)
add_dependencies(arrow::GTest::gtest_main googletest_ep)
add_dependencies(arrow::GTest::gmock googletest_ep)
endmacro()

if(ARROW_TESTING)
if(CMAKE_VERSION VERSION_LESS 3.23)
set(GTEST_USE_CONFIG TRUE)
else()
set(GTEST_USE_CONFIG FALSE)
endif()
# We can't find shred library version of GoogleTest on Windows with
# Conda's gtest package because it doesn't provide GTestConfig.cmake
# provided by GoogleTest and CMake's built-in FindGTtest.cmake
# doesn't support gtest_dll.dll.
resolve_dependency(GTest
HAVE_ALT
TRUE
REQUIRED_VERSION
1.10.0
USE_CONFIG
${GTEST_USE_CONFIG})
1.10.0)

if(GTest_SOURCE STREQUAL "SYSTEM")
get_target_property(gtest_cxx_standard GTest::gtest INTERFACE_COMPILE_FEATURES)
if((${gtest_cxx_standard} STREQUAL "cxx_std_11") OR (${gtest_cxx_standard} STREQUAL
"cxx_std_14"))
message(FATAL_ERROR "System GTest is built with a C++ standard lower than 17. Use bundled GTest via passing in CMake flag
-DGTest_SOURCE=\"BUNDLED\"")
endif()

find_package(PkgConfig QUIET)
pkg_check_modules(gtest_PC
gtest
Expand All@@ -2254,10 +2238,16 @@ if(ARROW_TESTING)

string(APPEND ARROW_TESTING_PC_LIBS " $<TARGET_FILE:GTest::gtest>")
endif()
set(ARROW_GTEST_GMOCK GTest::gmock)
set(ARROW_GTEST_GTEST GTest::gtest)
set(ARROW_GTEST_GTEST_MAIN GTest::gtest_main)
else()
# TODO: How to solve BUNDLED case? Do we install bundled GoogleTest?
# string(APPEND ARROW_TESTING_PC_CFLAGS " -I${GTEST_INCLUDE_DIR}")
# string(APPEND ARROW_TESTING_PC_LIBS " -lgtest")
set(ARROW_GTEST_GMOCK arrow::GTest::gmock)
set(ARROW_GTEST_GTEST arrow::GTest::gtest)
set(ARROW_GTEST_GTEST_MAIN arrow::GTest::gtest_main)
endif()
endif()

Expand Down
8 changes: 3 additions & 5 deletions cpp/src/arrow/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -717,18 +717,16 @@ if(ARROW_TESTING)
arrow::flatbuffers
rapidjson::rapidjson
arrow_shared
GTest::gtest
${ARROW_GTEST_GTEST}
SHARED_INSTALL_INTERFACE_LIBS
Arrow::arrow_shared
GTest::gtest
STATIC_LINK_LIBS
arrow::flatbuffers
rapidjson::rapidjson
arrow_static
GTest::gtest
${ARROW_GTEST_GTEST}
STATIC_INSTALL_INTERFACE_LIBS
Arrow::arrow_static
GTest::gtest)
Arrow::arrow_static)

add_custom_target(arrow_testing)
add_dependencies(arrow_testing ${ARROW_TESTING_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/adapters/orc/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,7 @@ else()
endif()

set(ORC_STATIC_TEST_LINK_LIBS orc::liborc ${ARROW_LIBRARIES_FOR_STATIC_TESTS}
GTest::gtest_main GTest::gtest)
${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST})

add_arrow_test(adapter_test
PREFIX
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/filesystem/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,7 +81,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} GTest::gtest)
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})
add_dependencies(arrow-tests arrow-s3fs-narrative-test)
endif()

Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/flight/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,8 +67,8 @@ list(APPEND
Boost::headers
Boost::filesystem
Boost::system
GTest::gtest
GTest::gmock)
${ARROW_GTEST_GTEST}
${ARROW_GTEST_GMOCK})
list(APPEND ARROW_FLIGHT_TEST_LINK_LIBS gRPC::grpc++)

# TODO(wesm): Protobuf shared vs static linking
Expand DownExpand Up@@ -308,7 +308,7 @@ if(ARROW_TESTING)
test_definitions.cc
test_util.cc
DEPENDENCIES
GTest::gtest
${ARROW_GTEST_GTEST}
flight_grpc_gen
arrow_dependencies
SHARED_LINK_LIBS
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/flight/integration_tests/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@ list(APPEND
ARROW_FLIGHT_INTEGRATION_TEST_LINK_LIBS
${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES}
GTest::gtest)
${ARROW_GTEST_GTEST})

add_executable(flight-test-integration-server test_integration_server.cc
test_integration.cc)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/gpu/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ endif()
if(ARROW_BUILD_BENCHMARKS)
add_arrow_benchmark(cuda_benchmark PREFIX "arrow-gpu")
target_link_libraries(arrow-gpu-cuda-benchmark
PUBLIC ${ARROW_CUDA_LIBRARY} GTest::gtest
PUBLIC ${ARROW_CUDA_LIBRARY} ${ARROW_GTEST_GTEST}
${ARROW_BENCHMARK_LINK_LIBS})
add_dependencies(arrow_cuda-benchmarks arrow-gpu-cuda-benchmark)
endif()
2 changes: 1 addition & 1 deletion cpp/src/arrow/testing/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ if(ARROW_BUILD_TESTS)
elseif(ARROW_BUILD_INTEGRATION)
add_executable(arrow-json-integration-test json_integration_test.cc)
target_link_libraries(arrow-json-integration-test ${ARROW_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::gtest)
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})

add_dependencies(arrow-json-integration-test arrow arrow_testing)
add_dependencies(arrow-integration arrow-json-integration-test)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/parquet/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -114,7 +114,7 @@ else()
set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_shared arrow_shared)
endif()

set(PARQUET_MIN_TEST_LIBS GTest::gtest_main GTest::gtest Boost::headers)
set(PARQUET_MIN_TEST_LIBS ${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST} Boost::headers)

if(APPLE)
set(PARQUET_MIN_TEST_LIBS ${PARQUET_MIN_TEST_LIBS} ${CMAKE_DL_LIBS})
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion ci/docker/alpine-linux-3.16-cpp.dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,6 +37,7 @@ RUN apk add \
glog-dev \
gmock \
grpc-dev \
gtest-dev \
libxml2-dev \
llvm13-dev \
llvm13-static \
Expand DownExpand Up@@ -95,7 +96,6 @@ ENV ARROW_ACERO=ON \
ARROW_WITH_ZSTD=ON \
AWSSDK_SOURCE=BUNDLED \
google_cloud_cpp_storage_SOURCE=BUNDLED \
GTest_SOURCE=BUNDLED \
ORC_SOURCE=BUNDLED \
PATH=/usr/lib/ccache/:$PATH \
xsimd_SOURCE=BUNDLED
4 changes: 2 additions & 2 deletions cpp/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -839,8 +839,8 @@ if(NOT MSVC_TOOLCHAIN)
list(APPEND ARROW_SHARED_LINK_LIBS ${CMAKE_DL_LIBS})
endif()

set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers GTest::gtest_main GTest::gtest
GTest::gmock)
set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers ${ARROW_GTEST_GTEST_MAIN}

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.

IMHO this is a regression as using variables instead of targets is an anti-pattern but I currently don't see a cleaner approach either.

I think we should rethink the entire dependency management once we have bumped the cmake version to 3.16 as we will have much better tools available. (this is of course out of scope for this PR)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

${ARROW_GTEST_GTEST} ${ARROW_GTEST_GMOCK})

if(ARROW_BUILD_TESTS)
add_dependencies(arrow_test_dependencies ${ARROW_TEST_LINK_TOOLCHAIN})
Expand Down
61 changes: 61 additions & 0 deletions cpp/cmake_modules/FindGTestAlt.cmake
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

if(GTestAlt_FOUND)
return()
endif()

set(find_package_args)
if(GTestAlt_FIND_VERSION)
list(APPEND find_package_args ${GTestAlt_FIND_VERSION})
endif()
if(GTestAlt_FIND_QUIETLY)
list(APPEND find_package_args QUIET)
endif()
if(CMAKE_VERSION VERSION_LESS 3.23)
list(APPEND find_package_args CONFIG)
endif()
# We can't find shred library version of GoogleTest on Windows with
# Conda's gtest package because it doesn't provide GTestConfig.cmake
# provided by GoogleTest and CMake's built-in FindGTtest.cmake
# doesn't support gtest_dll.dll.
find_package(GTest ${find_package_args})

set(GTestAlt_FOUND ${GTest_FOUND})
if(GTestAlt_FOUND)
set(KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
set(GTestAlt_CXX_STANDARD_TEST_SOURCE
"${CMAKE_CURRENT_BINARY_DIR}/gtest_cxx_standard_test.cc")
file(WRITE ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
"
#include <string_view>
#include <gtest/gtest.h>

TEST(CXX_STANDARD, MatcherStringView) {
testing::Matcher matcher(std::string_view(\"hello\"));
}
")
try_compile(GTestAlt_CXX_STANDARD_AVAILABLE ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
LINK_LIBRARIES GTest::gtest_main)
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE})
if(NOT GTestAlt_CXX_STANDARD_AVAILABLE)
message(STATUS "GTest can't be used with ${CMAKE_CXX_STANDARD}")
set(GTestAlt_FOUND FALSE)
endif()
endif()
46 changes: 18 additions & 28 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line numberDiff line numberDiff line change
Expand Up@@ -2190,54 +2190,38 @@ macro(build_gtest)
# The include directory must exist before it is referenced by a target.
file(MAKE_DIRECTORY "${GTEST_INCLUDE_DIR}")

add_library(GTest::gtest SHARED IMPORTED)
set_target_properties(GTest::gtest
add_library(arrow::GTest::gtest SHARED IMPORTED)
set_target_properties(arrow::GTest::gtest
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_SHARED_LIB}"
INTERFACE_COMPILE_DEFINITIONS
"GTEST_LINKED_AS_SHARED_LIBRARY=1"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::gtest_main SHARED IMPORTED)
set_target_properties(GTest::gtest_main
add_library(arrow::GTest::gtest_main SHARED IMPORTED)
set_target_properties(arrow::GTest::gtest_main
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_MAIN_SHARED_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::gmock SHARED IMPORTED)
set_target_properties(GTest::gmock
add_library(arrow::GTest::gmock SHARED IMPORTED)
set_target_properties(arrow::GTest::gmock
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GMOCK_SHARED_LIB}"
INTERFACE_COMPILE_DEFINITIONS
"GMOCK_LINKED_AS_SHARED_LIBRARY=1"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")
add_dependencies(toolchain-tests googletest_ep)
add_dependencies(GTest::gtest googletest_ep)
add_dependencies(GTest::gtest_main googletest_ep)
add_dependencies(GTest::gmock googletest_ep)
add_dependencies(arrow::GTest::gtest googletest_ep)
add_dependencies(arrow::GTest::gtest_main googletest_ep)
add_dependencies(arrow::GTest::gmock googletest_ep)
endmacro()

if(ARROW_TESTING)
if(CMAKE_VERSION VERSION_LESS 3.23)
set(GTEST_USE_CONFIG TRUE)
else()
set(GTEST_USE_CONFIG FALSE)
endif()
# We can't find shred library version of GoogleTest on Windows with
# Conda's gtest package because it doesn't provide GTestConfig.cmake
# provided by GoogleTest and CMake's built-in FindGTtest.cmake
# doesn't support gtest_dll.dll.
resolve_dependency(GTest
HAVE_ALT
TRUE
REQUIRED_VERSION
1.10.0
USE_CONFIG
${GTEST_USE_CONFIG})
1.10.0)

if(GTest_SOURCE STREQUAL "SYSTEM")
get_target_property(gtest_cxx_standard GTest::gtest INTERFACE_COMPILE_FEATURES)
if((${gtest_cxx_standard} STREQUAL "cxx_std_11") OR (${gtest_cxx_standard} STREQUAL
"cxx_std_14"))
message(FATAL_ERROR "System GTest is built with a C++ standard lower than 17. Use bundled GTest via passing in CMake flag
-DGTest_SOURCE=\"BUNDLED\"")
endif()

find_package(PkgConfig QUIET)
pkg_check_modules(gtest_PC
gtest
Expand All@@ -2254,10 +2238,16 @@ if(ARROW_TESTING)

string(APPEND ARROW_TESTING_PC_LIBS " $<TARGET_FILE:GTest::gtest>")
endif()
set(ARROW_GTEST_GMOCK GTest::gmock)
set(ARROW_GTEST_GTEST GTest::gtest)
set(ARROW_GTEST_GTEST_MAIN GTest::gtest_main)
else()
# TODO: How to solve BUNDLED case? Do we install bundled GoogleTest?
# string(APPEND ARROW_TESTING_PC_CFLAGS " -I${GTEST_INCLUDE_DIR}")
# string(APPEND ARROW_TESTING_PC_LIBS " -lgtest")
set(ARROW_GTEST_GMOCK arrow::GTest::gmock)
set(ARROW_GTEST_GTEST arrow::GTest::gtest)
set(ARROW_GTEST_GTEST_MAIN arrow::GTest::gtest_main)
endif()
endif()

Expand Down
8 changes: 3 additions & 5 deletions cpp/src/arrow/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -717,18 +717,16 @@ if(ARROW_TESTING)
arrow::flatbuffers
rapidjson::rapidjson
arrow_shared
GTest::gtest
${ARROW_GTEST_GTEST}
SHARED_INSTALL_INTERFACE_LIBS
Arrow::arrow_shared
GTest::gtest
STATIC_LINK_LIBS
arrow::flatbuffers
rapidjson::rapidjson
arrow_static
GTest::gtest
${ARROW_GTEST_GTEST}
STATIC_INSTALL_INTERFACE_LIBS
Arrow::arrow_static
GTest::gtest)
Arrow::arrow_static)

add_custom_target(arrow_testing)
add_dependencies(arrow_testing ${ARROW_TESTING_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/adapters/orc/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,7 @@ else()
endif()

set(ORC_STATIC_TEST_LINK_LIBS orc::liborc ${ARROW_LIBRARIES_FOR_STATIC_TESTS}
GTest::gtest_main GTest::gtest)
${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST})

add_arrow_test(adapter_test
PREFIX
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/filesystem/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,7 +81,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} GTest::gtest)
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})
add_dependencies(arrow-tests arrow-s3fs-narrative-test)
endif()

Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/flight/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,8 +67,8 @@ list(APPEND
Boost::headers
Boost::filesystem
Boost::system
GTest::gtest
GTest::gmock)
${ARROW_GTEST_GTEST}
${ARROW_GTEST_GMOCK})
list(APPEND ARROW_FLIGHT_TEST_LINK_LIBS gRPC::grpc++)

# TODO(wesm): Protobuf shared vs static linking
Expand DownExpand Up@@ -308,7 +308,7 @@ if(ARROW_TESTING)
test_definitions.cc
test_util.cc
DEPENDENCIES
GTest::gtest
${ARROW_GTEST_GTEST}
flight_grpc_gen
arrow_dependencies
SHARED_LINK_LIBS
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/flight/integration_tests/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@ list(APPEND
ARROW_FLIGHT_INTEGRATION_TEST_LINK_LIBS
${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES}
GTest::gtest)
${ARROW_GTEST_GTEST})

add_executable(flight-test-integration-server test_integration_server.cc
test_integration.cc)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/gpu/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ endif()
if(ARROW_BUILD_BENCHMARKS)
add_arrow_benchmark(cuda_benchmark PREFIX "arrow-gpu")
target_link_libraries(arrow-gpu-cuda-benchmark
PUBLIC ${ARROW_CUDA_LIBRARY} GTest::gtest
PUBLIC ${ARROW_CUDA_LIBRARY} ${ARROW_GTEST_GTEST}
${ARROW_BENCHMARK_LINK_LIBS})
add_dependencies(arrow_cuda-benchmarks arrow-gpu-cuda-benchmark)
endif()
2 changes: 1 addition & 1 deletion cpp/src/arrow/testing/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ if(ARROW_BUILD_TESTS)
elseif(ARROW_BUILD_INTEGRATION)
add_executable(arrow-json-integration-test json_integration_test.cc)
target_link_libraries(arrow-json-integration-test ${ARROW_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::gtest)
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})

add_dependencies(arrow-json-integration-test arrow arrow_testing)
add_dependencies(arrow-integration arrow-json-integration-test)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/parquet/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -114,7 +114,7 @@ else()
set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_shared arrow_shared)
endif()

set(PARQUET_MIN_TEST_LIBS GTest::gtest_main GTest::gtest Boost::headers)
set(PARQUET_MIN_TEST_LIBS ${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST} Boost::headers)

if(APPLE)
set(PARQUET_MIN_TEST_LIBS ${PARQUET_MIN_TEST_LIBS} ${CMAKE_DL_LIBS})
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion ci/docker/alpine-linux-3.16-cpp.dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,6 +37,7 @@ RUN apk add \
glog-dev \
gmock \
grpc-dev \
gtest-dev \
libxml2-dev \
llvm13-dev \
llvm13-static \
Expand DownExpand Up@@ -95,7 +96,6 @@ ENV ARROW_ACERO=ON \
ARROW_WITH_ZSTD=ON \
AWSSDK_SOURCE=BUNDLED \
google_cloud_cpp_storage_SOURCE=BUNDLED \
GTest_SOURCE=BUNDLED \
ORC_SOURCE=BUNDLED \
PATH=/usr/lib/ccache/:$PATH \
xsimd_SOURCE=BUNDLED
4 changes: 2 additions & 2 deletions cpp/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -839,8 +839,8 @@ if(NOT MSVC_TOOLCHAIN)
list(APPEND ARROW_SHARED_LINK_LIBS ${CMAKE_DL_LIBS})
endif()

set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers GTest::gtest_main GTest::gtest
GTest::gmock)
set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers ${ARROW_GTEST_GTEST_MAIN}

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.

IMHO this is a regression as using variables instead of targets is an anti-pattern but I currently don't see a cleaner approach either.

I think we should rethink the entire dependency management once we have bumped the cmake version to 3.16 as we will have much better tools available. (this is of course out of scope for this PR)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

${ARROW_GTEST_GTEST} ${ARROW_GTEST_GMOCK})

if(ARROW_BUILD_TESTS)
add_dependencies(arrow_test_dependencies ${ARROW_TEST_LINK_TOOLCHAIN})
Expand Down
61 changes: 61 additions & 0 deletions cpp/cmake_modules/FindGTestAlt.cmake
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

if(GTestAlt_FOUND)
return()
endif()

set(find_package_args)
if(GTestAlt_FIND_VERSION)
list(APPEND find_package_args ${GTestAlt_FIND_VERSION})
endif()
if(GTestAlt_FIND_QUIETLY)
list(APPEND find_package_args QUIET)
endif()
if(CMAKE_VERSION VERSION_LESS 3.23)
list(APPEND find_package_args CONFIG)
endif()
# We can't find shred library version of GoogleTest on Windows with
# Conda's gtest package because it doesn't provide GTestConfig.cmake
# provided by GoogleTest and CMake's built-in FindGTtest.cmake
# doesn't support gtest_dll.dll.
find_package(GTest ${find_package_args})

set(GTestAlt_FOUND ${GTest_FOUND})
if(GTestAlt_FOUND)
set(KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
set(GTestAlt_CXX_STANDARD_TEST_SOURCE
"${CMAKE_CURRENT_BINARY_DIR}/gtest_cxx_standard_test.cc")
file(WRITE ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
"
#include <string_view>
#include <gtest/gtest.h>

TEST(CXX_STANDARD, MatcherStringView) {
testing::Matcher matcher(std::string_view(\"hello\"));
}
")
try_compile(GTestAlt_CXX_STANDARD_AVAILABLE ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
LINK_LIBRARIES GTest::gtest_main)
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE})
if(NOT GTestAlt_CXX_STANDARD_AVAILABLE)
message(STATUS "GTest can't be used with ${CMAKE_CXX_STANDARD}")
set(GTestAlt_FOUND FALSE)
endif()
endif()
46 changes: 18 additions & 28 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line numberDiff line numberDiff line change
Expand Up@@ -2190,54 +2190,38 @@ macro(build_gtest)
# The include directory must exist before it is referenced by a target.
file(MAKE_DIRECTORY "${GTEST_INCLUDE_DIR}")

add_library(GTest::gtest SHARED IMPORTED)
set_target_properties(GTest::gtest
add_library(arrow::GTest::gtest SHARED IMPORTED)
set_target_properties(arrow::GTest::gtest
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_SHARED_LIB}"
INTERFACE_COMPILE_DEFINITIONS
"GTEST_LINKED_AS_SHARED_LIBRARY=1"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::gtest_main SHARED IMPORTED)
set_target_properties(GTest::gtest_main
add_library(arrow::GTest::gtest_main SHARED IMPORTED)
set_target_properties(arrow::GTest::gtest_main
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_MAIN_SHARED_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::gmock SHARED IMPORTED)
set_target_properties(GTest::gmock
add_library(arrow::GTest::gmock SHARED IMPORTED)
set_target_properties(arrow::GTest::gmock
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GMOCK_SHARED_LIB}"
INTERFACE_COMPILE_DEFINITIONS
"GMOCK_LINKED_AS_SHARED_LIBRARY=1"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")
add_dependencies(toolchain-tests googletest_ep)
add_dependencies(GTest::gtest googletest_ep)
add_dependencies(GTest::gtest_main googletest_ep)
add_dependencies(GTest::gmock googletest_ep)
add_dependencies(arrow::GTest::gtest googletest_ep)
add_dependencies(arrow::GTest::gtest_main googletest_ep)
add_dependencies(arrow::GTest::gmock googletest_ep)
endmacro()

if(ARROW_TESTING)
if(CMAKE_VERSION VERSION_LESS 3.23)
set(GTEST_USE_CONFIG TRUE)
else()
set(GTEST_USE_CONFIG FALSE)
endif()
# We can't find shred library version of GoogleTest on Windows with
# Conda's gtest package because it doesn't provide GTestConfig.cmake
# provided by GoogleTest and CMake's built-in FindGTtest.cmake
# doesn't support gtest_dll.dll.
resolve_dependency(GTest
HAVE_ALT
TRUE
REQUIRED_VERSION
1.10.0
USE_CONFIG
${GTEST_USE_CONFIG})
1.10.0)

if(GTest_SOURCE STREQUAL "SYSTEM")
get_target_property(gtest_cxx_standard GTest::gtest INTERFACE_COMPILE_FEATURES)
if((${gtest_cxx_standard} STREQUAL "cxx_std_11") OR (${gtest_cxx_standard} STREQUAL
"cxx_std_14"))
message(FATAL_ERROR "System GTest is built with a C++ standard lower than 17. Use bundled GTest via passing in CMake flag
-DGTest_SOURCE=\"BUNDLED\"")
endif()

find_package(PkgConfig QUIET)
pkg_check_modules(gtest_PC
gtest
Expand All@@ -2254,10 +2238,16 @@ if(ARROW_TESTING)

string(APPEND ARROW_TESTING_PC_LIBS " $<TARGET_FILE:GTest::gtest>")
endif()
set(ARROW_GTEST_GMOCK GTest::gmock)
set(ARROW_GTEST_GTEST GTest::gtest)
set(ARROW_GTEST_GTEST_MAIN GTest::gtest_main)
else()
# TODO: How to solve BUNDLED case? Do we install bundled GoogleTest?
# string(APPEND ARROW_TESTING_PC_CFLAGS " -I${GTEST_INCLUDE_DIR}")
# string(APPEND ARROW_TESTING_PC_LIBS " -lgtest")
set(ARROW_GTEST_GMOCK arrow::GTest::gmock)
set(ARROW_GTEST_GTEST arrow::GTest::gtest)
set(ARROW_GTEST_GTEST_MAIN arrow::GTest::gtest_main)
endif()
endif()

Expand Down
8 changes: 3 additions & 5 deletions cpp/src/arrow/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -717,18 +717,16 @@ if(ARROW_TESTING)
arrow::flatbuffers
rapidjson::rapidjson
arrow_shared
GTest::gtest
${ARROW_GTEST_GTEST}
SHARED_INSTALL_INTERFACE_LIBS
Arrow::arrow_shared
GTest::gtest
STATIC_LINK_LIBS
arrow::flatbuffers
rapidjson::rapidjson
arrow_static
GTest::gtest
${ARROW_GTEST_GTEST}
STATIC_INSTALL_INTERFACE_LIBS
Arrow::arrow_static
GTest::gtest)
Arrow::arrow_static)

add_custom_target(arrow_testing)
add_dependencies(arrow_testing ${ARROW_TESTING_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/adapters/orc/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,7 @@ else()
endif()

set(ORC_STATIC_TEST_LINK_LIBS orc::liborc ${ARROW_LIBRARIES_FOR_STATIC_TESTS}
GTest::gtest_main GTest::gtest)
${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST})

add_arrow_test(adapter_test
PREFIX
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/filesystem/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,7 +81,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} GTest::gtest)
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})
add_dependencies(arrow-tests arrow-s3fs-narrative-test)
endif()

Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/flight/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,8 +67,8 @@ list(APPEND
Boost::headers
Boost::filesystem
Boost::system
GTest::gtest
GTest::gmock)
${ARROW_GTEST_GTEST}
${ARROW_GTEST_GMOCK})
list(APPEND ARROW_FLIGHT_TEST_LINK_LIBS gRPC::grpc++)

# TODO(wesm): Protobuf shared vs static linking
Expand DownExpand Up@@ -308,7 +308,7 @@ if(ARROW_TESTING)
test_definitions.cc
test_util.cc
DEPENDENCIES
GTest::gtest
${ARROW_GTEST_GTEST}
flight_grpc_gen
arrow_dependencies
SHARED_LINK_LIBS
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/flight/integration_tests/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@ list(APPEND
ARROW_FLIGHT_INTEGRATION_TEST_LINK_LIBS
${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES}
GTest::gtest)
${ARROW_GTEST_GTEST})

add_executable(flight-test-integration-server test_integration_server.cc
test_integration.cc)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/gpu/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ endif()
if(ARROW_BUILD_BENCHMARKS)
add_arrow_benchmark(cuda_benchmark PREFIX "arrow-gpu")
target_link_libraries(arrow-gpu-cuda-benchmark
PUBLIC ${ARROW_CUDA_LIBRARY} GTest::gtest
PUBLIC ${ARROW_CUDA_LIBRARY} ${ARROW_GTEST_GTEST}
${ARROW_BENCHMARK_LINK_LIBS})
add_dependencies(arrow_cuda-benchmarks arrow-gpu-cuda-benchmark)
endif()
2 changes: 1 addition & 1 deletion cpp/src/arrow/testing/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ if(ARROW_BUILD_TESTS)
elseif(ARROW_BUILD_INTEGRATION)
add_executable(arrow-json-integration-test json_integration_test.cc)
target_link_libraries(arrow-json-integration-test ${ARROW_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::gtest)
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})

add_dependencies(arrow-json-integration-test arrow arrow_testing)
add_dependencies(arrow-integration arrow-json-integration-test)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/parquet/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -114,7 +114,7 @@ else()
set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_shared arrow_shared)
endif()

set(PARQUET_MIN_TEST_LIBS GTest::gtest_main GTest::gtest Boost::headers)
set(PARQUET_MIN_TEST_LIBS ${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST} Boost::headers)

if(APPLE)
set(PARQUET_MIN_TEST_LIBS ${PARQUET_MIN_TEST_LIBS} ${CMAKE_DL_LIBS})
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion ci/docker/alpine-linux-3.16-cpp.dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,6 +37,7 @@ RUN apk add \
glog-dev \
gmock \
grpc-dev \
gtest-dev \
libxml2-dev \
llvm13-dev \
llvm13-static \
Expand DownExpand Up@@ -95,7 +96,6 @@ ENV ARROW_ACERO=ON \
ARROW_WITH_ZSTD=ON \
AWSSDK_SOURCE=BUNDLED \
google_cloud_cpp_storage_SOURCE=BUNDLED \
GTest_SOURCE=BUNDLED \
ORC_SOURCE=BUNDLED \
PATH=/usr/lib/ccache/:$PATH \
xsimd_SOURCE=BUNDLED
4 changes: 2 additions & 2 deletions cpp/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -839,8 +839,8 @@ if(NOT MSVC_TOOLCHAIN)
list(APPEND ARROW_SHARED_LINK_LIBS ${CMAKE_DL_LIBS})
endif()

set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers GTest::gtest_main GTest::gtest
GTest::gmock)
set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers ${ARROW_GTEST_GTEST_MAIN}

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.

IMHO this is a regression as using variables instead of targets is an anti-pattern but I currently don't see a cleaner approach either.

I think we should rethink the entire dependency management once we have bumped the cmake version to 3.16 as we will have much better tools available. (this is of course out of scope for this PR)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

${ARROW_GTEST_GTEST} ${ARROW_GTEST_GMOCK})

if(ARROW_BUILD_TESTS)
add_dependencies(arrow_test_dependencies ${ARROW_TEST_LINK_TOOLCHAIN})
Expand Down
61 changes: 61 additions & 0 deletions cpp/cmake_modules/FindGTestAlt.cmake
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

if(GTestAlt_FOUND)
return()
endif()

set(find_package_args)
if(GTestAlt_FIND_VERSION)
list(APPEND find_package_args ${GTestAlt_FIND_VERSION})
endif()
if(GTestAlt_FIND_QUIETLY)
list(APPEND find_package_args QUIET)
endif()
if(CMAKE_VERSION VERSION_LESS 3.23)
list(APPEND find_package_args CONFIG)
endif()
# We can't find shred library version of GoogleTest on Windows with
# Conda's gtest package because it doesn't provide GTestConfig.cmake
# provided by GoogleTest and CMake's built-in FindGTtest.cmake
# doesn't support gtest_dll.dll.
find_package(GTest ${find_package_args})

set(GTestAlt_FOUND ${GTest_FOUND})
if(GTestAlt_FOUND)
set(KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
set(GTestAlt_CXX_STANDARD_TEST_SOURCE
"${CMAKE_CURRENT_BINARY_DIR}/gtest_cxx_standard_test.cc")
file(WRITE ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
"
#include <string_view>
#include <gtest/gtest.h>

TEST(CXX_STANDARD, MatcherStringView) {
testing::Matcher matcher(std::string_view(\"hello\"));
}
")
try_compile(GTestAlt_CXX_STANDARD_AVAILABLE ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
LINK_LIBRARIES GTest::gtest_main)
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE})
if(NOT GTestAlt_CXX_STANDARD_AVAILABLE)
message(STATUS "GTest can't be used with ${CMAKE_CXX_STANDARD}")
set(GTestAlt_FOUND FALSE)
endif()
endif()
46 changes: 18 additions & 28 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line numberDiff line numberDiff line change
Expand Up@@ -2190,54 +2190,38 @@ macro(build_gtest)
# The include directory must exist before it is referenced by a target.
file(MAKE_DIRECTORY "${GTEST_INCLUDE_DIR}")

add_library(GTest::gtest SHARED IMPORTED)
set_target_properties(GTest::gtest
add_library(arrow::GTest::gtest SHARED IMPORTED)
set_target_properties(arrow::GTest::gtest
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_SHARED_LIB}"
INTERFACE_COMPILE_DEFINITIONS
"GTEST_LINKED_AS_SHARED_LIBRARY=1"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::gtest_main SHARED IMPORTED)
set_target_properties(GTest::gtest_main
add_library(arrow::GTest::gtest_main SHARED IMPORTED)
set_target_properties(arrow::GTest::gtest_main
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_MAIN_SHARED_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::gmock SHARED IMPORTED)
set_target_properties(GTest::gmock
add_library(arrow::GTest::gmock SHARED IMPORTED)
set_target_properties(arrow::GTest::gmock
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GMOCK_SHARED_LIB}"
INTERFACE_COMPILE_DEFINITIONS
"GMOCK_LINKED_AS_SHARED_LIBRARY=1"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")
add_dependencies(toolchain-tests googletest_ep)
add_dependencies(GTest::gtest googletest_ep)
add_dependencies(GTest::gtest_main googletest_ep)
add_dependencies(GTest::gmock googletest_ep)
add_dependencies(arrow::GTest::gtest googletest_ep)
add_dependencies(arrow::GTest::gtest_main googletest_ep)
add_dependencies(arrow::GTest::gmock googletest_ep)
endmacro()

if(ARROW_TESTING)
if(CMAKE_VERSION VERSION_LESS 3.23)
set(GTEST_USE_CONFIG TRUE)
else()
set(GTEST_USE_CONFIG FALSE)
endif()
# We can't find shred library version of GoogleTest on Windows with
# Conda's gtest package because it doesn't provide GTestConfig.cmake
# provided by GoogleTest and CMake's built-in FindGTtest.cmake
# doesn't support gtest_dll.dll.
resolve_dependency(GTest
HAVE_ALT
TRUE
REQUIRED_VERSION
1.10.0
USE_CONFIG
${GTEST_USE_CONFIG})
1.10.0)

if(GTest_SOURCE STREQUAL "SYSTEM")
get_target_property(gtest_cxx_standard GTest::gtest INTERFACE_COMPILE_FEATURES)
if((${gtest_cxx_standard} STREQUAL "cxx_std_11") OR (${gtest_cxx_standard} STREQUAL
"cxx_std_14"))
message(FATAL_ERROR "System GTest is built with a C++ standard lower than 17. Use bundled GTest via passing in CMake flag
-DGTest_SOURCE=\"BUNDLED\"")
endif()

find_package(PkgConfig QUIET)
pkg_check_modules(gtest_PC
gtest
Expand All@@ -2254,10 +2238,16 @@ if(ARROW_TESTING)

string(APPEND ARROW_TESTING_PC_LIBS " $<TARGET_FILE:GTest::gtest>")
endif()
set(ARROW_GTEST_GMOCK GTest::gmock)
set(ARROW_GTEST_GTEST GTest::gtest)
set(ARROW_GTEST_GTEST_MAIN GTest::gtest_main)
else()
# TODO: How to solve BUNDLED case? Do we install bundled GoogleTest?
# string(APPEND ARROW_TESTING_PC_CFLAGS " -I${GTEST_INCLUDE_DIR}")
# string(APPEND ARROW_TESTING_PC_LIBS " -lgtest")
set(ARROW_GTEST_GMOCK arrow::GTest::gmock)
set(ARROW_GTEST_GTEST arrow::GTest::gtest)
set(ARROW_GTEST_GTEST_MAIN arrow::GTest::gtest_main)
endif()
endif()

Expand Down
8 changes: 3 additions & 5 deletions cpp/src/arrow/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -717,18 +717,16 @@ if(ARROW_TESTING)
arrow::flatbuffers
rapidjson::rapidjson
arrow_shared
GTest::gtest
${ARROW_GTEST_GTEST}
SHARED_INSTALL_INTERFACE_LIBS
Arrow::arrow_shared
GTest::gtest
STATIC_LINK_LIBS
arrow::flatbuffers
rapidjson::rapidjson
arrow_static
GTest::gtest
${ARROW_GTEST_GTEST}
STATIC_INSTALL_INTERFACE_LIBS
Arrow::arrow_static
GTest::gtest)
Arrow::arrow_static)

add_custom_target(arrow_testing)
add_dependencies(arrow_testing ${ARROW_TESTING_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/adapters/orc/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,7 @@ else()
endif()

set(ORC_STATIC_TEST_LINK_LIBS orc::liborc ${ARROW_LIBRARIES_FOR_STATIC_TESTS}
GTest::gtest_main GTest::gtest)
${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST})

add_arrow_test(adapter_test
PREFIX
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/filesystem/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,7 +81,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} GTest::gtest)
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})
add_dependencies(arrow-tests arrow-s3fs-narrative-test)
endif()

Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/flight/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,8 +67,8 @@ list(APPEND
Boost::headers
Boost::filesystem
Boost::system
GTest::gtest
GTest::gmock)
${ARROW_GTEST_GTEST}
${ARROW_GTEST_GMOCK})
list(APPEND ARROW_FLIGHT_TEST_LINK_LIBS gRPC::grpc++)

# TODO(wesm): Protobuf shared vs static linking
Expand DownExpand Up@@ -308,7 +308,7 @@ if(ARROW_TESTING)
test_definitions.cc
test_util.cc
DEPENDENCIES
GTest::gtest
${ARROW_GTEST_GTEST}
flight_grpc_gen
arrow_dependencies
SHARED_LINK_LIBS
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/flight/integration_tests/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@ list(APPEND
ARROW_FLIGHT_INTEGRATION_TEST_LINK_LIBS
${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES}
GTest::gtest)
${ARROW_GTEST_GTEST})

add_executable(flight-test-integration-server test_integration_server.cc
test_integration.cc)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/gpu/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ endif()
if(ARROW_BUILD_BENCHMARKS)
add_arrow_benchmark(cuda_benchmark PREFIX "arrow-gpu")
target_link_libraries(arrow-gpu-cuda-benchmark
PUBLIC ${ARROW_CUDA_LIBRARY} GTest::gtest
PUBLIC ${ARROW_CUDA_LIBRARY} ${ARROW_GTEST_GTEST}
${ARROW_BENCHMARK_LINK_LIBS})
add_dependencies(arrow_cuda-benchmarks arrow-gpu-cuda-benchmark)
endif()
2 changes: 1 addition & 1 deletion cpp/src/arrow/testing/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ if(ARROW_BUILD_TESTS)
elseif(ARROW_BUILD_INTEGRATION)
add_executable(arrow-json-integration-test json_integration_test.cc)
target_link_libraries(arrow-json-integration-test ${ARROW_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::gtest)
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})

add_dependencies(arrow-json-integration-test arrow arrow_testing)
add_dependencies(arrow-integration arrow-json-integration-test)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/parquet/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -114,7 +114,7 @@ else()
set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_shared arrow_shared)
endif()

set(PARQUET_MIN_TEST_LIBS GTest::gtest_main GTest::gtest Boost::headers)
set(PARQUET_MIN_TEST_LIBS ${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST} Boost::headers)

if(APPLE)
set(PARQUET_MIN_TEST_LIBS ${PARQUET_MIN_TEST_LIBS} ${CMAKE_DL_LIBS})
Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion ci/docker/alpine-linux-3.16-cpp.dockerfile
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,6 +37,7 @@ RUN apk add \
glog-dev \
gmock \
grpc-dev \
gtest-dev \
libxml2-dev \
llvm13-dev \
llvm13-static \
Expand DownExpand Up@@ -95,7 +96,6 @@ ENV ARROW_ACERO=ON \
ARROW_WITH_ZSTD=ON \
AWSSDK_SOURCE=BUNDLED \
google_cloud_cpp_storage_SOURCE=BUNDLED \
GTest_SOURCE=BUNDLED \
ORC_SOURCE=BUNDLED \
PATH=/usr/lib/ccache/:$PATH \
xsimd_SOURCE=BUNDLED
4 changes: 2 additions & 2 deletions cpp/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -839,8 +839,8 @@ if(NOT MSVC_TOOLCHAIN)
list(APPEND ARROW_SHARED_LINK_LIBS ${CMAKE_DL_LIBS})
endif()

set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers GTest::gtest_main GTest::gtest
GTest::gmock)
set(ARROW_TEST_LINK_TOOLCHAIN arrow::flatbuffers ${ARROW_GTEST_GTEST_MAIN}

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.

IMHO this is a regression as using variables instead of targets is an anti-pattern but I currently don't see a cleaner approach either.

I think we should rethink the entire dependency management once we have bumped the cmake version to 3.16 as we will have much better tools available. (this is of course out of scope for this PR)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

${ARROW_GTEST_GTEST} ${ARROW_GTEST_GMOCK})

if(ARROW_BUILD_TESTS)
add_dependencies(arrow_test_dependencies ${ARROW_TEST_LINK_TOOLCHAIN})
Expand Down
61 changes: 61 additions & 0 deletions cpp/cmake_modules/FindGTestAlt.cmake
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

if(GTestAlt_FOUND)
return()
endif()

set(find_package_args)
if(GTestAlt_FIND_VERSION)
list(APPEND find_package_args ${GTestAlt_FIND_VERSION})
endif()
if(GTestAlt_FIND_QUIETLY)
list(APPEND find_package_args QUIET)
endif()
if(CMAKE_VERSION VERSION_LESS 3.23)
list(APPEND find_package_args CONFIG)
endif()
# We can't find shred library version of GoogleTest on Windows with
# Conda's gtest package because it doesn't provide GTestConfig.cmake
# provided by GoogleTest and CMake's built-in FindGTtest.cmake
# doesn't support gtest_dll.dll.
find_package(GTest ${find_package_args})

set(GTestAlt_FOUND ${GTest_FOUND})
if(GTestAlt_FOUND)
set(KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
set(GTestAlt_CXX_STANDARD_TEST_SOURCE
"${CMAKE_CURRENT_BINARY_DIR}/gtest_cxx_standard_test.cc")
file(WRITE ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
"
#include <string_view>
#include <gtest/gtest.h>

TEST(CXX_STANDARD, MatcherStringView) {
testing::Matcher matcher(std::string_view(\"hello\"));
}
")
try_compile(GTestAlt_CXX_STANDARD_AVAILABLE ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${GTestAlt_CXX_STANDARD_TEST_SOURCE}
LINK_LIBRARIES GTest::gtest_main)
set(CMAKE_TRY_COMPILE_TARGET_TYPE ${KEEP_CMAKE_TRY_COMPILE_TARGET_TYPE})
if(NOT GTestAlt_CXX_STANDARD_AVAILABLE)
message(STATUS "GTest can't be used with ${CMAKE_CXX_STANDARD}")
set(GTestAlt_FOUND FALSE)
endif()
endif()
46 changes: 18 additions & 28 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line numberDiff line numberDiff line change
Expand Up@@ -2190,54 +2190,38 @@ macro(build_gtest)
# The include directory must exist before it is referenced by a target.
file(MAKE_DIRECTORY "${GTEST_INCLUDE_DIR}")

add_library(GTest::gtest SHARED IMPORTED)
set_target_properties(GTest::gtest
add_library(arrow::GTest::gtest SHARED IMPORTED)
set_target_properties(arrow::GTest::gtest
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_SHARED_LIB}"
INTERFACE_COMPILE_DEFINITIONS
"GTEST_LINKED_AS_SHARED_LIBRARY=1"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::gtest_main SHARED IMPORTED)
set_target_properties(GTest::gtest_main
add_library(arrow::GTest::gtest_main SHARED IMPORTED)
set_target_properties(arrow::GTest::gtest_main
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GTEST_MAIN_SHARED_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")

add_library(GTest::gmock SHARED IMPORTED)
set_target_properties(GTest::gmock
add_library(arrow::GTest::gmock SHARED IMPORTED)
set_target_properties(arrow::GTest::gmock
PROPERTIES ${_GTEST_IMPORTED_TYPE} "${GMOCK_SHARED_LIB}"
INTERFACE_COMPILE_DEFINITIONS
"GMOCK_LINKED_AS_SHARED_LIBRARY=1"
INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIR}")
add_dependencies(toolchain-tests googletest_ep)
add_dependencies(GTest::gtest googletest_ep)
add_dependencies(GTest::gtest_main googletest_ep)
add_dependencies(GTest::gmock googletest_ep)
add_dependencies(arrow::GTest::gtest googletest_ep)
add_dependencies(arrow::GTest::gtest_main googletest_ep)
add_dependencies(arrow::GTest::gmock googletest_ep)
endmacro()

if(ARROW_TESTING)
if(CMAKE_VERSION VERSION_LESS 3.23)
set(GTEST_USE_CONFIG TRUE)
else()
set(GTEST_USE_CONFIG FALSE)
endif()
# We can't find shred library version of GoogleTest on Windows with
# Conda's gtest package because it doesn't provide GTestConfig.cmake
# provided by GoogleTest and CMake's built-in FindGTtest.cmake
# doesn't support gtest_dll.dll.
resolve_dependency(GTest
HAVE_ALT
TRUE
REQUIRED_VERSION
1.10.0
USE_CONFIG
${GTEST_USE_CONFIG})
1.10.0)

if(GTest_SOURCE STREQUAL "SYSTEM")
get_target_property(gtest_cxx_standard GTest::gtest INTERFACE_COMPILE_FEATURES)
if((${gtest_cxx_standard} STREQUAL "cxx_std_11") OR (${gtest_cxx_standard} STREQUAL
"cxx_std_14"))
message(FATAL_ERROR "System GTest is built with a C++ standard lower than 17. Use bundled GTest via passing in CMake flag
-DGTest_SOURCE=\"BUNDLED\"")
endif()

find_package(PkgConfig QUIET)
pkg_check_modules(gtest_PC
gtest
Expand All@@ -2254,10 +2238,16 @@ if(ARROW_TESTING)

string(APPEND ARROW_TESTING_PC_LIBS " $<TARGET_FILE:GTest::gtest>")
endif()
set(ARROW_GTEST_GMOCK GTest::gmock)
set(ARROW_GTEST_GTEST GTest::gtest)
set(ARROW_GTEST_GTEST_MAIN GTest::gtest_main)
else()
# TODO: How to solve BUNDLED case? Do we install bundled GoogleTest?
# string(APPEND ARROW_TESTING_PC_CFLAGS " -I${GTEST_INCLUDE_DIR}")
# string(APPEND ARROW_TESTING_PC_LIBS " -lgtest")
set(ARROW_GTEST_GMOCK arrow::GTest::gmock)
set(ARROW_GTEST_GTEST arrow::GTest::gtest)
set(ARROW_GTEST_GTEST_MAIN arrow::GTest::gtest_main)
endif()
endif()

Expand Down
8 changes: 3 additions & 5 deletions cpp/src/arrow/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -717,18 +717,16 @@ if(ARROW_TESTING)
arrow::flatbuffers
rapidjson::rapidjson
arrow_shared
GTest::gtest
${ARROW_GTEST_GTEST}
SHARED_INSTALL_INTERFACE_LIBS
Arrow::arrow_shared
GTest::gtest
STATIC_LINK_LIBS
arrow::flatbuffers
rapidjson::rapidjson
arrow_static
GTest::gtest
${ARROW_GTEST_GTEST}
STATIC_INSTALL_INTERFACE_LIBS
Arrow::arrow_static
GTest::gtest)
Arrow::arrow_static)

add_custom_target(arrow_testing)
add_dependencies(arrow_testing ${ARROW_TESTING_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/adapters/orc/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,7 @@ else()
endif()

set(ORC_STATIC_TEST_LINK_LIBS orc::liborc ${ARROW_LIBRARIES_FOR_STATIC_TESTS}
GTest::gtest_main GTest::gtest)
${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST})

add_arrow_test(adapter_test
PREFIX
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/filesystem/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,7 +81,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} GTest::gtest)
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})
add_dependencies(arrow-tests arrow-s3fs-narrative-test)
endif()

Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/flight/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -67,8 +67,8 @@ list(APPEND
Boost::headers
Boost::filesystem
Boost::system
GTest::gtest
GTest::gmock)
${ARROW_GTEST_GTEST}
${ARROW_GTEST_GMOCK})
list(APPEND ARROW_FLIGHT_TEST_LINK_LIBS gRPC::grpc++)

# TODO(wesm): Protobuf shared vs static linking
Expand DownExpand Up@@ -308,7 +308,7 @@ if(ARROW_TESTING)
test_definitions.cc
test_util.cc
DEPENDENCIES
GTest::gtest
${ARROW_GTEST_GTEST}
flight_grpc_gen
arrow_dependencies
SHARED_LINK_LIBS
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/flight/integration_tests/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@ list(APPEND
ARROW_FLIGHT_INTEGRATION_TEST_LINK_LIBS
${ARROW_FLIGHT_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES}
GTest::gtest)
${ARROW_GTEST_GTEST})

add_executable(flight-test-integration-server test_integration_server.cc
test_integration.cc)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/gpu/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,7 +98,7 @@ endif()
if(ARROW_BUILD_BENCHMARKS)
add_arrow_benchmark(cuda_benchmark PREFIX "arrow-gpu")
target_link_libraries(arrow-gpu-cuda-benchmark
PUBLIC ${ARROW_CUDA_LIBRARY} GTest::gtest
PUBLIC ${ARROW_CUDA_LIBRARY} ${ARROW_GTEST_GTEST}
${ARROW_BENCHMARK_LINK_LIBS})
add_dependencies(arrow_cuda-benchmarks arrow-gpu-cuda-benchmark)
endif()
2 changes: 1 addition & 1 deletion cpp/src/arrow/testing/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ if(ARROW_BUILD_TESTS)
elseif(ARROW_BUILD_INTEGRATION)
add_executable(arrow-json-integration-test json_integration_test.cc)
target_link_libraries(arrow-json-integration-test ${ARROW_TEST_LINK_LIBS}
${GFLAGS_LIBRARIES} GTest::gtest)
${GFLAGS_LIBRARIES} ${ARROW_GTEST_GTEST})

add_dependencies(arrow-json-integration-test arrow arrow_testing)
add_dependencies(arrow-integration arrow-json-integration-test)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/parquet/CMakeLists.txt
Original file line numberDiff line numberDiff line change
Expand Up@@ -114,7 +114,7 @@ else()
set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_shared arrow_shared)
endif()

set(PARQUET_MIN_TEST_LIBS GTest::gtest_main GTest::gtest Boost::headers)
set(PARQUET_MIN_TEST_LIBS ${ARROW_GTEST_GTEST_MAIN} ${ARROW_GTEST_GTEST} Boost::headers)

if(APPLE)
set(PARQUET_MIN_TEST_LIBS ${PARQUET_MIN_TEST_LIBS} ${CMAKE_DL_LIBS})
Expand Down