From 01348fb619c669aa26a81a28ce71b010455c78da Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Mon, 15 Feb 2021 23:11:38 +0100 Subject: [PATCH] Move finding ZLIB to root CMakeLists.txt Small line decrease, but also easier to read what is happening. Now all dependencies can be read from the root CMakeLists.txt file. Signed-off-by: Andreas Sturmlechner --- CMakeLists.txt | 22 +++++++++++++++------- ConfigureChecks.cmake | 11 ----------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 770fa046..e537aeb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,8 +101,21 @@ math(EXPR TAGLIB_SOVERSION_PATCH "${TAGLIB_SOVERSION_REVISION}") include(ConfigureChecks.cmake) -if(${ZLIB_FOUND}) - set(ZLIB_LIBRARIES_FLAGS -lz) +# Determine whether zlib is installed. + +if(NOT ZLIB_SOURCE) + find_package(ZLIB) + if(ZLIB_FOUND) + set(HAVE_ZLIB 1) + set(ZLIB_LIBRARIES_FLAGS -lz) + else() + set(HAVE_ZLIB 0) + endif() +endif() + +if(NOT HAVE_ZLIB AND ZLIB_SOURCE) + set(HAVE_ZLIB 1) + set(HAVE_ZLIB_SOURCE 1) endif() if(NOT WIN32) @@ -120,11 +133,6 @@ if(NOT BUILD_FRAMEWORK) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/taglib.pc" DESTINATION "${LIB_INSTALL_DIR}/pkgconfig") endif() -if(NOT HAVE_ZLIB AND ZLIB_SOURCE) - set(HAVE_ZLIB 1) - set(HAVE_ZLIB_SOURCE 1) -endif() - include_directories(${CMAKE_CURRENT_BINARY_DIR}) configure_file(config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/config.h") diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 2fe2f129..7d2ff953 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -176,17 +176,6 @@ check_cxx_source_compiles(" } " HAVE_ISO_STRDUP) -# Determine whether zlib is installed. - -if(NOT ZLIB_SOURCE) - find_package(ZLIB) - if(ZLIB_FOUND) - set(HAVE_ZLIB 1) - else() - set(HAVE_ZLIB 0) - endif() -endif() - # Detect WinRT mode if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") set(PLATFORM WINRT 1)