Skip to content

Commit

Permalink
libmatroska2: use the system zlib if available
Browse files Browse the repository at this point in the history
It should always be there on Linux/macOS.
  • Loading branch information
robUx4 committed Dec 25, 2024
1 parent 1534aa9 commit 178f6c6
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions libmatroska2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,23 @@ option(CONFIG_LZO1X "Enable lzo (de)compression in libmatroska2" ON)
option(CONFIG_NOCODEC_HELPER "Enable Vorbis frame durations in libmatroska2" ON)

if (CONFIG_ZLIB)
include(FetchContent)
include(FindZLIB)

set(ZLIB_BUILD_EXAMPLES OFF)
if(NOT ZLIB_FOUND)
include(FetchContent)

FetchContent_Declare(
zlib
URL "https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.gz"
URL_HASH SHA512=580677aad97093829090d4b605ac81c50327e74a6c2de0b85dd2e8525553f3ddde17556ea46f8f007f89e435493c9a20bc997d1ef1c1c2c23274528e3c46b94f
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
set(ZLIB_BUILD_EXAMPLES OFF)

FetchContent_MakeAvailable(zlib)
target_compile_definitions("zlib" PRIVATE NO_GZIP)
FetchContent_Declare(
zlib
URL "https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.gz"
URL_HASH SHA512=580677aad97093829090d4b605ac81c50327e74a6c2de0b85dd2e8525553f3ddde17556ea46f8f007f89e435493c9a20bc997d1ef1c1c2c23274528e3c46b94f
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)

FetchContent_MakeAvailable(zlib)
target_compile_definitions("zlib" PRIVATE NO_GZIP)
endif()
endif()

set(matroska2_SOURCES
Expand Down Expand Up @@ -47,7 +51,11 @@ target_include_directories("matroska2"
target_include_directories("matroska2" PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)

if (CONFIG_ZLIB)
target_link_libraries("matroska2" PRIVATE $<BUILD_INTERFACE:zlib>)
if(ZLIB_FOUND)
target_link_libraries("matroska2" PRIVATE $<BUILD_INTERFACE:z>)
else()
target_link_libraries("matroska2" PRIVATE $<BUILD_INTERFACE:zlib>)
endif()
endif(CONFIG_ZLIB)
if (CONFIG_LZO1X)
add_subdirectory("minilzo")
Expand Down

0 comments on commit 178f6c6

Please sign in to comment.