-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Affected versions: 1.3.2
When configuring with either shared or static libs turned off, ZLIBConfig.cmake.in will still be configured unconditionally with set(_ZLIB_supported_components "shared" "static"). When looking for the lib using find_package, the default path will then unconditionally try to include() each config in the list, whether it has actually been built or not. That leads to config errors that can't be resolved without patching either the *.in or the configured result. Even when forcing ZLIB_FIND_COMPONENTS, other libraries like ZIP or PNG might look for the ZLIB without providing a component via find_package(ZLIB COMPONENTS ...), so without a working default path, configuration will also fail.
The *.in file should also contain something like set(_ZLIB_supported_components @COMPONENTS@), where @COMPONENTS@ should be filled depending on the values of ZLIB_BUILD_STATIC and ZLIB_BUILD_SHARED.
The most extreme case at the moment is when both are set to false. That will result in no binaries being built and thus, the config file will never be correct. Different issue, but unless a purely header and meta data export is an intended option, we should be forced to build at least one library type (i.e. (BUILD_STATIC || BUILD_SHARED) == true).