From 516a1563cbe84c1b9533649a3e37d441f91b3552 Mon Sep 17 00:00:00 2001 From: Daniel Scharrer Date: Tue, 19 Jun 2018 02:39:54 +0200 Subject: [PATCH] CMake: Use boost_{zlib,bzip2} when statically linking Boost The official Windows binaries for Boost come with these renamed versions of the zlib and bzip2 libraries. --- CMakeLists.txt | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f18b2bb..892caed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,19 +149,23 @@ include_directories(SYSTEM ${Boost_INCLUDE_DIR}) has_static_libs(Boost Boost_LIBRARIES) if(Boost_HAS_STATIC_LIBS) - - use_static_libs(ZLIB) - find_package(ZLIB REQUIRED) - use_static_libs_restore() - check_link_library(ZLIB ZLIB_LIBRARIES) - list(APPEND LIBRARIES ${ZLIB_LIBRARIES}) - - use_static_libs(BZip2) - find_package(BZip2 REQUIRED) - use_static_libs_restore() - check_link_library(BZip2 BZIP2_LIBRARIES) - list(APPEND LIBRARIES ${BZIP2_LIBRARIES}) - + foreach(Lib IN ITEMS ZLIB BZip2) + string(TOUPPER ${Lib} LIB) + string(TOLOWER ${Lib} lib) + use_static_libs(${Lib}) + if(WIN32) + find_package(Boost COMPONENTS ${lib} QUIET) + endif() + if(Boost_${LIB}_FOUND) + message (STATUS "Found boost_${lib}") + set(${LIB}_LIBRARIES ${Boost_${LIB}_LIBRARY}) + else() + find_package(${Lib} REQUIRED) + endif() + use_static_libs_restore() + check_link_library(${Lib} ${LIB}_LIBRARIES) + list(APPEND LIBRARIES ${${LIB}_LIBRARIES}) + endforeach() endif() set(INNOEXTRACT_HAVE_ICONV 0)