| 1 |
cmake_minimum_required(VERSION 3.5.1) |
| 2 |
if(CMAKE_VERSION VERSION_LESS 3.12) |
| 3 |
cmake_policy(VERSION ${CMAKE_VERSION}) |
| 4 |
else() |
| 5 |
cmake_policy(VERSION 3.5.1...3.13.2) |
| 6 |
endif() |
| 7 |
message(STATUS "Using CMake version ${CMAKE_VERSION}") |
| 8 |
|
| 9 |
set(CMAKE_MACOSX_RPATH 1) |
| 10 |
|
| 11 |
# If not specified on the command line, enable C11 as the default |
| 12 |
# Configuration items that affect the global compiler environment standards |
| 13 |
# should be issued before the "project" command. |
| 14 |
if(NOT CMAKE_C_STANDARD) |
| 15 |
set(CMAKE_C_STANDARD 11) # The C standard whose features are requested to build this target |
| 16 |
endif() |
| 17 |
if(NOT CMAKE_C_STANDARD_REQUIRED) |
| 18 |
set(CMAKE_C_STANDARD_REQUIRED ON) # Boolean describing whether the value of C_STANDARD is a requirement |
| 19 |
endif() |
| 20 |
if(NOT CMAKE_C_EXTENSIONS) |
| 21 |
set(CMAKE_C_EXTENSIONS OFF) # Boolean specifying whether compiler specific extensions are requested |
| 22 |
endif() |
| 23 |
set(VALID_C_STANDARDS "99" "11") |
| 24 |
if(NOT CMAKE_C_STANDARD IN_LIST VALID_C_STANDARDS) |
| 25 |
MESSAGE(FATAL_ERROR "CMAKE_C_STANDARD:STRING=${CMAKE_C_STANDARD} not in known standards list\n ${VALID_C_STANDARDS}") |
| 26 |
endif() |
| 27 |
|
| 28 |
# Parse the full version number from zlib.h and include in ZLIB_FULL_VERSION |
| 29 |
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib${SUFFIX}.h.in _zlib_h_contents) |
| 30 |
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([0-9]+.[0-9]+.[0-9]+).*\".*" |
| 31 |
"\\1" ZLIB_HEADER_VERSION ${_zlib_h_contents}) |
| 32 |
string(REGEX REPLACE ".*#define[ \t]+ZLIBNG_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" |
| 33 |
"\\1" ZLIBNG_HEADER_VERSION ${_zlib_h_contents}) |
| 34 |
message(STATUS "ZLIB_HEADER_VERSION: ${ZLIB_HEADER_VERSION}") |
| 35 |
message(STATUS "ZLIBNG_HEADER_VERSION: ${ZLIBNG_HEADER_VERSION}") |
| 36 |
|
| 37 |
project(zlib VERSION ${ZLIB_HEADER_VERSION} LANGUAGES C) |
| 38 |
|
| 39 |
include(CheckTypeSize) |
| 40 |
include(CheckSymbolExists) |
| 41 |
include(CheckFunctionExists) |
| 42 |
include(CheckIncludeFile) |
| 43 |
include(CheckCSourceCompiles) |
| 44 |
include(CheckCSourceRuns) |
| 45 |
include(CheckCCompilerFlag) |
| 46 |
include(CMakeDependentOption) |
| 47 |
include(FeatureSummary) |
| 48 |
|
| 49 |
include(cmake/detect-arch.cmake) |
| 50 |
include(cmake/detect-install-dirs.cmake) |
| 51 |
include(cmake/detect-coverage.cmake) |
| 52 |
include(cmake/detect-intrinsics.cmake) |
| 53 |
include(cmake/detect-sanitizer.cmake) |
| 54 |
include(cmake/fallback-macros.cmake) |
| 55 |
|
| 56 |
if(CMAKE_TOOLCHAIN_FILE) |
| 57 |
message(STATUS "Using CMake toolchain: ${CMAKE_TOOLCHAIN_FILE}") |
| 58 |
endif() |
| 59 |
|
| 60 |
# Make sure we use an appropriate BUILD_TYPE by default, "Release" to be exact |
| 61 |
# this should select the maximum generic optimisation on the current platform (i.e. -O3 for gcc/clang) |
| 62 |
if(NOT GENERATOR_IS_MULTI_CONFIG) |
| 63 |
if(NOT CMAKE_BUILD_TYPE) |
| 64 |
set(CMAKE_BUILD_TYPE "Release" CACHE STRING |
| 65 |
"Choose the type of build, standard options are: Debug Release RelWithDebInfo MinSizeRel." |
| 66 |
FORCE) |
| 67 |
add_feature_info(CMAKE_BUILD_TYPE 1 "Build type: ${CMAKE_BUILD_TYPE} (default)") |
| 68 |
else() |
| 69 |
add_feature_info(CMAKE_BUILD_TYPE 1 "Build type: ${CMAKE_BUILD_TYPE} (selected)") |
| 70 |
endif() |
| 71 |
endif() |
| 72 |
|
| 73 |
# |
| 74 |
# Options parsing |
| 75 |
# |
| 76 |
option(WITH_GZFILEOP "Compile with support for gzFile related functions" ON) |
| 77 |
option(ZLIB_COMPAT "Compile with zlib compatible API" OFF) |
| 78 |
option(ZLIB_ENABLE_TESTS "Build test binaries" ON) |
| 79 |
option(WITH_FUZZERS "Build test/fuzz" OFF) |
| 80 |
option(WITH_BENCHMARKS "Build test/benchmarks" OFF) |
| 81 |
option(WITH_BENCHMARK_APPS "Build application benchmarks" OFF) |
| 82 |
option(WITH_OPTIM "Build with optimisation" ON) |
| 83 |
option(WITH_REDUCED_MEM "Reduced memory usage for special cases (reduces performance)" OFF) |
| 84 |
option(WITH_NEW_STRATEGIES "Use new strategies" ON) |
| 85 |
option(WITH_NATIVE_INSTRUCTIONS |
| 86 |
"Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)" OFF) |
| 87 |
option(WITH_MAINTAINER_WARNINGS "Build with project maintainer warnings" OFF) |
| 88 |
option(WITH_CODE_COVERAGE "Enable code coverage reporting" OFF) |
| 89 |
option(WITH_INFLATE_STRICT "Build with strict inflate distance checking" OFF) |
| 90 |
option(WITH_INFLATE_ALLOW_INVALID_DIST "Build with zero fill for inflate invalid distances" OFF) |
| 91 |
option(WITH_UNALIGNED "Support unaligned reads on platforms that support it" ON) |
| 92 |
|
| 93 |
set(ZLIB_SYMBOL_PREFIX "" CACHE STRING "Give this prefix to all publicly exported symbols. |
| 94 |
Useful when embedding into a larger library. |
| 95 |
Default is no prefix (empty prefix).") |
| 96 |
|
| 97 |
# Add multi-choice option |
| 98 |
set(WITH_SANITIZER AUTO CACHE STRING "Enable sanitizer support") |
| 99 |
set_property(CACHE WITH_SANITIZER PROPERTY STRINGS "Memory" "Address" "Undefined" "Thread") |
| 100 |
|
| 101 |
if(BASEARCH_ARM_FOUND) |
| 102 |
option(WITH_ACLE "Build with ACLE" ON) |
| 103 |
option(WITH_NEON "Build with NEON intrinsics" ON) |
| 104 |
elseif(BASEARCH_PPC_FOUND) |
| 105 |
option(WITH_ALTIVEC "Build with AltiVec (VMX) optimisations for PowerPC" ON) |
| 106 |
option(WITH_POWER8 "Build with optimisations for POWER8" ON) |
| 107 |
option(WITH_POWER9 "Build with optimisations for POWER9" ON) |
| 108 |
elseif(BASEARCH_S360_FOUND) |
| 109 |
option(WITH_DFLTCC_DEFLATE "Build with DFLTCC intrinsics for compression on IBM Z" OFF) |
| 110 |
option(WITH_DFLTCC_INFLATE "Build with DFLTCC intrinsics for decompression on IBM Z" OFF) |
| 111 |
option(WITH_CRC32_VX "Build with vectorized CRC32 on IBM Z" ON) |
| 112 |
elseif(BASEARCH_X86_FOUND) |
| 113 |
option(FORCE_TZCNT "Always assume CPU is TZCNT capable" OFF) |
| 114 |
option(WITH_AVX2 "Build with AVX2" ON) |
| 115 |
option(WITH_AVX512 "Build with AVX512" ON) |
| 116 |
option(WITH_AVX512VNNI "Build with AVX512 VNNI extensions" ON) |
| 117 |
option(WITH_SSE2 "Build with SSE2" ON) |
| 118 |
option(WITH_SSSE3 "Build with SSSE3" ON) |
| 119 |
option(WITH_SSE41 "Build with SSE41" ON) |
| 120 |
option(WITH_SSE42 "Build with SSE42" ON) |
| 121 |
option(WITH_PCLMULQDQ "Build with PCLMULQDQ" ON) |
| 122 |
option(WITH_VPCLMULQDQ "Build with VPCLMULQDQ" ON) |
| 123 |
endif() |
| 124 |
|
| 125 |
option(INSTALL_UTILS "Copy minigzip and minideflate during install" OFF) |
| 126 |
|
| 127 |
mark_as_advanced(FORCE |
| 128 |
ZLIB_SYMBOL_PREFIX |
| 129 |
WITH_REDUCED_MEM |
| 130 |
WITH_ACLE WITH_NEON |
| 131 |
WITH_DFLTCC_DEFLATE |
| 132 |
WITH_DFLTCC_INFLATE |
| 133 |
WITH_CRC32_VX |
| 134 |
WITH_AVX2 WITH_SSE2 |
| 135 |
WITH_SSSE3 WITH_SSE41 |
| 136 |
WITH_SSE42 |
| 137 |
WITH_PCLMULQDQ |
| 138 |
WITH_ALTIVEC |
| 139 |
WITH_POWER8 |
| 140 |
WITH_POWER9 |
| 141 |
WITH_INFLATE_STRICT |
| 142 |
WITH_INFLATE_ALLOW_INVALID_DIST |
| 143 |
WITH_UNALIGNED |
| 144 |
INSTALL_UTILS |
| 145 |
) |
| 146 |
|
| 147 |
if(ZLIB_COMPAT) |
| 148 |
add_definitions(-DZLIB_COMPAT) |
| 149 |
set(WITH_GZFILEOP ON) |
| 150 |
set(SUFFIX "") |
| 151 |
set(ZLIB_FULL_VERSION ${ZLIB_HEADER_VERSION}.zlib-ng) |
| 152 |
else() |
| 153 |
set(SUFFIX "-ng") |
| 154 |
set(ZLIB_FULL_VERSION ${ZLIBNG_HEADER_VERSION}) |
| 155 |
endif() |
| 156 |
|
| 157 |
if(WITH_GZFILEOP) |
| 158 |
add_definitions(-DWITH_GZFILEOP) |
| 159 |
endif() |
| 160 |
|
| 161 |
if(CMAKE_C_COMPILER_ID MATCHES "^Intel") |
| 162 |
if(CMAKE_HOST_UNIX) |
| 163 |
set(WARNFLAGS -Wall) |
| 164 |
set(WARNFLAGS_MAINTAINER -Wall -Wcheck -Wremarks) |
| 165 |
set(WARNFLAGS_DISABLE) |
| 166 |
else() |
| 167 |
set(WARNFLAGS /Wall) |
| 168 |
set(WARNFLAGS_MAINTAINER /W5) |
| 169 |
set(WARNFLAGS_DISABLE) |
| 170 |
endif() |
| 171 |
if(WITH_NATIVE_INSTRUCTIONS) |
| 172 |
message(STATUS "Ignoring WITH_NATIVE_INSTRUCTIONS; not supported on this configuration") |
| 173 |
set(WITH_NATIVE_INSTRUCTIONS OFF) |
| 174 |
endif() |
| 175 |
elseif(MSVC) |
| 176 |
# Minimum supported MSVC version is 1800 = Visual Studio 12.0/2013 |
| 177 |
# See also https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html |
| 178 |
if(MSVC_VERSION VERSION_LESS 1800) |
| 179 |
message(SEND_ERROR "Unsupported Visual Studio compiler version (requires 2013 or later).") |
| 180 |
endif() |
| 181 |
# TODO. ICC can be used through MSVC. I'm not sure if we'd ever see that combination |
| 182 |
# (who'd use cmake from an IDE...) but checking for ICC before checking for MSVC should |
| 183 |
# avoid mistakes. |
| 184 |
# /Oi ? |
| 185 |
set(WARNFLAGS /W3) |
| 186 |
set(WARNFLAGS_MAINTAINER /W4) |
| 187 |
set(WARNFLAGS_DISABLE) |
| 188 |
if(BASEARCH_ARM_FOUND) |
| 189 |
add_definitions(-D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE) |
| 190 |
if(NOT "${ARCH}" MATCHES "aarch64") |
| 191 |
set(NEONFLAG "/arch:VFPv4") |
| 192 |
endif() |
| 193 |
endif() |
| 194 |
if(WITH_NATIVE_INSTRUCTIONS) |
| 195 |
message(STATUS "Ignoring WITH_NATIVE_INSTRUCTIONS; not supported on this configuration") |
| 196 |
set(WITH_NATIVE_INSTRUCTIONS OFF) |
| 197 |
endif() |
| 198 |
elseif(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") |
| 199 |
# Enable warnings in GCC and Clang |
| 200 |
set(WARNFLAGS -Wall) |
| 201 |
set(WARNFLAGS_MAINTAINER -Wextra -Wpedantic) |
| 202 |
set(WARNFLAGS_DISABLE -Wno-implicit-fallthrough) |
| 203 |
if(WITH_NATIVE_INSTRUCTIONS) |
| 204 |
if(BASEARCH_PPC_FOUND) |
| 205 |
set(NATIVEFLAG "-mcpu=native") |
| 206 |
else() |
| 207 |
set(NATIVEFLAG "-march=native") |
| 208 |
endif() |
| 209 |
else() |
| 210 |
if(BASEARCH_ARM_FOUND) |
| 211 |
if("${ARCH}" MATCHES "arm" AND NOT CMAKE_C_FLAGS MATCHES "-mfloat-abi") |
| 212 |
# Auto-detect support for ARM floating point ABI |
| 213 |
set(CMAKE_REQUIRED_FLAGS -mfloat-abi=softfp) |
| 214 |
check_c_source_compiles( |
| 215 |
"#include <features.h> |
| 216 |
int main() { return 0; }" |
| 217 |
HAVE_FLOATABI_SOFTFP) |
| 218 |
if(HAVE_FLOATABI_SOFTFP) |
| 219 |
set(FLOATABI -mfloat-abi=softfp) |
| 220 |
else() |
| 221 |
set(CMAKE_REQUIRED_FLAGS -mfloat-abi=hard) |
| 222 |
check_c_source_compiles( |
| 223 |
"#include <features.h> |
| 224 |
int main() { return 0; }" |
| 225 |
HAVE_FLOATABI_HARD) |
| 226 |
if(HAVE_FLOATABI_HARD) |
| 227 |
set(FLOATABI -mfloat-abi=hard) |
| 228 |
endif() |
| 229 |
endif() |
| 230 |
set(CMAKE_REQUIRED_FLAGS) |
| 231 |
if(FLOATABI) |
| 232 |
message(STATUS "ARM floating point arch: ${FLOATABI}") |
| 233 |
add_compile_options(${FLOATABI}) |
| 234 |
else() |
| 235 |
message(STATUS "ARM floating point arch not auto-detected") |
| 236 |
endif() |
| 237 |
endif() |
| 238 |
endif() |
| 239 |
# Check whether -fno-lto is available |
| 240 |
set(CMAKE_REQUIRED_FLAGS "-fno-lto") |
| 241 |
check_c_source_compiles( |
| 242 |
"int main() { return 0; }" |
| 243 |
FNO_LTO_AVAILABLE FAIL_REGEX "not supported") |
| 244 |
set(CMAKE_REQUIRED_FLAGS) |
| 245 |
if(FNO_LTO_AVAILABLE) |
| 246 |
set(NOLTOFLAG "-fno-lto") |
| 247 |
endif() |
| 248 |
endif() |
| 249 |
else() |
| 250 |
if(WITH_NATIVE_INSTRUCTIONS) |
| 251 |
message(STATUS "Ignoring WITH_NATIVE_INSTRUCTIONS; not implemented yet on this configuration") |
| 252 |
set(WITH_NATIVE_INSTRUCTIONS OFF) |
| 253 |
endif() |
| 254 |
endif() |
| 255 |
|
| 256 |
# Disable LTO |
| 257 |
if(NOT WITH_NATIVE_INSTRUCTIONS) |
| 258 |
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF) |
| 259 |
foreach(_cfg_name IN LISTS CMAKE_CONFIGURATION_TYPES) |
| 260 |
string(TOUPPER "${_cfg_name}" _cfg_name_uc) |
| 261 |
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_${_cfg_name_uc} OFF) |
| 262 |
endforeach() |
| 263 |
endif() |
| 264 |
|
| 265 |
# Set architecture alignment requirements |
| 266 |
if(NOT WITH_UNALIGNED) |
| 267 |
add_definitions(-DNO_UNALIGNED) |
| 268 |
message(STATUS "Unaligned reads manually disabled") |
| 269 |
endif() |
| 270 |
|
| 271 |
# Apply warning compiler flags |
| 272 |
if(WITH_MAINTAINER_WARNINGS) |
| 273 |
add_compile_options(${WARNFLAGS} ${WARNFLAGS_MAINTAINER} ${WARNFLAGS_DISABLE}) |
| 274 |
else() |
| 275 |
add_compile_options(${WARNFLAGS} ${WARNFLAGS_DISABLE}) |
| 276 |
endif() |
| 277 |
|
| 278 |
# Set code coverage compiler flags |
| 279 |
if(WITH_CODE_COVERAGE) |
| 280 |
add_code_coverage() |
| 281 |
endif() |
| 282 |
|
| 283 |
# Replace optimization level 3 added by default with level 2 |
| 284 |
if(NOT WITH_CODE_COVERAGE AND NOT MSVC AND NOT CMAKE_C_FLAGS MATCHES "([\\/\\-]O)3") |
| 285 |
string(REGEX REPLACE "([\\/\\-]O)3" "\\12" |
| 286 |
CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") |
| 287 |
endif() |
| 288 |
|
| 289 |
# Set native instruction set compiler flag |
| 290 |
if(WITH_NATIVE_INSTRUCTIONS AND DEFINED NATIVEFLAG) |
| 291 |
# Apply flag to all source files and compilation checks |
| 292 |
add_compile_options(${NATIVEFLAG}) |
| 293 |
endif() |
| 294 |
|
| 295 |
# |
| 296 |
# Check for standard/system includes |
| 297 |
# |
| 298 |
check_include_file(sys/auxv.h HAVE_SYS_AUXV_H) |
| 299 |
if(HAVE_SYS_AUXV_H) |
| 300 |
add_definitions(-DHAVE_SYS_AUXV_H) |
| 301 |
endif() |
| 302 |
check_include_file(sys/sdt.h HAVE_SYS_SDT_H) |
| 303 |
if(HAVE_SYS_SDT_H) |
| 304 |
add_definitions(-DHAVE_SYS_SDT_H) |
| 305 |
endif() |
| 306 |
check_include_file(unistd.h HAVE_UNISTD_H) |
| 307 |
|
| 308 |
# |
| 309 |
# Check to see if we have large file support |
| 310 |
# |
| 311 |
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64) |
| 312 |
check_type_size(off64_t OFF64_T) |
| 313 |
if(HAVE_OFF64_T) |
| 314 |
add_definitions(-D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64) |
| 315 |
else() |
| 316 |
check_type_size(_off64_t _OFF64_T) |
| 317 |
if(HAVE__OFF64_T) |
| 318 |
add_definitions(-D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64) |
| 319 |
else() |
| 320 |
check_type_size(__off64_t __OFF64_T) |
| 321 |
endif() |
| 322 |
endif() |
| 323 |
set(CMAKE_REQUIRED_DEFINITIONS) # clear variable |
| 324 |
|
| 325 |
# |
| 326 |
# Check for fseeko and other optional functions |
| 327 |
# |
| 328 |
check_function_exists(fseeko HAVE_FSEEKO) |
| 329 |
if(NOT HAVE_FSEEKO) |
| 330 |
add_definitions(-DNO_FSEEKO) |
| 331 |
endif() |
| 332 |
check_function_exists(strerror HAVE_STRERROR) |
| 333 |
if(NOT HAVE_STRERROR) |
| 334 |
add_definitions(-DNO_STRERROR) |
| 335 |
endif() |
| 336 |
set(CMAKE_REQUIRED_DEFINITIONS -D _POSIX_C_SOURCE=200112L) |
| 337 |
check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN) |
| 338 |
if(HAVE_POSIX_MEMALIGN) |
| 339 |
add_definitions(-DHAVE_POSIX_MEMALIGN) |
| 340 |
endif() |
| 341 |
set(CMAKE_REQUIRED_DEFINITIONS) |
| 342 |
|
| 343 |
if(WITH_SANITIZER STREQUAL "Address") |
| 344 |
add_address_sanitizer() |
| 345 |
elseif(WITH_SANITIZER STREQUAL "Memory") |
| 346 |
add_memory_sanitizer() |
| 347 |
elseif(WITH_SANITIZER STREQUAL "Thread") |
| 348 |
add_thread_sanitizer() |
| 349 |
elseif(WITH_SANITIZER STREQUAL "Undefined") |
| 350 |
add_undefined_sanitizer() |
| 351 |
endif() |
| 352 |
|
| 353 |
# |
| 354 |
# Check whether compiler supports -fno-semantic-interposition parameter |
| 355 |
# |
| 356 |
check_c_compiler_flag(-fno-semantic-interposition HAVE_NO_INTERPOSITION) |
| 357 |
|
| 358 |
# |
| 359 |
# Check if we can hide zlib internal symbols that are linked between separate source files using hidden |
| 360 |
# |
| 361 |
check_c_source_compiles( |
| 362 |
"#define Z_INTERNAL __attribute__((visibility (\"hidden\"))) |
| 363 |
int Z_INTERNAL foo; |
| 364 |
int main() { |
| 365 |
return 0; |
| 366 |
}" |
| 367 |
HAVE_ATTRIBUTE_VISIBILITY_HIDDEN FAIL_REGEX "not supported") |
| 368 |
if(HAVE_ATTRIBUTE_VISIBILITY_HIDDEN) |
| 369 |
add_definitions(-DHAVE_VISIBILITY_HIDDEN) |
| 370 |
endif() |
| 371 |
|
| 372 |
# |
| 373 |
# Check if we can hide zlib internal symbols that are linked between separate source files using internal |
| 374 |
# |
| 375 |
check_c_source_compiles( |
| 376 |
"#define Z_INTERNAL __attribute__((visibility (\"internal\"))) |
| 377 |
int Z_INTERNAL foo; |
| 378 |
int main() { |
| 379 |
return 0; |
| 380 |
}" |
| 381 |
HAVE_ATTRIBUTE_VISIBILITY_INTERNAL FAIL_REGEX "not supported") |
| 382 |
if(HAVE_ATTRIBUTE_VISIBILITY_INTERNAL) |
| 383 |
add_definitions(-DHAVE_VISIBILITY_INTERNAL) |
| 384 |
endif() |
| 385 |
|
| 386 |
# |
| 387 |
# check for __builtin_ctz() support in the compiler |
| 388 |
# |
| 389 |
check_c_source_compiles( |
| 390 |
"int main(void) { |
| 391 |
unsigned int zero = 0; |
| 392 |
long test = __builtin_ctz(zero); |
| 393 |
(void)test; |
| 394 |
return 0; |
| 395 |
}" |
| 396 |
HAVE_BUILTIN_CTZ |
| 397 |
) |
| 398 |
if(HAVE_BUILTIN_CTZ) |
| 399 |
add_definitions(-DHAVE_BUILTIN_CTZ) |
| 400 |
endif() |
| 401 |
# |
| 402 |
# check for __builtin_ctzll() support in the compiler |
| 403 |
# |
| 404 |
check_c_source_compiles( |
| 405 |
"int main(void) { |
| 406 |
unsigned int zero = 0; |
| 407 |
long test = __builtin_ctzll(zero); |
| 408 |
(void)test; |
| 409 |
return 0; |
| 410 |
}" |
| 411 |
HAVE_BUILTIN_CTZLL |
| 412 |
) |
| 413 |
if(HAVE_BUILTIN_CTZLL) |
| 414 |
add_definitions(-DHAVE_BUILTIN_CTZLL) |
| 415 |
endif() |
| 416 |
|
| 417 |
# |
| 418 |
# check for ptrdiff_t support |
| 419 |
# |
| 420 |
check_c_source_compiles( |
| 421 |
"#include <stddef.h> |
| 422 |
int main() { |
| 423 |
ptrdiff_t *a; |
| 424 |
(void)a; |
| 425 |
return 0; |
| 426 |
}" |
| 427 |
HAVE_PTRDIFF_T |
| 428 |
) |
| 429 |
if(NOT HAVE_PTRDIFF_T) |
| 430 |
set(NEED_PTRDIFF_T 1) |
| 431 |
|
| 432 |
check_type_size("void *" SIZEOF_DATA_PTR) |
| 433 |
message(STATUS "sizeof(void *) is ${SIZEOF_DATA_PTR} bytes") |
| 434 |
|
| 435 |
if(${SIZEOF_DATA_PTR} MATCHES "4") |
| 436 |
set(PTRDIFF_TYPE "uint32_t") |
| 437 |
elseif(${SIZEOF_DATA_PTR} MATCHES "8") |
| 438 |
set(PTRDIFF_TYPE "uint64_t") |
| 439 |
else() |
| 440 |
message(FATAL_ERROR "sizeof(void *) is neither 32 nor 64 bit") |
| 441 |
endif() |
| 442 |
endif() |
| 443 |
|
| 444 |
# Macro to check if source compiles |
| 445 |
# (and, when compiling very natively, also runs). |
| 446 |
macro(check_c_source_compile_or_run source flag) |
| 447 |
if(CMAKE_CROSSCOMPILING OR NOT WITH_NATIVE_INSTRUCTIONS) |
| 448 |
check_c_source_compiles("${source}" ${flag}) |
| 449 |
else() |
| 450 |
check_c_source_runs("${source}" ${flag}) |
| 451 |
endif() |
| 452 |
endmacro() |
| 453 |
|
| 454 |
add_compile_options($<$<CONFIG:Debug>:-DZLIB_DEBUG>) |
| 455 |
|
| 456 |
if(MSVC) |
| 457 |
set(CMAKE_DEBUG_POSTFIX "d") |
| 458 |
add_definitions(-D_CRT_SECURE_NO_DEPRECATE) |
| 459 |
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) |
| 460 |
endif() |
| 461 |
|
| 462 |
if(BASEARCH_X86_FOUND) |
| 463 |
# FORCE_SSE2 option will only be shown if HAVE_SSE2_INTRIN is true |
| 464 |
if("${ARCH}" MATCHES "i[3-6]86") |
| 465 |
cmake_dependent_option(FORCE_SSE2 "Always assume CPU is SSE2 capable" OFF "HAVE_SSE2_INTRIN" OFF) |
| 466 |
endif() |
| 467 |
endif() |
| 468 |
|
| 469 |
# |
| 470 |
# Enable deflate_quick at level 1 |
| 471 |
# |
| 472 |
if(NOT WITH_NEW_STRATEGIES) |
| 473 |
add_definitions(-DNO_QUICK_STRATEGY) |
| 474 |
endif() |
| 475 |
# |
| 476 |
# Enable deflate_medium at level 4-6 |
| 477 |
# |
| 478 |
if(NOT WITH_NEW_STRATEGIES) |
| 479 |
add_definitions(-DNO_MEDIUM_STRATEGY) |
| 480 |
endif() |
| 481 |
# |
| 482 |
# Enable inflate compilation options |
| 483 |
# |
| 484 |
if(WITH_INFLATE_STRICT) |
| 485 |
add_definitions(-DINFLATE_STRICT) |
| 486 |
message(STATUS "Inflate strict distance checking enabled") |
| 487 |
endif() |
| 488 |
if(WITH_INFLATE_ALLOW_INVALID_DIST) |
| 489 |
add_definitions(-DINFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR) |
| 490 |
message(STATUS "Inflate zero data for invalid distances enabled") |
| 491 |
endif() |
| 492 |
# |
| 493 |
# Enable reduced memory configuration |
| 494 |
# |
| 495 |
if(WITH_REDUCED_MEM) |
| 496 |
add_definitions(-DHASH_SIZE=32768u -DGZBUFSIZE=8192) |
| 497 |
message(STATUS "Configured for reduced memory environment") |
| 498 |
endif() |
| 499 |
|
| 500 |
|
| 501 |
set(ZLIB_ARCH_SRCS) |
| 502 |
set(ZLIB_ARCH_HDRS) |
| 503 |
set(ARCHDIR "arch/generic") |
| 504 |
if(BASEARCH_ARM_FOUND) |
| 505 |
set(ARCHDIR "arch/arm") |
| 506 |
elseif(BASEARCH_PPC_FOUND) |
| 507 |
set(ARCHDIR "arch/power") |
| 508 |
elseif(BASEARCH_S360_FOUND) |
| 509 |
set(ARCHDIR "arch/s390") |
| 510 |
elseif(BASEARCH_X86_FOUND) |
| 511 |
set(ARCHDIR "arch/x86") |
| 512 |
if(NOT ${ARCH} MATCHES "x86_64") |
| 513 |
add_feature_info(SSE2 1 "Support the SSE2 instruction set, using \"${SSE2FLAG}\"") |
| 514 |
endif() |
| 515 |
else() |
| 516 |
message(STATUS "No optimized architecture: using ${ARCHDIR}") |
| 517 |
endif() |
| 518 |
|
| 519 |
if(WITH_OPTIM) |
| 520 |
if(BASEARCH_ARM_FOUND) |
| 521 |
add_definitions(-DARM_FEATURES) |
| 522 |
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") |
| 523 |
if(NOT "${ARCH}" MATCHES "aarch64") |
| 524 |
check_c_source_compiles( |
| 525 |
"#include <sys/auxv.h> |
| 526 |
int main() { |
| 527 |
return (getauxval(AT_HWCAP2) & HWCAP2_CRC32); |
| 528 |
}" |
| 529 |
ARM_AUXV_HAS_CRC32 |
| 530 |
) |
| 531 |
if(ARM_AUXV_HAS_CRC32) |
| 532 |
add_definitions(-DARM_AUXV_HAS_CRC32) |
| 533 |
else() |
| 534 |
check_c_source_compiles( |
| 535 |
"#include <sys/auxv.h> |
| 536 |
#include <asm/hwcap.h> |
| 537 |
int main() { |
| 538 |
return (getauxval(AT_HWCAP2) & HWCAP2_CRC32); |
| 539 |
}" |
| 540 |
ARM_HWCAP_HAS_CRC32 |
| 541 |
) |
| 542 |
if (ARM_HWCAP_HAS_CRC32) |
| 543 |
add_definitions(-DARM_AUXV_HAS_CRC32 -DARM_ASM_HWCAP) |
| 544 |
else() |
| 545 |
message(STATUS "HWCAP2_CRC32 not present in sys/auxv.h; cannot detect support at runtime.") |
| 546 |
endif() |
| 547 |
endif() |
| 548 |
else() |
| 549 |
check_c_source_compiles( |
| 550 |
"#include <sys/auxv.h> |
| 551 |
int main() { |
| 552 |
return (getauxval(AT_HWCAP) & HWCAP_CRC32); |
| 553 |
}" |
| 554 |
ARM_AUXV_HAS_CRC32 |
| 555 |
) |
| 556 |
if(ARM_AUXV_HAS_CRC32) |
| 557 |
add_definitions(-DARM_AUXV_HAS_CRC32) |
| 558 |
else() |
| 559 |
message(STATUS "HWCAP_CRC32 not present in sys/auxv.h; cannot detect support at runtime.") |
| 560 |
endif() |
| 561 |
endif() |
| 562 |
if(NOT "${ARCH}" MATCHES "aarch64") |
| 563 |
check_c_source_compiles( |
| 564 |
"#include <sys/auxv.h> |
| 565 |
int main() { |
| 566 |
return (getauxval(AT_HWCAP) & HWCAP_ARM_NEON); |
| 567 |
}" |
| 568 |
ARM_AUXV_HAS_NEON |
| 569 |
) |
| 570 |
if(ARM_AUXV_HAS_NEON) |
| 571 |
add_definitions(-DARM_AUXV_HAS_NEON) |
| 572 |
else() |
| 573 |
check_c_source_compiles( |
| 574 |
"#include <sys/auxv.h> |
| 575 |
int main() { |
| 576 |
return (getauxval(AT_HWCAP) & HWCAP_NEON); |
| 577 |
}" |
| 578 |
ARM_AUXV_HAS_NEON |
| 579 |
) |
| 580 |
if (ARM_AUXV_HAS_NEON) |
| 581 |
add_definitions(-DARM_AUXV_HAS_NEON) |
| 582 |
else() |
| 583 |
message(STATUS "Neither HWCAP_ARM_NEON or HWCAP_NEON present in sys/auxv.h; cannot detect support at runtime.") |
| 584 |
endif() |
| 585 |
endif() |
| 586 |
endif() |
| 587 |
endif() |
| 588 |
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/arm_features.h) |
| 589 |
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/arm_features.c) |
| 590 |
if(WITH_ACLE AND NOT "${ARCH}" MATCHES "armv[2-7]") |
| 591 |
check_acle_compiler_flag() |
| 592 |
if(HAVE_ACLE_FLAG) |
| 593 |
add_definitions(-DARM_ACLE_CRC_HASH) |
| 594 |
set(ACLE_SRCS ${ARCHDIR}/crc32_acle.c ${ARCHDIR}/insert_string_acle.c) |
| 595 |
set_property(SOURCE ${ACLE_SRCS} PROPERTY COMPILE_FLAGS "${ACLEFLAG} ${NOLTOFLAG}") |
| 596 |
list(APPEND ZLIB_ARCH_SRCS ${ACLE_SRCS}) |
| 597 |
add_feature_info(ACLE_CRC 1 "Support ACLE optimized CRC hash generation, using \"${ACLEFLAG}\"") |
| 598 |
else() |
| 599 |
set(WITH_ACLE OFF) |
| 600 |
endif() |
| 601 |
else() |
| 602 |
set(WITH_ACLE OFF) |
| 603 |
endif() |
| 604 |
if(WITH_NEON) |
| 605 |
check_neon_compiler_flag() |
| 606 |
if(MFPU_NEON_AVAILABLE) |
| 607 |
add_definitions(-DARM_NEON -DARM_NEON_ADLER32 -DARM_NEON_CHUNKSET -DARM_NEON_SLIDEHASH) |
| 608 |
set(NEON_SRCS ${ARCHDIR}/adler32_neon.c ${ARCHDIR}/chunkset_neon.c |
| 609 |
${ARCHDIR}/compare256_neon.c ${ARCHDIR}/slide_hash_neon.c) |
| 610 |
list(APPEND ZLIB_ARCH_SRCS ${NEON_SRCS}) |
| 611 |
set_property(SOURCE ${NEON_SRCS} PROPERTY COMPILE_FLAGS "${NEONFLAG} ${NOLTOFLAG}") |
| 612 |
if(MSVC) |
| 613 |
add_definitions(-D__ARM_NEON__) |
| 614 |
endif() |
| 615 |
add_feature_info(NEON_ADLER32 1 "Support NEON instructions in adler32, using \"${NEONFLAG}\"") |
| 616 |
add_feature_info(NEON_SLIDEHASH 1 "Support NEON instructions in slide_hash, using \"${NEONFLAG}\"") |
| 617 |
check_neon_ld4_intrinsics() |
| 618 |
if(NEON_HAS_LD4) |
| 619 |
add_definitions(-DARM_NEON_HASLD4) |
| 620 |
endif() |
| 621 |
else() |
| 622 |
set(WITH_NEON OFF) |
| 623 |
endif() |
| 624 |
endif() |
| 625 |
elseif(BASEARCH_PPC_FOUND) |
| 626 |
# Common arch detection code |
| 627 |
if(WITH_ALTIVEC) |
| 628 |
check_ppc_intrinsics() |
| 629 |
endif() |
| 630 |
if(WITH_POWER8) |
| 631 |
check_power8_intrinsics() |
| 632 |
endif() |
| 633 |
if(WITH_POWER9) |
| 634 |
check_power9_intrinsics() |
| 635 |
endif() |
| 636 |
if(HAVE_VMX OR HAVE_POWER8_INTRIN OR HAVE_POWER9_INTRIN) |
| 637 |
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/power_features.h) |
| 638 |
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/power_features.c) |
| 639 |
endif() |
| 640 |
# VMX specific options and files |
| 641 |
if(WITH_ALTIVEC) |
| 642 |
if(HAVE_VMX) |
| 643 |
add_definitions(-DPPC_FEATURES) |
| 644 |
if(HAVE_ALTIVEC) |
| 645 |
add_definitions(-DPPC_VMX_ADLER32) |
| 646 |
add_definitions(-DPPC_VMX_SLIDEHASH) |
| 647 |
set(PPC_SRCS ${ARCHDIR}/adler32_vmx.c ${ARCHDIR}/slide_hash_vmx.c) |
| 648 |
list(APPEND ZLIB_ARCH_SRCS ${PPC_SRCS}) |
| 649 |
add_feature_info(ALTIVEC 1 "Support the AltiVec instruction set, using \"-maltivec\"") |
| 650 |
set_property(SOURCE ${PPC_SRCS} PROPERTY COMPILE_FLAGS "${PPCFLAGS}") |
| 651 |
else() |
| 652 |
set(WITH_ALTIVEC OFF) |
| 653 |
endif() |
| 654 |
endif() |
| 655 |
endif() |
| 656 |
# Power8 specific options and files |
| 657 |
if(WITH_POWER8) |
| 658 |
if(HAVE_POWER8_INTRIN) |
| 659 |
add_definitions(-DPOWER8) |
| 660 |
add_definitions(-DPOWER_FEATURES) |
| 661 |
add_definitions(-DPOWER8_VSX_ADLER32) |
| 662 |
add_definitions(-DPOWER8_VSX_CHUNKSET) |
| 663 |
add_definitions(-DPOWER8_VSX_SLIDEHASH) |
| 664 |
set(POWER8_SRCS ${ARCHDIR}/adler32_power8.c ${ARCHDIR}/chunkset_power8.c ${ARCHDIR}/slide_hash_power8.c) |
| 665 |
if("${ARCH}" MATCHES "powerpc64(le)?") |
| 666 |
add_definitions(-DPOWER8_VSX_CRC32) |
| 667 |
list(APPEND POWER8_SRCS ${ARCHDIR}/crc32_power8.c) |
| 668 |
endif() |
| 669 |
list(APPEND ZLIB_ARCH_SRCS ${POWER8_SRCS}) |
| 670 |
set_property(SOURCE ${POWER8_SRCS} PROPERTY COMPILE_FLAGS "${POWER8FLAG} ${NOLTOFLAG}") |
| 671 |
else() |
| 672 |
set(WITH_POWER8 OFF) |
| 673 |
endif() |
| 674 |
endif() |
| 675 |
# Power9 specific options and files |
| 676 |
if(WITH_POWER9) |
| 677 |
if(HAVE_POWER9_INTRIN) |
| 678 |
add_definitions(-DPOWER9) |
| 679 |
set(POWER9_SRCS ${ARCHDIR}/compare256_power9.c) |
| 680 |
list(APPEND ZLIB_ARCH_SRCS ${POWER9_SRCS}) |
| 681 |
set_property(SOURCE ${POWER9_SRCS} PROPERTY COMPILE_FLAGS "${POWER9FLAG} ${NOLTOFLAG}") |
| 682 |
else() |
| 683 |
set(WITH_POWER9 OFF) |
| 684 |
endif() |
| 685 |
endif() |
| 686 |
elseif(BASEARCH_S360_FOUND) |
| 687 |
check_s390_intrinsics() |
| 688 |
if(HAVE_S390_INTRIN) |
| 689 |
add_definitions(-DS390_FEATURES) |
| 690 |
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/s390_features.h) |
| 691 |
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/s390_features.c) |
| 692 |
endif() |
| 693 |
if(WITH_DFLTCC_DEFLATE OR WITH_DFLTCC_INFLATE) |
| 694 |
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/dfltcc_common.c) |
| 695 |
endif() |
| 696 |
if(WITH_DFLTCC_DEFLATE) |
| 697 |
add_definitions(-DS390_DFLTCC_DEFLATE) |
| 698 |
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/dfltcc_deflate.c) |
| 699 |
endif() |
| 700 |
if(WITH_DFLTCC_INFLATE) |
| 701 |
add_definitions(-DS390_DFLTCC_INFLATE) |
| 702 |
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/dfltcc_inflate.c) |
| 703 |
endif() |
| 704 |
if(WITH_CRC32_VX) |
| 705 |
check_vgfma_intrinsics() |
| 706 |
if(HAVE_VGFMA_INTRIN) |
| 707 |
add_definitions(-DS390_CRC32_VX) |
| 708 |
set(CRC32_VX_SRCS ${ARCHDIR}/crc32-vx.c) |
| 709 |
list(APPEND ZLIB_ARCH_SRCS ${CRC32_VX_SRCS}) |
| 710 |
set_property(SOURCE ${CRC32_VX_SRCS} PROPERTY COMPILE_FLAGS "${VGFMAFLAG} ${NOLTOFLAG}") |
| 711 |
else() |
| 712 |
set(WITH_CRC32_VX OFF) |
| 713 |
endif() |
| 714 |
endif() |
| 715 |
elseif(BASEARCH_X86_FOUND) |
| 716 |
add_definitions(-DX86_FEATURES) |
| 717 |
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/x86_features.h) |
| 718 |
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/x86_features.c) |
| 719 |
if(MSVC) |
| 720 |
list(APPEND ZLIB_ARCH_HDRS fallback_builtins.h) |
| 721 |
endif() |
| 722 |
if(WITH_AVX2) |
| 723 |
check_avx2_intrinsics() |
| 724 |
if(HAVE_AVX2_INTRIN) |
| 725 |
add_definitions(-DX86_AVX2 -DX86_AVX2_ADLER32 -DX86_AVX_CHUNKSET) |
| 726 |
set(AVX2_SRCS ${ARCHDIR}/slide_hash_avx2.c) |
| 727 |
add_feature_info(AVX2_SLIDEHASH 1 "Support AVX2 optimized slide_hash, using \"${AVX2FLAG}\"") |
| 728 |
list(APPEND AVX2_SRCS ${ARCHDIR}/chunkset_avx.c) |
| 729 |
add_feature_info(AVX_CHUNKSET 1 "Support AVX optimized chunkset, using \"${AVX2FLAG}\"") |
| 730 |
list(APPEND AVX2_SRCS ${ARCHDIR}/compare256_avx2.c) |
| 731 |
add_feature_info(AVX2_COMPARE256 1 "Support AVX2 optimized compare256, using \"${AVX2FLAG}\"") |
| 732 |
list(APPEND AVX2_SRCS ${ARCHDIR}/adler32_avx2.c) |
| 733 |
add_feature_info(AVX2_ADLER32 1 "Support AVX2-accelerated adler32, using \"${AVX2FLAG}\"") |
| 734 |
list(APPEND ZLIB_ARCH_SRCS ${AVX2_SRCS}) |
| 735 |
set_property(SOURCE ${AVX2_SRCS} PROPERTY COMPILE_FLAGS "${AVX2FLAG} ${NOLTOFLAG}") |
| 736 |
else() |
| 737 |
set(WITH_AVX2 OFF) |
| 738 |
endif() |
| 739 |
endif() |
| 740 |
if(WITH_AVX512) |
| 741 |
check_avx512_intrinsics() |
| 742 |
if(HAVE_AVX512_INTRIN) |
| 743 |
add_definitions(-DX86_AVX512 -DX86_AVX512_ADLER32) |
| 744 |
list(APPEND AVX512_SRCS ${ARCHDIR}/adler32_avx512.c) |
| 745 |
add_feature_info(AVX512_ADLER32 1 "Support AVX512-accelerated adler32, using \"${AVX512FLAG}\"") |
| 746 |
list(APPEND ZLIB_ARCH_SRCS ${AVX512_SRCS}) |
| 747 |
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/adler32_avx512_p.h) |
| 748 |
if(HAVE_MASK_INTRIN) |
| 749 |
add_definitions(-DX86_MASK_INTRIN) |
| 750 |
endif() |
| 751 |
set_property(SOURCE ${AVX512_SRCS} PROPERTY COMPILE_FLAGS "${AVX512FLAG} ${NOLTOFLAG}") |
| 752 |
else() |
| 753 |
set(WITH_AVX512 OFF) |
| 754 |
endif() |
| 755 |
endif() |
| 756 |
if(WITH_AVX512VNNI) |
| 757 |
check_avx512vnni_intrinsics() |
| 758 |
if(HAVE_AVX512VNNI_INTRIN) |
| 759 |
add_definitions(-DX86_AVX512VNNI -DX86_AVX512VNNI_ADLER32) |
| 760 |
add_feature_info(AVX512VNNI_ADLER32 1 "Support AVX512VNNI adler32, using \"${AVX512VNNIFLAG}\"") |
| 761 |
list(APPEND AVX512VNNI_SRCS ${ARCHDIR}/adler32_avx512_vnni.c) |
| 762 |
list(APPEND ZLIB_ARCH_SRCS ${AVX512VNNI_SRCS}) |
| 763 |
set_property(SOURCE ${AVX512VNNI_SRCS} PROPERTY COMPILE_FLAGS "${AVX512VNNIFLAG} ${NOLTOFLAG}") |
| 764 |
else() |
| 765 |
set(WITH_AVX512VNNI OFF) |
| 766 |
endif() |
| 767 |
endif() |
| 768 |
if(WITH_SSE41) |
| 769 |
check_sse41_intrinsics() |
| 770 |
if(HAVE_SSE41_INTRIN) |
| 771 |
add_definitions(-DX86_SSE41) |
| 772 |
list(APPEND SSE41_SRCS ${ARCHDIR}/chunkset_sse41.c) |
| 773 |
list(APPEND ZLIB_ARCH_SRCS ${SSE41_SRCS}) |
| 774 |
set_property(SOURCE ${SSE41_SRCS} PROPERTY COMPILE_FLAGS "${SSE41FLAG} ${NOLTOFLAG}") |
| 775 |
else() |
| 776 |
set(WITH_SSE41 OFF) |
| 777 |
endif() |
| 778 |
endif() |
| 779 |
if(WITH_SSE42) |
| 780 |
check_sse42_intrinsics() |
| 781 |
if(HAVE_SSE42CRC_INLINE_ASM OR HAVE_SSE42CRC_INTRIN) |
| 782 |
add_definitions(-DX86_SSE42_CRC_HASH -DX86_SSE42_ADLER32) |
| 783 |
set(SSE42_SRCS ${ARCHDIR}/adler32_sse42.c ${ARCHDIR}/insert_string_sse42.c) |
| 784 |
add_feature_info(SSE42_CRC 1 "Support SSE4.2 optimized CRC hash generation, using \"${SSE42FLAG}\"") |
| 785 |
list(APPEND ZLIB_ARCH_SRCS ${SSE42_SRCS}) |
| 786 |
set_property(SOURCE ${SSE42_SRCS} PROPERTY COMPILE_FLAGS "${SSE42FLAG} ${NOLTOFLAG}") |
| 787 |
if(HAVE_SSE42CRC_INTRIN) |
| 788 |
add_definitions(-DX86_SSE42_CRC_INTRIN) |
| 789 |
endif() |
| 790 |
endif() |
| 791 |
if(NOT HAVE_SSE42CRC_INLINE_ASM AND NOT HAVE_SSE42CRC_INTRIN AND NOT HAVE_SSE42CMPSTR_INTRIN) |
| 792 |
set(WITH_SSE4 OFF) |
| 793 |
endif() |
| 794 |
endif() |
| 795 |
if(FORCE_TZCNT) |
| 796 |
add_definitions(-DX86_NOCHECK_TZCNT) |
| 797 |
endif() |
| 798 |
add_feature_info(FORCE_TZCNT FORCE_TZCNT "Assume CPU is TZCNT capable") |
| 799 |
if(WITH_SSE2) |
| 800 |
check_sse2_intrinsics() |
| 801 |
if(HAVE_SSE2_INTRIN) |
| 802 |
add_definitions(-DX86_SSE2 -DX86_SSE2_CHUNKSET -DX86_SSE2_SLIDEHASH) |
| 803 |
set(SSE2_SRCS ${ARCHDIR}/chunkset_sse2.c ${ARCHDIR}/compare256_sse2.c ${ARCHDIR}/slide_hash_sse2.c) |
| 804 |
list(APPEND ZLIB_ARCH_SRCS ${SSE2_SRCS}) |
| 805 |
if(NOT ${ARCH} MATCHES "x86_64") |
| 806 |
set_property(SOURCE ${SSE2_SRCS} PROPERTY COMPILE_FLAGS "${SSE2FLAG} ${NOLTOFLAG}") |
| 807 |
add_feature_info(FORCE_SSE2 FORCE_SSE2 "Assume CPU is SSE2 capable") |
| 808 |
if(FORCE_SSE2) |
| 809 |
add_definitions(-DX86_NOCHECK_SSE2) |
| 810 |
endif() |
| 811 |
endif() |
| 812 |
else() |
| 813 |
set(WITH_SSE2 OFF) |
| 814 |
endif() |
| 815 |
endif() |
| 816 |
if(WITH_SSSE3) |
| 817 |
check_ssse3_intrinsics() |
| 818 |
if(HAVE_SSSE3_INTRIN) |
| 819 |
add_definitions(-DX86_SSSE3 -DX86_SSSE3_ADLER32) |
| 820 |
set(SSSE3_SRCS ${ARCHDIR}/adler32_ssse3.c) |
| 821 |
add_feature_info(SSSE3_ADLER32 1 "Support SSSE3-accelerated adler32, using \"${SSSE3FLAG}\"") |
| 822 |
list(APPEND ZLIB_ARCH_SRCS ${SSSE3_SRCS}) |
| 823 |
set_property(SOURCE ${SSSE3_SRCS} PROPERTY COMPILE_FLAGS "${SSSE3FLAG} ${NOLTOFLAG}") |
| 824 |
else() |
| 825 |
set(WITH_SSSE3 OFF) |
| 826 |
endif() |
| 827 |
endif() |
| 828 |
if(WITH_PCLMULQDQ AND WITH_SSSE3 AND WITH_SSE42) |
| 829 |
check_pclmulqdq_intrinsics() |
| 830 |
if(HAVE_PCLMULQDQ_INTRIN AND HAVE_SSSE3_INTRIN) |
| 831 |
add_definitions(-DX86_PCLMULQDQ_CRC) |
| 832 |
set(PCLMULQDQ_SRCS ${ARCHDIR}/crc32_fold_pclmulqdq.c) |
| 833 |
add_feature_info(PCLMUL_CRC 1 "Support CRC hash generation using PCLMULQDQ, using \"${SSSE3FLAG} ${SSE42FLAG} ${PCLMULFLAG}\"") |
| 834 |
list(APPEND ZLIB_ARCH_SRCS ${PCLMULQDQ_SRCS}) |
| 835 |
set_property(SOURCE ${PCLMULQDQ_SRCS} PROPERTY COMPILE_FLAGS "${SSSE3FLAG} ${SSE42FLAG} ${PCLMULFLAG} ${NOLTOFLAG}") |
| 836 |
|
| 837 |
if(WITH_VPCLMULQDQ AND WITH_AVX512) |
| 838 |
check_vpclmulqdq_intrinsics() |
| 839 |
if(HAVE_VPCLMULQDQ_INTRIN AND HAVE_AVX512_INTRIN) |
| 840 |
add_definitions(-DX86_VPCLMULQDQ_CRC) |
| 841 |
set(VPCLMULQDQ_SRCS ${ARCHDIR}/crc32_fold_vpclmulqdq.c) |
| 842 |
add_feature_info(VPCLMUL_CRC 1 "Support CRC hash generation using VPCLMULQDQ, using \"${VPCLMULFLAG} ${AVX512FLAG}\"") |
| 843 |
list(APPEND ZLIB_ARCH_SRCS ${VPCLMULQDQ_SRCS}) |
| 844 |
set_property(SOURCE ${VPCLMULQDQ_SRCS} PROPERTY COMPILE_FLAGS "${VPCLMULFLAG} ${AVX512FLAG} ${NOLTOFLAG}") |
| 845 |
else() |
| 846 |
set(WITH_VPCLMULQDQ OFF) |
| 847 |
endif() |
| 848 |
else() |
| 849 |
set(WITH_VPCLMULQDQ OFF) |
| 850 |
endif() |
| 851 |
else() |
| 852 |
set(WITH_PCLMULQDQ OFF) |
| 853 |
set(WITH_VPCLMULQDQ OFF) |
| 854 |
endif() |
| 855 |
else() |
| 856 |
set(WITH_PCLMULQDQ OFF) |
| 857 |
set(WITH_VPCLMULQDQ OFF) |
| 858 |
endif() |
| 859 |
endif() |
| 860 |
endif() |
| 861 |
|
| 862 |
message(STATUS "Architecture-specific source files: ${ZLIB_ARCH_SRCS}") |
| 863 |
|
| 864 |
#============================================================================ |
| 865 |
# zconf.h |
| 866 |
#============================================================================ |
| 867 |
|
| 868 |
macro(generate_cmakein input output) |
| 869 |
file(REMOVE ${output}) |
| 870 |
file(STRINGS ${input} _lines) |
| 871 |
foreach(_line IN LISTS _lines) |
| 872 |
string(REGEX REPLACE "#ifdef HAVE_UNISTD_H.*" "@ZCONF_UNISTD_LINE@" _line "${_line}") |
| 873 |
string(REGEX REPLACE "#ifdef NEED_PTRDIFF_T.*" "@ZCONF_PTRDIFF_LINE@" _line "${_line}") |
| 874 |
if(NEED_PTRDIFF_T) |
| 875 |
string(REGEX REPLACE "typedef PTRDIFF_TYPE" "typedef @PTRDIFF_TYPE@" _line "${_line}") |
| 876 |
endif() |
| 877 |
file(APPEND ${output} "${_line}\n") |
| 878 |
endforeach() |
| 879 |
endmacro(generate_cmakein) |
| 880 |
|
| 881 |
generate_cmakein( ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.in ${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h.cmakein ) |
| 882 |
|
| 883 |
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) |
| 884 |
# If we're doing an out of source build and the user has a zconf.h |
| 885 |
# in their source tree... |
| 886 |
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h) |
| 887 |
message(STATUS "Renaming") |
| 888 |
message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h") |
| 889 |
message(STATUS "to 'zconf${SUFFIX}.h.included' because this file is included with zlib") |
| 890 |
message(STATUS "but CMake generates it automatically in the build directory.") |
| 891 |
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.included) |
| 892 |
endif() |
| 893 |
|
| 894 |
# If we're doing an out of source build and the user has a zconf.h.cmakein |
| 895 |
# in their source tree... |
| 896 |
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.cmakein) |
| 897 |
message(STATUS "Renaming") |
| 898 |
message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.cmakein") |
| 899 |
message(STATUS "to 'zconf${SUFFIX}.h.cmakeincluded' because this file is included with zlib") |
| 900 |
message(STATUS "but CMake generates it automatically in the build directory.") |
| 901 |
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.cmakein ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.cmakeincluded) |
| 902 |
endif() |
| 903 |
endif() |
| 904 |
|
| 905 |
# Refer to prefix symbolically to ease relocation by end user, |
| 906 |
# as Makefile-generated .pc file does. |
| 907 |
if(INC_INSTALL_DIR STREQUAL "${CMAKE_INSTALL_PREFIX}/include") |
| 908 |
set(PC_INC_INSTALL_DIR "\${prefix}/include") |
| 909 |
else() |
| 910 |
set(PC_INC_INSTALL_DIR "${INC_INSTALL_DIR}") |
| 911 |
endif() |
| 912 |
if(LIB_INSTALL_DIR STREQUAL "${CMAKE_INSTALL_PREFIX}/lib") |
| 913 |
set(PC_LIB_INSTALL_DIR "\${exec_prefix}/lib") |
| 914 |
else() |
| 915 |
set(PC_LIB_INSTALL_DIR "${LIB_INSTALL_DIR}") |
| 916 |
endif() |
| 917 |
|
| 918 |
#============================================================================ |
| 919 |
# zlib |
| 920 |
#============================================================================ |
| 921 |
|
| 922 |
set(ZLIB_PUBLIC_HDRS |
| 923 |
${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h |
| 924 |
${CMAKE_CURRENT_BINARY_DIR}/zlib_name_mangling${SUFFIX}.h |
| 925 |
${CMAKE_CURRENT_BINARY_DIR}/zlib${SUFFIX}.h |
| 926 |
) |
| 927 |
set(ZLIB_PRIVATE_HDRS |
| 928 |
adler32_p.h |
| 929 |
chunkset_tpl.h |
| 930 |
cpu_features.h |
| 931 |
crc32_braid_p.h |
| 932 |
crc32_braid_comb_p.h |
| 933 |
crc32_braid_tbl.h |
| 934 |
crc32_fold.h |
| 935 |
deflate.h |
| 936 |
deflate_p.h |
| 937 |
functable.h |
| 938 |
inffast.h |
| 939 |
inffixed_tbl.h |
| 940 |
inflate.h |
| 941 |
inflate_p.h |
| 942 |
inftrees.h |
| 943 |
insert_string_tpl.h |
| 944 |
match_tpl.h |
| 945 |
trees.h |
| 946 |
trees_emit.h |
| 947 |
trees_tbl.h |
| 948 |
zbuild.h |
| 949 |
zendian.h |
| 950 |
zutil.h |
| 951 |
) |
| 952 |
set(ZLIB_SRCS |
| 953 |
adler32.c |
| 954 |
adler32_fold.c |
| 955 |
chunkset.c |
| 956 |
compare256.c |
| 957 |
compress.c |
| 958 |
cpu_features.c |
| 959 |
crc32_braid.c |
| 960 |
crc32_braid_comb.c |
| 961 |
crc32_fold.c |
| 962 |
deflate.c |
| 963 |
deflate_fast.c |
| 964 |
deflate_huff.c |
| 965 |
deflate_medium.c |
| 966 |
deflate_quick.c |
| 967 |
deflate_rle.c |
| 968 |
deflate_slow.c |
| 969 |
deflate_stored.c |
| 970 |
functable.c |
| 971 |
infback.c |
| 972 |
inffast.c |
| 973 |
inflate.c |
| 974 |
inftrees.c |
| 975 |
insert_string.c |
| 976 |
insert_string_roll.c |
| 977 |
slide_hash.c |
| 978 |
trees.c |
| 979 |
uncompr.c |
| 980 |
zutil.c |
| 981 |
) |
| 982 |
|
| 983 |
set(ZLIB_GZFILE_PRIVATE_HDRS |
| 984 |
gzguts.h |
| 985 |
) |
| 986 |
set(ZLIB_GZFILE_SRCS |
| 987 |
gzlib.c |
| 988 |
${CMAKE_CURRENT_BINARY_DIR}/gzread.c |
| 989 |
gzwrite.c |
| 990 |
) |
| 991 |
|
| 992 |
set(ZLIB_ALL_SRCS ${ZLIB_SRCS} ${ZLIB_ARCH_HDRS} ${ZLIB_ARCH_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) |
| 993 |
if(WITH_GZFILEOP) |
| 994 |
list(APPEND ZLIB_ALL_SRCS ${ZLIB_GZFILE_PRIVATE_HDRS} ${ZLIB_GZFILE_SRCS}) |
| 995 |
endif() |
| 996 |
|
| 997 |
if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) |
| 998 |
set(ZLIB_DLL_SRCS win32/zlib${SUFFIX}1.rc) |
| 999 |
endif() |
| 1000 |
|
| 1001 |
if(NOT DEFINED BUILD_SHARED_LIBS) |
| 1002 |
add_library(zlib SHARED ${ZLIB_ALL_SRCS} ${ZLIB_DLL_SRCS}) |
| 1003 |
add_library(zlibstatic STATIC ${ZLIB_ALL_SRCS}) |
| 1004 |
|
| 1005 |
set(ZLIB_INSTALL_LIBRARIES zlib zlibstatic) |
| 1006 |
else() |
| 1007 |
add_library(zlib ${ZLIB_ALL_SRCS}) |
| 1008 |
|
| 1009 |
if(BUILD_SHARED_LIBS) |
| 1010 |
target_sources(zlib PRIVATE ${ZLIB_DLL_SRCS}) |
| 1011 |
else() |
| 1012 |
add_library(zlibstatic ALIAS zlib) |
| 1013 |
endif() |
| 1014 |
|
| 1015 |
set(ZLIB_INSTALL_LIBRARIES zlib) |
| 1016 |
endif() |
| 1017 |
|
| 1018 |
foreach(ZLIB_INSTALL_LIBRARY ${ZLIB_INSTALL_LIBRARIES}) |
| 1019 |
if(NOT ZLIB_COMPAT) |
| 1020 |
target_compile_definitions(${ZLIB_INSTALL_LIBRARY} PUBLIC ZLIBNG_NATIVE_API) |
| 1021 |
endif() |
| 1022 |
target_include_directories(${ZLIB_INSTALL_LIBRARY} PUBLIC |
| 1023 |
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}>" |
| 1024 |
"$<INSTALL_INTERFACE:include>") |
| 1025 |
endforeach() |
| 1026 |
|
| 1027 |
if(WIN32) |
| 1028 |
# Shared library |
| 1029 |
if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) |
| 1030 |
set_target_properties(zlib PROPERTIES OUTPUT_NAME zlib${SUFFIX}) |
| 1031 |
endif() |
| 1032 |
# Static library |
| 1033 |
if(NOT DEFINED BUILD_SHARED_LIBS) |
| 1034 |
if(MSVC) |
| 1035 |
set_target_properties(zlibstatic PROPERTIES OUTPUT_NAME zlibstatic${SUFFIX}) |
| 1036 |
else() |
| 1037 |
set_target_properties(zlibstatic PROPERTIES OUTPUT_NAME z${SUFFIX}) |
| 1038 |
endif() |
| 1039 |
elseif(NOT BUILD_SHARED_LIBS) |
| 1040 |
if(MSVC) |
| 1041 |
set_target_properties(zlib PROPERTIES OUTPUT_NAME zlibstatic${SUFFIX}) |
| 1042 |
else() |
| 1043 |
set_target_properties(zlib PROPERTIES OUTPUT_NAME z${SUFFIX}) |
| 1044 |
endif() |
| 1045 |
endif() |
| 1046 |
else() |
| 1047 |
# On unix-like platforms the library is almost always called libz |
| 1048 |
set_target_properties(${ZLIB_INSTALL_LIBRARIES} PROPERTIES OUTPUT_NAME z${SUFFIX}) |
| 1049 |
endif() |
| 1050 |
|
| 1051 |
if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) |
| 1052 |
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) |
| 1053 |
|
| 1054 |
if(ZLIB_COMPAT) |
| 1055 |
set_target_properties(zlib PROPERTIES SOVERSION 1) |
| 1056 |
else() |
| 1057 |
set_target_properties(zlib PROPERTIES SOVERSION 2) |
| 1058 |
endif() |
| 1059 |
|
| 1060 |
if(NOT CYGWIN) |
| 1061 |
# This property causes shared libraries on Linux to have the full version |
| 1062 |
# encoded into their final filename. We disable this on Cygwin because |
| 1063 |
# it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll |
| 1064 |
# seems to be the default. |
| 1065 |
# |
| 1066 |
# This has no effect with MSVC, on that platform the version info for |
| 1067 |
# the DLL comes from the resource file win32/zlib1.rc |
| 1068 |
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION}) |
| 1069 |
endif() |
| 1070 |
|
| 1071 |
if(UNIX) |
| 1072 |
if(HAVE_NO_INTERPOSITION) |
| 1073 |
set_target_properties(zlib PROPERTIES COMPILE_FLAGS "-fno-semantic-interposition") |
| 1074 |
endif() |
| 1075 |
if(NOT APPLE) |
| 1076 |
set_target_properties(zlib PROPERTIES LINK_FLAGS |
| 1077 |
"-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib${SUFFIX}.map\"") |
| 1078 |
else() |
| 1079 |
# Match configure/make's behavior (i.e. don't use @rpath on mac). |
| 1080 |
set_target_properties(zlib PROPERTIES INSTALL_NAME_DIR "${LIB_INSTALL_DIR}") |
| 1081 |
endif() |
| 1082 |
endif() |
| 1083 |
if(MSYS OR CYGWIN) |
| 1084 |
# Suppress version number from shared library name |
| 1085 |
set(CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION 0) |
| 1086 |
elseif(WIN32) |
| 1087 |
# Creates zlib1.dll when building shared library version |
| 1088 |
if(ZLIB_COMPAT) |
| 1089 |
set_target_properties(zlib PROPERTIES SUFFIX "1.dll") |
| 1090 |
else() |
| 1091 |
set_target_properties(zlib PROPERTIES SUFFIX "2.dll") |
| 1092 |
endif() |
| 1093 |
endif() |
| 1094 |
endif() |
| 1095 |
|
| 1096 |
if(HAVE_UNISTD_H) |
| 1097 |
SET(ZCONF_UNISTD_LINE "#if 1 /* was set to #if 1 by configure/cmake/etc */") |
| 1098 |
else() |
| 1099 |
SET(ZCONF_UNISTD_LINE "#if 0 /* was set to #if 0 by configure/cmake/etc */") |
| 1100 |
endif() |
| 1101 |
if(NEED_PTRDIFF_T) |
| 1102 |
SET(ZCONF_PTRDIFF_LINE "#if 1 /* was set to #if 1 by configure/cmake/etc */") |
| 1103 |
else() |
| 1104 |
SET(ZCONF_PTRDIFF_LINE "#ifdef NEED_PTRDIFF_T /* may be set to #if 1 by configure/cmake/etc */") |
| 1105 |
endif() |
| 1106 |
|
| 1107 |
set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib${SUFFIX}.pc) |
| 1108 |
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein |
| 1109 |
${ZLIB_PC} @ONLY) |
| 1110 |
configure_file(${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h.cmakein |
| 1111 |
${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h @ONLY) |
| 1112 |
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib${SUFFIX}.h.in |
| 1113 |
${CMAKE_CURRENT_BINARY_DIR}/zlib${SUFFIX}.h @ONLY) |
| 1114 |
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/gzread.c.in |
| 1115 |
${CMAKE_CURRENT_BINARY_DIR}/gzread.c @ONLY) |
| 1116 |
|
| 1117 |
|
| 1118 |
if (NOT ZLIB_SYMBOL_PREFIX STREQUAL "") |
| 1119 |
add_feature_info(ZLIB_SYMBOL_PREFIX ON "Publicly exported symbols have a custom prefix") |
| 1120 |
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib_name_mangling${SUFFIX}.h.in |
| 1121 |
${CMAKE_CURRENT_BINARY_DIR}/zlib_name_mangling${SUFFIX}.h @ONLY) |
| 1122 |
else() |
| 1123 |
add_feature_info(ZLIB_SYMBOL_PREFIX OFF "Publicly exported symbols DO NOT have a custom prefix") |
| 1124 |
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib_name_mangling.h.empty |
| 1125 |
${CMAKE_CURRENT_BINARY_DIR}/zlib_name_mangling${SUFFIX}.h COPYONLY) |
| 1126 |
endif() |
| 1127 |
# add_definitions(-DZLIB_SYMBOL_PREFIX=${ZLIB_SYMBOL_PREFIX}) # not needed |
| 1128 |
|
| 1129 |
|
| 1130 |
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) |
| 1131 |
install(TARGETS ${ZLIB_INSTALL_LIBRARIES} |
| 1132 |
RUNTIME DESTINATION "${BIN_INSTALL_DIR}" |
| 1133 |
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}" |
| 1134 |
LIBRARY DESTINATION "${LIB_INSTALL_DIR}") |
| 1135 |
endif() |
| 1136 |
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL) |
| 1137 |
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zlib${SUFFIX}.h |
| 1138 |
DESTINATION "${INC_INSTALL_DIR}" RENAME zlib${SUFFIX}.h) |
| 1139 |
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zlib_name_mangling${SUFFIX}.h |
| 1140 |
DESTINATION "${INC_INSTALL_DIR}" RENAME zlib_name_mangling${SUFFIX}.h) |
| 1141 |
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h |
| 1142 |
DESTINATION "${INC_INSTALL_DIR}" RENAME zconf${SUFFIX}.h) |
| 1143 |
endif() |
| 1144 |
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL) |
| 1145 |
install(FILES ${ZLIB_PC} DESTINATION "${PKGCONFIG_INSTALL_DIR}") |
| 1146 |
endif() |
| 1147 |
|
| 1148 |
#============================================================================ |
| 1149 |
# Example binaries |
| 1150 |
#============================================================================ |
| 1151 |
|
| 1152 |
option(ZLIB_ENABLE_TESTS "Build test binaries" ON) |
| 1153 |
if(ZLIB_ENABLE_TESTS) |
| 1154 |
enable_testing() |
| 1155 |
|
| 1156 |
add_subdirectory(test) |
| 1157 |
endif() |
| 1158 |
|
| 1159 |
add_feature_info(WITH_GZFILEOP WITH_GZFILEOP "Compile with support for gzFile related functions") |
| 1160 |
add_feature_info(ZLIB_COMPAT ZLIB_COMPAT "Compile with zlib compatible API") |
| 1161 |
add_feature_info(ZLIB_ENABLE_TESTS ZLIB_ENABLE_TESTS "Build test binaries") |
| 1162 |
add_feature_info(WITH_SANITIZER WITH_SANITIZER "Enable sanitizer support") |
| 1163 |
add_feature_info(WITH_FUZZERS WITH_FUZZERS "Build test/fuzz") |
| 1164 |
add_feature_info(WITH_BENCHMARKS WITH_BENCHMARKS "Build test/benchmarks") |
| 1165 |
add_feature_info(WITH_BENCHMARK_APPS WITH_BENCHMARK_APPS "Build application benchmarks") |
| 1166 |
add_feature_info(WITH_OPTIM WITH_OPTIM "Build with optimisation") |
| 1167 |
add_feature_info(WITH_NEW_STRATEGIES WITH_NEW_STRATEGIES "Use new strategies") |
| 1168 |
add_feature_info(WITH_NATIVE_INSTRUCTIONS WITH_NATIVE_INSTRUCTIONS |
| 1169 |
"Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)") |
| 1170 |
add_feature_info(WITH_MAINTAINER_WARNINGS WITH_MAINTAINER_WARNINGS "Build with project maintainer warnings") |
| 1171 |
add_feature_info(WITH_CODE_COVERAGE WITH_CODE_COVERAGE "Enable code coverage reporting") |
| 1172 |
add_feature_info(WITH_INFLATE_STRICT WITH_INFLATE_STRICT "Build with strict inflate distance checking") |
| 1173 |
add_feature_info(WITH_INFLATE_ALLOW_INVALID_DIST WITH_INFLATE_ALLOW_INVALID_DIST "Build with zero fill for inflate invalid distances") |
| 1174 |
|
| 1175 |
if(BASEARCH_ARM_FOUND) |
| 1176 |
add_feature_info(WITH_ACLE WITH_ACLE "Build with ACLE") |
| 1177 |
add_feature_info(WITH_NEON WITH_NEON "Build with NEON intrinsics") |
| 1178 |
elseif(BASEARCH_PPC_FOUND) |
| 1179 |
add_feature_info(WITH_ALTIVEC WITH_ALTIVEC "Build with AltiVec optimisations") |
| 1180 |
add_feature_info(WITH_POWER8 WITH_POWER8 "Build with optimisations for POWER8") |
| 1181 |
add_feature_info(WITH_POWER9 WITH_POWER9 "Build with optimisations for POWER9") |
| 1182 |
elseif(BASEARCH_S360_FOUND) |
| 1183 |
add_feature_info(WITH_DFLTCC_DEFLATE WITH_DFLTCC_DEFLATE "Build with DFLTCC intrinsics for compression on IBM Z") |
| 1184 |
add_feature_info(WITH_DFLTCC_INFLATE WITH_DFLTCC_INFLATE "Build with DFLTCC intrinsics for decompression on IBM Z") |
| 1185 |
add_feature_info(WITH_CRC32_VX WITH_CRC32_VX "Build with vectorized CRC32 on IBM Z") |
| 1186 |
elseif(BASEARCH_X86_FOUND) |
| 1187 |
add_feature_info(WITH_AVX2 WITH_AVX2 "Build with AVX2") |
| 1188 |
add_feature_info(WITH_AVX512 WITH_AVX512 "Build with AVX512") |
| 1189 |
add_feature_info(WITH_AVX512VNNI WITH_AVX512VNNI "Build with AVX512 VNNI") |
| 1190 |
add_feature_info(WITH_SSE2 WITH_SSE2 "Build with SSE2") |
| 1191 |
add_feature_info(WITH_SSSE3 WITH_SSSE3 "Build with SSSE3") |
| 1192 |
add_feature_info(WITH_SSE41 WITH_SSE41 "Build with SSE41") |
| 1193 |
add_feature_info(WITH_SSE42 WITH_SSE42 "Build with SSE42") |
| 1194 |
add_feature_info(WITH_PCLMULQDQ WITH_PCLMULQDQ "Build with PCLMULQDQ") |
| 1195 |
add_feature_info(WITH_VPCLMULQDQ WITH_VPCLMULQDQ "Build with VPCLMULQDQ") |
| 1196 |
endif() |
| 1197 |
|
| 1198 |
add_feature_info(INSTALL_UTILS INSTALL_UTILS "Copy minigzip and minideflate during install") |
| 1199 |
|
| 1200 |
FEATURE_SUMMARY(WHAT ALL INCLUDE_QUIET_PACKAGES) |