Skip to content

Commit 000e689

Browse files
committed
CMake: don't try to use bundled zlib when the system's path is in the cache
The code surrounding zlib bundling did not take into consideration that ZLIB_LIBRARY gets cached, and assumed that FIND(ZLIB) would always set ZLIB_FOUND, which does not hold true, as this variable signifies that we have found the package and had to look at the system, as its location was not cached. Only use the bundled sources if the external zlib is neither newly-found nor cached.
1 parent 6222103 commit 000e689

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ ENDIF()
131131
IF (ZLIB_FOUND)
132132
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
133133
LINK_LIBRARIES(${ZLIB_LIBRARIES})
134-
ELSE()
134+
# Fake the message CMake would have shown
135+
MESSAGE("-- Found zlib: ${ZLIB_LIBRARY}")
136+
ELSEIF (NOT ZLIB_LIBRARY)
135137
MESSAGE( "zlib was not found; using bundled 3rd-party sources." )
136138
INCLUDE_DIRECTORIES(deps/zlib)
137139
ADD_DEFINITIONS(-DNO_VIZ -DSTDC -DNO_GZIP)

0 commit comments

Comments
 (0)