Skip to content

Commit

Permalink
ARROW-4930: [C++] Improve find_package() support
Browse files Browse the repository at this point in the history
Backward incompatibilities:

  * find_package(Arrow) doesn't find Arrow Python.
    Users need to use find_package(ArrowPython).

  * find_package(ArrowCuda) doesn't work on not Windows (case
    sensitive environments). Use find_package(ArrowCUDA) instead.

Summary:

  * Create arrow_find_package() in FindArrow.cmake and use it in
    Find*.cmake.

  * arrow_find_package() is a function that finds an Arrow related
    package. It supports ARROW_HOME/PARQUET_HOME environment variable,
    CMake package configuration and pkg-config.

  * arrow_find_package() can find libraries installed under
    lib/x86_64-linux-gnu/ (on Debian), lib64/ (on CentOS), lib/,
    bin/ (on Windows).

    * We can remove workaround for ARROW-1090 in python/setup.py:
      https://issues.apache.org/jira/projects/ARROW/issues/ARROW-1090

  * Create Find*.cmake per component. It means that FindArrow.cmake
    doesn't find Arrow Python. Use find_package(ArrowPython) instead
    of find_package(Arrow).

    * Install Find*.cmake to be reusable.

    * Changes for Linux packages are for this.

  * Rename arrowConfig.cmake, arrowTarget.cmake and so on to
    ArrowConfig.cmake, ArrowTarget.cmake and so on to use the same
    package for FindArrow.cmake. arrow-config.cmake is added for
    backward compatibility. So users can use find_package(arrow)
    instead of find_package(Arrow).

  * ArrowConfig.cmake provides more useful variables such as
    ARROW_SO_VERSION and ARROW_FULL_SO_VERSION.

  * Rename FindArrowCuda.cmake to FindArrowCUDA.cmake because "CUDA"
    is the official name.

  * Use find_package_handle_standard_args() in Find*.cmake. It means
    that we can check required version by find_package(Arrow 0.15.0).

    * Changes for Parquet are for detecting Parquet version.

  * Use consistent variable names in Find*.cmake with keeping backward
    compatibility:

    * ${PACKAGE}_LIBS -> ${PACKAGE}_LIB_DIR: Because we use
      ${ARROW_INCLUDE_DIR} and CMake uses _DIR, _DIRECTORY, _PATH and
      so on.

    * ${PACKAGE}_SHARED_IMP_LIB -> ${PACKAGE}_IMPORT_LIB: Because
      CMake doesn't use SHARED for import library such as CMAKE_IMPORT_LIBRARY_SUFFIX.

  * Find*.cmake provides CMake targets such as arrow_shared and
    arrow_static even if it uses ARROW_HOME or pkg-config. Users can
    use them to link to Arrow.

  * Remove needless ABI_VERSION handling in python/CMakeLists.txt
    because ABI_VERSION just exists just for backward compatibility.
    We should use only SO_VERSION.

  * Rename "executable" to "plasma_store_server" in
    plasma.pc. "executable" is deprecated.

  * Add arrow-python-flight.pc.

Resolved issues:

  * ARROW-5021 [C++] Review hardcoded "lib" paths in
    Find$PACKAGE.cmake related to endogenous libraries
    https://issues.apache.org/jira/browse/ARROW-5021

Removed workarounds:

  * ARROW-1090 [Python] build_ext usability
    https://issues.apache.org/jira/projects/ARROW/issues/ARROW-1090

  * ARROW-5025 [Python][Packaging] wheel for Windows are broken
    https://issues.apache.org/jira/browse/ARROW-5025

  * ARROW-5026 [Python][Packaging] conda package on non Windows is broken
    https://issues.apache.org/jira/browse/ARROW-5026

Closes apache#5767 from kou/cpp-fix-discovery and squashes the following commits:

175fa0f <Sutou Kouhei> Add comments for shared library paths manipulation in pkg-config mode
62fef66 <Sutou Kouhei> Add comments to internal functions and macros
81b9daa <Sutou Kouhei> SHARED_IMPLIB -> IMPORT_LIB
00fe010 <Sutou Kouhei> Don't reset defined ARROW_MSVC_STATIC_LIB_SUFFIX
a2adff0 <Sutou Kouhei> Fix a typo
67665eb <Sutou Kouhei> Add a comment why we can't load targets multiple times
070c5d5 <Sutou Kouhei> Always load options
aea7801 <Sutou Kouhei> Update variable name
5c4634f <Sutou Kouhei> Use absolute path instead of library name
d7a94dd <Sutou Kouhei> Add missing _path
4da45f7 <Sutou Kouhei> Format
0f352f1 <Sutou Kouhei> Fix a typo
ef152c4 <Sutou Kouhei> Add missing libarrow-python-flight
20b98d9 <Sutou Kouhei> Add missing arrow-python-flight.pc
53d1508 <Sutou Kouhei> Install Find*.cmake only for enabled modules
1b41a1f <Sutou Kouhei> ARROW-4930:  Improve find_package() support

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
  • Loading branch information
