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)