Skip to content

BLD: Respect existing zstd target - #93

Open
NuLL3rr0r wants to merge 1 commit into
databento:mainfrom
NuLL3rr0r:zstd-fix
Open

BLD: Respect existing zstd target#93
NuLL3rr0r wants to merge 1 commit into
databento:mainfrom
NuLL3rr0r:zstd-fix

Conversation

@NuLL3rr0r

Copy link
Copy Markdown

Pull request

Summary

Respect an existing zstd::libzstd target provided by the consuming project instead of unconditionally calling find_package(zstd REQUIRED).

Databento currently searches for zstd before checking whether the expected target already exists. This can cause a conflict when a consuming project provides its own zstd target while a separate system installation is also discoverable. In this case, the system zstd package may attempt to define zstd::libzstd again.

This was encountered on FreeBSD with zstd installed under /usr/local, resulting in:

Some (but not all) targets in this export set were already defined.

Targets Defined: zstd::libzstd

Targets not yet defined: zstd::libzstd_shared, zstd::libzstd_static

The change only calls find_package(zstd REQUIRED) when zstd::libzstd does not already exist. This follows the same pattern already used for other dependencies such as nlohmann_json, httplib, and date.

Consumers that do not provide zstd::libzstd are unaffected and continue to use the existing zstd package discovery.

No new dependencies are required.

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How has this change been tested?

Tested as a dependency of a consuming CMake project that builds zstd with add_subdirectory() and provides zstd::libzstd before adding Databento.

Test configuration:

  • FreeBSD, Linux, and Windows
  • On FreeBSD, zstd also installed system-wide under /usr/local
  • consuming project provides its own zstd::libzstd target

Before this change, configuration fails on FreeBSD because the system zstd package attempts to redefine an existing target.

Checklist

  • My code builds locally with no new warnings (scripts/build.sh)
  • My code follows the [style guidelines](https://google.github.io/styleguide/cppguide.html)
  • New and existing unit tests pass locally with my changes (scripts/test.sh)
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Declaration

I confirm this contribution is made under an Apache 2.0 license and that I have the authority
necessary to make this contribution on behalf of its copyright owner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant