[zlib] Patch to not build more things than needed

This commit is contained in:
Alexander Karatarakis 2017-09-24 00:03:34 -07:00
parent bdbf00c7ab
commit e4e5298911
3 changed files with 51 additions and 6 deletions

View File

@ -1,3 +1,3 @@
Source: zlib
Version: 1.2.11-2
Version: 1.2.11-3
Description: A compression library

View File

@ -0,0 +1,42 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0fe939d..8d2f5f1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,7 @@ set(VERSION "1.2.11")
option(ASM686 "Enable building i686 assembly implementation")
option(AMD64 "Enable building amd64 assembly implementation")
+option(SKIP_BUILD_EXAMPLES "Skip build of the examples" OFF)
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
@@ -211,7 +212,15 @@ elseif(BUILD_SHARED_LIBS AND WIN32)
endif()
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
- install(TARGETS zlib zlibstatic
+ if (BUILD_SHARED_LIBS)
+ set(ZLIB_TARGETS zlib)
+ set_target_properties(zlibstatic PROPERTIES EXCLUDE_FROM_ALL ON)
+ else()
+ set(ZLIB_TARGETS zlibstatic)
+ set_target_properties(zlib PROPERTIES EXCLUDE_FROM_ALL ON)
+ endif()
+
+ install(TARGETS ${ZLIB_TARGETS}
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
@@ -230,6 +239,7 @@ endif()
# Example binaries
#============================================================================
+if (NOT SKIP_BUILD_EXAMPLES)
add_executable(example test/example.c)
target_link_libraries(example zlib)
add_test(example example)
@@ -247,3 +257,4 @@ if(HAVE_OFF64_T)
target_link_libraries(minigzip64 zlib)
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
endif()
+endif()

View File

@ -7,11 +7,18 @@ vcpkg_download_distfile(ARCHIVE_FILE
)
vcpkg_extract_source_archive(${ARCHIVE_FILE})
vcpkg_apply_patches(
SOURCE_PATH ${SOURCE_PATH}
PATCHES
${CMAKE_CURRENT_LIST_DIR}/cmake_dont_build_more_than_needed.patch
)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DSKIP_INSTALL_FILES=ON
-DSKIP_BUILD_EXAMPLES=ON
OPTIONS_DEBUG
-DSKIP_INSTALL_HEADERS=ON
)
@ -19,11 +26,7 @@ vcpkg_configure_cmake(
vcpkg_install_cmake()
# Both dynamic and static are built, so keep only the one needed
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/zlibstatic.lib ${CURRENT_PACKAGES_DIR}/debug/lib/zlibstaticd.lib)
else()
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/zlib.lib ${CURRENT_PACKAGES_DIR}/debug/lib/zlibd.lib)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/zlibstatic.lib ${CURRENT_PACKAGES_DIR}/lib/zlib.lib)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/zlibstaticd.lib ${CURRENT_PACKAGES_DIR}/debug/lib/zlibd.lib)
endif()