summaryrefslogtreecommitdiffstats
path: root/Modules/FindZLIB.cmake
diff options
context:
space:
mode:
authorStefan Hacker <mail@hacst.net>2018-02-15 19:48:50 (GMT)
committerStefan Hacker <mail@hacst.net>2018-02-15 20:38:48 (GMT)
commitc01eede89474ffb1e52595138b18b080e655a46c (patch)
treea73c59329ff91068d2d2e236a8b5cfec5774b795 /Modules/FindZLIB.cmake
parenta2ec98b7d97df67d50e90e790b2bd235f7c278cc (diff)
downloadCMake-c01eede89474ffb1e52595138b18b080e655a46c.zip
CMake-c01eede89474ffb1e52595138b18b080e655a46c.tar.gz
CMake-c01eede89474ffb1e52595138b18b080e655a46c.tar.bz2
FindZLIB: Search names per directory
FindZLIB accepts various names for zlib (e.g. "z", "zlib", ...) in various search locations. Before this patch zlib ignored the priority implied by the search locations and instead prioritized based on the library name. Consequently ensuring the pick of a zlib from e.g. a CMAKE_PREFIX_PATH was not possible if it didn't have the highest priority name ("z"). This unexpected behavior led to bugs in third party projects (e.g. https://github.com/Microsoft/vcpkg/issues/1939). A common way to encounter the issue in the wild is on Windows with the popular Anaconda python distribution which puts a "z.lib" in a lib/ subdirectory reachable from a bin/ path in PATH. From then on cmake will always pick up this library instead of the one intended by the user. This patch adds the NAMES_PER_DIR option to the find_library calls made by FindZLIB making it search each directory for all names before considering lower priority directory names resolving these issues.
Diffstat (limited to 'Modules/FindZLIB.cmake')
-rw-r--r--Modules/FindZLIB.cmake4
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake
index 4065999..a5c04ac 100644
--- a/Modules/FindZLIB.cmake
+++ b/Modules/FindZLIB.cmake
@@ -75,8 +75,8 @@ endforeach()
# Allow ZLIB_LIBRARY to be set manually, as the location of the zlib library
if(NOT ZLIB_LIBRARY)
foreach(search ${_ZLIB_SEARCHES})
- find_library(ZLIB_LIBRARY_RELEASE NAMES ${ZLIB_NAMES} ${${search}} PATH_SUFFIXES lib)
- find_library(ZLIB_LIBRARY_DEBUG NAMES ${ZLIB_NAMES_DEBUG} ${${search}} PATH_SUFFIXES lib)
+ find_library(ZLIB_LIBRARY_RELEASE NAMES ${ZLIB_NAMES} NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib)
+ find_library(ZLIB_LIBRARY_DEBUG NAMES ${ZLIB_NAMES_DEBUG} NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib)
endforeach()
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)