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
2 changes: 2 additions & 0 deletions ci/appveyor-cpp-build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ if "%JOB%" == "Static_Crt_Build" (
-DARROW_BOOST_USE_SHARED=OFF ^
-DARROW_BUILD_SHARED=OFF ^
-DCMAKE_BUILD_TYPE=Debug ^
-DARROW_TEST_LINKAGE=static ^
-DARROW_CXXFLAGS="/MP" ^
.. || exit /B

Expand All @@ -51,6 +52,7 @@ if "%JOB%" == "Static_Crt_Build" (
-DARROW_BOOST_USE_SHARED=OFF ^
-DARROW_BUILD_SHARED=OFF ^
-DCMAKE_BUILD_TYPE=Release ^
-DARROW_TEST_LINKAGE=static ^
-DCMAKE_CXX_FLAGS_RELEASE="/MT %CMAKE_CXX_FLAGS_RELEASE%" ^
-DARROW_CXXFLAGS="/WX /MP" ^
.. || exit /B
Expand Down
71 changes: 43 additions & 28 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
"Build the Arrow googletest unit tests"
ON)

set(ARROW_TEST_LINKAGE "shared" CACHE STRING
"Linkage of Arrow libraries with unit tests executables. \
static|shared (default shared)")

set(ARROW_TEST_INCLUDE_LABELS "" CACHE STRING
"Only build unit tests having the indicated label or labels. \
Pass multiple labels by dividing with semicolons")
Expand Down Expand Up @@ -436,8 +440,6 @@ endif()

if(NOT ARROW_BUILD_TESTS)
set(NO_TESTS 1)
else()
set(ARROW_BUILD_SHARED ON)
endif()

if(NOT ARROW_BUILD_BENCHMARKS)
Expand Down Expand Up @@ -683,13 +685,6 @@ if (ARROW_STATIC_LINK_LIBS)
add_dependencies(arrow_dependencies ${ARROW_STATIC_LINK_LIBS})
endif()

if (ARROW_BUILD_BENCHMARKS)
set(ARROW_BENCHMARK_LINK_LIBS
arrow_benchmark_main
arrow_static
gtest_static)
endif()

set(ARROW_SHARED_PRIVATE_LINK_LIBS
${ARROW_STATIC_LINK_LIBS}
${BOOST_SYSTEM_LIBRARY}
Expand All @@ -708,30 +703,50 @@ if (NOT MSVC)
${CMAKE_DL_LIBS})
endif()

if (ARROW_BUILD_STATIC)
set(ARROW_MIN_TEST_LIBS
arrow_static
gtest_main_static
gtest_static)
else ()
set(ARROW_MIN_TEST_LIBS
arrow_shared
${ARROW_LINK_LIBS}
double-conversion_static
${BOOST_SYSTEM_LIBRARY}
${BOOST_FILESYSTEM_LIBRARY}
${BOOST_REGEX_LIBRARY}
gtest_main_static
gtest_static)
endif()
set(ARROW_TEST_STATIC_LINK_LIBS
arrow_testing_static
arrow_static
${ARROW_LINK_LIBS}
gtest_main_static
gtest_static)

set(ARROW_TEST_SHARED_LINK_LIBS
arrow_testing_shared
arrow_shared
${ARROW_LINK_LIBS}
double-conversion_static
${BOOST_SYSTEM_LIBRARY}
${BOOST_FILESYSTEM_LIBRARY}
${BOOST_REGEX_LIBRARY}
gtest_main_static
gtest_static)

if(NOT MSVC)
set(ARROW_MIN_TEST_LIBS
${ARROW_MIN_TEST_LIBS}
set(ARROW_TEST_SHARED_LINK_LIBS
${ARROW_TEST_SHARED_LINK_LIBS}
${CMAKE_DL_LIBS})
endif()

set(ARROW_TEST_LINK_LIBS ${ARROW_MIN_TEST_LIBS})
if ("${ARROW_TEST_LINKAGE}" STREQUAL "shared")
if (NOT ARROW_BUILD_SHARED)
message(FATAL_ERROR "If using shared linkage for unit tests, must also \
pass ARROW_BUILD_SHARED=on")
endif()
# Use shared linking for unit tests if it's available
set(ARROW_TEST_LINK_LIBS ${ARROW_TEST_SHARED_LINK_LIBS})
else()
if (NOT ARROW_BUILD_STATIC)
message(FATAL_ERROR "If using static linkage for unit tests, must also \
pass ARROW_BUILD_STATIC=on")
endif()
set(ARROW_TEST_LINK_LIBS ${ARROW_TEST_STATIC_LINK_LIBS})
endif()

if (ARROW_BUILD_BENCHMARKS)
set(ARROW_BENCHMARK_LINK_LIBS
arrow_benchmark_main
${ARROW_TEST_LINK_LIBS})
endif()

if (ARROW_JEMALLOC)
add_definitions(-DARROW_JEMALLOC)
Expand Down
24 changes: 4 additions & 20 deletions cpp/cmake_modules/BuildUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ function(ADD_ARROW_LIB LIB_NAME)
set(LIB_NAME_STATIC ${LIB_NAME})
endif()

if (ARROW_BUILD_STATIC AND WIN32)
target_compile_definitions(${LIB_NAME}_static PUBLIC ARROW_STATIC)
endif()

set_target_properties(${LIB_NAME}_static
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}"
Expand Down Expand Up @@ -460,26 +464,6 @@ function(ADD_ARROW_TEST REL_TEST_NAME)
LABELS ${ARG_LABELS})
endfunction()

# A wrapper for add_dependencies() that is compatible with NO_TESTS.
function(ADD_ARROW_TEST_DEPENDENCIES REL_TEST_NAME)
if(NO_TESTS)
return()
endif()
get_filename_component(TEST_NAME ${REL_TEST_NAME} NAME_WE)

add_dependencies(${TEST_NAME} ${ARGN})
endfunction()

# A wrapper for target_link_libraries() that is compatible with NO_TESTS.
function(ARROW_TEST_LINK_LIBRARIES REL_TEST_NAME)
if(NO_TESTS)
return()
endif()
get_filename_component(TEST_NAME ${REL_TEST_NAME} NAME_WE)

target_link_libraries(${TEST_NAME} ${ARGN})
endfunction()

############################################################
# Fuzzing
############################################################
Expand Down
26 changes: 22 additions & 4 deletions cpp/src/arrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,28 @@ ADD_ARROW_LIB(arrow
SHARED_PRIVATE_LINK_LIBS ${ARROW_SHARED_PRIVATE_LINK_LIBS}
STATIC_LINK_LIBS ${ARROW_STATIC_LINK_LIBS})

if (ARROW_BUILD_STATIC AND WIN32)
target_compile_definitions(arrow_static PUBLIC ARROW_STATIC)
endif()

if (ARROW_BUILD_TESTS OR ARROW_BUILD_BENCHMARKS)
# that depend on gtest
ADD_ARROW_LIB(arrow_testing
SOURCES test-util.cc
OUTPUTS ARROW_TESTING_LIBRARIES
DEPENDENCIES gtest_static
SHARED_LINK_LIBS arrow_shared gtest_static
STATIC_LINK_LIBS arrow_static)

if (ARROW_BUILD_STATIC AND WIN32)
target_compile_definitions(arrow_testing_static PUBLIC ARROW_STATIC)
endif()

set(ARROW_LIBRARIES
${ARROW_LIBRARIES}
${ARROW_TESTING_LIBRARIES})
endif()

find_package(Backtrace)

foreach(LIB_TARGET ${ARROW_LIBRARIES})
Expand All @@ -180,10 +202,6 @@ foreach(LIB_TARGET ${ARROW_LIBRARIES})
endif()
endforeach()

if (ARROW_BUILD_STATIC AND WIN32)
target_compile_definitions(arrow_static PUBLIC ARROW_STATIC)
endif()

# Headers: top level
install(FILES
allocator.h
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/dbi/hiveserver2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ set_property(SOURCE ${ARROW_HIVESERVER2_SRCS}
" -Wno-shadow-field")

set(ARROW_HIVESERVER2_TEST_LINK_LIBS
${ARROW_TEST_LINK_LIBS}
arrow_hiveserver2_static
arrow_hiveserver2_thrift
${ARROW_TEST_LINK_LIBS}
thriftstatic)

if (ARROW_BUILD_TESTS)
Expand Down
1 change: 1 addition & 0 deletions cpp/src/arrow/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ if (ARROW_BUILD_TESTS)
set(ARROW_PYTHON_MIN_TEST_LIBS
arrow_python_test_main
arrow_python_shared
arrow_testing_shared
arrow_shared)

set(ARROW_PYTHON_TEST_LINK_LIBS ${ARROW_PYTHON_MIN_TEST_LIBS})
Expand Down
Loading