11cb0ef41Sopenharmony_cidiff --git a/third_party/zlib/CMakeLists.txt b/third_party/zlib/CMakeLists.txt 21cb0ef41Sopenharmony_ciindex b412dc7feb732..0431278405046 100644 31cb0ef41Sopenharmony_ci--- a/third_party/zlib/CMakeLists.txt 41cb0ef41Sopenharmony_ci+++ b/third_party/zlib/CMakeLists.txt 51cb0ef41Sopenharmony_ci@@ -1,4 +1,4 @@ 61cb0ef41Sopenharmony_ci-cmake_minimum_required(VERSION 2.4.4) 71cb0ef41Sopenharmony_ci+cmake_minimum_required(VERSION 3.0) 81cb0ef41Sopenharmony_ci set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci project(zlib C) 111cb0ef41Sopenharmony_ci@@ -21,6 +21,26 @@ check_include_file(sys/types.h HAVE_SYS_TYPES_H) 121cb0ef41Sopenharmony_ci check_include_file(stdint.h HAVE_STDINT_H) 131cb0ef41Sopenharmony_ci check_include_file(stddef.h HAVE_STDDEF_H) 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci+option(ENABLE_SIMD_OPTIMIZATIONS "Enable all SIMD optimizations" OFF) 161cb0ef41Sopenharmony_ci+ 171cb0ef41Sopenharmony_ci+# TODO(cavalcantii): add support for other OSes (e.g. Android, fuchsia, osx) 181cb0ef41Sopenharmony_ci+# and architectures (e.g. Arm). 191cb0ef41Sopenharmony_ci+if (ENABLE_SIMD_OPTIMIZATIONS) 201cb0ef41Sopenharmony_ci+ add_definitions(-DINFLATE_CHUNK_SIMD_SSE2) 211cb0ef41Sopenharmony_ci+ add_definitions(-DADLER32_SIMD_SSSE3) 221cb0ef41Sopenharmony_ci+ add_definitions(-DINFLATE_CHUNK_READ_64LE) 231cb0ef41Sopenharmony_ci+ add_definitions(-DCRC32_SIMD_SSE42_PCLMUL) 241cb0ef41Sopenharmony_ci+ add_definitions(-DDEFLATE_SLIDE_HASH_SSE2) 251cb0ef41Sopenharmony_ci+ add_compile_options(-msse4.2 -mpclmul) 261cb0ef41Sopenharmony_ci+ # Required by CPU features detection code. 271cb0ef41Sopenharmony_ci+ add_definitions(-DX86_NOT_WINDOWS) 281cb0ef41Sopenharmony_ci+ # Apparently some environments (e.g. CentOS) require to explicitly link 291cb0ef41Sopenharmony_ci+ # with pthread and that is required by the CPU features detection code. 301cb0ef41Sopenharmony_ci+ find_package (Threads REQUIRED) 311cb0ef41Sopenharmony_ci+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") 321cb0ef41Sopenharmony_ci+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") 331cb0ef41Sopenharmony_ci+endif() 341cb0ef41Sopenharmony_ci+ 351cb0ef41Sopenharmony_ci # 361cb0ef41Sopenharmony_ci # Check to see if we have large file support 371cb0ef41Sopenharmony_ci # 381cb0ef41Sopenharmony_ci@@ -120,10 +140,25 @@ set(ZLIB_SRCS 391cb0ef41Sopenharmony_ci zutil.c 401cb0ef41Sopenharmony_ci ) 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci-if(NOT MINGW) 431cb0ef41Sopenharmony_ci- set(ZLIB_DLL_SRCS 441cb0ef41Sopenharmony_ci- win32/zlib1.rc # If present will override custom build rule below. 451cb0ef41Sopenharmony_ci- ) 461cb0ef41Sopenharmony_ci+ 471cb0ef41Sopenharmony_ci+#============================================================================ 481cb0ef41Sopenharmony_ci+# Update list of source files if optimizations were enabled 491cb0ef41Sopenharmony_ci+#============================================================================ 501cb0ef41Sopenharmony_ci+if (ENABLE_SIMD_OPTIMIZATIONS) 511cb0ef41Sopenharmony_ci+ list(REMOVE_ITEM ZLIB_SRCS inflate.c) 521cb0ef41Sopenharmony_ci+ 531cb0ef41Sopenharmony_ci+ list(APPEND ZLIB_PRIVATE_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/adler32_simd.h) 541cb0ef41Sopenharmony_ci+ list(APPEND ZLIB_PRIVATE_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/optimizations/chunkcopy.h) 551cb0ef41Sopenharmony_ci+ list(APPEND ZLIB_PRIVATE_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/optimizations/inffast_chunk.h) 561cb0ef41Sopenharmony_ci+ list(APPEND ZLIB_PRIVATE_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/cpu_features.h) 571cb0ef41Sopenharmony_ci+ list(APPEND ZLIB_PRIVATE_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/crc32_simd.h) 581cb0ef41Sopenharmony_ci+ 591cb0ef41Sopenharmony_ci+ list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/adler32_simd.c) 601cb0ef41Sopenharmony_ci+ list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/optimizations/inffast_chunk.c) 611cb0ef41Sopenharmony_ci+ list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/optimizations/inflate.c) 621cb0ef41Sopenharmony_ci+ list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/cpu_features.c) 631cb0ef41Sopenharmony_ci+ list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/crc32_simd.c) 641cb0ef41Sopenharmony_ci+ list(APPEND ZLIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/crc_folding.c) 651cb0ef41Sopenharmony_ci endif() 661cb0ef41Sopenharmony_ci 671cb0ef41Sopenharmony_ci # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION 681cb0ef41Sopenharmony_ci@@ -191,23 +226,9 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) 691cb0ef41Sopenharmony_ci endif() 701cb0ef41Sopenharmony_ci 711cb0ef41Sopenharmony_ci #============================================================================ 721cb0ef41Sopenharmony_ci-# Example binaries 731cb0ef41Sopenharmony_ci+# Benchmarker 741cb0ef41Sopenharmony_ci #============================================================================ 751cb0ef41Sopenharmony_ci- 761cb0ef41Sopenharmony_ci-add_executable(example test/example.c) 771cb0ef41Sopenharmony_ci-target_link_libraries(example zlib) 781cb0ef41Sopenharmony_ci-add_test(example example) 791cb0ef41Sopenharmony_ci- 801cb0ef41Sopenharmony_ci-add_executable(minigzip test/minigzip.c) 811cb0ef41Sopenharmony_ci-target_link_libraries(minigzip zlib) 821cb0ef41Sopenharmony_ci- 831cb0ef41Sopenharmony_ci-if(HAVE_OFF64_T) 841cb0ef41Sopenharmony_ci- add_executable(example64 test/example.c) 851cb0ef41Sopenharmony_ci- target_link_libraries(example64 zlib) 861cb0ef41Sopenharmony_ci- set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") 871cb0ef41Sopenharmony_ci- add_test(example64 example64) 881cb0ef41Sopenharmony_ci- 891cb0ef41Sopenharmony_ci- add_executable(minigzip64 test/minigzip.c) 901cb0ef41Sopenharmony_ci- target_link_libraries(minigzip64 zlib) 911cb0ef41Sopenharmony_ci- set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") 921cb0ef41Sopenharmony_ci-endif() 931cb0ef41Sopenharmony_ci+enable_language(CXX) 941cb0ef41Sopenharmony_ci+set(CMAKE_CXX_STANDARD 14) # workaround for older compilers (e.g. g++ 5.4). 951cb0ef41Sopenharmony_ci+add_executable(zlib_bench contrib/bench/zlib_bench.cc) 961cb0ef41Sopenharmony_ci+target_link_libraries(zlib_bench zlib) 97