Skip to content

Commit

Permalink
CMakeLists.txt work around zlib/CMakeLists.txt bug
Browse files Browse the repository at this point in the history
Move the include_directories() call with the source and binary
directories of ext/zlib after add_subdirectory(ext/zlib) to work around
a zlib/CMakeLists.txt bug fixed by
madler/zlib#818.

The parent project's include directories at the time of an
add_subdirectory() call are used by the child project, so the order of
include_directories() and add_subdirectory() is important.
  • Loading branch information
wantehchang committed May 25, 2023
1 parent 0008c77 commit 130113b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ endif()
# Any proper unix environment should ignore these entire following blocks.
option(AVIF_LOCAL_ZLIBPNG "Build zlib and libpng by providing your own copy inside the ext subdir." OFF)
if(AVIF_LOCAL_ZLIBPNG)
add_subdirectory(ext/zlib)
# Put the value of ZLIB_INCLUDE_DIR in the cache. This works around cmake behavior that has been updated by
# cmake policy CMP0102 in cmake 3.17. Remove the CACHE workaround when we require cmake 3.17 or later. See
# https://gitlab.kitware.com/cmake/cmake/-/issues/21343.
set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/zlib" CACHE PATH "zlib include dir")
# This include_directories() call must be before add_subdirectory(ext/zlib) to work around the
# zlib/CMakeLists.txt bug fixed by https://github.com/madler/zlib/pull/818.
include_directories(${ZLIB_INCLUDE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/ext/zlib")
add_subdirectory(ext/zlib)
set(CMAKE_DEBUG_POSTFIX "")

# This is the only way I could avoid libpng going crazy if it found awk.exe, seems benign otherwise
Expand Down

0 comments on commit 130113b

Please sign in to comment.