diff --git a/CMakeLists.txt b/CMakeLists.txt index c46928da..8c056d6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,10 @@ FetchContent_MakeAvailable(ZLIB) if(NOT DEFINED ZLIB_INCLUDE_DIRS) set(ZLIB_INCLUDE_DIRS "${zlib_BINARY_DIR};${zlib_SOURCE_DIR}") # libpng's `genout` script relies on this variable to be set. endif() +# Statically building zlib (from source) generates a target named differently. +if(NOT TARGET ZLIB::ZLIB AND TARGET zlibstatic) + add_library(ZLIB::ZLIB ALIAS zlibstatic) +endif() if(NOT DEFINED PNG_TESTS) # Unless overridden (e.g. in the cache), we don't care about libpng's tests. set(PNG_TESTS OFF) diff --git a/cmake/deps.cmake b/cmake/deps.cmake index 727eb68c..82e5a591 100644 --- a/cmake/deps.cmake +++ b/cmake/deps.cmake @@ -8,10 +8,10 @@ FetchContent_Declare(PNG EXCLUDE_FROM_ALL # We only install the runtime dependencies, and do so separately. FIND_PACKAGE_ARGS 1.5.4) -set(PNG_TESTS OFF CACHE INTERNAL "") # We do not care for these two (and they can even cause compile errors!) -set(PNG_TOOLS OFF CACHE INTERNAL "") -set(PNG_SHARED ON CACHE INTERNAL "") # Upstream seems to favour the dynamic lib over the static one? -set(PNG_STATIC OFF CACHE INTERNAL "") +set(PNG_TESTS OFF CACHE INTERNAL "") # We do not need libpng's tests or tools +set(PNG_TOOLS OFF CACHE INTERNAL "") # (and they can even cause compile errors!) +set(PNG_SHARED OFF CACHE INTERNAL "") +set(PNG_STATIC ON CACHE INTERNAL "") FetchContent_Declare(ZLIB URL https://www.zlib.net/zlib-1.3.2.tar.xz @@ -21,5 +21,5 @@ FetchContent_Declare(ZLIB # We thus enforce 1.0.4, but note that the libpng source code mentions that "it may work with versions as old as zlib 0.95". FIND_PACKAGE_ARGS 1.0.4) -set(ZLIB_BUILD_SHARED ON CACHE INTERNAL "") -set(ZLIB_BUILD_STATIC OFF CACHE INTERNAL "") +set(ZLIB_BUILD_SHARED OFF CACHE INTERNAL "") +set(ZLIB_BUILD_STATIC ON CACHE INTERNAL "")