Skip to content

Add FetchContent compatibility #759

Closed
@hopeless-programmer-online

Description

I prefer to use FetchContent for dependency management.
With this:

FetchContent_Declare(
    zlib
    GIT_REPOSITORY "https://github.com/madler/zlib.git"
    FIND_PACKAGE_ARGS NAMES ZLIB
)
FetchContent_MakeAvailable(zlib)

the whole process of cloning the repo, generating and building it as a dependency might be automated by cmake.

The problem is that the example executable relies on the assumption that the whole project with the headers is the top-level cmake project.
And of course this is not true in case of FetchContent which will download zlib as a subdirectory.

There are several different approaches on how to fix this.
But the simplest one I can see is to add an option to disable tests and examples, like ZLIB_BUILD_TESTS.

I can provide an example project that uses zlib as 3rdparty via FetchContent to reproduce the issue if needed.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions