facebook / facebook/rocksdb

Resulting CMake Config is not relocatable

Open
#4,892 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
32.1k
Forks
6.9k
Avg merge
32m
Merged PRs (30d)
1

Description

### Expected behavior

The generated [CMake Config](https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#config-file-packages) under `/usr/lib/cmake/rocksdb` is relocatable and does not contain any fixed paths to the build location.

### Actual behavior

The generated [CMake Config](https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html?highlight=config#config-file-packages) under `/usr/lib/cmake/rocksdb` is **not** relocatable and does contain fixed paths to the build location.

### Steps to reproduce the behavior

Build rocksdb using CMake and inspect the resulting files in `/usr/lib/cmake/rocksdb`. It contains somthing like the following:

```
set_target_properties(RocksDB::rocksdb PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
INTERFACE_LINK_LIBRARIES "/builds/recipe-sysroot/usr/lib/libz.so;/builds/recipe-sysroot/usr/lib/libbz2.so;/builds/recipe-sysroot/usr/lib/liblz4.so;-lpthread"
)
```
With absolute paths to the build directory `/builds`.

### Analysis

This is a well known issue with CMake and it is even [documented in the CMake Manual](https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-relocatable-packages).

In a nutshell the issue is that the CMake concepts used RocksDB are old and from the 2.8 era. Modern CMake recomends to use [Imported Targets](https://cmake.org/cmake/help/latest/command/add_library.html#imported-libraries) which does not suffer from the same issue. But it requires a higher minumum CMake version (3.7+) to work properly.

### Proposed Solution

- Increase the minumum required CMake version to 3.7
- Rework the finding of external libraries to make use of imported targets

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.