Skip to content
Closed
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
8 changes: 4 additions & 4 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,8 @@ set(ARROW_TEST_STATIC_LINK_LIBS
arrow_testing_static
arrow_static
${ARROW_LINK_LIBS}
gtest_main_static
gtest_static)
${GTEST_MAIN_LIBRARY}
${GTEST_LIBRARY})

set(ARROW_TEST_SHARED_LINK_LIBS
arrow_testing_shared
Expand All @@ -807,8 +807,8 @@ set(ARROW_TEST_SHARED_LINK_LIBS
${BOOST_SYSTEM_LIBRARY}
${BOOST_FILESYSTEM_LIBRARY}
${BOOST_REGEX_LIBRARY}
gtest_main_static
gtest_static)
${GTEST_MAIN_LIBRARY}
${GTEST_LIBRARY})

if(NOT MSVC)
set(ARROW_TEST_SHARED_LINK_LIBS
Expand Down
2 changes: 1 addition & 1 deletion cpp/cmake_modules/BuildUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ function(ADD_TEST_CASE REL_TEST_NAME)
bash -c "cd '${CMAKE_SOURCE_DIR}'; \
valgrind --suppressions=valgrind.supp --tool=memcheck --gen-suppressions=all \
--leak-check=full --leak-check-heuristics=stdstring --error-exitcode=1 ${TEST_PATH}")
elseif(MSVC)
elseif(WIN32)
add_test(${TEST_NAME} ${TEST_PATH})
else()
add_test(${TEST_NAME}
Expand Down
71 changes: 50 additions & 21 deletions cpp/cmake_modules/FindGTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
# GTEST_INCLUDE_DIR, directory containing headers
# GTEST_LIBS, directory containing gtest libraries
# GTEST_STATIC_LIB, path to libgtest.a
# GTEST_STATIC_MAIN_LIB, path to libgtest_main.a
# GTEST_SHARED_LIB, path to libgtest's shared library
# GTEST_SHARED_MAIN_LIB, path to libgtest_main's shared library
# GTEST_FOUND, whether gtest has been found

if( NOT "${GTEST_HOME}" STREQUAL "")
Expand All @@ -38,34 +40,60 @@ elseif ( GTest_HOME )
list( APPEND _gtest_roots ${GTest_HOME} )
endif()

set(GTEST_STATIC_LIB_NAME
${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX})
set(GTEST_MAIN_STATIC_LIB_NAME
${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX})
set(GTEST_SHARED_LIB_NAME
${CMAKE_SHARED_LIBRARY_PREFIX}gtest${CMAKE_SHARED_LIBRARY_SUFFIX})
set(GTEST_MAIN_SHARED_LIB_NAME
${CMAKE_SHARED_LIBRARY_PREFIX}gtest_main${CMAKE_SHARED_LIBRARY_SUFFIX})

# Try the parameterized roots, if they exist
if ( _gtest_roots )
find_path( GTEST_INCLUDE_DIR NAMES gtest/gtest.h
PATHS ${_gtest_roots} NO_DEFAULT_PATH
PATH_SUFFIXES "include" )
find_library( GTEST_LIBRARIES NAMES gtest gtest_main
PATHS ${_gtest_roots} NO_DEFAULT_PATH
PATH_SUFFIXES "lib" )
else ()
find_path( GTEST_INCLUDE_DIR NAMES gtest/gtest.h )
find_library( GTEST_LIBRARIES NAMES gtest )
endif ()
if(_gtest_roots)
Copy link
Member

Choose a reason for hiding this comment

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

We should standardize on a CMake indentation rule, and ideally (but not sure it's possible) enforce it. Apparently there's cmake_format.

Copy link
Member

Choose a reason for hiding this comment

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

@pitrou Can you make a JIRA for that? Then we can implement that.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

We should standardize on a CMake indentation rule

I think so too.

find_path(GTEST_INCLUDE_DIR NAMES gtest/gtest.h
PATHS ${_gtest_roots} NO_DEFAULT_PATH
PATH_SUFFIXES "include")
set(lib_dirs
"lib/${CMAKE_LIBRARY_ARCHITECTURE}"
"lib64"
"lib")
Copy link
Member

Choose a reason for hiding this comment

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

Is there an already-defined variable for this? It seems weird to have to hardcode such search paths for each system library.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have similar variable in FindProtobuf.cmake: https://github.com/apache/arrow/blob/master/cpp/cmake_modules/FindProtobuf.cmake#L39
(I added it.)

We can remove it by removing NO_DEFAULT_PATH from our find_library() calls.

To be honest, I want to remove all our custom find codes. For example:

index c7496c6a..20cb55cf 100644
--- a/cpp/cmake_modules/FindGTest.cmake
+++ b/cpp/cmake_modules/FindGTest.cmake
@@ -33,13 +33,6 @@
 #  GTEST_SHARED_MAIN_LIB, path to libgtest_main's shared library
 #  GTEST_FOUND, whether gtest has been found
 
-if( NOT "${GTEST_HOME}" STREQUAL "")
-    file( TO_CMAKE_PATH "${GTEST_HOME}" _native_path )
-    list( APPEND _gtest_roots ${_native_path} )
-elseif ( GTest_HOME )
-    list( APPEND _gtest_roots ${GTest_HOME} )
-endif()
-
 set(GTEST_STATIC_LIB_NAME
   ${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX})
 set(GTEST_MAIN_STATIC_LIB_NAME
@@ -49,35 +42,11 @@ set(GTEST_SHARED_LIB_NAME
 set(GTEST_MAIN_SHARED_LIB_NAME
   ${CMAKE_SHARED_LIBRARY_PREFIX}gtest_main${CMAKE_SHARED_LIBRARY_SUFFIX})
 
-# Try the parameterized roots, if they exist
-if(_gtest_roots)
-  find_path(GTEST_INCLUDE_DIR NAMES gtest/gtest.h
-    PATHS ${_gtest_roots} NO_DEFAULT_PATH
-    PATH_SUFFIXES "include")
-  set(lib_dirs
-    "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
-    "lib64"
-    "lib")
-  find_library(GTEST_STATIC_LIB NAMES ${GTEST_STATIC_LIB_NAME}
-    PATHS ${_gtest_roots} NO_DEFAULT_PATH
-    PATH_SUFFIXES ${lib_dirs})
-  find_library(GTEST_MAIN_STATIC_LIB NAMES ${GTEST_MAIN_STATIC_LIB_NAME}
-    PATHS ${_gtest_roots} NO_DEFAULT_PATH
-    PATH_SUFFIXES ${lib_dirs})
-  find_library(GTEST_SHARED_LIB NAMES ${GTEST_SHARED_LIB_NAME}
-    PATHS ${_gtest_roots} NO_DEFAULT_PATH
-    PATH_SUFFIXES ${lib_dirs})
-  find_library(GTEST_MAIN_SHARED_LIB NAMES ${GTEST_MAIN_SHARED_LIB_NAME}
-    PATHS ${_gtest_roots} NO_DEFAULT_PATH
-    PATH_SUFFIXES ${lib_dirs})
-else()
-  find_path(GTEST_INCLUDE_DIR NAMES gtest/gtest.h)
-  find_library(GTEST_STATIC_LIB NAMES ${GTEST_STATIC_LIB_NAME})
-  find_library(GTEST_MAIN_STATIC_LIB NAMES ${GTEST_MAIN_STATIC_LIB_NAME})
-  find_library(GTEST_SHARED_LIB NAMES ${GTEST_SHARED_LIB_NAME})
-  find_library(GTEST_MAIN_SHARED_LIB NAMES ${GTEST_MAIN_SHARED_LIB_NAME})
-endif()
-
+find_path(GTEST_INCLUDE_DIR NAMES gtest/gtest.h)
+find_library(GTEST_STATIC_LIB NAMES ${GTEST_STATIC_LIB_NAME})
+find_library(GTEST_MAIN_STATIC_LIB NAMES ${GTEST_MAIN_STATIC_LIB_NAME})
+find_library(GTEST_SHARED_LIB NAMES ${GTEST_SHARED_LIB_NAME})
+find_library(GTEST_MAIN_SHARED_LIB NAMES ${GTEST_MAIN_SHARED_LIB_NAME})
 
 if(GTEST_INCLUDE_DIR AND
     (GTEST_STATIC_LIB AND GTEST_MAIN_STATIC_LIB) OR
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 5a75a9b0..50fe37a1 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -29,35 +29,7 @@ set(ARROW_RE2_LINKAGE "static" CACHE STRING
 set(THIRDPARTY_DIR "${arrow_SOURCE_DIR}/thirdparty")
 
 if (NOT "$ENV{ARROW_BUILD_TOOLCHAIN}" STREQUAL "")
-  set(BROTLI_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  set(BZ2_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  set(CARES_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  set(DOUBLE_CONVERSION_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  set(FLATBUFFERS_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  set(GFLAGS_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  set(GLOG_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  set(GRPC_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  # Using gtest from the toolchain breaks AppVeyor builds
-  if (NOT MSVC)
-    set(GTEST_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  endif()
-  set(JEMALLOC_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  set(LZ4_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  # orc disabled as it's not in conda-forge (but in Anaconda with an incompatible ABI)
-  # set(ORC_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  set(PROTOBUF_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  set(RAPIDJSON_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  set(RE2_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  set(SNAPPY_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  set(THRIFT_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  set(ZLIB_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  set(ZSTD_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
-
-  if (NOT DEFINED ENV{BOOST_ROOT})
-    # Since we have to set this in the environment, we check whether
-    # $BOOST_ROOT is defined inside here
-    set(ENV{BOOST_ROOT} "$ENV{ARROW_BUILD_TOOLCHAIN}")
-  endif()
+  list(INSERT CMAKE_PREFIX_PATH 0 "$ENV{ARROW_BUILD_TOOLCHAIN}")
 endif()
 
 # Home path for each third-party lib can be overriden with env vars
@@ -600,7 +572,10 @@ endif()
 # Google gtest
 
 if(ARROW_BUILD_TESTS OR ARROW_BUILD_BENCHMARKS)
-  if("${GTEST_HOME}" STREQUAL "")
+  find_package(GTest)
+  if(GTest_FOUND)
+    set(GTEST_VENDORED 0)
+  else()
     if(APPLE)
       set(GTEST_CMAKE_CXX_FLAGS "-fPIC -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-value -Wno-ignored-attributes")
     elseif(NOT MSVC)
@@ -628,9 +603,6 @@ if(ARROW_BUILD_TESTS OR ARROW_BUILD_BENCHMARKS)
       BUILD_BYPRODUCTS ${GTEST_STATIC_LIB} ${GTEST_MAIN_STATIC_LIB}
       CMAKE_ARGS ${GTEST_CMAKE_ARGS}
       ${EP_LOG_OPTIONS})
-  else()
-    find_package(GTest REQUIRED)
-    set(GTEST_VENDORED 0)
   endif()
 
   message(STATUS "GTest include dir: ${GTEST_INCLUDE_DIR}")

Users can change package search path by CMAKE_PREFIX_PATH. Users can also use <PackageName>_ROOT (GTest_Root for this case) CMake variable and environment variable for each package since CMake 3.12: https://cmake.org/cmake/help/v3.12/command/find_library.html

If called from within a find module loaded by find_package(<PackageName>), search prefixes unique to the current package being found. Specifically look in the <PackageName>_ROOT CMake variable and the <PackageName>_ROOT environment variable. The package root variables are maintained as a stack so if called from nested find modules, root paths from the parent’s find module will be searched after paths from the current module, i.e. <CurrentPackage>_ROOT, ENV{<CurrentPackage>_ROOT}, <ParentPackage>_ROOT, ENV{<ParentPackage>_ROOT}, etc.

Our custom find code uses <PackageName>_HOME for this propose.

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps open a JIRA for that?

Copy link
Member Author

Choose a reason for hiding this comment

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

find_library(GTEST_STATIC_LIB NAMES ${GTEST_STATIC_LIB_NAME}
PATHS ${_gtest_roots} NO_DEFAULT_PATH
PATH_SUFFIXES ${lib_dirs})
find_library(GTEST_MAIN_STATIC_LIB NAMES ${GTEST_MAIN_STATIC_LIB_NAME}
PATHS ${_gtest_roots} NO_DEFAULT_PATH
PATH_SUFFIXES ${lib_dirs})
find_library(GTEST_SHARED_LIB NAMES ${GTEST_SHARED_LIB_NAME}
PATHS ${_gtest_roots} NO_DEFAULT_PATH
PATH_SUFFIXES ${lib_dirs})
find_library(GTEST_MAIN_SHARED_LIB NAMES ${GTEST_MAIN_SHARED_LIB_NAME}
PATHS ${_gtest_roots} NO_DEFAULT_PATH
PATH_SUFFIXES ${lib_dirs})
else()
find_path(GTEST_INCLUDE_DIR NAMES gtest/gtest.h)
find_library(GTEST_STATIC_LIB NAMES ${GTEST_STATIC_LIB_NAME})
find_library(GTEST_MAIN_STATIC_LIB NAMES ${GTEST_MAIN_STATIC_LIB_NAME})
find_library(GTEST_SHARED_LIB NAMES ${GTEST_SHARED_LIB_NAME})
find_library(GTEST_MAIN_SHARED_LIB NAMES ${GTEST_MAIN_SHARED_LIB_NAME})
endif()


if (GTEST_INCLUDE_DIR AND GTEST_LIBRARIES)
if(GTEST_INCLUDE_DIR AND
(GTEST_STATIC_LIB AND GTEST_MAIN_STATIC_LIB) OR
(GTEST_SHARED_LIB AND GTEST_MAIN_SHARED_LIB))
set(GTEST_FOUND TRUE)
get_filename_component( GTEST_LIBS ${GTEST_LIBRARIES} PATH )
set(GTEST_LIB_NAME gtest)
set(GTEST_STATIC_LIB ${GTEST_LIBS}/${CMAKE_STATIC_LIBRARY_PREFIX}${GTEST_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
set(GTEST_MAIN_STATIC_LIB ${GTEST_LIBS}/${CMAKE_STATIC_LIBRARY_PREFIX}${GTEST_LIB_NAME}_main${CMAKE_STATIC_LIBRARY_SUFFIX})
set(GTEST_SHARED_LIB ${GTEST_LIBS}/${CMAKE_SHARED_LIBRARY_PREFIX}${GTEST_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
else ()
else()
set(GTEST_FOUND FALSE)
endif ()
endif()

if (GTEST_FOUND)
if (NOT GTest_FIND_QUIETLY)
message(STATUS "Found the GTest library: ${GTEST_LIBRARIES}")
message(STATUS "Found the GTest library:")
message(STATUS "GTEST_STATIC_LIB: ${GTEST_STATIC_LIB}")
message(STATUS "GTEST_MAIN_STATIC_LIB: ${GTEST_MAIN_STATIC_LIB}")
message(STATUS "GTEST_SHARED_LIB: ${GTEST_SHARED_LIB}")
message(STATUS "GTEST_MAIN_SHARED_LIB: ${GTEST_MAIN_SHARED_LIB}")
endif ()
else ()
if (NOT GTest_FIND_QUIETLY)
Expand All @@ -86,7 +114,8 @@ endif ()
mark_as_advanced(
GTEST_INCLUDE_DIR
GTEST_LIBS
GTEST_LIBRARIES
GTEST_STATIC_LIB
GTEST_MAIN_STATIC_LIB
GTEST_SHARED_LIB
GTEST_MAIN_SHARED_LIB
)
26 changes: 19 additions & 7 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -634,16 +634,28 @@ if(ARROW_BUILD_TESTS OR ARROW_BUILD_BENCHMARKS)
endif()

message(STATUS "GTest include dir: ${GTEST_INCLUDE_DIR}")
message(STATUS "GTest static library: ${GTEST_STATIC_LIB}")
include_directories(SYSTEM ${GTEST_INCLUDE_DIR})
ADD_THIRDPARTY_LIB(gtest
STATIC_LIB ${GTEST_STATIC_LIB})
ADD_THIRDPARTY_LIB(gtest_main
STATIC_LIB ${GTEST_MAIN_STATIC_LIB})
if(GTEST_STATIC_LIB)
Copy link
Member

Choose a reason for hiding this comment

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

By the way, is there a reason to prefer the static lib over the shared lib? Is it for Windows?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, there isn't.
I just choose the static library because we used the static library before this change.

message(STATUS "GTest static library: ${GTEST_STATIC_LIB}")
ADD_THIRDPARTY_LIB(gtest
STATIC_LIB ${GTEST_STATIC_LIB})
ADD_THIRDPARTY_LIB(gtest_main
STATIC_LIB ${GTEST_MAIN_STATIC_LIB})
set(GTEST_LIBRARY gtest_static)
set(GTEST_MAIN_LIBRARY gtest_main_static)
else()
message(STATUS "GTest shared library: ${GTEST_SHARED_LIB}")
ADD_THIRDPARTY_LIB(gtest
SHARED_LIB ${GTEST_SHARED_LIB})
ADD_THIRDPARTY_LIB(gtest_main
SHARED_LIB ${GTEST_MAIN_SHARED_LIB})
set(GTEST_LIBRARY gtest_shared)
set(GTEST_MAIN_LIBRARY gtest_main_shared)
endif()

if(GTEST_VENDORED)
add_dependencies(gtest_static googletest_ep)
add_dependencies(gtest_main_static googletest_ep)
add_dependencies(${GTEST_LIBRARY} googletest_ep)
add_dependencies(${GTEST_MAIN_LIBRARY} googletest_ep)
endif()
endif()

Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ if (ARROW_BUILD_TESTS OR ARROW_BUILD_BENCHMARKS)
ADD_ARROW_LIB(arrow_testing
SOURCES test-util.cc
OUTPUTS ARROW_TESTING_LIBRARIES
DEPENDENCIES gtest_static
SHARED_LINK_LIBS arrow_shared gtest_static
DEPENDENCIES ${GTEST_LIBRARY}
SHARED_LINK_LIBS arrow_shared ${GTEST_LIBRARY}
STATIC_LINK_LIBS arrow_static)

if (ARROW_BUILD_STATIC AND WIN32)
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/arrow/flight/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ if (ARROW_BUILD_TESTS OR ARROW_BUILD_BENCHMARKS)
target_link_libraries(flight-test-server
${ARROW_FLIGHT_TEST_STATIC_LINK_LIBS}
gflags_static
gtest_static)
${GTEST_LIBRARY})

# This is needed for the unit tests
if (ARROW_BUILD_TESTS)
Expand Down Expand Up @@ -117,7 +117,7 @@ if (ARROW_BUILD_BENCHMARKS)
arrow_flight_static
${ARROW_FLIGHT_STATIC_LINK_LIBS}
gflags_static
gtest_static)
${GTEST_LIBRARY})

add_executable(flight-benchmark
flight-benchmark.cc
Expand All @@ -126,7 +126,7 @@ if (ARROW_BUILD_BENCHMARKS)
arrow_flight_static
${ARROW_FLIGHT_STATIC_LINK_LIBS}
gflags_static
gtest_static)
${GTEST_LIBRARY})

add_dependencies(flight-benchmark flight-perf-server)
endif(ARROW_BUILD_BENCHMARKS)
2 changes: 1 addition & 1 deletion cpp/src/arrow/gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ if (ARROW_BUILD_BENCHMARKS)
cuda_add_executable(arrow-cuda-benchmark cuda-benchmark.cc)
target_link_libraries(arrow-cuda-benchmark
arrow_cuda_shared
gtest_static
${GTEST_LIBRARY}
${ARROW_BENCHMARK_LINK_LIBS})
add_dependencies(arrow_cuda-benchmarks arrow-cuda-benchmark)
endif()
17 changes: 6 additions & 11 deletions cpp/src/arrow/io/test-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,11 @@
#include <string>
#include <vector>

#ifndef _MSC_VER
#include <fcntl.h>
#endif

#if defined(__MINGW32__) // MinGW
// nothing
#elif defined(_MSC_VER) // Visual Studio
#ifdef _WIN32
#include <crtdbg.h>
#include <io.h>
#else // POSIX / Linux
// nothing
#else
#include <fcntl.h>
#endif

#include "arrow/buffer.h"
Expand Down Expand Up @@ -64,7 +59,7 @@ static inline bool FileExists(const std::string& path) {
return std::ifstream(path.c_str()).good();
}

#if defined(_MSC_VER)
#if defined(_WIN32)
static inline void InvalidParamHandler(const wchar_t* expr, const wchar_t* func,
const wchar_t* source_file,
unsigned int source_line, uintptr_t reserved) {
Expand All @@ -74,7 +69,7 @@ static inline void InvalidParamHandler(const wchar_t* expr, const wchar_t* func,
#endif

static inline bool FileIsClosed(int fd) {
#if defined(_MSC_VER)
#if defined(_WIN32)
// Disables default behavior on wrong params which causes the application to crash
// https://msdn.microsoft.com/en-us/library/ksazx244.aspx
_set_invalid_parameter_handler(InvalidParamHandler);
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ if (ARROW_BUILD_TESTS)
util/test_main.cc)

target_link_libraries(arrow_python_test_main
gtest_static)
${GTEST_LIBRARY})
target_include_directories(arrow_python_test_main SYSTEM PUBLIC
${ARROW_PYTHON_INCLUDES})

Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/python/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ if (PYARROW_BUILD_TESTS)

if (APPLE)
target_link_libraries(arrow/python_test_main
gtest_static
${GTEST_LIBRARY}
dl)
set_target_properties(arrow/python_test_main
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
target_link_libraries(arrow/python_test_main
gtest_static
${GTEST_LIBRARY}
pthread
dl
)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if (ARROW_BUILD_BENCHMARKS)
endif()

# TODO(wesm): Some benchmarks include gtest.h
add_dependencies(arrow_benchmark_main gtest_static)
add_dependencies(arrow_benchmark_main ${GTEST_LIBRARY})
endif()

ADD_ARROW_TEST(bit-util-test)
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/parquet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ if(MSVC)
endif()

set(PARQUET_MIN_TEST_LIBS
gtest_main_static
gtest_static)
${GTEST_MAIN_LIBRARY}
${GTEST_LIBRARY})

if (APPLE)
set(PARQUET_MIN_TEST_LIBS
Expand Down