Skip to content

Conversation

@otegami
Copy link

@otegami otegami commented Dec 9, 2025

Summary

Fixes #105

Add a new CMake option OPENZL_USE_SYSTEM_ZSTD that
allows using system-installed zstd library via
find_package(zstd CONFIG) instead of the bundled
version. This is useful for Linux distributions that
package zstd separately.

When enabled:

  • Uses find_package(zstd CONFIG REQUIRED) to find system zstd
  • Creates a libzstd alias target for compatibility with existing code
  • Exported config includes find_dependency(zstd) for downstream projects

When disabled (default):

  • Behavior unchanged (uses git submodule or FetchContent)

Type of Change

New feature (non-breaking change which adds functionality)

Test Plan

Build with system zstd

cmake \
	-S .\
	-B ../openzl.build \
	-DOPENZL_USE_SYSTEM_ZSTD=ON \
	-DOPENZL_BUILD_TESTS=ON \
	-DCMAKE_INSTALL_PREFIX=/tmp/local &&\
cmake --build ../openzl.build -j4 &&\
ctest --test-dir ../openzl.build --output-on-failure

Verify installation does not include zstd files

cmake --install ../openzl.build
ls /tmp/local/lib/ | grep libzstd # should be empty

Build with bundled zstd (default)

cmake \
	-S . \
	-B ../openzl.build \
	-DOPENZL_BUILD_TESTS=ON \
	-DCMAKE_INSTALL_PREFIX=/tmp/local &&\
cmake --build openzl.build -j4 &&\
ctest --test-dir ../openzl.build --output-on-failure

Verify installation includes zstd files

cmake --install ../openzl.build
ls /tmp/local/lib/ | grep libzstd
libzstd.a
libzstd.so
libzstd.so.1
libzstd.so.1.5.7

Test Configuration

  • Compiler: GCC 13.3.0
  • Build type: default
  • Platform: Linux (Ubuntu)

@meta-cla meta-cla bot added the cla signed label Dec 9, 2025
@otegami otegami marked this pull request as draft December 9, 2025 08:21
## Summary

GitHub: GH-facebook#105

Add a new CMake option `OPENZL_USE_SYSTEM_ZSTD` that
allows using system-installed zstd library via
`find_package(zstd CONFIG)` instead of the bundled
version. This is useful for Linux distributions that
package zstd separately.

When enabled:
- Uses `find_package(zstd CONFIG REQUIRED)` to find
  system zstd
- Creates a `libzstd` alias target for compatibility
  with existing code
- Exported config includes `find_dependency(zstd)` for
  downstream projects

When disabled (default):
- Behavior unchanged (uses git submodule or FetchContent)

## Type of Change

New feature (non-breaking change which adds functionality)

## Test Plan

### Build with system zstd

```console
cmake \
  -S .\
  -B ../openzl.build \
  -DOPENZL_USE_SYSTEM_ZSTD=ON \
  -DOPENZL_BUILD_TESTS=ON \
  -DCMAKE_INSTALL_PREFIX=/tmp/local &&\
cmake --build ../openzl.build -j4 &&\
ctest --test-dir ../openzl.build --output-on-failure
```

### Verify installation does not include zstd files

```console
cmake --install ../openzl.build
ls /tmp/local/lib/ | grep libzstd # should be empty
```

### Build with bundled zstd (default)

```console
cmake \
  -S . \
  -B ../openzl.build \
  -DOPENZL_BUILD_TESTS=ON \
  -DCMAKE_INSTALL_PREFIX=/tmp/local &&\
cmake --build openzl.build -j4 &&\
ctest --test-dir ../openzl.build --output-on-failure
```

### Verify installation includes zstd files

```console
cmake --install ../openzl.build
ls /tmp/local/lib/ | grep libzstd
libzstd.a
libzstd.so
libzstd.so.1
libzstd.so.1.5.7
```

### Test Configuration
- Compiler: GCC 13.3.0
- Build type: default
- Platform: Linux (Ubuntu)
@otegami otegami marked this pull request as ready for review December 9, 2025 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

allow system libzstd

1 participant