Skip to content

Commit 754fa52

Browse files
committed
Use an option instead of a flag for USE_BUNDLED_ZLIB
Now `USE_BUNDLED_ZLIB` can be set to the string `Chromium` to enable the Chromium implementation of zlib.
1 parent 83265b3 commit 754fa52

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ OPTION(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)"
5050
OPTION(USE_LEAK_CHECKER "Run tests with leak checker" OFF)
5151
OPTION(DEBUG_POOL "Enable debug pool allocator" OFF)
5252
OPTION(ENABLE_WERROR "Enable compilation with -Werror" OFF)
53-
OPTION(USE_BUNDLED_ZLIB "Use the bundled version of zlib" OFF)
54-
OPTION(USE_CHROMIUM_ZLIB "If using the bundled version of zlib, use the Chromium flavor (x86_64 processor with SSE4.2 and CLMUL required)" OFF)
53+
OPTION(USE_BUNDLED_ZLIB "Use the bundled version of zlib. Can be set to one of Bundled(ON)/Chromium. The Chromium option requires a x86_64 processor with SSE4.2 and CLMUL" OFF)
5554
SET(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation; either system or builtin.")
5655
OPTION(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
5756
SET(REGEX_BACKEND "" CACHE STRING "Regular expression implementation. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")

src/CMakeLists.txt

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ENDIF()
77
ADD_FEATURE_INFO(debugpool GIT_DEBUG_POOL "debug pool allocator")
88

99
INCLUDE(PkgBuildConfig)
10+
INCLUDE(SanitizeBool)
1011

1112
# This variable will contain the libraries we need to put into
1213
# libgit2.pc's Requires.private. That is, what we're linking to or
@@ -186,7 +187,12 @@ ELSE()
186187
ENDIF()
187188

188189
# Optional external dependency: zlib
189-
IF(NOT USE_BUNDLED_ZLIB)
190+
SanitizeBool(USE_BUNDLED_ZLIB)
191+
IF(USE_BUNDLED_ZLIB STREQUAL ON)
192+
SET(USE_BUNDLED_ZLIB "Bundled")
193+
ENDIF()
194+
195+
IF(USE_BUNDLED_ZLIB STREQUAL "OFF")
190196
FIND_PACKAGE(ZLIB)
191197
IF(ZLIB_FOUND)
192198
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${ZLIB_INCLUDE_DIRS})
@@ -201,18 +207,16 @@ IF(NOT USE_BUNDLED_ZLIB)
201207
MESSAGE(STATUS "zlib was not found; using bundled 3rd-party sources." )
202208
ENDIF()
203209
ENDIF()
204-
IF(USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND)
205-
IF(USE_CHROMIUM_ZLIB)
206-
ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/chromium-zlib" "${libgit2_BINARY_DIR}/deps/chromium-zlib")
207-
LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/chromium-zlib")
208-
LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:chromium_zlib>)
209-
ADD_FEATURE_INFO(zlib ON "using (Chromium) bundled zlib")
210-
ELSE()
211-
ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/zlib" "${libgit2_BINARY_DIR}/deps/zlib")
212-
LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
213-
LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:zlib>)
214-
ADD_FEATURE_INFO(zlib ON "using bundled zlib")
215-
ENDIF()
210+
IF(USE_BUNDLED_ZLIB STREQUAL "Chromium")
211+
ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/chromium-zlib" "${libgit2_BINARY_DIR}/deps/chromium-zlib")
212+
LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/chromium-zlib")
213+
LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:chromium_zlib>)
214+
ADD_FEATURE_INFO(zlib ON "using (Chromium) bundled zlib")
215+
ELSEIF(USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND)
216+
ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/zlib" "${libgit2_BINARY_DIR}/deps/zlib")
217+
LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
218+
LIST(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:zlib>)
219+
ADD_FEATURE_INFO(zlib ON "using bundled zlib")
216220
ENDIF()
217221

218222
# Optional external dependency: libssh2

0 commit comments

Comments
 (0)