Sorry for repost - CPMAddPackage with ZLIB

Hello all,

I apologize for the repost, however I think this question is better placed in this sub-forum.

I am fairly new to CMake but am interested in using the CMake Package Management (CPM) to add a local library/source files. My question is probably simple, so please forgive.

I would like to know how to download and install shared library for zlib via a call(s) to CPMAddPackagecall, then link against this downloaded package for some local C++ code. Can anyone point me to an example of this or provide some simple code that illustrates this?

Bonus question, if this is okay, I would was thinking of using Boost.Iostreams for compression/decompression via CPMAddPackage call later on, but have read that there can be issues with ZLIB and Boost.Iostreams in Windows environment. I need my code to run on both Windows andLinux environments. Does anyone have any information on this situation?

Thanks to any help.

I think I might have solved the issue. I am posting it here for anyone else who may run into the same problem.

In a Cmake script called third_party.cmake in cmake/ directory.

# CPM script

# Storage location

# Add ZLIB
set(ZLIB_REPO ""
     CACHE STRING "ZLIB repository location."
    NAME zlib 
    GIT_TAG "v1.2.13"
                               PUBLIC $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
                               PUBLIC $<INSTALL_INTERFACE:include>)
                               PUBLIC $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
                               PUBLIC $<INSTALL_INTERFACE:include>)
    message(STATUS "Cmake added local zlib: ${zlib_SOURCE_DIR}")
    message(FATAL_ERROR "Cmake failed to add local zlib")