From 6efdfd1a4c047166ce47f703711c3f22cc024a49 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Tue, 12 Apr 2022 17:31:25 +0900 Subject: [PATCH 01/46] ARROW-16168: [C++][CMake] Use target to add include paths We can remove "include_directories(SYSTEM)" by this. --- cpp/CMakeLists.txt | 10 +++ cpp/cmake_modules/BuildUtils.cmake | 11 +++ cpp/cmake_modules/ThirdpartyToolchain.cmake | 74 ++------------------- cpp/src/arrow/CMakeLists.txt | 3 +- 4 files changed, 29 insertions(+), 69 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index ec12feab3d2..11934023b79 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -808,6 +808,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(TARGET 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) diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index 174b1c515a7..d11cea06e4a 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -310,6 +310,17 @@ function(ADD_ARROW_LIB LIB_NAME) if(ARG_PRIVATE_INCLUDES) target_include_directories(${LIB_NAME}_objlib PRIVATE ${ARG_PRIVATE_INCLUDES}) endif() + foreach(LIB ${ARG_SHARED_LINK_LIBS} ${ARG_SHARED_PRIVATE_LINK_LIBS} + ${ARG_STATIC_LINK_LIBS}) + if(TARGET ${LIB}) + target_include_directories(${LIB_NAME}_objlib + PRIVATE "$" + ) + target_compile_definitions(${LIB_NAME}_objlib + PRIVATE "$" + ) + endif() + endforeach() else() # Prepare arguments for separate compilation of static and shared libs below # TODO: add PCH directives diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 865406e705b..da07b479c09 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -1056,9 +1056,6 @@ if(ARROW_WITH_SNAPPY) get_target_property(SNAPPY_LIB Snappy::snappy IMPORTED_LOCATION) string(APPEND ARROW_PC_LIBS_PRIVATE " ${SNAPPY_LIB}") endif() - # TODO: Don't use global includes but rather target_include_directories - get_target_property(SNAPPY_INCLUDE_DIRS Snappy::snappy INTERFACE_INCLUDE_DIRECTORIES) - include_directories(SYSTEM ${SNAPPY_INCLUDE_DIRS}) endif() # ---------------------------------------------------------------------- @@ -1122,10 +1119,6 @@ endmacro() if(ARROW_WITH_BROTLI) resolve_dependency(Brotli PC_PACKAGE_NAMES libbrotlidec libbrotlienc) - # TODO: Don't use global includes but rather target_include_directories - get_target_property(BROTLI_INCLUDE_DIR Brotli::brotlicommon - INTERFACE_INCLUDE_DIRECTORIES) - include_directories(SYSTEM ${BROTLI_INCLUDE_DIR}) endif() if(PARQUET_REQUIRE_ENCRYPTION AND NOT ARROW_PARQUET) @@ -1242,9 +1235,6 @@ endmacro() if(ARROW_USE_GLOG) resolve_dependency(GLOG PC_PACKAGE_NAMES libglog) - # TODO: Don't use global includes but rather target_include_directories - get_target_property(GLOG_INCLUDE_DIR glog::glog INTERFACE_INCLUDE_DIRECTORIES) - include_directories(SYSTEM ${GLOG_INCLUDE_DIR}) endif() # ---------------------------------------------------------------------- @@ -1321,8 +1311,6 @@ if(ARROW_NEED_GFLAGS) ${ARROW_GFLAGS_REQUIRED_VERSION} IS_RUNTIME_DEPENDENCY FALSE) - # TODO: Don't use global includes but rather target_include_directories - include_directories(SYSTEM ${GFLAGS_INCLUDE_DIR}) if(NOT TARGET ${GFLAGS_LIBRARIES}) if(TARGET gflags-shared) @@ -1423,8 +1411,6 @@ if(ARROW_WITH_THRIFT) PC_PACKAGE_NAMES thrift) endif() - # TODO: Don't use global includes but rather target_include_directories - include_directories(SYSTEM ${THRIFT_INCLUDE_DIR}) string(REPLACE "." ";" VERSION_LIST ${THRIFT_VERSION}) list(GET VERSION_LIST 0 THRIFT_VERSION_MAJOR) @@ -1558,9 +1544,6 @@ if(ARROW_WITH_PROTOBUF) add_definitions(-DPROTOBUF_USE_DLLS) endif() - # TODO: Don't use global includes but rather target_include_directories - include_directories(SYSTEM ${PROTOBUF_INCLUDE_DIR}) - if(TARGET arrow::protobuf::libprotobuf) set(ARROW_PROTOBUF_LIBPROTOBUF arrow::protobuf::libprotobuf) else() @@ -2003,10 +1986,6 @@ if(ARROW_TESTING) # endif() # set(CMAKE_REQUIRED_LIBRARIES) endif() - - get_target_property(GTEST_INCLUDE_DIR GTest::gtest INTERFACE_INCLUDE_DIRECTORIES) - # TODO: Don't use global includes but rather target_include_directories - include_directories(SYSTEM ${GTEST_INCLUDE_DIR}) endif() macro(build_benchmark) @@ -2077,10 +2056,6 @@ if(ARROW_BUILD_BENCHMARKS) ${BENCHMARK_REQUIRED_VERSION} IS_RUNTIME_DEPENDENCY FALSE) - # TODO: Don't use global includes but rather target_include_directories - get_target_property(BENCHMARK_INCLUDE_DIR benchmark::benchmark - INTERFACE_INCLUDE_DIRECTORIES) - include_directories(SYSTEM ${BENCHMARK_INCLUDE_DIR}) endif() macro(build_rapidjson) @@ -2124,8 +2099,8 @@ if(ARROW_WITH_RAPIDJSON) set(RAPIDJSON_INCLUDE_DIR "${RapidJSON_INCLUDE_DIR}") endif() - # TODO: Don't use global includes but rather target_include_directories - include_directories(SYSTEM ${RAPIDJSON_INCLUDE_DIR}) + add_library(rapidjson::rapidjson INTERFACE IMPORTED) + target_include_directories(rapidjson::rapidjson INTERFACE "${RAPIDJSON_INCLUDE_DIR}") endif() macro(build_xsimd) @@ -2152,8 +2127,9 @@ if((NOT ARROW_SIMD_LEVEL STREQUAL "NONE") OR (NOT ARROW_RUNTIME_SIMD_LEVEL STREQ )) set(xsimd_SOURCE "BUNDLED") resolve_dependency(xsimd) - # TODO: Don't use global includes but rather target_include_directories - include_directories(SYSTEM ${XSIMD_INCLUDE_DIR}) + + add_library(xsimd INTERFACE IMPORTED) + target_include_directories(xsimd INTERFACE "${XSIMD_INCLUDE_DIR}") endif() macro(build_zlib) @@ -2195,10 +2171,6 @@ endmacro() if(ARROW_WITH_ZLIB) resolve_dependency(ZLIB PC_PACKAGE_NAMES zlib) - - # TODO: Don't use global includes but rather target_include_directories - get_target_property(ZLIB_INCLUDE_DIR ZLIB::ZLIB INTERFACE_INCLUDE_DIRECTORIES) - include_directories(SYSTEM ${ZLIB_INCLUDE_DIR}) endif() macro(build_lz4) @@ -2253,10 +2225,6 @@ endmacro() if(ARROW_WITH_LZ4) resolve_dependency(Lz4 PC_PACKAGE_NAMES liblz4) - - # TODO: Don't use global includes but rather target_include_directories - get_target_property(LZ4_INCLUDE_DIR LZ4::lz4 INTERFACE_INCLUDE_DIRECTORIES) - include_directories(SYSTEM ${LZ4_INCLUDE_DIR}) endif() macro(build_zstd) @@ -2339,11 +2307,6 @@ if(ARROW_WITH_ZSTD) endif() endif() endif() - - # TODO: Don't use global includes but rather target_include_directories - get_target_property(ZSTD_INCLUDE_DIR ${ARROW_ZSTD_LIBZSTD} - INTERFACE_INCLUDE_DIRECTORIES) - include_directories(SYSTEM ${ZSTD_INCLUDE_DIR}) endif() # ---------------------------------------------------------------------- @@ -2399,10 +2362,6 @@ if(ARROW_WITH_RE2) string(APPEND ARROW_PC_LIBS_PRIVATE " ${RE2_LIB}") endif() add_definitions(-DARROW_WITH_RE2) - - # TODO: Don't use global includes but rather target_include_directories - get_target_property(RE2_INCLUDE_DIR re2::re2 INTERFACE_INCLUDE_DIRECTORIES) - include_directories(SYSTEM ${RE2_INCLUDE_DIR}) endif() macro(build_bzip2) @@ -2514,22 +2473,7 @@ if(ARROW_WITH_UTF8PROC) "2.2.0" PC_PACKAGE_NAMES libutf8proc) - add_definitions(-DARROW_WITH_UTF8PROC) - - # TODO: Don't use global definitions but rather - # target_compile_definitions or target_link_libraries - get_target_property(UTF8PROC_COMPILER_DEFINITIONS utf8proc::utf8proc - INTERFACE_COMPILER_DEFINITIONS) - if(UTF8PROC_COMPILER_DEFINITIONS) - add_definitions(-D${UTF8PROC_COMPILER_DEFINITIONS}) - endif() - - # TODO: Don't use global includes but rather - # target_include_directories or target_link_libraries - get_target_property(UTF8PROC_INCLUDE_DIR utf8proc::utf8proc - INTERFACE_INCLUDE_DIRECTORIES) - include_directories(SYSTEM ${UTF8PROC_INCLUDE_DIR}) endif() macro(build_cares) @@ -3450,9 +3394,6 @@ macro(build_grpc) TRUE PC_PACKAGE_NAMES libcares) - # TODO: Don't use global includes but rather target_include_directories - get_target_property(c-ares_INCLUDE_DIR c-ares::cares INTERFACE_INCLUDE_DIRECTORIES) - include_directories(SYSTEM ${c-ares_INCLUDE_DIR}) # First need Abseil resolve_dependency_absl() @@ -3708,10 +3649,6 @@ if(ARROW_WITH_GRPC) PC_PACKAGE_NAMES grpc++) - # TODO: Don't use global includes but rather target_include_directories - get_target_property(GRPC_INCLUDE_DIR gRPC::grpc++ INTERFACE_INCLUDE_DIRECTORIES) - include_directories(SYSTEM ${GRPC_INCLUDE_DIR}) - if(GRPC_VENDORED) set(GRPCPP_PP_INCLUDE TRUE) # Examples need to link to static Arrow if we're using static gRPC @@ -3719,6 +3656,7 @@ if(ARROW_WITH_GRPC) else() # grpc++ headers may reside in ${GRPC_INCLUDE_DIR}/grpc++ or ${GRPC_INCLUDE_DIR}/grpcpp # depending on the gRPC version. + get_target_property(GRPC_INCLUDE_DIR gRPC::grpc++ INTERFACE_INCLUDE_DIRECTORIES) if(EXISTS "${GRPC_INCLUDE_DIR}/grpcpp/impl/codegen/config_protobuf.h") set(GRPCPP_PP_INCLUDE TRUE) elseif(EXISTS "${GRPC_INCLUDE_DIR}/grpc++/impl/codegen/config_protobuf.h") diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index 690c51a4a62..bd258bac0da 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -625,7 +625,8 @@ if(ARROW_TESTING) arrow_shared GTest::gtest STATIC_LINK_LIBS - arrow_static) + arrow_static + GTest::gtest) add_custom_target(arrow_testing) add_dependencies(arrow_testing ${ARROW_TESTING_LIBRARIES}) From aa0cbfd27529dd85eb2e5e663c782db4c0eaf57f Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Tue, 12 Apr 2022 18:08:32 +0900 Subject: [PATCH 02/46] Suppress sign-compare warnings from g++ e.g.: In file included from /arrow/cpp/src/arrow/testing/gtest_util.h:31, from /arrow/cpp/src/arrow/io/test_common.cc:35: /build/cpp/googletest_ep-prefix/include/gtest/gtest.h: In instantiation of 'testing::AssertionResult testing::internal::CmpHelperEQ(const char*, const char*, const T1&, const T2&) [with T1 = long int; T2 = long unsigned int]': /build/cpp/googletest_ep-prefix/include/gtest/gtest.h:1564:23: required from 'static testing::AssertionResult testing::internal::EqHelper::Compare(const char*, const char*, const T1&, const T2&) [with T1 = long int; T2 = long unsigned int; typename std::enable_if<((! std::is_integral<_Tp>::value) || (! std::is_pointer<_Dp>::value))>::type* = 0]' /arrow/cpp/src/arrow/io/test_common.cc:47:3: required from here /build/cpp/googletest_ep-prefix/include/gtest/gtest.h:1545:11: error: comparison of integer expressions of different signedness: 'const long int' and 'const long unsigned int' [-Werror=sign-compare] 1545 | if (lhs == rhs) { | ~~~~^~~~~~ --- cpp/cmake_modules/SetupCxxFlags.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cpp/cmake_modules/SetupCxxFlags.cmake b/cpp/cmake_modules/SetupCxxFlags.cmake index a11f37dd4d9..41215b59cbc 100644 --- a/cpp/cmake_modules/SetupCxxFlags.cmake +++ b/cpp/cmake_modules/SetupCxxFlags.cmake @@ -290,6 +290,7 @@ if("${BUILD_WARNING_LEVEL}" STREQUAL "CHECKIN") set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wall") set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-conversion") set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-deprecated-declarations") + set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-sign-compare") set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-sign-conversion") set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wunused-result") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") From e00602b32112416d1a710ae1dbf0cdb23d87dfc5 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Tue, 12 Apr 2022 18:22:17 +0900 Subject: [PATCH 03/46] Ensure creating xsimd's include directory --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index da07b479c09..ca48e653b61 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2116,6 +2116,8 @@ macro(build_xsimd) CMAKE_ARGS ${XSIMD_CMAKE_ARGS}) set(XSIMD_INCLUDE_DIR "${XSIMD_PREFIX}/include") + # The include directory must exist before it is referenced by a target. + file(MAKE_DIRECTORY "${XSIMD_INCLUDE_DIR}") add_dependencies(toolchain xsimd_ep) add_dependencies(toolchain-tests xsimd_ep) From f538f93f444e239cd0b91dbeb606a127dcac09ce Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Tue, 12 Apr 2022 18:45:04 +0900 Subject: [PATCH 04/46] Treat thirdparty library's include directory as system --- cpp/cmake_modules/BuildUtils.cmake | 2 +- cpp/cmake_modules/SetupCxxFlags.cmake | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index d11cea06e4a..89d8aef3193 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -313,7 +313,7 @@ function(ADD_ARROW_LIB LIB_NAME) foreach(LIB ${ARG_SHARED_LINK_LIBS} ${ARG_SHARED_PRIVATE_LINK_LIBS} ${ARG_STATIC_LINK_LIBS}) if(TARGET ${LIB}) - target_include_directories(${LIB_NAME}_objlib + target_include_directories(${LIB_NAME}_objlib SYSTEM PRIVATE "$" ) target_compile_definitions(${LIB_NAME}_objlib diff --git a/cpp/cmake_modules/SetupCxxFlags.cmake b/cpp/cmake_modules/SetupCxxFlags.cmake index 41215b59cbc..a11f37dd4d9 100644 --- a/cpp/cmake_modules/SetupCxxFlags.cmake +++ b/cpp/cmake_modules/SetupCxxFlags.cmake @@ -290,7 +290,6 @@ if("${BUILD_WARNING_LEVEL}" STREQUAL "CHECKIN") set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wall") set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-conversion") set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-deprecated-declarations") - set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-sign-compare") set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-sign-conversion") set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wunused-result") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") From 8ec1abddb4aa136f78b01c885096312306407ffd Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 13 Apr 2022 05:32:40 +0900 Subject: [PATCH 05/46] Ensure making include directory --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index ca48e653b61..7f038d8d1e8 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2077,6 +2077,8 @@ macro(build_rapidjson) CMAKE_ARGS ${RAPIDJSON_CMAKE_ARGS}) set(RAPIDJSON_INCLUDE_DIR "${RAPIDJSON_PREFIX}/include") + # The include directory must exist before it is referenced by a target. + file(MAKE_DIRECTORY "${RAPIDJSON_INCLUDE_DIR}") add_dependencies(toolchain rapidjson_ep) add_dependencies(toolchain-tests rapidjson_ep) From 72ee8b144a36d26c70691ee2fc6fd6a00739d0e2 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 13 Apr 2022 11:53:01 +0900 Subject: [PATCH 06/46] Add workaround for RapidJSON's CMake package We need to convert MSYS2 path to Windows PATH explicitly. --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 7f038d8d1e8..cbf38c55c81 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2100,6 +2100,12 @@ if(ARROW_WITH_RAPIDJSON) if(RapidJSON_INCLUDE_DIR) set(RAPIDJSON_INCLUDE_DIR "${RapidJSON_INCLUDE_DIR}") endif() + if(WIN32 AND "${RAPIDJSON_INCLUDE_DIR}" MATCHES "^/") + # MSYS2 + execute_process(COMMAND "cygpath" "--windows" "${RAPIDJSON_INCLUDE_DIR}" + OUTPUT_VARIABLE RAPIDJSON_INCLUDE_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() add_library(rapidjson::rapidjson INTERFACE IMPORTED) target_include_directories(rapidjson::rapidjson INTERFACE "${RAPIDJSON_INCLUDE_DIR}") From 0abf7283b25457de0ac181fd9a92849192e51f88 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 13 Apr 2022 11:53:50 +0900 Subject: [PATCH 07/46] Define interface library for Winsock --- cpp/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 11934023b79..3f53296e26d 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -938,8 +938,9 @@ if(CMAKE_THREAD_LIBS_INIT) endif() if(WIN32) - # Winsock - list(APPEND ARROW_SYSTEM_LINK_LIBS "ws2_32.dll") + add_library(arrow::winsock INTERFACE IMPORTED) + target_link_libraries(arrow::winsock INTERFACE "ws2_32.dll") + list(APPEND ARROW_SYSTEM_LINK_LIBS arrow::winsock) endif() if(NOT WIN32 AND NOT APPLE) From b316be81874e14b93cceb49e6a6d2bc7ceb4edb0 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 13 Apr 2022 13:33:19 +0900 Subject: [PATCH 08/46] Define interface library for -lrt --- cpp/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 3f53296e26d..5fd5efbe985 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -944,8 +944,9 @@ if(WIN32) endif() if(NOT WIN32 AND NOT APPLE) - # Pass -lrt on Linux only - list(APPEND ARROW_SYSTEM_LINK_LIBS rt) + add_library(arrow::rt INTERFACE IMPORTED) + target_link_libraries(arrow::rt INTERFACE "rt") + list(APPEND ARROW_SYSTEM_LINK_LIBS arrow::rt) endif() list(APPEND ARROW_LINK_LIBS ${ARROW_SYSTEM_LINK_LIBS}) From 5e70b3652c7992b1ad976730c24ed10dc7036e13 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 13 Apr 2022 13:34:29 +0900 Subject: [PATCH 09/46] Add missing static link dependencies --- cpp/src/parquet/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/parquet/CMakeLists.txt b/cpp/src/parquet/CMakeLists.txt index 4dcda67acf7..c3c01b86c81 100644 --- a/cpp/src/parquet/CMakeLists.txt +++ b/cpp/src/parquet/CMakeLists.txt @@ -105,7 +105,7 @@ endfunction() # TODO(wesm): Handling of ABI/SO version if(ARROW_BUILD_STATIC) - set(PARQUET_STATIC_LINK_LIBS arrow_static) + set(PARQUET_STATIC_LINK_LIBS arrow_static ${ARROW_STATIC_LINK_LIBS}) set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_static arrow_static) else() set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_shared arrow_shared) From 3baa7ae03a5874735486bdd7127bdf39e0de1470 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 13 Apr 2022 14:43:54 +0900 Subject: [PATCH 10/46] Use target_link_libraries() --- cpp/src/parquet/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/parquet/CMakeLists.txt b/cpp/src/parquet/CMakeLists.txt index c3c01b86c81..3169a3b08de 100644 --- a/cpp/src/parquet/CMakeLists.txt +++ b/cpp/src/parquet/CMakeLists.txt @@ -263,7 +263,7 @@ if(WIN32 AND NOT (ARROW_TEST_LINKAGE STREQUAL "static")) add_library(parquet_test_support STATIC "${ARROW_SOURCE_DIR}/src/generated/parquet_constants.cpp" "${ARROW_SOURCE_DIR}/src/generated/parquet_types.cpp") - add_dependencies(parquet_test_support thrift::thrift) + target_link_libraries(parquet_test_support thrift::thrift) set(PARQUET_SHARED_TEST_LINK_LIBS ${PARQUET_SHARED_TEST_LINK_LIBS} parquet_test_support) set(PARQUET_LIBRARIES ${PARQUET_LIBRARIES} parquet_test_support) endif() From e9f87d517ec86a3a6f1a64c5bb90818ed3ce6af6 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 13 Apr 2022 14:44:56 +0900 Subject: [PATCH 11/46] Add missing libs --- cpp/src/arrow/dataset/CMakeLists.txt | 2 +- cpp/src/parquet/CMakeLists.txt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cpp/src/arrow/dataset/CMakeLists.txt b/cpp/src/arrow/dataset/CMakeLists.txt index 6aa4794a3fa..478c13691b0 100644 --- a/cpp/src/arrow/dataset/CMakeLists.txt +++ b/cpp/src/arrow/dataset/CMakeLists.txt @@ -30,7 +30,7 @@ set(ARROW_DATASET_SRCS projector.cc scanner.cc) -set(ARROW_DATASET_LINK_STATIC arrow_static) +set(ARROW_DATASET_LINK_STATIC arrow_static ${ARROW_STATIC_LINK_LIBS}) set(ARROW_DATASET_LINK_SHARED arrow_shared) if(ARROW_CSV) diff --git a/cpp/src/parquet/CMakeLists.txt b/cpp/src/parquet/CMakeLists.txt index 3169a3b08de..d0368fe2892 100644 --- a/cpp/src/parquet/CMakeLists.txt +++ b/cpp/src/parquet/CMakeLists.txt @@ -106,7 +106,8 @@ endfunction() if(ARROW_BUILD_STATIC) set(PARQUET_STATIC_LINK_LIBS arrow_static ${ARROW_STATIC_LINK_LIBS}) - set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_static arrow_static) + set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_static arrow_static + ${ARROW_STATIC_LINK_LIBS}) else() set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_shared arrow_shared) endif() From 4290208b62c3d2159fe0ca72a318b3de4c47f574 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 13 Apr 2022 14:45:07 +0900 Subject: [PATCH 12/46] Fix a typo --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index cbf38c55c81..30a21205147 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2467,7 +2467,7 @@ macro(build_utf8proc) add_library(utf8proc::utf8proc STATIC IMPORTED) set_target_properties(utf8proc::utf8proc PROPERTIES IMPORTED_LOCATION "${UTF8PROC_STATIC_LIB}" - INTERFACE_COMPILER_DEFINITIONS "UTF8PROC_STATIC" + INTERFACE_COMPILE_DEFINITIONS "UTF8PROC_STATIC" INTERFACE_INCLUDE_DIRECTORIES "${UTF8PROC_PREFIX}/include") From 4c62dbe60311bb130574967a87fb8fcbaa602318 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 13 Apr 2022 15:10:16 +0900 Subject: [PATCH 13/46] Create target for -ldl --- cpp/CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 5fd5efbe985..789993d991c 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -850,8 +850,10 @@ if(((ARROW_FLIGHT endif() if(NOT MSVC_TOOLCHAIN) - list(APPEND ARROW_LINK_LIBS ${CMAKE_DL_LIBS}) - list(APPEND ARROW_SHARED_INSTALL_INTERFACE_LIBS ${CMAKE_DL_LIBS}) + add_library(arrow::dl INTERFACE IMPORTED) + target_link_libraries(arrow::dl INTERFACE ${CMAKE_DL_LIBS}) + list(APPEND ARROW_LINK_LIBS arrow::dl) + list(APPEND ARROW_SHARED_INSTALL_INTERFACE_LIBS arrow::dl) endif() set(ARROW_TEST_LINK_TOOLCHAIN @@ -877,8 +879,8 @@ set(ARROW_TEST_STATIC_LINK_LIBS arrow_testing_static arrow_static ${ARROW_LINK_L set(ARROW_TEST_SHARED_LINK_LIBS arrow_testing_shared arrow_shared ${ARROW_LINK_LIBS} ${ARROW_TEST_LINK_TOOLCHAIN}) -if(NOT MSVC) - set(ARROW_TEST_SHARED_LINK_LIBS ${ARROW_TEST_SHARED_LINK_LIBS} ${CMAKE_DL_LIBS}) +if(TARGET arrow::dl) + list(APPEND ARROW_TEST_SHARED_LINK_LIBS arrow::dl) endif() if("${ARROW_TEST_LINKAGE}" STREQUAL "shared") From c9ec064a54f837cf82f34616ca114c6db2656899 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 13 Apr 2022 15:10:43 +0900 Subject: [PATCH 14/46] Remove needless DEPENDENCIES --- cpp/src/parquet/CMakeLists.txt | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/cpp/src/parquet/CMakeLists.txt b/cpp/src/parquet/CMakeLists.txt index d0368fe2892..f149732c053 100644 --- a/cpp/src/parquet/CMakeLists.txt +++ b/cpp/src/parquet/CMakeLists.txt @@ -219,18 +219,6 @@ if(NOT PARQUET_MINIMAL_DEPENDENCY) # Link publicly with parquet_static (because internal users need to # transitively link all dependencies) set(PARQUET_STATIC_LINK_LIBS ${PARQUET_STATIC_LINK_LIBS} thrift::thrift) - - # Although we don't link parquet_objlib against anything, we need it to depend - # on these libs as we may generate their headers via ExternalProject_Add - if(ARROW_BUILD_SHARED) - set(PARQUET_DEPENDENCIES ${PARQUET_DEPENDENCIES} ${PARQUET_SHARED_LINK_LIBS} - ${PARQUET_SHARED_PRIVATE_LINK_LIBS}) - endif() - - if(ARROW_BUILD_STATIC) - set(PARQUET_DEPENDENCIES ${PARQUET_DEPENDENCIES} ${PARQUET_STATIC_LINK_LIBS}) - endif() - endif(NOT PARQUET_MINIMAL_DEPENDENCY) if(CXX_LINKER_SUPPORTS_VERSION_SCRIPT) @@ -249,8 +237,6 @@ add_arrow_lib(parquet "$<$:parquet/pch.h>" OUTPUTS PARQUET_LIBRARIES - DEPENDENCIES - ${PARQUET_DEPENDENCIES} SHARED_LINK_FLAGS ${PARQUET_SHARED_LINK_FLAGS} SHARED_LINK_LIBS From 7e96eb559fc54fc3d3dce5993ace739a8bf9206f Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Fri, 15 Apr 2022 14:59:03 +0900 Subject: [PATCH 15/46] Don't use target for system libraries --- cpp/CMakeLists.txt | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 789993d991c..11934023b79 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -850,10 +850,8 @@ if(((ARROW_FLIGHT endif() if(NOT MSVC_TOOLCHAIN) - add_library(arrow::dl INTERFACE IMPORTED) - target_link_libraries(arrow::dl INTERFACE ${CMAKE_DL_LIBS}) - list(APPEND ARROW_LINK_LIBS arrow::dl) - list(APPEND ARROW_SHARED_INSTALL_INTERFACE_LIBS arrow::dl) + list(APPEND ARROW_LINK_LIBS ${CMAKE_DL_LIBS}) + list(APPEND ARROW_SHARED_INSTALL_INTERFACE_LIBS ${CMAKE_DL_LIBS}) endif() set(ARROW_TEST_LINK_TOOLCHAIN @@ -879,8 +877,8 @@ set(ARROW_TEST_STATIC_LINK_LIBS arrow_testing_static arrow_static ${ARROW_LINK_L set(ARROW_TEST_SHARED_LINK_LIBS arrow_testing_shared arrow_shared ${ARROW_LINK_LIBS} ${ARROW_TEST_LINK_TOOLCHAIN}) -if(TARGET arrow::dl) - list(APPEND ARROW_TEST_SHARED_LINK_LIBS arrow::dl) +if(NOT MSVC) + set(ARROW_TEST_SHARED_LINK_LIBS ${ARROW_TEST_SHARED_LINK_LIBS} ${CMAKE_DL_LIBS}) endif() if("${ARROW_TEST_LINKAGE}" STREQUAL "shared") @@ -940,15 +938,13 @@ if(CMAKE_THREAD_LIBS_INIT) endif() if(WIN32) - add_library(arrow::winsock INTERFACE IMPORTED) - target_link_libraries(arrow::winsock INTERFACE "ws2_32.dll") - list(APPEND ARROW_SYSTEM_LINK_LIBS arrow::winsock) + # Winsock + list(APPEND ARROW_SYSTEM_LINK_LIBS "ws2_32.dll") endif() if(NOT WIN32 AND NOT APPLE) - add_library(arrow::rt INTERFACE IMPORTED) - target_link_libraries(arrow::rt INTERFACE "rt") - list(APPEND ARROW_SYSTEM_LINK_LIBS arrow::rt) + # Pass -lrt on Linux only + list(APPEND ARROW_SYSTEM_LINK_LIBS rt) endif() list(APPEND ARROW_LINK_LIBS ${ARROW_SYSTEM_LINK_LIBS}) From 91a54e75200d192bfcef3ee678848d3e1da711b4 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Fri, 15 Apr 2022 15:18:00 +0900 Subject: [PATCH 16/46] Remove include_directories(SYSTEM) --- cpp/CMakeLists.txt | 4 +-- cpp/cmake_modules/ThirdpartyToolchain.cmake | 31 ++++++------------- .../parquet/parquet_arrow/CMakeLists.txt | 4 +-- .../arrow/flight/transport/ucx/CMakeLists.txt | 1 - cpp/src/arrow/gpu/CMakeLists.txt | 1 - cpp/src/plasma/CMakeLists.txt | 4 +-- 6 files changed, 14 insertions(+), 31 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 11934023b79..ab7ef1135be 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -692,8 +692,8 @@ endif() # # Libraries to link statically with libarrow.so -set(ARROW_LINK_LIBS) -set(ARROW_STATIC_LINK_LIBS) +set(ARROW_LINK_LIBS arrow::flatbuffers arrow::hadoop) +set(ARROW_STATIC_LINK_LIBS arrow::flatbuffers arrow::hadoop) set(ARROW_STATIC_INSTALL_INTERFACE_LIBS) if(ARROW_USE_OPENSSL) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 30a21205147..522a3f909e7 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -260,8 +260,8 @@ endmacro() set(THIRDPARTY_DIR "${arrow_SOURCE_DIR}/thirdparty") -# Include vendored Flatbuffers -include_directories(SYSTEM "${THIRDPARTY_DIR}/flatbuffers/include") +add_library(arrow::flatbuffers INTERFACE IMPORTED) +target_include_directories(arrow::flatbuffers INTERFACE "${THIRDPARTY_DIR}/flatbuffers/include") # ---------------------------------------------------------------------- # Some EP's require other EP's @@ -989,8 +989,6 @@ if(ARROW_BOOST_REQUIRED) message(STATUS "Boost include dir: ${Boost_INCLUDE_DIR}") message(STATUS "Boost libraries: ${ARROW_BOOST_LIBS}") - - include_directories(SYSTEM ${Boost_INCLUDE_DIR}) endif() # ---------------------------------------------------------------------- @@ -1170,9 +1168,7 @@ if(ARROW_USE_OPENSSL) message(STATUS "Found OpenSSL Crypto Library: ${OPENSSL_CRYPTO_LIBRARY}") message(STATUS "Building with OpenSSL (Version: ${OPENSSL_VERSION}) support") - list(APPEND ARROW_SYSTEM_DEPENDENCIES "OpenSSL") - - include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR}) + list(APPEND ARROW_SYSTEM_DEPENDENCIES OpenSSL) else() message(STATUS "Building without OpenSSL support. Minimum OpenSSL version ${ARROW_OPENSSL_REQUIRED_VERSION} required." ) @@ -1743,15 +1739,14 @@ if(ARROW_JEMALLOC) # Don't use the include directory directly so that we can point to a path # that is unique to our codebase. - include_directories(SYSTEM "${CMAKE_CURRENT_BINARY_DIR}/jemalloc_ep-prefix/src/") + set(JEMALLOC_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/jemalloc_ep-prefix/src/") # The include directory must exist before it is referenced by a target. - file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/jemalloc_ep-prefix/src/") + file(MAKE_DIRECTORY "${JEMALLOC_INCLUDE_DIR}") add_library(jemalloc::jemalloc STATIC IMPORTED) set_target_properties(jemalloc::jemalloc PROPERTIES INTERFACE_LINK_LIBRARIES Threads::Threads IMPORTED_LOCATION "${JEMALLOC_STATIC_LIB}" - INTERFACE_INCLUDE_DIRECTORIES - "${CMAKE_CURRENT_BINARY_DIR}/jemalloc_ep-prefix/src") + INTERFACE_INCLUDE_DIRECTORIES "${JEMALLOC_INCLUDE_DIR}") add_dependencies(jemalloc::jemalloc jemalloc_ep) list(APPEND ARROW_BUNDLED_STATIC_LIBS jemalloc::jemalloc) @@ -1793,7 +1788,6 @@ if(ARROW_MIMALLOC) CMAKE_ARGS ${MIMALLOC_CMAKE_ARGS} BUILD_BYPRODUCTS "${MIMALLOC_STATIC_LIB}") - include_directories(SYSTEM ${MIMALLOC_INCLUDE_DIR}) file(MAKE_DIRECTORY ${MIMALLOC_INCLUDE_DIR}) add_library(mimalloc::mimalloc STATIC IMPORTED) @@ -2434,7 +2428,6 @@ if(ARROW_WITH_BZ2) PROPERTIES IMPORTED_LOCATION "${BZIP2_LIBRARIES}" INTERFACE_INCLUDE_DIRECTORIES "${BZIP2_INCLUDE_DIR}") endif() - include_directories(SYSTEM "${BZIP2_INCLUDE_DIR}") endif() macro(build_utf8proc) @@ -3750,7 +3743,6 @@ if(ARROW_WITH_NLOHMANN_JSON) resolve_dependency(nlohmann_json) get_target_property(nlohmann_json_INCLUDE_DIR nlohmann_json::nlohmann_json INTERFACE_INCLUDE_DIRECTORIES) - include_directories(SYSTEM ${nlohmann_json_INCLUDE_DIR}) message(STATUS "Found nlohmann_json headers: ${nlohmann_json_INCLUDE_DIR}") endif() @@ -3880,9 +3872,6 @@ if(ARROW_WITH_GOOGLE_CLOUD_CPP) resolve_dependency(google_cloud_cpp_storage) get_target_property(google_cloud_cpp_storage_INCLUDE_DIR google-cloud-cpp::storage INTERFACE_INCLUDE_DIRECTORIES) - include_directories(SYSTEM ${google_cloud_cpp_storage_INCLUDE_DIR}) - get_target_property(absl_base_INCLUDE_DIR absl::base INTERFACE_INCLUDE_DIRECTORIES) - include_directories(SYSTEM ${absl_base_INCLUDE_DIR}) message(STATUS "Found google-cloud-cpp::storage headers: ${google_cloud_cpp_storage_INCLUDE_DIR}" ) endif() @@ -3904,9 +3893,10 @@ set(HDFS_H_PATH "${HADOOP_HOME}/include/hdfs.h") if(NOT EXISTS ${HDFS_H_PATH}) message(FATAL_ERROR "Did not find hdfs.h at ${HDFS_H_PATH}") endif() -message(STATUS "Found hdfs.h at: " ${HDFS_H_PATH}) +message(STATUS "Found hdfs.h at: ${HDFS_H_PATH}") -include_directories(SYSTEM "${HADOOP_HOME}/include") +add_library(arrow::hadoop INTERFACE IMPORTED) +target_include_directories(arrow::hadoop INTERFACE "${HADOOP_HOME}/include") # ---------------------------------------------------------------------- # Apache ORC @@ -3991,7 +3981,6 @@ endmacro() if(ARROW_ORC) resolve_dependency(ORC) - include_directories(SYSTEM ${ORC_INCLUDE_DIR}) message(STATUS "Found ORC static library: ${ORC_STATIC_LIB}") message(STATUS "Found ORC headers: ${ORC_INCLUDE_DIR}") endif() @@ -4208,7 +4197,6 @@ if(ARROW_WITH_OPENTELEMETRY) resolve_dependency(opentelemetry-cpp) get_target_property(OPENTELEMETRY_INCLUDE_DIR opentelemetry-cpp::api INTERFACE_INCLUDE_DIRECTORIES) - include_directories(SYSTEM ${OPENTELEMETRY_INCLUDE_DIR}) message(STATUS "Found OpenTelemetry headers: ${OPENTELEMETRY_INCLUDE_DIR}") endif() @@ -4434,7 +4422,6 @@ if(ARROW_S3) endif() endif() - include_directories(SYSTEM ${AWSSDK_INCLUDE_DIR}) message(STATUS "Found AWS SDK headers: ${AWSSDK_INCLUDE_DIR}") message(STATUS "Found AWS SDK libraries: ${AWSSDK_LINK_LIBRARIES}") diff --git a/cpp/examples/parquet/parquet_arrow/CMakeLists.txt b/cpp/examples/parquet/parquet_arrow/CMakeLists.txt index eb5bb869170..32f980060c9 100644 --- a/cpp/examples/parquet/parquet_arrow/CMakeLists.txt +++ b/cpp/examples/parquet/parquet_arrow/CMakeLists.txt @@ -38,7 +38,5 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Arrow REQUIRED) find_package(Parquet REQUIRED) -include_directories(SYSTEM ${ARROW_INCLUDE_DIR} ${PARQUET_INCLUDE_DIR}) - add_executable(parquet-arrow-example reader_writer.cc) -target_link_libraries(parquet-arrow-example ${PARQUET_SHARED_LIB} ${ARROW_SHARED_LIB}) +target_link_libraries(parquet-arrow-example parquet_shared arrow_shared) diff --git a/cpp/src/arrow/flight/transport/ucx/CMakeLists.txt b/cpp/src/arrow/flight/transport/ucx/CMakeLists.txt index 6e315b68d6c..8e28c105b4f 100644 --- a/cpp/src/arrow/flight/transport/ucx/CMakeLists.txt +++ b/cpp/src/arrow/flight/transport/ucx/CMakeLists.txt @@ -29,7 +29,6 @@ set(ARROW_FLIGHT_TRANSPORT_UCX_SRCS util_internal.cc) set(ARROW_FLIGHT_TRANSPORT_UCX_LINK_LIBS) -include_directories(SYSTEM ${UCX_INCLUDE_DIRS}) list(APPEND ARROW_FLIGHT_TRANSPORT_UCX_LINK_LIBS PkgConfig::UCX) add_arrow_lib(arrow_flight_transport_ucx diff --git a/cpp/src/arrow/gpu/CMakeLists.txt b/cpp/src/arrow/gpu/CMakeLists.txt index 7a66622f847..635d256e6da 100644 --- a/cpp/src/arrow/gpu/CMakeLists.txt +++ b/cpp/src/arrow/gpu/CMakeLists.txt @@ -39,7 +39,6 @@ else() # CUDAToolkit is only available in CMake >= 3.17 find_package(CUDAToolkit REQUIRED) set(ARROW_CUDA_SHARED_LINK_LIBS CUDA::cuda_driver) - include_directories(SYSTEM ${CUDAToolkit_INCLUDE_DIRS}) endif() set(ARROW_CUDA_SRCS cuda_arrow_ipc.cc cuda_context.cc cuda_internal.cc cuda_memory.cc) diff --git a/cpp/src/plasma/CMakeLists.txt b/cpp/src/plasma/CMakeLists.txt index 46603d6f85c..e04de94c7d3 100644 --- a/cpp/src/plasma/CMakeLists.txt +++ b/cpp/src/plasma/CMakeLists.txt @@ -52,8 +52,8 @@ set(PLASMA_STORE_SRCS store.cc thirdparty/ae/ae.c) -set(PLASMA_LINK_LIBS arrow_shared) -set(PLASMA_STATIC_LINK_LIBS arrow_static) +set(PLASMA_LINK_LIBS arrow_shared arrow::flatbuffers) +set(PLASMA_STATIC_LINK_LIBS arrow_static arrow::flatbuffers) if(ARROW_CUDA) list(INSERT PLASMA_LINK_LIBS 0 arrow_cuda_shared) From 89b111025aef56e46febc6292eada7436ebf68e0 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Fri, 15 Apr 2022 17:30:30 +0900 Subject: [PATCH 17/46] Add missing Boost dependencies --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 21 +++++++++++++++------ cpp/src/gandiva/CMakeLists.txt | 2 +- cpp/src/parquet/CMakeLists.txt | 7 ++++--- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 522a3f909e7..4c14f5db15d 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -261,7 +261,8 @@ endmacro() set(THIRDPARTY_DIR "${arrow_SOURCE_DIR}/thirdparty") add_library(arrow::flatbuffers INTERFACE IMPORTED) -target_include_directories(arrow::flatbuffers INTERFACE "${THIRDPARTY_DIR}/flatbuffers/include") +target_include_directories(arrow::flatbuffers + INTERFACE "${THIRDPARTY_DIR}/flatbuffers/include") # ---------------------------------------------------------------------- # Some EP's require other EP's @@ -770,6 +771,7 @@ macro(build_boost) # This is needed by the thrift_ep build set(BOOST_ROOT ${BOOST_PREFIX}) + set(Boost_INCLUDE_DIR "${BOOST_PREFIX}") if(ARROW_BOOST_REQUIRE_LIBRARY) set(BOOST_LIB_DIR "${BOOST_PREFIX}/stage/lib") @@ -829,9 +831,17 @@ macro(build_boost) set(BOOST_BUILD_PRODUCTS ${BOOST_STATIC_SYSTEM_LIBRARY} ${BOOST_STATIC_FILESYSTEM_LIBRARY}) - add_thirdparty_lib(boost_system STATIC_LIB "${BOOST_STATIC_SYSTEM_LIBRARY}") + add_thirdparty_lib(boost_system + STATIC_LIB + "${BOOST_STATIC_SYSTEM_LIBRARY}" + INCLUDE_DIRECTORIES + "${Boost_INCLUDE_DIR}") - add_thirdparty_lib(boost_filesystem STATIC_LIB "${BOOST_STATIC_FILESYSTEM_LIBRARY}") + add_thirdparty_lib(boost_filesystem + STATIC_LIB + "${BOOST_STATIC_FILESYSTEM_LIBRARY}" + INCLUDE_DIRECTORIES + "${Boost_INCLUDE_DIR}") externalproject_add(boost_ep URL ${BOOST_SOURCE_URL} @@ -852,8 +862,6 @@ macro(build_boost) URL ${BOOST_SOURCE_URL} URL_HASH "SHA256=${ARROW_BOOST_BUILD_SHA256_CHECKSUM}") endif() - set(Boost_INCLUDE_DIR "${BOOST_PREFIX}") - set(Boost_INCLUDE_DIRS "${Boost_INCLUDE_DIR}") add_dependencies(toolchain boost_ep) set(BOOST_VENDORED TRUE) endmacro() @@ -1746,7 +1754,8 @@ if(ARROW_JEMALLOC) set_target_properties(jemalloc::jemalloc PROPERTIES INTERFACE_LINK_LIBRARIES Threads::Threads IMPORTED_LOCATION "${JEMALLOC_STATIC_LIB}" - INTERFACE_INCLUDE_DIRECTORIES "${JEMALLOC_INCLUDE_DIR}") + INTERFACE_INCLUDE_DIRECTORIES + "${JEMALLOC_INCLUDE_DIR}") add_dependencies(jemalloc::jemalloc jemalloc_ep) list(APPEND ARROW_BUNDLED_STATIC_LIBS jemalloc::jemalloc) diff --git a/cpp/src/gandiva/CMakeLists.txt b/cpp/src/gandiva/CMakeLists.txt index 71faf9a38ec..fb141805914 100644 --- a/cpp/src/gandiva/CMakeLists.txt +++ b/cpp/src/gandiva/CMakeLists.txt @@ -99,7 +99,7 @@ set(SRC_FILES ${GANDIVA_PRECOMPILED_CC_PATH}) set(GANDIVA_SHARED_PRIVATE_LINK_LIBS arrow_shared LLVM::LLVM_INTERFACE - ${GANDIVA_OPENSSL_LIBS}) + ${GANDIVA_OPENSSL_LIBS} ${ARROW_BOOST_LIBS}) set(GANDIVA_STATIC_LINK_LIBS arrow_static LLVM::LLVM_INTERFACE ${GANDIVA_OPENSSL_LIBS}) diff --git a/cpp/src/parquet/CMakeLists.txt b/cpp/src/parquet/CMakeLists.txt index f149732c053..1b67059cbfa 100644 --- a/cpp/src/parquet/CMakeLists.txt +++ b/cpp/src/parquet/CMakeLists.txt @@ -112,7 +112,7 @@ else() set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_shared arrow_shared) endif() -set(PARQUET_MIN_TEST_LIBS GTest::gtest_main GTest::gtest) +set(PARQUET_MIN_TEST_LIBS GTest::gtest_main GTest::gtest ${ARROW_BOOST_LIBS}) if(APPLE) set(PARQUET_MIN_TEST_LIBS ${PARQUET_MIN_TEST_LIBS} ${CMAKE_DL_LIBS}) @@ -214,11 +214,12 @@ if(NOT PARQUET_MINIMAL_DEPENDENCY) # These are libraries that we will link privately with parquet_shared (as they # do not need to be linked transitively by other linkers) - set(PARQUET_SHARED_PRIVATE_LINK_LIBS thrift::thrift) + set(PARQUET_SHARED_PRIVATE_LINK_LIBS thrift::thrift ${ARROW_BOOST_LIBS}) # Link publicly with parquet_static (because internal users need to # transitively link all dependencies) - set(PARQUET_STATIC_LINK_LIBS ${PARQUET_STATIC_LINK_LIBS} thrift::thrift) + set(PARQUET_STATIC_LINK_LIBS ${PARQUET_STATIC_LINK_LIBS} thrift::thrift + ${ARROW_BOOST_LIBS}) endif(NOT PARQUET_MINIMAL_DEPENDENCY) if(CXX_LINKER_SUPPORTS_VERSION_SCRIPT) From 104e8f941140ba25f390fa69edad88f7d67871f1 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 18 Apr 2022 14:30:37 +0900 Subject: [PATCH 18/46] Add missing Boost dependencies to Thrift --- cpp/cmake_modules/BuildUtils.cmake | 13 ++----------- cpp/cmake_modules/ThirdpartyToolchain.cmake | 7 +++++++ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index 89d8aef3193..52cb1a016b9 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -310,17 +310,8 @@ function(ADD_ARROW_LIB LIB_NAME) if(ARG_PRIVATE_INCLUDES) target_include_directories(${LIB_NAME}_objlib PRIVATE ${ARG_PRIVATE_INCLUDES}) endif() - foreach(LIB ${ARG_SHARED_LINK_LIBS} ${ARG_SHARED_PRIVATE_LINK_LIBS} - ${ARG_STATIC_LINK_LIBS}) - if(TARGET ${LIB}) - target_include_directories(${LIB_NAME}_objlib SYSTEM - PRIVATE "$" - ) - target_compile_definitions(${LIB_NAME}_objlib - PRIVATE "$" - ) - endif() - endforeach() + 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 diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 4c14f5db15d..67ca532f064 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -861,6 +861,10 @@ macro(build_boost) INSTALL_COMMAND "" URL ${BOOST_SOURCE_URL} URL_HASH "SHA256=${ARROW_BOOST_BUILD_SHA256_CHECKSUM}") + add_library(Boost::system INTERFACE IMPORTED) + target_include_directories(Boost::system INTERFACE "${Boost_INCLUDE_DIR}") + add_library(Boost::filesystem INTERFACE IMPORTED) + target_include_directories(Boost::system INTERFACE "${Boost_INCLUDE_DIR}") endif() add_dependencies(toolchain boost_ep) set(BOOST_VENDORED TRUE) @@ -1397,6 +1401,9 @@ macro(build_thrift) set_target_properties(thrift::thrift PROPERTIES IMPORTED_LOCATION "${THRIFT_STATIC_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${THRIFT_INCLUDE_DIR}") + if(BOOST_VENDORED) + target_link_libraries(thrift::thrift INTERFACE ${ARROW_BOOST_LIBS}) + endif() add_dependencies(toolchain thrift_ep) add_dependencies(thrift::thrift thrift_ep) set(THRIFT_VERSION ${ARROW_THRIFT_BUILD_VERSION}) From 3169e33992c26578f8551e88fbbf19910aa2287b Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 18 Apr 2022 14:33:06 +0900 Subject: [PATCH 19/46] Fix indent --- cpp/cmake_modules/BuildUtils.cmake | 5 +++-- cpp/cmake_modules/ThirdpartyToolchain.cmake | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index 52cb1a016b9..d74f2401116 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -310,8 +310,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}) + 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 diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 67ca532f064..c30a8195b5d 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -861,10 +861,10 @@ macro(build_boost) INSTALL_COMMAND "" URL ${BOOST_SOURCE_URL} URL_HASH "SHA256=${ARROW_BOOST_BUILD_SHA256_CHECKSUM}") - add_library(Boost::system INTERFACE IMPORTED) - target_include_directories(Boost::system INTERFACE "${Boost_INCLUDE_DIR}") - add_library(Boost::filesystem INTERFACE IMPORTED) - target_include_directories(Boost::system INTERFACE "${Boost_INCLUDE_DIR}") + add_library(Boost::system INTERFACE IMPORTED) + target_include_directories(Boost::system INTERFACE "${Boost_INCLUDE_DIR}") + add_library(Boost::filesystem INTERFACE IMPORTED) + target_include_directories(Boost::system INTERFACE "${Boost_INCLUDE_DIR}") endif() add_dependencies(toolchain boost_ep) set(BOOST_VENDORED TRUE) From c8f2c1c0d151c0408ccb689439687950a609ca7a Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 18 Apr 2022 16:31:06 +0900 Subject: [PATCH 20/46] Clean Boost related targets --- cpp/CMakeLists.txt | 14 +---- cpp/cmake_modules/BuildUtils.cmake | 16 ----- cpp/cmake_modules/FindBoostAlt.cmake | 63 -------------------- cpp/cmake_modules/ThirdpartyToolchain.cmake | 66 ++++++++++++++------- cpp/src/arrow/filesystem/CMakeLists.txt | 4 +- cpp/src/arrow/flight/CMakeLists.txt | 11 +--- cpp/src/gandiva/CMakeLists.txt | 2 +- cpp/src/parquet/CMakeLists.txt | 7 +-- 8 files changed, 57 insertions(+), 126 deletions(-) delete mode 100644 cpp/cmake_modules/FindBoostAlt.cmake diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index ab7ef1135be..600138a5aeb 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -840,15 +840,6 @@ 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}) @@ -858,8 +849,9 @@ set(ARROW_TEST_LINK_TOOLCHAIN GTest::gtest_main GTest::gtest GTest::gmock - ${BOOST_FILESYSTEM_LIBRARY} - ${BOOST_SYSTEM_LIBRARY}) + Boost::headers + Boost::filesystem + Boost::system) if(ARROW_BUILD_TESTS) add_dependencies(arrow_test_dependencies ${ARROW_TEST_LINK_TOOLCHAIN}) diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index d74f2401116..54397ff8b59 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -30,22 +30,6 @@ 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) set(options) set(one_value_args SHARED_LIB STATIC_LIB) diff --git a/cpp/cmake_modules/FindBoostAlt.cmake b/cpp/cmake_modules/FindBoostAlt.cmake deleted file mode 100644 index 072e267c1fb..00000000000 --- a/cpp/cmake_modules/FindBoostAlt.cmake +++ /dev/null @@ -1,63 +0,0 @@ -# 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(DEFINED ENV{BOOST_ROOT} OR DEFINED BOOST_ROOT) - # In older versions of CMake (such as 3.2), the system paths for Boost will - # be looked in first even if we set $BOOST_ROOT or pass -DBOOST_ROOT - set(Boost_NO_SYSTEM_PATHS ON) -endif() - -set(BoostAlt_FIND_PACKAGE_OPTIONS) -if(BoostAlt_FIND_VERSION) - list(APPEND BoostAlt_FIND_PACKAGE_OPTIONS ${BoostAlt_FIND_VERSION}) -endif() -if(BoostAlt_FIND_REQUIRED) - list(APPEND BoostAlt_FIND_PACKAGE_OPTIONS REQUIRED) -endif() -if(BoostAlt_FIND_QUIETLY) - list(APPEND BoostAlt_FIND_PACKAGE_OPTIONS QUIET) -endif() - -if(ARROW_BOOST_USE_SHARED) - # Find shared Boost libraries. - set(Boost_USE_STATIC_LIBS OFF) - set(BUILD_SHARED_LIBS_KEEP ${BUILD_SHARED_LIBS}) - set(BUILD_SHARED_LIBS ON) - - find_package(Boost ${BoostAlt_FIND_PACKAGE_OPTIONS} COMPONENTS system filesystem) - set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_KEEP}) - unset(BUILD_SHARED_LIBS_KEEP) -else() - # Find static boost headers and libs - # TODO Differentiate here between release and debug builds - set(Boost_USE_STATIC_LIBS ON) - find_package(Boost ${BoostAlt_FIND_PACKAGE_OPTIONS} COMPONENTS system filesystem) -endif() - -if(Boost_FOUND) - set(BoostAlt_FOUND ON) - if(MSVC_TOOLCHAIN) - # disable autolinking in boost - add_definitions(-DBOOST_ALL_NO_LIB) - if(ARROW_BOOST_USE_SHARED) - # force all boost libraries to dynamic link - add_definitions(-DBOOST_ALL_DYN_LINK) - endif() - endif() -else() - set(BoostAlt_FOUND OFF) -endif() diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index c30a8195b5d..40eed3b8fdc 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -836,12 +836,16 @@ macro(build_boost) "${BOOST_STATIC_SYSTEM_LIBRARY}" INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIR}") + add_library(Boost::system INTERFACE IMPORTED) + target_link_libraries(Boost::system INTERFACE boost_system_static) add_thirdparty_lib(boost_filesystem STATIC_LIB "${BOOST_STATIC_FILESYSTEM_LIBRARY}" INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIR}") + add_library(Boost::filesystem INTERFACE IMPORTED) + target_link_libraries(Boost::filesystem INTERFACE boost_filesystem_static) externalproject_add(boost_ep URL ${BOOST_SOURCE_URL} @@ -861,11 +865,16 @@ macro(build_boost) INSTALL_COMMAND "" URL ${BOOST_SOURCE_URL} URL_HASH "SHA256=${ARROW_BOOST_BUILD_SHA256_CHECKSUM}") - add_library(Boost::system INTERFACE IMPORTED) - target_include_directories(Boost::system INTERFACE "${Boost_INCLUDE_DIR}") - add_library(Boost::filesystem INTERFACE IMPORTED) - target_include_directories(Boost::system INTERFACE "${Boost_INCLUDE_DIR}") endif() + add_library(Boost::headers INTERFACE IMPORTED) + target_include_directories(Boost::headers INTERFACE "${Boost_INCLUDE_DIR}") + add_dependencies(Boost::headers boost_ep) + add_library(Boost::disable_autolinking INTERFACE IMPORTED) + if(WIN32) + target_compile_definitions(Boost::disable_autolinking INTERFACE "BOOST_ALL_NO_LIB") + endif() + # This doesn't add BOOST_ALL_DYN_LINK because bundled Boost is a static library. + add_library(Boost::dynamic_linking INTERFACE IMPORTED) add_dependencies(toolchain boost_ep) set(BOOST_VENDORED TRUE) endmacro() @@ -978,29 +987,48 @@ else() endif() if(ARROW_BOOST_REQUIRED) + if(ARROW_BOOST_USE_SHARED) + # Find shared Boost libraries. + set(Boost_USE_STATIC_LIBS OFF) + set(BUILD_SHARED_LIBS_KEEP ${BUILD_SHARED_LIBS}) + set(BUILD_SHARED_LIBS ON) + else() + # Find static boost headers and libs + # TODO Differentiate here between release and debug builds + set(Boost_USE_STATIC_LIBS ON) + endif() resolve_dependency(Boost - HAVE_ALT - TRUE REQUIRED_VERSION ${ARROW_BOOST_REQUIRED_VERSION} IS_RUNTIME_DEPENDENCY # libarrow.so doesn't depend on libboost*. FALSE) + if(ARROW_BOOST_USE_SHARED) + set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_KEEP}) + unset(BUILD_SHARED_LIBS_KEEP) + endif() - if(TARGET Boost::system) - set(BOOST_SYSTEM_LIBRARY Boost::system) - set(BOOST_FILESYSTEM_LIBRARY Boost::filesystem) - elseif(BoostAlt_FOUND) - set(BOOST_SYSTEM_LIBRARY ${Boost_SYSTEM_LIBRARY}) - set(BOOST_FILESYSTEM_LIBRARY ${Boost_FILESYSTEM_LIBRARY}) - else() - set(BOOST_SYSTEM_LIBRARY boost_system_static) - set(BOOST_FILESYSTEM_LIBRARY boost_filesystem_static) + foreach(BOOST_LIBRARY Boost::headers Boost::filesystem Boost::system) + if(NOT TARGET ${BOOST_LIBRARY}) + continue() + endif() + target_link_libraries(${BOOST_LIBRARY} INTERFACE Boost::disable_autolinking) + if(ARROW_BOOST_USE_SHARED) + target_link_libraries(${BOOST_LIBRARY} INTERFACE Boost::dynamic_linking) + endif() + endforeach() + + 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 + target_compile_definitions(Boost::headers INTERFACE "BOOST_USE_WINDOWS_H=1") endif() - set(ARROW_BOOST_LIBS ${BOOST_SYSTEM_LIBRARY} ${BOOST_FILESYSTEM_LIBRARY}) message(STATUS "Boost include dir: ${Boost_INCLUDE_DIR}") - message(STATUS "Boost libraries: ${ARROW_BOOST_LIBS}") endif() # ---------------------------------------------------------------------- @@ -1401,9 +1429,7 @@ macro(build_thrift) set_target_properties(thrift::thrift PROPERTIES IMPORTED_LOCATION "${THRIFT_STATIC_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${THRIFT_INCLUDE_DIR}") - if(BOOST_VENDORED) - target_link_libraries(thrift::thrift INTERFACE ${ARROW_BOOST_LIBS}) - endif() + target_link_libraries(thrift::thrift INTERFACE Boost::headers) add_dependencies(toolchain thrift_ep) add_dependencies(thrift::thrift thrift_ep) set(THRIFT_VERSION ${ARROW_THRIFT_BUILD_VERSION}) diff --git a/cpp/src/arrow/filesystem/CMakeLists.txt b/cpp/src/arrow/filesystem/CMakeLists.txt index c301a57bade..44b71ed27f5 100644 --- a/cpp/src/arrow/filesystem/CMakeLists.txt +++ b/cpp/src/arrow/filesystem/CMakeLists.txt @@ -40,7 +40,7 @@ if(ARROW_S3) EXTRA_LABELS filesystem) if(TARGET arrow-s3fs-test) - set(ARROW_S3FS_TEST_COMPILE_DEFINITIONS ${ARROW_BOOST_PROCESS_COMPILE_DEFINITIONS}) + set(ARROW_S3FS_TEST_COMPILE_DEFINITIONS) get_target_property(AWS_CPP_SDK_S3_TYPE aws-cpp-sdk-s3 TYPE) # We need to initialize AWS C++ SDK for direct use (not via # arrow::fs::S3FileSystem) in arrow-s3fs-test if we use static AWS @@ -74,8 +74,6 @@ if(ARROW_S3) SOURCES s3fs_benchmark.cc s3_test_util.cc) - target_compile_definitions(arrow-filesystem-s3fs-benchmark - PRIVATE ${ARROW_BOOST_PROCESS_COMPILE_DEFINITIONS}) if(ARROW_TEST_LINKAGE STREQUAL "static") target_link_libraries(arrow-filesystem-s3fs-benchmark PRIVATE parquet_static) else() diff --git a/cpp/src/arrow/flight/CMakeLists.txt b/cpp/src/arrow/flight/CMakeLists.txt index f9d135654b4..db97aad9f00 100644 --- a/cpp/src/arrow/flight/CMakeLists.txt +++ b/cpp/src/arrow/flight/CMakeLists.txt @@ -250,8 +250,9 @@ if(ARROW_TESTING) arrow_shared arrow_flight_shared arrow_testing_shared - ${BOOST_FILESYSTEM_LIBRARY} - ${BOOST_SYSTEM_LIBRARY} + Boost::headers + Boost::filesystem + Boost::system GTest::gtest ${ARROW_FLIGHT_TEST_INTERFACE_LIBS} STATIC_LINK_LIBS @@ -261,12 +262,6 @@ if(ARROW_TESTING) ${ARROW_FLIGHT_TEST_INTERFACE_LIBS}) endif() -foreach(LIB_TARGET ${ARROW_FLIGHT_TESTING_LIBRARIES}) - target_compile_definitions(${LIB_TARGET} - PRIVATE ARROW_FLIGHT_EXPORTING - ${ARROW_BOOST_PROCESS_COMPILE_DEFINITIONS}) -endforeach() - add_arrow_test(flight_internals_test STATIC_LINK_LIBS ${ARROW_FLIGHT_TEST_LINK_LIBS} diff --git a/cpp/src/gandiva/CMakeLists.txt b/cpp/src/gandiva/CMakeLists.txt index fb141805914..38bd2732388 100644 --- a/cpp/src/gandiva/CMakeLists.txt +++ b/cpp/src/gandiva/CMakeLists.txt @@ -99,7 +99,7 @@ set(SRC_FILES ${GANDIVA_PRECOMPILED_CC_PATH}) set(GANDIVA_SHARED_PRIVATE_LINK_LIBS arrow_shared LLVM::LLVM_INTERFACE - ${GANDIVA_OPENSSL_LIBS} ${ARROW_BOOST_LIBS}) + ${GANDIVA_OPENSSL_LIBS} Boost::headers) set(GANDIVA_STATIC_LINK_LIBS arrow_static LLVM::LLVM_INTERFACE ${GANDIVA_OPENSSL_LIBS}) diff --git a/cpp/src/parquet/CMakeLists.txt b/cpp/src/parquet/CMakeLists.txt index 1b67059cbfa..28e4f00caca 100644 --- a/cpp/src/parquet/CMakeLists.txt +++ b/cpp/src/parquet/CMakeLists.txt @@ -112,7 +112,7 @@ else() set(ARROW_LIBRARIES_FOR_STATIC_TESTS arrow_testing_shared arrow_shared) endif() -set(PARQUET_MIN_TEST_LIBS GTest::gtest_main GTest::gtest ${ARROW_BOOST_LIBS}) +set(PARQUET_MIN_TEST_LIBS GTest::gtest_main GTest::gtest Boost::headers) if(APPLE) set(PARQUET_MIN_TEST_LIBS ${PARQUET_MIN_TEST_LIBS} ${CMAKE_DL_LIBS}) @@ -214,12 +214,11 @@ if(NOT PARQUET_MINIMAL_DEPENDENCY) # These are libraries that we will link privately with parquet_shared (as they # do not need to be linked transitively by other linkers) - set(PARQUET_SHARED_PRIVATE_LINK_LIBS thrift::thrift ${ARROW_BOOST_LIBS}) + set(PARQUET_SHARED_PRIVATE_LINK_LIBS thrift::thrift) # Link publicly with parquet_static (because internal users need to # transitively link all dependencies) - set(PARQUET_STATIC_LINK_LIBS ${PARQUET_STATIC_LINK_LIBS} thrift::thrift - ${ARROW_BOOST_LIBS}) + set(PARQUET_STATIC_LINK_LIBS ${PARQUET_STATIC_LINK_LIBS} thrift::thrift) endif(NOT PARQUET_MINIMAL_DEPENDENCY) if(CXX_LINKER_SUPPORTS_VERSION_SCRIPT) From 37e5b6a3c526fcdfc3ec934aceacc1b5db9ebc0f Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 18 Apr 2022 17:11:34 +0900 Subject: [PATCH 21/46] Boost::* may not be built --- cpp/CMakeLists.txt | 11 +++++++---- cpp/cmake_modules/ThirdpartyToolchain.cmake | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 600138a5aeb..70348f48af8 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -848,10 +848,13 @@ endif() set(ARROW_TEST_LINK_TOOLCHAIN GTest::gtest_main GTest::gtest - GTest::gmock - Boost::headers - Boost::filesystem - Boost::system) + GTest::gmock) +if(TARGET Boost::filesystem) + list(APPEND ARROW_TEST_LINK_TOOLCHAIN Boost::filesystem) +endif() +if(TARGET Boost::system) + list(APPEND ARROW_TEST_LINK_TOOLCHAIN Boost::system) +endif() if(ARROW_BUILD_TESTS) add_dependencies(arrow_test_dependencies ${ARROW_TEST_LINK_TOOLCHAIN}) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 40eed3b8fdc..972d56e2c36 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -838,6 +838,7 @@ macro(build_boost) "${Boost_INCLUDE_DIR}") add_library(Boost::system INTERFACE IMPORTED) target_link_libraries(Boost::system INTERFACE boost_system_static) + target_include_directories(Boost::system INTERFACE "${Boost_INCLUDE_DIR}") add_thirdparty_lib(boost_filesystem STATIC_LIB @@ -846,6 +847,7 @@ macro(build_boost) "${Boost_INCLUDE_DIR}") add_library(Boost::filesystem INTERFACE IMPORTED) target_link_libraries(Boost::filesystem INTERFACE boost_filesystem_static) + target_include_directories(Boost::filesystem INTERFACE "${Boost_INCLUDE_DIR}") externalproject_add(boost_ep URL ${BOOST_SOURCE_URL} From d4b69827605985879a7b1bf9bf103af213598b5a Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 18 Apr 2022 17:22:44 +0900 Subject: [PATCH 22/46] Add missing COMPONENTS --- cpp/CMakeLists.txt | 10 +++------- cpp/cmake_modules/ThirdpartyToolchain.cmake | 8 +++++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 70348f48af8..f05f8494398 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -848,13 +848,9 @@ endif() set(ARROW_TEST_LINK_TOOLCHAIN GTest::gtest_main GTest::gtest - GTest::gmock) -if(TARGET Boost::filesystem) - list(APPEND ARROW_TEST_LINK_TOOLCHAIN Boost::filesystem) -endif() -if(TARGET Boost::system) - list(APPEND ARROW_TEST_LINK_TOOLCHAIN Boost::system) -endif() + GTest::gmock + Boost::filesystem + Boost::system) if(ARROW_BUILD_TESTS) add_dependencies(arrow_test_dependencies ${ARROW_TEST_LINK_TOOLCHAIN}) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 972d56e2c36..5aebefc4fcc 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -200,7 +200,7 @@ endmacro() macro(resolve_dependency DEPENDENCY_NAME) set(options) set(one_value_args HAVE_ALT IS_RUNTIME_DEPENDENCY REQUIRED_VERSION USE_CONFIG) - set(multi_value_args PC_PACKAGE_NAMES) + set(multi_value_args COMPONENTS PC_PACKAGE_NAMES) cmake_parse_arguments(ARG "${options}" "${one_value_args}" @@ -225,6 +225,9 @@ macro(resolve_dependency DEPENDENCY_NAME) if(ARG_USE_CONFIG) list(APPEND FIND_PACKAGE_ARGUMENTS CONFIG) endif() + if(ARG_COMPONENTS) + list(APPEND FIND_PACKAGE_ARGUMENTS COMPONENTS ${ARG_COMPONENTS}) + endif() if(${DEPENDENCY_NAME}_SOURCE STREQUAL "AUTO") find_package(${FIND_PACKAGE_ARGUMENTS}) if(${${PACKAGE_NAME}_FOUND}) @@ -1002,6 +1005,9 @@ if(ARROW_BOOST_REQUIRED) resolve_dependency(Boost REQUIRED_VERSION ${ARROW_BOOST_REQUIRED_VERSION} + COMPONENTS + system + filesystem IS_RUNTIME_DEPENDENCY # libarrow.so doesn't depend on libboost*. FALSE) From 499712312144b282c9134d8df131f46a5a64d46a Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 18 Apr 2022 17:53:57 +0900 Subject: [PATCH 23/46] Add missing Boost dependency --- cpp/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index f05f8494398..c2dae066273 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -696,6 +696,11 @@ set(ARROW_LINK_LIBS arrow::flatbuffers arrow::hadoop) set(ARROW_STATIC_LINK_LIBS arrow::flatbuffers arrow::hadoop) set(ARROW_STATIC_INSTALL_INTERFACE_LIBS) +if(TARGET Boost::headers) + 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}) From 984d8d59466c1dac13f5917102ff5501ce153d15 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 18 Apr 2022 18:08:23 +0900 Subject: [PATCH 24/46] Fix link order --- cpp/src/plasma/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/src/plasma/CMakeLists.txt b/cpp/src/plasma/CMakeLists.txt index e04de94c7d3..74b4cbe38b7 100644 --- a/cpp/src/plasma/CMakeLists.txt +++ b/cpp/src/plasma/CMakeLists.txt @@ -52,8 +52,8 @@ set(PLASMA_STORE_SRCS store.cc thirdparty/ae/ae.c) -set(PLASMA_LINK_LIBS arrow_shared arrow::flatbuffers) -set(PLASMA_STATIC_LINK_LIBS arrow_static arrow::flatbuffers) +set(PLASMA_LINK_LIBS arrow::flatbuffers arrow_shared) +set(PLASMA_STATIC_LINK_LIBS arrow::flatbuffers arrow_static) if(ARROW_CUDA) list(INSERT PLASMA_LINK_LIBS 0 arrow_cuda_shared) From 0ce320c38b42615c210f1280905dcf5bec93539a Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 18 Apr 2022 18:08:37 +0900 Subject: [PATCH 25/46] We can't use target_link_library(OBJECT_LIBRARY) with CMake < 3.12 --- cpp/cmake_modules/BuildUtils.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index 54397ff8b59..43256e26c4f 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -255,7 +255,9 @@ 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.0") # 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 From 746ef8823b06e71522fde6d6dbb9a0c758609d85 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 18 Apr 2022 18:15:15 +0900 Subject: [PATCH 26/46] Add support for CMake < 3.15 --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 5aebefc4fcc..5586e7fbcc9 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -1016,6 +1016,12 @@ if(ARROW_BOOST_REQUIRED) unset(BUILD_SHARED_LIBS_KEEP) endif() + # For CMake < 3.15 + if(NOT TARGET Boost::headers) + add_library(Boost::headers INTERFACE IMPORTED) + target_include_directories(Boost::headers INTERFACE "${Boost_INCLUDE_DIR}") + endif() + foreach(BOOST_LIBRARY Boost::headers Boost::filesystem Boost::system) if(NOT TARGET ${BOOST_LIBRARY}) continue() From 6c3eeb0dbae58c6465f50f6a4bd947246bdd7c79 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 18 Apr 2022 21:51:58 +0900 Subject: [PATCH 27/46] Add missing utf8proc dependency --- cpp/src/gandiva/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cpp/src/gandiva/CMakeLists.txt b/cpp/src/gandiva/CMakeLists.txt index 38bd2732388..67f96a4449c 100644 --- a/cpp/src/gandiva/CMakeLists.txt +++ b/cpp/src/gandiva/CMakeLists.txt @@ -100,8 +100,12 @@ set(SRC_FILES set(GANDIVA_SHARED_PRIVATE_LINK_LIBS arrow_shared LLVM::LLVM_INTERFACE ${GANDIVA_OPENSSL_LIBS} Boost::headers) - -set(GANDIVA_STATIC_LINK_LIBS arrow_static LLVM::LLVM_INTERFACE ${GANDIVA_OPENSSL_LIBS}) +set(GANDIVA_STATIC_LINK_LIBS arrow_static LLVM::LLVM_INTERFACE ${GANDIVA_OPENSSL_LIBS} + Boost::headers) +if(ARROW_WITH_UTF8PROC) + list(APPEND GANDIVA_SHARED_PRIVATE_LINK_LIBS utf8proc::utf8proc) + list(APPEND GANDIVA_STATIC_LINK_LIBS utf8proc::utf8proc) +endif() if(ARROW_GANDIVA_STATIC_LIBSTDCPP AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )) From 6bcec5cea6f0c4dcf8d1f20a1ac9e373bcb1a93f Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 18 Apr 2022 22:15:52 +0900 Subject: [PATCH 28/46] Fix dependency order --- cpp/src/plasma/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/plasma/CMakeLists.txt b/cpp/src/plasma/CMakeLists.txt index 74b4cbe38b7..d78a5ccfdcc 100644 --- a/cpp/src/plasma/CMakeLists.txt +++ b/cpp/src/plasma/CMakeLists.txt @@ -113,13 +113,13 @@ list(APPEND PLASMA_EXTERNAL_STORE_SOURCES "external_store.cc" "hash_table_store. # We use static libraries for the plasma-store-server executable so that it can # be copied around and used in different locations. add_executable(plasma-store-server ${PLASMA_EXTERNAL_STORE_SOURCES} ${PLASMA_STORE_SRCS}) -target_link_libraries(plasma-store-server ${GFLAGS_LIBRARIES}) if(ARROW_BUILD_STATIC) target_link_libraries(plasma-store-server plasma_static ${PLASMA_STATIC_LINK_LIBS}) else() # Fallback to shared libs in the case that static libraries are not build. target_link_libraries(plasma-store-server plasma_shared ${PLASMA_LINK_LIBS}) endif() +target_link_libraries(plasma-store-server ${GFLAGS_LIBRARIES}) add_dependencies(plasma plasma-store-server) if(ARROW_RPATH_ORIGIN) From e3f8406417ab8ddb9dcf61a0f59198b05923f40b Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 18 Apr 2022 22:39:49 +0900 Subject: [PATCH 29/46] Add missing ARROW_FLIGHT_EXPORTING --- cpp/src/arrow/flight/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpp/src/arrow/flight/CMakeLists.txt b/cpp/src/arrow/flight/CMakeLists.txt index db97aad9f00..684080841a2 100644 --- a/cpp/src/arrow/flight/CMakeLists.txt +++ b/cpp/src/arrow/flight/CMakeLists.txt @@ -260,6 +260,10 @@ if(ARROW_TESTING) arrow_flight_static arrow_testing_static ${ARROW_FLIGHT_TEST_INTERFACE_LIBS}) + + foreach(LIB_TARGET ${ARROW_FLIGHT_TESTING_LIBRARIES}) + target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_EXPORTING) + endforeach() endif() add_arrow_test(flight_internals_test From 4362fbcd5a51292a27477ee74308fa66421d159f Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 18 Apr 2022 23:19:36 +0900 Subject: [PATCH 30/46] Add missing dependencies --- cpp/src/gandiva/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cpp/src/gandiva/CMakeLists.txt b/cpp/src/gandiva/CMakeLists.txt index 67f96a4449c..c80e65ad2ba 100644 --- a/cpp/src/gandiva/CMakeLists.txt +++ b/cpp/src/gandiva/CMakeLists.txt @@ -106,6 +106,10 @@ if(ARROW_WITH_UTF8PROC) list(APPEND GANDIVA_SHARED_PRIVATE_LINK_LIBS utf8proc::utf8proc) list(APPEND GANDIVA_STATIC_LINK_LIBS utf8proc::utf8proc) endif() +if(TARGET xsimd) + list(APPEND GANDIVA_SHARED_PRIVATE_LINK_LIBS xsimd) + list(APPEND GANDIVA_STATIC_LINK_LIBS xsimd) +endif() if(ARROW_GANDIVA_STATIC_LIBSTDCPP AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )) From 991256c6795290a6a7b6b56ce2f886c7851a710b Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Tue, 19 Apr 2022 09:09:36 +0900 Subject: [PATCH 31/46] Debug --- ci/scripts/PKGBUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/scripts/PKGBUILD b/ci/scripts/PKGBUILD index 38f28a23282..d423e18138e 100644 --- a/ci/scripts/PKGBUILD +++ b/ci/scripts/PKGBUILD @@ -122,6 +122,7 @@ build() { -DCMAKE_BUILD_TYPE="release" \ -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \ -DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD} \ + -DCMAKE_FIND_DEBUG_MODE=ON \ -DCMAKE_VERBOSE_MAKEFILE=ON make -j3 From 048d7de5ab04572e4e575925d49c73a334cd7af3 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Tue, 19 Apr 2022 09:09:47 +0900 Subject: [PATCH 32/46] Remove duplicated entries --- cpp/cmake_modules/DefineOptions.cmake | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cpp/cmake_modules/DefineOptions.cmake b/cpp/cmake_modules/DefineOptions.cmake index ab7d2edf567..f3d94353abc 100644 --- a/cpp/cmake_modules/DefineOptions.cmake +++ b/cpp/cmake_modules/DefineOptions.cmake @@ -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. @@ -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}) From 591077db7f6396ef5409efb1035f56a8d835fae1 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Tue, 19 Apr 2022 10:04:16 +0900 Subject: [PATCH 33/46] Use static utf8proc --- ci/scripts/PKGBUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/scripts/PKGBUILD b/ci/scripts/PKGBUILD index d423e18138e..b9b0194f5c8 100644 --- a/ci/scripts/PKGBUILD +++ b/ci/scripts/PKGBUILD @@ -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 \ @@ -122,7 +123,6 @@ build() { -DCMAKE_BUILD_TYPE="release" \ -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \ -DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD} \ - -DCMAKE_FIND_DEBUG_MODE=ON \ -DCMAKE_VERBOSE_MAKEFILE=ON make -j3 From ffe7aecc8aceb7986512b4225d911bbadb47a896 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Tue, 19 Apr 2022 14:50:02 +0900 Subject: [PATCH 34/46] Add support for CMake < 3.11 again --- cpp/CMakeLists.txt | 1 + cpp/cmake_modules/BuildUtils.cmake | 2 +- cpp/cmake_modules/ThirdpartyToolchain.cmake | 106 ++++++++++++++++---- cpp/src/arrow/CMakeLists.txt | 2 + 4 files changed, 90 insertions(+), 21 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index c2dae066273..a846278a7ab 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -851,6 +851,7 @@ if(NOT MSVC_TOOLCHAIN) endif() set(ARROW_TEST_LINK_TOOLCHAIN + arrow::flatbuffers GTest::gtest_main GTest::gtest GTest::gmock diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index 43256e26c4f..9affb96ae13 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -257,7 +257,7 @@ function(ADD_ARROW_LIB LIB_NAME) if(WIN32 OR (CMAKE_GENERATOR STREQUAL Xcode) - OR CMAKE_VERSION VERSION_LESS "3.12.0") + 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 diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 5586e7fbcc9..e5474497b19 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -264,8 +264,14 @@ endmacro() set(THIRDPARTY_DIR "${arrow_SOURCE_DIR}/thirdparty") add_library(arrow::flatbuffers INTERFACE IMPORTED) -target_include_directories(arrow::flatbuffers - INTERFACE "${THIRDPARTY_DIR}/flatbuffers/include") +if(CMAKE_VERSION VERSION_LESS 3.11) + set_target_properties(arrow::flatbuffers + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${THIRDPARTY_DIR}/flatbuffers/include") +else() + target_include_directoriebs(arrow::flatbuffers INTERFACE + "${THIRDPARTY_DIR}/flatbuffers/include") +endif() # ---------------------------------------------------------------------- # Some EP's require other EP's @@ -840,8 +846,15 @@ macro(build_boost) INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIR}") add_library(Boost::system INTERFACE IMPORTED) - target_link_libraries(Boost::system INTERFACE boost_system_static) - target_include_directories(Boost::system INTERFACE "${Boost_INCLUDE_DIR}") + if(CMAKE_VERSION VERSION_LESS 3.11) + set_target_properties(Boost::system + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${Boost_INCLUDE_DIR}" INTERFACE_LINK_LIBRARIES + boost_system_static) + else() + target_include_directories(Boost::system INTERFACE "${Boost_INCLUDE_DIR}") + target_link_libraries(Boost::system INTERFACE boost_system_static) + endif() add_thirdparty_lib(boost_filesystem STATIC_LIB @@ -849,8 +862,15 @@ macro(build_boost) INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIR}") add_library(Boost::filesystem INTERFACE IMPORTED) - target_link_libraries(Boost::filesystem INTERFACE boost_filesystem_static) - target_include_directories(Boost::filesystem INTERFACE "${Boost_INCLUDE_DIR}") + if(CMAKE_VERSION VERSION_LESS 3.11) + set_target_properties(Boost::filesystem + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${Boost_INCLUDE_DIR}" INTERFACE_LINK_LIBRARIES + boost_filesystem_static) + else() + target_include_directories(Boost::filesystem INTERFACE "${Boost_INCLUDE_DIR}") + target_link_libraries(Boost::filesystem INTERFACE boost_filesystem_static) + endif() externalproject_add(boost_ep URL ${BOOST_SOURCE_URL} @@ -872,15 +892,26 @@ macro(build_boost) URL_HASH "SHA256=${ARROW_BOOST_BUILD_SHA256_CHECKSUM}") endif() add_library(Boost::headers INTERFACE IMPORTED) - target_include_directories(Boost::headers INTERFACE "${Boost_INCLUDE_DIR}") + if(CMAKE_VERSION VERSION_LESS 3.11) + set_target_properties(Boost::headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${Boost_INCLUDE_DIR}") + else() + target_include_directories(Boost::headers INTERFACE "${Boost_INCLUDE_DIR}") + endif() add_dependencies(Boost::headers boost_ep) - add_library(Boost::disable_autolinking INTERFACE IMPORTED) - if(WIN32) - target_compile_definitions(Boost::disable_autolinking INTERFACE "BOOST_ALL_NO_LIB") + # If Boost is found but one of system or filesystem components aren't found, + # Boost::disable_autolinking and Boost::dynamic_linking are already defined. + if(NOT TARGET Boost::disable_autolinking) + add_library(Boost::disable_autolinking INTERFACE IMPORTED) + if(WIN32) + target_compile_definitions(Boost::disable_autolinking INTERFACE "BOOST_ALL_NO_LIB") + endif() + endif() + if(NOT TARGET Boost::dynamic_linking) + # This doesn't add BOOST_ALL_DYN_LINK because bundled Boost is a static library. + add_library(Boost::dynamic_linking INTERFACE IMPORTED) + add_dependencies(toolchain boost_ep) endif() - # This doesn't add BOOST_ALL_DYN_LINK because bundled Boost is a static library. - add_library(Boost::dynamic_linking INTERFACE IMPORTED) - add_dependencies(toolchain boost_ep) set(BOOST_VENDORED TRUE) endmacro() @@ -1019,16 +1050,31 @@ if(ARROW_BOOST_REQUIRED) # For CMake < 3.15 if(NOT TARGET Boost::headers) add_library(Boost::headers INTERFACE IMPORTED) - target_include_directories(Boost::headers INTERFACE "${Boost_INCLUDE_DIR}") + if(CMAKE_VERSION VERSION_LESS 3.11) + set_target_properties(Boost::headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${Boost_INCLUDE_DIR}") + else() + target_include_directories(Boost::headers INTERFACE "${Boost_INCLUDE_DIR}") + endif() endif() foreach(BOOST_LIBRARY Boost::headers Boost::filesystem Boost::system) if(NOT TARGET ${BOOST_LIBRARY}) continue() endif() - target_link_libraries(${BOOST_LIBRARY} INTERFACE Boost::disable_autolinking) + if(CMAKE_VERSION VERSION_LESS 3.11) + set_target_properties(${BOOST_LIBRARY} PROPERTIES INTERFACE_LINK_LIBRARIES + Boost::disable_autolinking) + else() + target_link_libraries(${BOOST_LIBRARY} INTERFACE Boost::disable_autolinking) + endif() if(ARROW_BOOST_USE_SHARED) - target_link_libraries(${BOOST_LIBRARY} INTERFACE Boost::dynamic_linking) + if(CMAKE_VERSION VERSION_LESS 3.11) + set_target_properties(${BOOST_LIBRARY} PROPERTIES INTERFACE_LINK_LIBRARIES + Boost::dynamic_linking) + else() + target_link_libraries(${BOOST_LIBRARY} INTERFACE Boost::dynamic_linking) + endif() endif() endforeach() @@ -1443,7 +1489,12 @@ macro(build_thrift) set_target_properties(thrift::thrift PROPERTIES IMPORTED_LOCATION "${THRIFT_STATIC_LIB}" INTERFACE_INCLUDE_DIRECTORIES "${THRIFT_INCLUDE_DIR}") - target_link_libraries(thrift::thrift INTERFACE Boost::headers) + if(CMAKE_VERSION VERSION_LESS 3.11) + set_target_properties(${BOOST_LIBRARY} PROPERTIES INTERFACE_LINK_LIBRARIES + Boost::headers) + else() + target_link_libraries(thrift::thrift INTERFACE Boost::headers) + endif() add_dependencies(toolchain thrift_ep) add_dependencies(thrift::thrift thrift_ep) set(THRIFT_VERSION ${ARROW_THRIFT_BUILD_VERSION}) @@ -2158,7 +2209,12 @@ if(ARROW_WITH_RAPIDJSON) endif() add_library(rapidjson::rapidjson INTERFACE IMPORTED) - target_include_directories(rapidjson::rapidjson INTERFACE "${RAPIDJSON_INCLUDE_DIR}") + if(CMAKE_VERSION VERSION_LESS 3.11) + set_target_properties(rapidjson::rapidjson PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${RAPIDJSON_INCLUDE_DIR}") + else() + target_include_directories(rapidjson::rapidjson INTERFACE "${RAPIDJSON_INCLUDE_DIR}") + endif() endif() macro(build_xsimd) @@ -2189,7 +2245,12 @@ if((NOT ARROW_SIMD_LEVEL STREQUAL "NONE") OR (NOT ARROW_RUNTIME_SIMD_LEVEL STREQ resolve_dependency(xsimd) add_library(xsimd INTERFACE IMPORTED) - target_include_directories(xsimd INTERFACE "${XSIMD_INCLUDE_DIR}") + if(CMAKE_VERSION VERSION_LESS 3.11) + set_target_properties(xsimd PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${XSIMD_INCLUDE_DIR}") + else() + target_include_directories(xsimd INTERFACE "${XSIMD_INCLUDE_DIR}") + endif() endif() macro(build_zlib) @@ -3952,7 +4013,12 @@ endif() message(STATUS "Found hdfs.h at: ${HDFS_H_PATH}") add_library(arrow::hadoop INTERFACE IMPORTED) -target_include_directories(arrow::hadoop INTERFACE "${HADOOP_HOME}/include") +if(CMAKE_VERSION VERSION_LESS 3.11) + set_target_properties(arrow::hadoop PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${HADOOP_HOME}/include") +else() + target_include_directories(arrow::hadoop INTERFACE "${HADOOP_HOME}/include") +endif() # ---------------------------------------------------------------------- # Apache ORC diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index bd258bac0da..b653b35ac68 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -622,9 +622,11 @@ if(ARROW_TESTING) DEPENDENCIES arrow_test_dependencies SHARED_LINK_LIBS + arrow::flatbuffers arrow_shared GTest::gtest STATIC_LINK_LIBS + arrow::flatbuffers arrow_static GTest::gtest) From 6bee1880324848da931670ae614a709b6b78bc3c Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Tue, 19 Apr 2022 15:25:00 +0900 Subject: [PATCH 35/46] Fix a typo --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index e5474497b19..9f9f725fc45 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -269,8 +269,8 @@ if(CMAKE_VERSION VERSION_LESS 3.11) PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${THIRDPARTY_DIR}/flatbuffers/include") else() - target_include_directoriebs(arrow::flatbuffers INTERFACE - "${THIRDPARTY_DIR}/flatbuffers/include") + target_include_directories(arrow::flatbuffers INTERFACE + "${THIRDPARTY_DIR}/flatbuffers/include") endif() # ---------------------------------------------------------------------- From 52dbe2307605a6d1d0b0967122cd34aa1889f996 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Tue, 19 Apr 2022 15:54:09 +0900 Subject: [PATCH 36/46] Fix style --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 9f9f725fc45..06ba7eb0287 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -269,8 +269,8 @@ if(CMAKE_VERSION VERSION_LESS 3.11) PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${THIRDPARTY_DIR}/flatbuffers/include") else() - target_include_directories(arrow::flatbuffers INTERFACE - "${THIRDPARTY_DIR}/flatbuffers/include") + target_include_directories(arrow::flatbuffers + INTERFACE "${THIRDPARTY_DIR}/flatbuffers/include") endif() # ---------------------------------------------------------------------- From 63c6680126e1df69f62520fe7f012124bb95f99f Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 20 Apr 2022 09:14:16 +0900 Subject: [PATCH 37/46] Add missing RapidJSON dependency --- cpp/src/arrow/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index b653b35ac68..3b49f4ca00a 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -623,10 +623,12 @@ if(ARROW_TESTING) arrow_test_dependencies SHARED_LINK_LIBS arrow::flatbuffers + rapidjson::rapidjson arrow_shared GTest::gtest STATIC_LINK_LIBS arrow::flatbuffers + rapidjson::rapidjson arrow_static GTest::gtest) From b583fd79bad4f13b599a643064c6e0d0b5d894dd Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Sun, 24 Apr 2022 07:07:53 +0900 Subject: [PATCH 38/46] Add support for Ubuntu 18.04 --- cpp/cmake_modules/BuildUtils.cmake | 87 ++++----------------- cpp/cmake_modules/ThirdpartyToolchain.cmake | 45 ++++------- cpp/src/arrow/flight/CMakeLists.txt | 15 ++-- cpp/src/arrow/flight/sql/CMakeLists.txt | 4 +- cpp/src/arrow/python/CMakeLists.txt | 7 +- cpp/src/gandiva/CMakeLists.txt | 4 + 6 files changed, 54 insertions(+), 108 deletions(-) diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index 9affb96ae13..febe61694ac 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -30,9 +30,9 @@ set(ARROW_LIBRARY_PATH_SUFFIXES "Library/bin") set(ARROW_INCLUDE_PATH_SUFFIXES "include" "Library" "Library/include") -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}" @@ -43,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) - + 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() diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 06ba7eb0287..7f6af2e6149 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -840,37 +840,16 @@ macro(build_boost) set(BOOST_BUILD_PRODUCTS ${BOOST_STATIC_SYSTEM_LIBRARY} ${BOOST_STATIC_FILESYSTEM_LIBRARY}) - add_thirdparty_lib(boost_system - STATIC_LIB + add_thirdparty_lib(Boost::system + STATIC "${BOOST_STATIC_SYSTEM_LIBRARY}" INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIR}") - add_library(Boost::system INTERFACE IMPORTED) - if(CMAKE_VERSION VERSION_LESS 3.11) - set_target_properties(Boost::system - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES - "${Boost_INCLUDE_DIR}" INTERFACE_LINK_LIBRARIES - boost_system_static) - else() - target_include_directories(Boost::system INTERFACE "${Boost_INCLUDE_DIR}") - target_link_libraries(Boost::system INTERFACE boost_system_static) - endif() - - add_thirdparty_lib(boost_filesystem - STATIC_LIB + add_thirdparty_lib(Boost::filesystem + STATIC "${BOOST_STATIC_FILESYSTEM_LIBRARY}" INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIR}") - add_library(Boost::filesystem INTERFACE IMPORTED) - if(CMAKE_VERSION VERSION_LESS 3.11) - set_target_properties(Boost::filesystem - PROPERTIES INTERFACE_INCLUDE_DIRECTORIES - "${Boost_INCLUDE_DIR}" INTERFACE_LINK_LIBRARIES - boost_filesystem_static) - else() - target_include_directories(Boost::filesystem INTERFACE "${Boost_INCLUDE_DIR}") - target_link_libraries(Boost::filesystem INTERFACE boost_filesystem_static) - endif() externalproject_add(boost_ep URL ${BOOST_SOURCE_URL} @@ -880,8 +859,8 @@ macro(build_boost) CONFIGURE_COMMAND ${BOOST_CONFIGURE_COMMAND} BUILD_COMMAND ${BOOST_BUILD_COMMAND} INSTALL_COMMAND "" ${EP_LOG_OPTIONS}) - add_dependencies(boost_system_static boost_ep) - add_dependencies(boost_filesystem_static boost_ep) + add_dependencies(Boost::system boost_ep) + add_dependencies(Boost::filesystem boost_ep) else() externalproject_add(boost_ep ${EP_LOG_OPTIONS} @@ -1382,8 +1361,8 @@ macro(build_gflags) add_dependencies(toolchain gflags_ep) - add_thirdparty_lib(gflags STATIC_LIB ${GFLAGS_STATIC_LIB}) - set(GFLAGS_LIBRARY gflags_static) + add_thirdparty_lib(gflags::gflags_static STATIC ${GFLAGS_STATIC_LIB}) + set(GFLAGS_LIBRARY gflags::gflags_static) set_target_properties(${GFLAGS_LIBRARY} PROPERTIES INTERFACE_COMPILE_DEFINITIONS "GFLAGS_IS_A_DLL=0" INTERFACE_INCLUDE_DIRECTORIES "${GFLAGS_INCLUDE_DIR}") @@ -1395,7 +1374,7 @@ macro(build_gflags) set(GFLAGS_VENDORED TRUE) - list(APPEND ARROW_BUNDLED_STATIC_LIBS gflags_static) + list(APPEND ARROW_BUNDLED_STATIC_LIBS gflags::gflags_static) endmacro() if(ARROW_NEED_GFLAGS) @@ -1409,7 +1388,9 @@ if(ARROW_NEED_GFLAGS) FALSE) if(NOT TARGET ${GFLAGS_LIBRARIES}) - if(TARGET gflags-shared) + if(TARGET gflags::gflags_shared) + set(GFLAGS_LIBRARIES gflags::gflags_shared) + elseif(TARGET gflags-shared) set(GFLAGS_LIBRARIES gflags-shared) elseif(TARGET gflags_shared) set(GFLAGS_LIBRARIES gflags_shared) @@ -1600,6 +1581,8 @@ macro(build_protobuf) URL_HASH "SHA256=${ARROW_PROTOBUF_BUILD_SHA256_CHECKSUM}") file(MAKE_DIRECTORY "${PROTOBUF_INCLUDE_DIR}") + # For compatibility of CMake's FindProtobuf.cmake. + set(Protobuf_INCLUDE_DIRS "${PROTOBUF_INCLUDE_DIR}") add_library(arrow::protobuf::libprotobuf STATIC IMPORTED) set_target_properties(arrow::protobuf::libprotobuf diff --git a/cpp/src/arrow/flight/CMakeLists.txt b/cpp/src/arrow/flight/CMakeLists.txt index 684080841a2..c09159eb151 100644 --- a/cpp/src/arrow/flight/CMakeLists.txt +++ b/cpp/src/arrow/flight/CMakeLists.txt @@ -58,6 +58,13 @@ else() list(APPEND ARROW_FLIGHT_TEST_LINK_LIBS arrow_cuda_shared) endif() endif() +list(APPEND + ARROW_FLIGHT_TEST_INTERFACE_LIBS + Boost::headers + Boost::filesystem + Boost::system + GTest::gtest + GTest::gmock) # Needed for Flight SQL and integration set(ARROW_FLIGHT_TEST_LINK_LIBS @@ -250,16 +257,14 @@ if(ARROW_TESTING) arrow_shared arrow_flight_shared arrow_testing_shared - Boost::headers - Boost::filesystem - Boost::system - GTest::gtest ${ARROW_FLIGHT_TEST_INTERFACE_LIBS} STATIC_LINK_LIBS arrow_static arrow_flight_static arrow_testing_static - ${ARROW_FLIGHT_TEST_INTERFACE_LIBS}) + ${ARROW_FLIGHT_TEST_INTERFACE_LIBS} + PRIVATE_INCLUDES + "${Protobuf_INCLUDE_DIRS}") foreach(LIB_TARGET ${ARROW_FLIGHT_TESTING_LIBRARIES}) target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_EXPORTING) diff --git a/cpp/src/arrow/flight/sql/CMakeLists.txt b/cpp/src/arrow/flight/sql/CMakeLists.txt index 6efe6e76bfe..6a3c9222105 100644 --- a/cpp/src/arrow/flight/sql/CMakeLists.txt +++ b/cpp/src/arrow/flight/sql/CMakeLists.txt @@ -59,7 +59,9 @@ add_arrow_lib(arrow_flight_sql SHARED_LINK_LIBS arrow_flight_shared STATIC_LINK_LIBS - arrow_flight_static) + arrow_flight_static + PRIVATE_INCLUDES + "${Protobuf_INCLUDE_DIRS}") if(ARROW_FLIGHT_TEST_LINKAGE STREQUAL "static") set(ARROW_FLIGHT_SQL_TEST_LINK_LIBS arrow_flight_sql_static diff --git a/cpp/src/arrow/python/CMakeLists.txt b/cpp/src/arrow/python/CMakeLists.txt index 34dea64df5a..3f838b3e87d 100644 --- a/cpp/src/arrow/python/CMakeLists.txt +++ b/cpp/src/arrow/python/CMakeLists.txt @@ -98,8 +98,11 @@ add_arrow_lib(arrow_python ${ARROW_VERSION_SCRIPT_FLAGS} # Defined in cpp/arrow/CMakeLists.txt SHARED_LINK_LIBS ${ARROW_PYTHON_SHARED_LINK_LIBS} + SHARED_PRIVATE_LINK_LIBS + xsimd STATIC_LINK_LIBS ${PYTHON_OTHER_LIBS} + xsimd EXTRA_INCLUDES "${ARROW_PYTHON_INCLUDES}") @@ -138,7 +141,9 @@ if(ARROW_FLIGHT AND ARROW_BUILD_SHARED) STATIC_LINK_LIBS ${PYTHON_OTHER_LIBS} EXTRA_INCLUDES - "${ARROW_PYTHON_INCLUDES}") + "${ARROW_PYTHON_INCLUDES}" + PRIVATE_INCLUDES + "${Protobuf_INCLUDE_DIRS}") add_dependencies(arrow_python ${ARROW_PYFLIGHT_LIBRARIES}) diff --git a/cpp/src/gandiva/CMakeLists.txt b/cpp/src/gandiva/CMakeLists.txt index c80e65ad2ba..5a8c0483b5c 100644 --- a/cpp/src/gandiva/CMakeLists.txt +++ b/cpp/src/gandiva/CMakeLists.txt @@ -102,6 +102,10 @@ set(GANDIVA_SHARED_PRIVATE_LINK_LIBS arrow_shared LLVM::LLVM_INTERFACE ${GANDIVA_OPENSSL_LIBS} Boost::headers) set(GANDIVA_STATIC_LINK_LIBS arrow_static LLVM::LLVM_INTERFACE ${GANDIVA_OPENSSL_LIBS} Boost::headers) +if(ARROW_WITH_RE2) + list(APPEND GANDIVA_SHARED_PRIVATE_LINK_LIBS re2::re2) + list(APPEND GANDIVA_STATIC_LINK_LIBS re2::re2) +endif() if(ARROW_WITH_UTF8PROC) list(APPEND GANDIVA_SHARED_PRIVATE_LINK_LIBS utf8proc::utf8proc) list(APPEND GANDIVA_STATIC_LINK_LIBS utf8proc::utf8proc) From 9e878a0712b57c94ac849e8123f52a943313a050 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 9 May 2022 13:53:38 +0900 Subject: [PATCH 39/46] Add missing arrow::flatbuffers dependency --- cpp/src/arrow/gpu/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpp/src/arrow/gpu/CMakeLists.txt b/cpp/src/arrow/gpu/CMakeLists.txt index 635d256e6da..934a11f810c 100644 --- a/cpp/src/arrow/gpu/CMakeLists.txt +++ b/cpp/src/arrow/gpu/CMakeLists.txt @@ -29,6 +29,7 @@ if(DEFINED ENV{CUDA_HOME}) set(CUDA_TOOLKIT_ROOT_DIR "$ENV{CUDA_HOME}") endif() +set(ARROW_CUDA_LINK_LIBS arrow::flatbuffers) if(CMAKE_VERSION VERSION_LESS 3.17) find_package(CUDA REQUIRED) set(ARROW_CUDA_SHARED_LINK_LIBS ${CUDA_CUDA_LIBRARY}) @@ -56,9 +57,11 @@ add_arrow_lib(arrow_cuda ${ARROW_VERSION_SCRIPT_FLAGS} # Defined in cpp/arrow/CMakeLists.txt SHARED_LINK_LIBS arrow_shared + ${ARROW_CUDA_LINK_LIBS} ${ARROW_CUDA_SHARED_LINK_LIBS} # Static arrow_cuda must also link against CUDA shared libs STATIC_LINK_LIBS + ${ARROW_CUDA_LINK_LIBS} ${ARROW_CUDA_SHARED_LINK_LIBS}) add_dependencies(arrow_cuda ${ARROW_CUDA_LIBRARIES}) From d6284e33f6657c27b5feee7e876e348436d5d7c8 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 9 May 2022 14:07:40 +0900 Subject: [PATCH 40/46] Fix a typo --- cpp/cmake_modules/Findutf8proc.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/cmake_modules/Findutf8proc.cmake b/cpp/cmake_modules/Findutf8proc.cmake index 4d732f18694..867361cd104 100644 --- a/cpp/cmake_modules/Findutf8proc.cmake +++ b/cpp/cmake_modules/Findutf8proc.cmake @@ -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() From 6ed7965764b43a9ed0a3e2c7aa9c46b9074e431e Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Tue, 10 May 2022 17:51:18 +0900 Subject: [PATCH 41/46] Use if(VARIABLE) instead of if(TARGET) --- cpp/CMakeLists.txt | 4 ++-- cpp/cmake_modules/ThirdpartyToolchain.cmake | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index a846278a7ab..ec3f6b76cd2 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -696,7 +696,7 @@ set(ARROW_LINK_LIBS arrow::flatbuffers arrow::hadoop) set(ARROW_STATIC_LINK_LIBS arrow::flatbuffers arrow::hadoop) set(ARROW_STATIC_INSTALL_INTERFACE_LIBS) -if(TARGET Boost::headers) +if(ARROW_USE_BOOST) list(APPEND ARROW_LINK_LIBS Boost::headers) list(APPEND ARROW_STATIC_LINK_LIBS Boost::headers) endif() @@ -818,7 +818,7 @@ if(ARROW_WITH_RAPIDJSON) list(APPEND ARROW_STATIC_LINK_LIBS rapidjson::rapidjson) endif() -if(TARGET xsimd) +if(ARROW_USE_XSIMD) list(APPEND ARROW_LINK_LIBS xsimd) list(APPEND ARROW_STATIC_LINK_LIBS xsimd) endif() diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 7f6af2e6149..25e5872b08d 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -990,18 +990,18 @@ if(ARROW_BUILD_INTEGRATION OR ARROW_BUILD_TESTS OR (ARROW_FLIGHT AND ARROW_BUILD_BENCHMARKS) OR (ARROW_S3 AND ARROW_BUILD_BENCHMARKS)) - set(ARROW_BOOST_REQUIRED TRUE) + set(ARROW_USE_BOOST TRUE) set(ARROW_BOOST_REQUIRE_LIBRARY TRUE) elseif(ARROW_GANDIVA OR (ARROW_WITH_THRIFT AND THRIFT_REQUIRES_BOOST) OR (NOT ARROW_USE_NATIVE_INT128)) - set(ARROW_BOOST_REQUIRED TRUE) + set(ARROW_USE_BOOST TRUE) set(ARROW_BOOST_REQUIRE_LIBRARY FALSE) else() - set(ARROW_BOOST_REQUIRED FALSE) + set(ARROW_USE_BOOST FALSE) endif() -if(ARROW_BOOST_REQUIRED) +if(ARROW_USE_BOOST) if(ARROW_BOOST_USE_SHARED) # Find shared Boost libraries. set(Boost_USE_STATIC_LIBS OFF) @@ -2224,6 +2224,11 @@ endmacro() if((NOT ARROW_SIMD_LEVEL STREQUAL "NONE") OR (NOT ARROW_RUNTIME_SIMD_LEVEL STREQUAL "NONE" )) + set(ARROW_USE_XSIMD TRUE) +else() + set(ARROW_USE_XSIMD FALSE) +endif() +if(ARROW_USE_XSIMD) set(xsimd_SOURCE "BUNDLED") resolve_dependency(xsimd) From d590421f658a164c76f57aca873b58efee770e78 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Tue, 10 May 2022 17:54:02 +0900 Subject: [PATCH 42/46] Add a comment for object library and CMake < 3.12 --- cpp/cmake_modules/BuildUtils.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index febe61694ac..f3e3269d4fe 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -209,6 +209,9 @@ function(ADD_ARROW_LIB LIB_NAME) # 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) From 019c3f72dc810eec82f0cf2d93e989808ea4c610 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Tue, 10 May 2022 18:05:03 +0900 Subject: [PATCH 43/46] Add missing xsimd availability check --- cpp/src/arrow/python/CMakeLists.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cpp/src/arrow/python/CMakeLists.txt b/cpp/src/arrow/python/CMakeLists.txt index 3f838b3e87d..c37240a426c 100644 --- a/cpp/src/arrow/python/CMakeLists.txt +++ b/cpp/src/arrow/python/CMakeLists.txt @@ -71,13 +71,19 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL endif() set(ARROW_PYTHON_SHARED_LINK_LIBS arrow_shared) +set(ARROW_PYTHON_SHARED_PRIVATE_LINK_LIBS) +set(ARROW_PYTHON_STATIC_LINK_LIBS ${PYTHON_OTHER_LIBS}) + if(WIN32) list(APPEND ARROW_PYTHON_SHARED_LINK_LIBS ${PYTHON_LIBRARIES} ${PYTHON_OTHER_LIBS}) endif() - if(PARQUET_REQUIRE_ENCRYPTION) list(APPEND ARROW_PYTHON_SHARED_LINK_LIBS parquet_shared) endif() +if(ARROW_USE_XSIMD) + list(APPEND ARROW_PYTHON_SHARED_PRIVATE_LINK_LIBS xsimd) + list(APPEND ARROW_PYTHON_STATIC_LINK_LIBS xsimd) +endif() set(ARROW_PYTHON_INCLUDES ${NUMPY_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS}) @@ -99,10 +105,9 @@ add_arrow_lib(arrow_python SHARED_LINK_LIBS ${ARROW_PYTHON_SHARED_LINK_LIBS} SHARED_PRIVATE_LINK_LIBS - xsimd + ${ARROW_PYTHON_SHARED_PRIVATE_LINK_LIBS} STATIC_LINK_LIBS - ${PYTHON_OTHER_LIBS} - xsimd + ${ARROW_PYTHON_STATIC_LINK_LIBS} EXTRA_INCLUDES "${ARROW_PYTHON_INCLUDES}") From c6708e41312a79cb6cc4559ed7b22eb56baa4455 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Tue, 10 May 2022 18:05:52 +0900 Subject: [PATCH 44/46] Use if(VARIABLE) instead of if(TARGET) --- cpp/src/gandiva/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/gandiva/CMakeLists.txt b/cpp/src/gandiva/CMakeLists.txt index 5a8c0483b5c..2c8564b918e 100644 --- a/cpp/src/gandiva/CMakeLists.txt +++ b/cpp/src/gandiva/CMakeLists.txt @@ -110,7 +110,7 @@ if(ARROW_WITH_UTF8PROC) list(APPEND GANDIVA_SHARED_PRIVATE_LINK_LIBS utf8proc::utf8proc) list(APPEND GANDIVA_STATIC_LINK_LIBS utf8proc::utf8proc) endif() -if(TARGET xsimd) +if(ARROW_USE_XSIMD) list(APPEND GANDIVA_SHARED_PRIVATE_LINK_LIBS xsimd) list(APPEND GANDIVA_STATIC_LINK_LIBS xsimd) endif() From 8bbe58c2b3b6ce3738e46a8657fcbd8429754429 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 11 May 2022 05:19:30 +0900 Subject: [PATCH 45/46] Add a note for arrow::hadoop --- cpp/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index ec3f6b76cd2..23e0ba311f3 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -691,7 +691,11 @@ endif() # Linker and Dependencies # -# Libraries to link statically with libarrow.so +# 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) set(ARROW_STATIC_LINK_LIBS arrow::flatbuffers arrow::hadoop) set(ARROW_STATIC_INSTALL_INTERFACE_LIBS) From e643481c9014b8aaa08ff937ba79b35ff277c660 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 11 May 2022 05:19:39 +0900 Subject: [PATCH 46/46] Remove meaningless TODO comment --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 25e5872b08d..32669b2c072 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -1009,7 +1009,6 @@ if(ARROW_USE_BOOST) set(BUILD_SHARED_LIBS ON) else() # Find static boost headers and libs - # TODO Differentiate here between release and debug builds set(Boost_USE_STATIC_LIBS ON) endif() resolve_dependency(Boost