Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
6efdfd1
ARROW-16168: [C++][CMake] Use target to add include paths
kou Apr 12, 2022
aa0cbfd
Suppress sign-compare warnings from g++
kou Apr 12, 2022
e00602b
Ensure creating xsimd's include directory
kou Apr 12, 2022
f538f93
Treat thirdparty library's include directory as system
kou Apr 12, 2022
8ec1abd
Ensure making include directory
kou Apr 12, 2022
72ee8b1
Add workaround for RapidJSON's CMake package
kou Apr 13, 2022
0abf728
Define interface library for Winsock
kou Apr 13, 2022
b316be8
Define interface library for -lrt
kou Apr 13, 2022
5e70b36
Add missing static link dependencies
kou Apr 13, 2022
3baa7ae
Use target_link_libraries()
kou Apr 13, 2022
e9f87d5
Add missing libs
kou Apr 13, 2022
4290208
Fix a typo
kou Apr 13, 2022
4c62dbe
Create target for -ldl
kou Apr 13, 2022
c9ec064
Remove needless DEPENDENCIES
kou Apr 13, 2022
7e96eb5
Don't use target for system libraries
kou Apr 15, 2022
91a54e7
Remove include_directories(SYSTEM)
kou Apr 15, 2022
89b1110
Add missing Boost dependencies
kou Apr 15, 2022
104e8f9
Add missing Boost dependencies to Thrift
kou Apr 18, 2022
3169e33
Fix indent
kou Apr 18, 2022
c8f2c1c
Clean Boost related targets
kou Apr 18, 2022
37e5b6a
Boost::* may not be built
kou Apr 18, 2022
d4b6982
Add missing COMPONENTS
kou Apr 18, 2022
4997123
Add missing Boost dependency
kou Apr 18, 2022
984d8d5
Fix link order
kou Apr 18, 2022
0ce320c
We can't use target_link_library(OBJECT_LIBRARY) with CMake < 3.12
kou Apr 18, 2022
746ef88
Add support for CMake < 3.15
kou Apr 18, 2022
6c3eeb0
Add missing utf8proc dependency
kou Apr 18, 2022
6bcec5c
Fix dependency order
kou Apr 18, 2022
e3f8406
Add missing ARROW_FLIGHT_EXPORTING
kou Apr 18, 2022
4362fbc
Add missing dependencies
kou Apr 18, 2022
991256c
Debug
kou Apr 19, 2022
048d7de
Remove duplicated entries
kou Apr 19, 2022
591077d
Use static utf8proc
kou Apr 19, 2022
ffe7aec
Add support for CMake < 3.11 again
kou Apr 19, 2022
6bee188
Fix a typo
kou Apr 19, 2022
52dbe23
Fix style
kou Apr 19, 2022
63c6680
Add missing RapidJSON dependency
kou Apr 20, 2022
b583fd7
Add support for Ubuntu 18.04
kou Apr 23, 2022
9e878a0
Add missing arrow::flatbuffers dependency
kou May 9, 2022
d6284e3
Fix a typo
kou May 9, 2022
6ed7965
Use if(VARIABLE) instead of if(TARGET)
kou May 10, 2022
d590421
Add a comment for object library and CMake < 3.12
kou May 10, 2022
019c3f7
Add missing xsimd availability check
kou May 10, 2022
c6708e4
Use if(VARIABLE) instead of if(TARGET)
kou May 10, 2022
8bbe58c
Add a note for arrow::hadoop
kou May 10, 2022
e643481
Remove meaningless TODO comment
kou May 10, 2022
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
1 change: 1 addition & 0 deletions ci/scripts/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ build() {
-DARROW_S3="${ARROW_S3}" \
-DARROW_SNAPPY_USE_SHARED=OFF \
-DARROW_USE_GLOG=OFF \
-DARROW_UTF8PROC_USE_SHARED=OFF \
-DARROW_WITH_LZ4=ON \
-DARROW_WITH_RE2="${ARROW_WITH_RE2}" \
-DARROW_WITH_SNAPPY=ON \
Expand Down
39 changes: 25 additions & 14 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -691,11 +691,20 @@ endif()
# Linker and Dependencies
#

# Libraries to link statically with libarrow.so
set(ARROW_LINK_LIBS)
set(ARROW_STATIC_LINK_LIBS)
# Libraries to link statically with libarrow.so.
#
# Note that arrow::hadoop is a header only target that refers
# cpp/thirdparty/hadoop/include/. See
# cpp/cmake_modules/ThirdpartyToolchain.cmake for details.
set(ARROW_LINK_LIBS arrow::flatbuffers arrow::hadoop)
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, is arrow::hadoop enabled unconditionally??

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. Because we build cpp/src/arrow/io_hdfs_internal.cc unconditionally.

Note that arrow::hadoop is a header only target that refers cpp/thirdparty/hadoop/include/.

Copy link
Member

Choose a reason for hiding this comment

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

I see. Can you add that last sentence as a comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

set(ARROW_STATIC_LINK_LIBS arrow::flatbuffers arrow::hadoop)
set(ARROW_STATIC_INSTALL_INTERFACE_LIBS)

if(ARROW_USE_BOOST)
list(APPEND ARROW_LINK_LIBS Boost::headers)
list(APPEND ARROW_STATIC_LINK_LIBS Boost::headers)
endif()

if(ARROW_USE_OPENSSL)
set(ARROW_OPENSSL_LIBS OpenSSL::Crypto OpenSSL::SSL)
list(APPEND ARROW_LINK_LIBS ${ARROW_OPENSSL_LIBS})
Expand Down Expand Up @@ -808,6 +817,16 @@ if(ARROW_WITH_RE2)
endif()
endif()

if(ARROW_WITH_RAPIDJSON)
list(APPEND ARROW_LINK_LIBS rapidjson::rapidjson)
list(APPEND ARROW_STATIC_LINK_LIBS rapidjson::rapidjson)
endif()

if(ARROW_USE_XSIMD)
list(APPEND ARROW_LINK_LIBS xsimd)
list(APPEND ARROW_STATIC_LINK_LIBS xsimd)
endif()

add_custom_target(arrow_dependencies)
add_custom_target(arrow_benchmark_dependencies)
add_custom_target(arrow_test_dependencies)
Expand All @@ -830,26 +849,18 @@ endif()

set(ARROW_SHARED_PRIVATE_LINK_LIBS ${ARROW_STATIC_LINK_LIBS})

# boost::filesystem is needed for S3 and Flight tests as a boost::process dependency.
if(((ARROW_FLIGHT
OR ARROW_S3
OR ARROW_GCS)
AND (ARROW_BUILD_TESTS OR ARROW_BUILD_INTEGRATION)
))
list(APPEND ARROW_TEST_LINK_LIBS ${BOOST_FILESYSTEM_LIBRARY} ${BOOST_SYSTEM_LIBRARY})
endif()

if(NOT MSVC_TOOLCHAIN)
list(APPEND ARROW_LINK_LIBS ${CMAKE_DL_LIBS})
list(APPEND ARROW_SHARED_INSTALL_INTERFACE_LIBS ${CMAKE_DL_LIBS})
endif()

set(ARROW_TEST_LINK_TOOLCHAIN
arrow::flatbuffers
GTest::gtest_main
GTest::gtest
GTest::gmock
${BOOST_FILESYSTEM_LIBRARY}
${BOOST_SYSTEM_LIBRARY})
Boost::filesystem
Boost::system)

