zlib icon indicating copy to clipboard operation
zlib copied to clipboard

cmake config files

Open imrichardcole opened this issue 1 year ago • 4 comments

A lot of modern libraries now ship their own cmake config files, this reduces finding the package to pretty much just:

set(foo_DIR "path/to/foo/lib/cmake/foo")
find_package(foo
    CONFIG
    REQUIRED
)

Has this ever been considered for zlib? Happy to raise a PR if so.

imrichardcole avatar Sep 11 '24 09:09 imrichardcole

There is a CMakeLists.txt file in zlib. What are you proposing?

madler avatar Sep 18 '24 06:09 madler

The CMakeLists.txt included with zlib is for building zlib. I'm hoping @imrichardcole is suggesting a CMake module file that is distributed with the (pre-)built zlib library that makes it easier for downstream builds to locate the zlib header and lib files. Downstream builds would use CMake's find_package function to locate zlib by name only and avoid having to hardcode paths and use fixed locations. We create our own zlib CMake module file when we build zlib in our CI system, so I for one would welcome such a contribution from imricharcole.

Mr-Clam avatar Sep 18 '24 08:09 Mr-Clam

Yes, exactly as @Mr-Clam says. This is for the scenario where you want to use a pre-built zlib, rather than include the CMakeLists.txt and build as though it's part of your own source tree. It removes a need for custom FindZlib.cmake files (which was what alerted me to the issue in the first place)

I pretty much have a PR ready to go, it might be easier to understand when you see it.

imrichardcole avatar Sep 18 '24 08:09 imrichardcole

@imrichardcole there's an open PR that addresses this: https://github.com/madler/zlib/pull/1004 👍

witte avatar Sep 29 '24 03:09 witte

See https://github.com/madler/zlib/pull/1027 .

madler avatar Feb 02 '25 21:02 madler