kou authored and pitrou committed Nov 5, 2019
1 parent e0e8e53 commit a44b372
Show file tree
Hide file tree
Showing 53 changed files with 1,322 additions and 833 deletions.
3 changes: 2 additions & 1 deletion .dir-locals.el
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@

((sh-mode . ((indent-tabs-mode . nil)
(sh-indentation . 2)
(sh-basic-offset . 2))))
(sh-basic-offset . 2)))
(cmake-mode . ((indent-tabs-mode . nil))))
2 changes: 1 addition & 1 deletion c_glib/test/helper/plasma-store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
module Helper
class PlasmaStore
def initialize(options={})
@path = `pkg-config --variable=executable plasma`.chomp
@path = `pkg-config --variable=plasma_store_server plasma`.chomp
@memory_size = options[:memory_size] || 1024 * 1024
@socket_file = Tempfile.new(["plasma-store", ".sock"])
@socket_file.close
Expand Down
42 changes: 42 additions & 0 deletions cpp/ArrowConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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:https://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.
#
# This module sets the following variables in your project::
#
# Arrow_FOUND - true if arrow found on the system

@PACKAGE_INIT@

set(ARROW_VERSION "@ARROW_VERSION@")
set(ARROW_SO_VERSION "@ARROW_SO_VERSION@")
set(ARROW_FULL_SO_VERSION "@ARROW_FULL_SO_VERSION@")

# ARROW-5575: Move this to ParquetConfig.cmake when we split target files
set(PARQUET_VERSION "@PARQUET_VERSION@")
set(PARQUET_SO_VERSION "@ARROW_SO_VERSION@")
set(PARQUET_FULL_SO_VERSION "@ARROW_FULL_SO_VERSION@")

# ARROW-5575: Move this to PlasmaConfig.cmake when we split target files
set(PLASMA_STORE_SERVER "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/plasma-store-server@CMAKE_EXECUTABLE_SUFFIX@")

include("${CMAKE_CURRENT_LIST_DIR}/ArrowOptions.cmake")

# Load targets only once. If we load targets multiple times, CMake reports
# already existent target error.
if(NOT (TARGET arrow_shared OR TARGET arrow_static))
include("${CMAKE_CURRENT_LIST_DIR}/ArrowTargets.cmake")
endif()
35 changes: 18 additions & 17 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ endif()

set(BUILD_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/build-support")

set(ARROW_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")

set(ARROW_LLVM_VERSION "7.0")
# TODO: Remove this when we drop LLVM 7 support.
set(ARROW_LLVM_VERSION_FALLBACK "7.1")
Expand Down Expand Up @@ -823,25 +825,24 @@ include(CMakePackageConfigHelpers)

# Makes the project importable from the build directory
export(EXPORT ${PROJECT_NAME}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")

configure_package_config_file(${PROJECT_NAME}Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${${PROJECT_NAME}_VERSION}
COMPATIBILITY AnyNewerVersion)
config_summary_cmake_setters("${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Options.cmake")
FILE "${CMAKE_CURRENT_BINARY_DIR}/ArrowTargets.cmake")

configure_package_config_file(ArrowConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/ArrowConfig.cmake"
INSTALL_DESTINATION "${ARROW_CMAKE_INSTALL_DIR}")
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/ArrowConfigVersion.cmake
VERSION ${${PROJECT_NAME}_VERSION}
COMPATIBILITY AnyNewerVersion)
config_summary_cmake_setters("${CMAKE_CURRENT_BINARY_DIR}/ArrowOptions.cmake")

install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}Targets.cmake
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Options.cmake
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
FILE ArrowTargets.cmake
DESTINATION "${ARROW_CMAKE_INSTALL_DIR}")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ArrowConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/ArrowConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/ArrowOptions.cmake
${CMAKE_CURRENT_SOURCE_DIR}/arrow-config.cmake
DESTINATION "${ARROW_CMAKE_INSTALL_DIR}")

config_summary_message()
if(${ARROW_BUILD_CONFIG_SUMMARY_JSON})
Expand Down
26 changes: 26 additions & 0 deletions cpp/arrow-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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:https://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.

message(WARNING "find_package(arrow) is deprecated. Use find_package(Arrow) instead.")
find_package(Arrow CONFIG)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(arrow
REQUIRED_VARS
ARROW_INCLUDE_DIR
VERSION_VAR
ARROW_VERSION)
5 changes: 5 additions & 0 deletions cpp/cmake_modules/BuildUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -740,3 +740,8 @@ function(ARROW_ADD_PKG_CONFIG MODULE)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${MODULE}.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/")
endfunction()

function(ARROW_INSTALL_CMAKE_FIND_MODULE MODULE)
install(FILES "${ARROW_SOURCE_DIR}/cmake_modules/Find${MODULE}.cmake"
DESTINATION "${ARROW_CMAKE_INSTALL_DIR}")
endfunction()
Loading

0 comments on commit a44b372

Please sign in to comment.