if(ARROW_BUILD_TESTS)
add_dependencies(arrow_test_dependencies ${ARROW_TEST_LINK_TOOLCHAIN})
Expand Down
113 changes: 26 additions & 87 deletions cpp/cmake_modules/BuildUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,9 @@ set(ARROW_LIBRARY_PATH_SUFFIXES
"Library/bin")
set(ARROW_INCLUDE_PATH_SUFFIXES "include" "Library" "Library/include")

set(ARROW_BOOST_PROCESS_COMPILE_DEFINITIONS)
if(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# boost/process/detail/windows/handle_workaround.hpp doesn't work
# without BOOST_USE_WINDOWS_H with MinGW because MinGW doesn't
# provide __kernel_entry without winternl.h.
#
# See also:
# https://github.com/boostorg/process/blob/develop/include/boost/process/detail/windows/handle_workaround.hpp
#
# You can use this like the following:
#
# target_compile_definitions(target PRIVATE
# ${ARROW_BOOST_PROCESS_COMPILE_DEFINITIONS})
list(APPEND ARROW_BOOST_PROCESS_COMPILE_DEFINITIONS "BOOST_USE_WINDOWS_H=1")
endif()

function(ADD_THIRDPARTY_LIB LIB_NAME)
function(add_thirdparty_lib LIB_NAME LIB_TYPE LIB)
set(options)
set(one_value_args SHARED_LIB STATIC_LIB)
set(one_value_args)
set(multi_value_args DEPS INCLUDE_DIRECTORIES)
cmake_parse_arguments(ARG
"${options}"
Expand All @@ -59,78 +43,25 @@ function(ADD_THIRDPARTY_LIB LIB_NAME)
message(SEND_ERROR "Error: unrecognized arguments: ${ARG_UNPARSED_ARGUMENTS}")
endif()

if(ARG_STATIC_LIB AND ARG_SHARED_LIB)
set(AUG_LIB_NAME "${LIB_NAME}_static")
add_library(${AUG_LIB_NAME} STATIC IMPORTED)
set_target_properties(${AUG_LIB_NAME} PROPERTIES IMPORTED_LOCATION
"${ARG_STATIC_LIB}")
if(ARG_DEPS)
set_target_properties(${AUG_LIB_NAME} PROPERTIES INTERFACE_LINK_LIBRARIES
"${ARG_DEPS}")
endif()
message(STATUS "Added static library dependency ${AUG_LIB_NAME}: ${ARG_STATIC_LIB}")
if(ARG_INCLUDE_DIRECTORIES)
set_target_properties(${AUG_LIB_NAME} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${ARG_INCLUDE_DIRECTORIES}")
endif()

set(AUG_LIB_NAME "${LIB_NAME}_shared")
add_library(${AUG_LIB_NAME} SHARED IMPORTED)

if(WIN32)
# Mark the ".lib" location as part of a Windows DLL
set_target_properties(${AUG_LIB_NAME} PROPERTIES IMPORTED_IMPLIB
"${ARG_SHARED_LIB}")
else()
set_target_properties(${AUG_LIB_NAME} PROPERTIES IMPORTED_LOCATION
"${ARG_SHARED_LIB}")
endif()
if(ARG_DEPS)
set_target_properties(${AUG_LIB_NAME} PROPERTIES INTERFACE_LINK_LIBRARIES
"${ARG_DEPS}")
endif()
message(STATUS "Added shared library dependency ${AUG_LIB_NAME}: ${ARG_SHARED_LIB}")
if(ARG_INCLUDE_DIRECTORIES)
set_target_properties(${AUG_LIB_NAME} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${ARG_INCLUDE_DIRECTORIES}")
endif()
elseif(ARG_STATIC_LIB)
set(AUG_LIB_NAME "${LIB_NAME}_static")
add_library(${AUG_LIB_NAME} STATIC IMPORTED)
set_target_properties(${AUG_LIB_NAME} PROPERTIES IMPORTED_LOCATION
"${ARG_STATIC_LIB}")
if(ARG_DEPS)
set_target_properties(${AUG_LIB_NAME} PROPERTIES INTERFACE_LINK_LIBRARIES
"${ARG_DEPS}")
endif()
message(STATUS "Added static library dependency ${AUG_LIB_NAME}: ${ARG_STATIC_LIB}")
if(ARG_INCLUDE_DIRECTORIES)
set_target_properties(${AUG_LIB_NAME} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${ARG_INCLUDE_DIRECTORIES}")
endif()
elseif(ARG_SHARED_LIB)
set(AUG_LIB_NAME "${LIB_NAME}_shared")
add_library(${AUG_LIB_NAME} SHARED IMPORTED)

Copy link
Member

Choose a reason for hiding this comment

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

Nice simplification here!

add_library(${LIB_NAME} ${LIB_TYPE} IMPORTED)
if(${LIB_TYPE} STREQUAL "STATIC")
set_target_properties(${LIB_NAME} PROPERTIES IMPORTED_LOCATION "${LIB}")
message(STATUS "Added static library dependency ${LIB_NAME}: ${LIB}")
else()
if(WIN32)
# Mark the ".lib" location as part of a Windows DLL
set_target_properties(${AUG_LIB_NAME} PROPERTIES IMPORTED_IMPLIB
"${ARG_SHARED_LIB}")
set_target_properties(${LIB_NAME} PROPERTIES IMPORTED_IMPLIB "${LIB}")
else()
set_target_properties(${AUG_LIB_NAME} PROPERTIES IMPORTED_LOCATION
"${ARG_SHARED_LIB}")
endif()
message(STATUS "Added shared library dependency ${AUG_LIB_NAME}: ${ARG_SHARED_LIB}")
if(ARG_DEPS)
set_target_properties(${AUG_LIB_NAME} PROPERTIES INTERFACE_LINK_LIBRARIES
"${ARG_DEPS}")
endif()
if(ARG_INCLUDE_DIRECTORIES)
set_target_properties(${AUG_LIB_NAME} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${ARG_INCLUDE_DIRECTORIES}")
set_target_properties(${LIB_NAME} PROPERTIES IMPORTED_LOCATION "${LIB}")
endif()
else()
message(FATAL_ERROR "No static or shared library provided for ${LIB_NAME}")
message(STATUS "Added shared library dependency ${LIB_NAME}: ${LIB}")
endif()
if(ARG_DEPS)
set_target_properties(${LIB_NAME} PROPERTIES INTERFACE_LINK_LIBRARIES "${ARG_DEPS}")
endif()
if(ARG_INCLUDE_DIRECTORIES)
set_target_properties(${LIB_NAME} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${ARG_INCLUDE_DIRECTORIES}")
endif()
endfunction()

Expand Down Expand Up @@ -271,11 +202,16 @@ function(ADD_ARROW_LIB LIB_NAME)
set(OUTPUT_PATH ${BUILD_OUTPUT_ROOT_DIRECTORY})
endif()

if(WIN32 OR (CMAKE_GENERATOR STREQUAL Xcode))
if(WIN32
OR (CMAKE_GENERATOR STREQUAL Xcode)
OR CMAKE_VERSION VERSION_LESS 3.12)
# We need to compile C++ separately for each library kind (shared and static)
# because of dllexport declarations on Windows.
# The Xcode generator doesn't reliably work with Xcode as target names are not
# guessed correctly.
# We can't use target for object library with CMake 3.11 or earlier.
# See also: Object Libraries:
# https://cmake.org/cmake/help/latest/command/add_library.html#object-libraries
set(USE_OBJLIB OFF)
else()
set(USE_OBJLIB ON)
Expand Down Expand Up @@ -310,6 +246,9 @@ function(ADD_ARROW_LIB LIB_NAME)
if(ARG_PRIVATE_INCLUDES)
target_include_directories(${LIB_NAME}_objlib PRIVATE ${ARG_PRIVATE_INCLUDES})
endif()
target_link_libraries(${LIB_NAME}_objlib
PRIVATE ${ARG_SHARED_LINK_LIBS} ${ARG_SHARED_PRIVATE_LINK_LIBS}
${ARG_STATIC_LINK_LIBS})
else()
# Prepare arguments for separate compilation of static and shared libs below
# TODO: add PCH directives
Expand Down
10 changes: 3 additions & 7 deletions cpp/cmake_modules/DefineOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
"Rely on Protocol Buffers shared libraries where relevant"
${ARROW_DEPENDENCY_USE_SHARED})

define_option(ARROW_SNAPPY_USE_SHARED "Rely on snappy shared libraries where relevant"
${ARROW_DEPENDENCY_USE_SHARED})

if(WIN32)
# It seems that Thrift doesn't support DLL well yet.
# MSYS2, conda-forge and vcpkg don't build shared library.
Expand All @@ -366,13 +369,6 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
"Rely on utf8proc shared libraries where relevant"
${ARROW_DEPENDENCY_USE_SHARED})

define_option(ARROW_SNAPPY_USE_SHARED "Rely on snappy shared libraries where relevant"
${ARROW_DEPENDENCY_USE_SHARED})

define_option(ARROW_UTF8PROC_USE_SHARED
"Rely on utf8proc shared libraries where relevant"
${ARROW_DEPENDENCY_USE_SHARED})

define_option(ARROW_ZSTD_USE_SHARED "Rely on zstd shared libraries where relevant"
${ARROW_DEPENDENCY_USE_SHARED})

Expand Down
63 changes: 0 additions & 63 deletions cpp/cmake_modules/FindBoostAlt.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion cpp/cmake_modules/Findutf8proc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ if(utf8proc_FOUND)
INTERFACE_INCLUDE_DIRECTORIES
"${utf8proc_INCLUDE_DIR}")
if(NOT ARROW_UTF8PROC_USE_SHARED)
set_target_properties(utf8proc::utf8proc PROPERTIES INTERFACE_COMPILER_DEFINITIONS
set_target_properties(utf8proc::utf8proc PROPERTIES INTERFACE_COMPILE_DEFINITIONS
"UTF8PROC_STATIC")
endif()
endif()
Loading