apache / apache/arrow

[C++] CMake Windows Install - Wrong Config File Locations

Open
#49,090 4 comments 0 reactions 0 assignees View on GitHub
Component: C++ Type: bug
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the bug, including details regarding any error messages, version, and platform.

The way CMake installs Arrow on Windows does not follow CMake's requirements for subsequently finding config files. The consequence of this is that the default find_package() calls from third parties will fail to find arrow libraries correctly.

The [CMake Docs](https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure) list the patterns by which find_package will discover files like `ArrowConfig.cmake` and `ArrowComputeConfig.cmake`. Some patterns are Windows-only, some are Unix-only. The cross-platform search paths are:

```
/*/(lib/\|lib*\|share)/cmake/*/
/*/(lib/\|lib*\|share)/*/
/*/(lib/\|lib*\|share)/*/(cmake\|CMake)/
```

When the CMAKE_INSTALL_PREFIX is not overriden, Arrow installs configs for the main library and compute to:

```
C:/Program Files/arrow/lib/cmake/Arrow/ArrowConfig.cmake
C:/Program Files/arrow/lib/cmake/ArrowCompute/ArrowComputeConfig.cmake
```

Ignoring case, this allows `find_package(Arrow)` to work because that matches the `/*/(lib/\|lib*\|share)/cmake/*/ ` convention; however, `find_package(ArrowCompute)` fails.

If you specify a INSTALL_PREFIX like C:\arrow-dist, you end up with:

```
C:/arrow-dist/lib/cmake/Arrow/ArrowConfig.cmake
C:/arrow-dist/lib/cmake/ArrowCompute/ArrowComputeConfig.cmake
```

In this case, neither config file can be found by `find_package`, assumedly because CMake expects the name to appear after the ``

This was discovered in my fork of Arrow with the help of @raulcd

### Component(s)

C++

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.