head	1.1;
branch	1.1.1;
access;
symbols
	brotli-1-2-1:1.1.1.2
	netbsd-11-0-RELEASE:1.1.1.1
	netbsd-11-0-RC7:1.1.1.1
	netbsd-11-0-RC6:1.1.1.1
	netbsd-11-0-RC5:1.1.1.1
	netbsd-11-0-RC4:1.1.1.1
	netbsd-11-0-RC3:1.1.1.1
	netbsd-11-0-RC2:1.1.1.1
	netbsd-11-0-RC1:1.1.1.1
	netbsd-11:1.1.1.1.0.2
	netbsd-11-base:1.1.1.1
	brotli-1-0-9:1.1.1.1
	GOOGLE:1.1.1;
locks; strict;
comment	@# @;


1.1
date	2023.01.29.06.38.34;	author mrg;	state Exp;
branches
	1.1.1.1;
next	;
commitid	gOcuvoN6w4Ry1pbE;

1.1.1.1
date	2023.01.29.06.38.34;	author mrg;	state Exp;
branches
	1.1.1.1.2.1;
next	1.1.1.2;
commitid	gOcuvoN6w4Ry1pbE;

1.1.1.2
date	2026.10.28.21.11.59;	author mrg;	state Exp;
branches;
next	;
commitid	3cPg6n1vuoDZUh1H;

1.1.1.1.2.1
date	2026.10.29.16.03.48;	author martin;	state Exp;
branches;
next	;
commitid	Zd6vMoBhuWqLbo1H;


desc
@@


1.1
log
@Initial revision
@
text
@# Ubuntu 12.04 LTS has CMake 2.8.7, and is an important target since
# several CI services, such as Travis and Drone, use it.  Solaris 11
# has 2.8.6, and it's not difficult to support if you already have to
# support 2.8.7.
cmake_minimum_required(VERSION 2.8.6)

project(brotli C)

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "Setting build type to Release as none was specified.")
  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
else()
  message(STATUS "Build type is '${CMAKE_BUILD_TYPE}'")
endif()

include(CheckCSourceCompiles)
check_c_source_compiles(
  "#if defined(__EMSCRIPTEN__)
   int main() {return 0;}
   #endif"
  BROTLI_EMSCRIPTEN
)
if (BROTLI_EMSCRIPTEN)
  message("-- Compiler is EMSCRIPTEN")
else()
  message("-- Compiler is not EMSCRIPTEN")
endif()

# If Brotli is being bundled in another project, we don't want to
# install anything.  However, we want to let people override this, so
# we'll use the BROTLI_BUNDLED_MODE variable to let them do that; just
# set it to OFF in your project before you add_subdirectory(brotli).
get_directory_property(BROTLI_PARENT_DIRECTORY PARENT_DIRECTORY)
if(NOT DEFINED BROTLI_BUNDLED_MODE)
  # Bundled mode hasn't been set one way or the other, set the default
  # depending on whether or not we are the top-level project.
  if(BROTLI_PARENT_DIRECTORY)
    set(BROTLI_BUNDLED_MODE ON)
  else()
    set(BROTLI_BUNDLED_MODE OFF)
  endif()
endif()
mark_as_advanced(BROTLI_BUNDLED_MODE)

include(GNUInstallDirs)

# Parse version information from common/version.h. Normally we would
# define these values here and write them out to configuration file(s)
# (i.e., config.h), but in this case we parse them from
# common/version.h to be less intrusive.
function(hex_to_dec HEXADECIMAL DECIMAL)
  string(TOUPPER "${HEXADECIMAL}" _tail)
  set(_decimal 0)
  string(LENGTH "${_tail}" _tail_length)
  while (_tail_length GREATER 0)
    math(EXPR _decimal "${_decimal} * 16")
    string(SUBSTRING "${_tail}" 0 1 _digit)
    string(SUBSTRING "${_tail}" 1 -1 _tail)
    if (_digit STREQUAL "A")
      math(EXPR _decimal "${_decimal} + 10")
    elseif (_digit STREQUAL "B")
      math(EXPR _decimal "${_decimal} + 11")
    elseif (_digit STREQUAL "C")
      math(EXPR _decimal "${_decimal} + 12")
    elseif (_digit STREQUAL "D")
      math(EXPR _decimal "${_decimal} + 13")
    elseif (_digit STREQUAL "E")
      math(EXPR _decimal "${_decimal} + 14")
    elseif (_digit STREQUAL "F")
      math(EXPR _decimal "${_decimal} + 15")
    else()
      math(EXPR _decimal "${_decimal} + ${_digit}")
    endif()
    string(LENGTH "${_tail}" _tail_length)
  endwhile()
  set(${DECIMAL} ${_decimal} PARENT_SCOPE)
endfunction(hex_to_dec)

# Version information
file(STRINGS "c/common/version.h" _brotli_version_line REGEX "^#define BROTLI_VERSION (0x[0-9a-fA-F]+)$")
string(REGEX REPLACE "^#define BROTLI_VERSION 0x([0-9a-fA-F]+)$" "\\1" _brotli_version_hex "${_brotli_version_line}")
hex_to_dec("${_brotli_version_hex}" _brotli_version)
math(EXPR BROTLI_VERSION_MAJOR "${_brotli_version} >> 24")
math(EXPR BROTLI_VERSION_MINOR "(${_brotli_version} >> 12) & 4095")
math(EXPR BROTLI_VERSION_PATCH "${_brotli_version} & 4095")
set(BROTLI_VERSION "${BROTLI_VERSION_MAJOR}.${BROTLI_VERSION_MINOR}.${BROTLI_VERSION_PATCH}")
mark_as_advanced(BROTLI_VERSION BROTLI_VERSION_MAJOR BROTLI_VERSION_MINOR BROTLI_VERSION_PATCH)

# ABI Version information
file(STRINGS "c/common/version.h" _brotli_abi_info_line REGEX "^#define BROTLI_ABI_VERSION (0x[0-9a-fA-F]+)$")
string(REGEX REPLACE "^#define BROTLI_ABI_VERSION 0x([0-9a-fA-F]+)$" "\\1" _brotli_abi_info_hex "${_brotli_abi_info_line}")
hex_to_dec("${_brotli_abi_info_hex}" _brotli_abi_info)
math(EXPR BROTLI_ABI_CURRENT "${_brotli_abi_info} >> 24")
math(EXPR BROTLI_ABI_REVISION "(${_brotli_abi_info} >> 12) & 4095")
math(EXPR BROTLI_ABI_AGE "${_brotli_abi_info} & 4095")
math(EXPR BROTLI_ABI_COMPATIBILITY "${BROTLI_ABI_CURRENT} - ${BROTLI_ABI_AGE}")
mark_as_advanced(BROTLI_ABI_CURRENT BROTLI_ABI_REVISION BROTLI_ABI_AGE BROTLI_ABI_COMPATIBILITY)

if (ENABLE_SANITIZER)
  set(CMAKE_C_FLAGS " ${CMAKE_C_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
  set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${ENABLE_SANITIZER}")

  # By default, brotli depends on undefined behavior, but setting
  # BROTLI_BUILD_PORTABLE should result in a build which does not.
  if(ENABLE_SANITIZER STREQUAL "undefined")
    add_definitions(-DBROTLI_BUILD_PORTABLE)
  endif()
endif ()

include(CheckFunctionExists)
set(LIBM_LIBRARY)
CHECK_FUNCTION_EXISTS(log2 LOG2_RES)
if(NOT LOG2_RES)
  set(orig_req_libs "${CMAKE_REQUIRED_LIBRARIES}")
  set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};m")
  CHECK_FUNCTION_EXISTS(log2 LOG2_LIBM_RES)
  if(LOG2_LIBM_RES)
    set(LIBM_LIBRARY "m")
    add_definitions(-DBROTLI_HAVE_LOG2=1)
  else()
    add_definitions(-DBROTLI_HAVE_LOG2=0)
  endif()

  set(CMAKE_REQUIRED_LIBRARIES "${orig_req_libs}")
  unset(LOG2_LIBM_RES)
  unset(orig_req_libs)
else()
  add_definitions(-DBROTLI_HAVE_LOG2=1)
endif()
unset(LOG2_RES)

set(BROTLI_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/c/include")
mark_as_advanced(BROTLI_INCLUDE_DIRS)

set(BROTLI_LIBRARIES_CORE brotlienc brotlidec brotlicommon)
set(BROTLI_LIBRARIES ${BROTLI_LIBRARIES_CORE} ${LIBM_LIBRARY})
mark_as_advanced(BROTLI_LIBRARIES)

set(BROTLI_LIBRARIES_CORE_STATIC brotlienc-static brotlidec-static brotlicommon-static)
set(BROTLI_LIBRARIES_STATIC ${BROTLI_LIBRARIES_CORE_STATIC} ${LIBM_LIBRARY})
mark_as_advanced(BROTLI_LIBRARIES_STATIC)

if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
  add_definitions(-DOS_LINUX)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
  add_definitions(-DOS_FREEBSD)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  add_definitions(-DOS_MACOSX)
endif()

function(transform_sources_list INPUT_FILE OUTPUT_FILE)
  file(READ ${INPUT_FILE} TEXT)
  string(REGEX REPLACE "\\\\\n" "~continuation~" TEXT ${TEXT})
  string(REGEX REPLACE "([a-zA-Z_][a-zA-Z0-9_]*)[\t ]*=[\t ]*([^\n]*)" "SET(\\1 \\2)" TEXT ${TEXT})
  string(REPLACE "~continuation~" "\n" TEXT ${TEXT})
  file(WRITE ${OUTPUT_FILE} ${TEXT})
endfunction()

transform_sources_list("scripts/sources.lst" "${CMAKE_CURRENT_BINARY_DIR}/sources.lst.cmake")
include("${CMAKE_CURRENT_BINARY_DIR}/sources.lst.cmake")

if(BROTLI_EMSCRIPTEN)
  set(BROTLI_SHARED_LIBS "")
else()
  set(BROTLI_SHARED_LIBS brotlicommon brotlidec brotlienc)
  add_library(brotlicommon SHARED ${BROTLI_COMMON_C})
  add_library(brotlidec SHARED ${BROTLI_DEC_C})
  add_library(brotlienc SHARED ${BROTLI_ENC_C})
endif()

set(BROTLI_STATIC_LIBS brotlicommon-static brotlidec-static brotlienc-static)
add_library(brotlicommon-static STATIC ${BROTLI_COMMON_C})
add_library(brotlidec-static STATIC ${BROTLI_DEC_C})
add_library(brotlienc-static STATIC ${BROTLI_ENC_C})

# Older CMake versions does not understand INCLUDE_DIRECTORIES property.
include_directories(${BROTLI_INCLUDE_DIRS})

foreach(lib IN LISTS BROTLI_SHARED_LIBS)
  target_compile_definitions(${lib} PUBLIC "BROTLI_SHARED_COMPILATION" )
  string(TOUPPER "${lib}" LIB)
  set_target_properties (${lib} PROPERTIES DEFINE_SYMBOL "${LIB}_SHARED_COMPILATION")
endforeach()

foreach(lib IN LISTS BROTLI_SHARED_LIBS BROTLI_STATIC_LIBS)
  target_link_libraries(${lib} ${LIBM_LIBRARY})
  set_property(TARGET ${lib} APPEND PROPERTY INCLUDE_DIRECTORIES ${BROTLI_INCLUDE_DIRS})
  set_target_properties(${lib} PROPERTIES
    VERSION "${BROTLI_ABI_COMPATIBILITY}.${BROTLI_ABI_AGE}.${BROTLI_ABI_REVISION}"
    SOVERSION "${BROTLI_ABI_COMPATIBILITY}")
  if(NOT BROTLI_EMSCRIPTEN)
    set_target_properties(${lib} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
  endif()
  set_property(TARGET ${lib} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${BROTLI_INCLUDE_DIRS}")
endforeach()

if(NOT BROTLI_EMSCRIPTEN)
target_link_libraries(brotlidec brotlicommon)
target_link_libraries(brotlienc brotlicommon)
endif()

target_link_libraries(brotlidec-static brotlicommon-static)
target_link_libraries(brotlienc-static brotlicommon-static)

# For projects stuck on older versions of CMake, this will set the
# BROTLI_INCLUDE_DIRS and BROTLI_LIBRARIES variables so they still
# have a relatively easy way to use Brotli:
#
#   include_directories(${BROTLI_INCLUDE_DIRS})
#   target_link_libraries(foo ${BROTLI_LIBRARIES})
if(BROTLI_PARENT_DIRECTORY)
  set(BROTLI_INCLUDE_DIRS "${BROTLI_INCLUDE_DIRS}" PARENT_SCOPE)
  set(BROTLI_LIBRARIES "${BROTLI_LIBRARIES}" PARENT_SCOPE)
endif()

# Build the brotli executable
add_executable(brotli ${BROTLI_CLI_C})
target_link_libraries(brotli ${BROTLI_LIBRARIES_STATIC})

# Installation
if(NOT BROTLI_EMSCRIPTEN)
if(NOT BROTLI_BUNDLED_MODE)
  install(
    TARGETS brotli
    RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
  )

  install(
    TARGETS ${BROTLI_LIBRARIES_CORE}
    ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
    LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
    RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
  )

  install(
    TARGETS ${BROTLI_LIBRARIES_CORE_STATIC}
    ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
    LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
    RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
  )

  install(
    DIRECTORY ${BROTLI_INCLUDE_DIRS}/brotli
    DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
  )
endif()  # BROTLI_BUNDLED_MODE
endif()  # BROTLI_EMSCRIPTEN

# Tests

# If we're targeting Windows but not running on Windows, we need Wine
# to run the tests...
if(NOT BROTLI_DISABLE_TESTS)
  if(WIN32 AND NOT CMAKE_HOST_WIN32)
    find_program(BROTLI_WRAPPER NAMES wine)

    if(NOT BROTLI_WRAPPER)
      message(STATUS "wine not found, disabling tests")
      set(BROTLI_DISABLE_TESTS TRUE)
    endif()
  endif()
endif()

# If our compiler is a cross-compiler that we know about (arm/aarch64),
# then we need to use qemu to execute the tests.
if(NOT BROTLI_DISABLE_TESTS)
  if ("${CMAKE_C_COMPILER}" MATCHES "^.*/arm-linux-gnueabihf-.*$")
    message(STATUS "Detected arm-linux-gnueabihf cross-compilation")
    set(BROTLI_WRAPPER "qemu-arm")
    set(BROTLI_WRAPPER_LD_PREFIX "/usr/arm-linux-gnueabihf")
  endif()

  if ("${CMAKE_C_COMPILER}" MATCHES "^.*/arm-linux-gnueabi-.*$")
    message(STATUS "Detected arm-linux-gnueabi cross-compilation")
    set(BROTLI_WRAPPER "qemu-arm")
    set(BROTLI_WRAPPER_LD_PREFIX "/usr/arm-linux-gnueabi")
  endif()

  if ("${CMAKE_C_COMPILER}" MATCHES "^.*/aarch64-linux-gnu-.*$")
    message(STATUS "Detected aarch64-linux-gnu cross-compilation")
    set(BROTLI_WRAPPER "qemu-aarch64")
    set(BROTLI_WRAPPER_LD_PREFIX "/usr/aarch64-linux-gnu")
  endif()
endif()

if(NOT BROTLI_DISABLE_TESTS)
  include(CTest)
  enable_testing()

  set(ROUNDTRIP_INPUTS
    tests/testdata/alice29.txt
    tests/testdata/asyoulik.txt
    tests/testdata/lcet10.txt
    tests/testdata/plrabn12.txt
    c/enc/encode.c
    c/common/dictionary.h
    c/dec/decode.c)

  foreach(INPUT ${ROUNDTRIP_INPUTS})
    get_filename_component(OUTPUT_NAME "${INPUT}" NAME)

    set(OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}")
    set(INPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}")

    if (EXISTS "${INPUT_FILE}")
      foreach(quality 1 6 9 11)
        add_test(NAME "${BROTLI_TEST_PREFIX}roundtrip/${INPUT}/${quality}"
          COMMAND "${CMAKE_COMMAND}"
            -DBROTLI_WRAPPER=${BROTLI_WRAPPER}
            -DBROTLI_WRAPPER_LD_PREFIX=${BROTLI_WRAPPER_LD_PREFIX}
            -DBROTLI_CLI=$<TARGET_FILE:brotli>
            -DQUALITY=${quality}
            -DINPUT=${INPUT_FILE}
            -DOUTPUT=${OUTPUT_FILE}.${quality}
            -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/run-roundtrip-test.cmake)
      endforeach()
    else()
      message(WARNING "Test file ${INPUT} does not exist.")
    endif()
  endforeach()

  file(GLOB_RECURSE
    COMPATIBILITY_INPUTS
    RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
    tests/testdata/*.compressed*)

  foreach(INPUT ${COMPATIBILITY_INPUTS})
    add_test(NAME "${BROTLI_TEST_PREFIX}compatibility/${INPUT}"
      COMMAND "${CMAKE_COMMAND}"
        -DBROTLI_WRAPPER=${BROTLI_WRAPPER}
        -DBROTLI_WRAPPER_LD_PREFIX=${BROTLI_WRAPPER_LD_PREFIX}
        -DBROTLI_CLI=$<TARGET_FILE:brotli>
        -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}
        -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/run-compatibility-test.cmake)
  endforeach()
endif()

# Generate a pkg-config files

function(generate_pkg_config_path outvar path)
  string(LENGTH "${path}" path_length)

  set(path_args ${ARGV})
  list(REMOVE_AT path_args 0 1)
  list(LENGTH path_args path_args_remaining)

  set("${outvar}" "${path}")

  while(path_args_remaining GREATER 1)
    list(GET path_args 0 name)
    list(GET path_args 1 value)

    get_filename_component(value_full "${value}" ABSOLUTE)
    string(LENGTH "${value}" value_length)

    if(path_length EQUAL value_length AND path STREQUAL value)
      set("${outvar}" "\${${name}}")
      break()
    elseif(path_length GREATER value_length)
      # We might be in a subdirectory of the value, but we have to be
      # careful about a prefix matching but not being a subdirectory
      # (for example, /usr/lib64 is not a subdirectory of /usr/lib).
      # We'll do this by making sure the next character is a directory
      # separator.
      string(SUBSTRING "${path}" ${value_length} 1 sep)
      if(sep STREQUAL "/")
        string(SUBSTRING "${path}" 0 ${value_length} s)
        if(s STREQUAL value)
          string(SUBSTRING "${path}" "${value_length}" -1 suffix)
          set("${outvar}" "\${${name}}${suffix}")
          break()
        endif()
      endif()
    endif()

    list(REMOVE_AT path_args 0 1)
    list(LENGTH path_args path_args_remaining)
  endwhile()

  set("${outvar}" "${${outvar}}" PARENT_SCOPE)
endfunction(generate_pkg_config_path)

function(transform_pc_file INPUT_FILE OUTPUT_FILE VERSION)
  file(READ ${INPUT_FILE} TEXT)

  set(PREFIX "${CMAKE_INSTALL_PREFIX}")
  string(REGEX REPLACE "@@prefix@@" "${PREFIX}" TEXT ${TEXT})
  string(REGEX REPLACE "@@exec_prefix@@" "${PREFIX}" TEXT ${TEXT})

  generate_pkg_config_path(LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}" prefix "${PREFIX}")
  string(REGEX REPLACE "@@libdir@@" "${LIBDIR}" TEXT ${TEXT})

  generate_pkg_config_path(INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}" prefix "${PREFIX}")
  string(REGEX REPLACE "@@includedir@@" "${INCLUDEDIR}" TEXT ${TEXT})

  string(REGEX REPLACE "@@PACKAGE_VERSION@@" "${VERSION}" TEXT ${TEXT})

  file(WRITE ${OUTPUT_FILE} ${TEXT})
endfunction()

transform_pc_file("scripts/libbrotlicommon.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libbrotlicommon.pc" "${BROTLI_VERSION}")

transform_pc_file("scripts/libbrotlidec.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libbrotlidec.pc" "${BROTLI_VERSION}")

transform_pc_file("scripts/libbrotlienc.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libbrotlienc.pc" "${BROTLI_VERSION}")

if(NOT BROTLI_EMSCRIPTEN)
if(NOT BROTLI_BUNDLED_MODE)
  install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libbrotlicommon.pc"
    DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
  install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libbrotlidec.pc"
    DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
  install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libbrotlienc.pc"
    DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endif()  # BROTLI_BUNDLED_MODE
endif()  # BROTLI_EMSCRIPTEN

if (ENABLE_COVERAGE STREQUAL "yes")
  SETUP_TARGET_FOR_COVERAGE(coverage test coverage)
endif ()
@


1.1.1.1
log
@initial import of brotli 1.0.9.

modern blender wants freetype to have brotli support enabled or it
won't build.  fortunately, enabling the decoder support (all it
needs currently) is relatively easy and small (~160k on amd64)
without exposing brotli as a first class citizen is easy, so this
will be linked into xsrc freetype directly.

XXX: pullup-10?  or perhaps force -10 to use pkgsrc freetype?

from pkgsrc DESCR:
Brotli is a generic-purpose lossless compression algorithm that compresses data
using a combination of a modern variant of the LZ77 algorithm, Huffman coding
and 2nd order context modeling, with a compression ratio comparable to the best
currently available general-purpose compression methods. It is similar in speed
with deflate but offers more dense compression.
@
text
@@


1.1.1.1.2.1
log
@Pull up the following, requested by mrg in ticket #562:

	external/mit/brotli/dist/BUILD.bazel            up to 1.1.1.1
	external/mit/brotli/dist/c/common/dictionary_inc.h up to 1.1.1.1
	external/mit/brotli/dist/c/common/shared_dictionary.c up to 1.1.1.1
	external/mit/brotli/dist/c/common/shared_dictionary_internal.h up to 1.1.1.1
	external/mit/brotli/dist/c/common/static_init.h up to 1.1.1.1
	external/mit/brotli/dist/c/dec/prefix.c         up to 1.1.1.1
	external/mit/brotli/dist/c/dec/prefix_inc.h     up to 1.1.1.1
	external/mit/brotli/dist/c/dec/static_init.c    up to 1.1.1.1
	external/mit/brotli/dist/c/dec/static_init.h    up to 1.1.1.1
	external/mit/brotli/dist/c/include/brotli/shared_dictionary.h up to 1.1.1.1
	external/mit/brotli/dist/docs/brotli.svg        up to 1.1.1.1
	external/mit/brotli/dist/scripts/download_testdata.sh up to 1.1.1.1
	external/mit/brotli/dist/tests/testdata/zerosukkanooa.compressed up to 1.1.1.1
	external/mit/brotli/dist/tests/cli_test.sh      up to 1.1.1.1
	external/mit/brotli/dist/SECURITY.md            up to 1.1.1.1
	external/mit/brotli/dist/.bazelignore           up to 1.1.1.1
	external/mit/brotli/dist/CHANGELOG.md           up to 1.1.1.1
	external/mit/brotli/dist/BUILD                  delete
	external/mit/brotli/dist/Makefile               delete
	external/mit/brotli/dist/Makefile.am            delete
	external/mit/brotli/dist/WORKSPACE              delete
	external/mit/brotli/dist/bootstrap              delete
	external/mit/brotli/dist/compiler_config_setting.bzl delete
	external/mit/brotli/dist/configure              delete
	external/mit/brotli/dist/configure-cmake        delete
	external/mit/brotli/dist/configure.ac           delete
	external/mit/brotli/dist/premake5.lua           delete
	external/mit/brotli/dist/c/enc/backward_references.c delete
	external/mit/brotli/dist/c/enc/backward_references.h delete
	external/mit/brotli/dist/c/enc/backward_references_hq.c delete
	external/mit/brotli/dist/c/enc/backward_references_hq.h delete
	external/mit/brotli/dist/c/enc/backward_references_inc.h delete
	external/mit/brotli/dist/c/enc/bit_cost.c       delete
	external/mit/brotli/dist/c/enc/bit_cost.h       delete
	external/mit/brotli/dist/c/enc/bit_cost_inc.h   delete
	external/mit/brotli/dist/c/enc/block_encoder_inc.h delete
	external/mit/brotli/dist/c/enc/block_splitter.c delete
	external/mit/brotli/dist/c/enc/block_splitter.h delete
	external/mit/brotli/dist/c/enc/block_splitter_inc.h delete
	external/mit/brotli/dist/c/enc/brotli_bit_stream.c delete
	external/mit/brotli/dist/c/enc/brotli_bit_stream.h delete
	external/mit/brotli/dist/c/enc/cluster.c        delete
	external/mit/brotli/dist/c/enc/cluster.h        delete
	external/mit/brotli/dist/c/enc/cluster_inc.h    delete
	external/mit/brotli/dist/c/enc/command.c        delete
	external/mit/brotli/dist/c/enc/command.h        delete
	external/mit/brotli/dist/c/enc/compress_fragment.c delete
	external/mit/brotli/dist/c/enc/compress_fragment.h delete
	external/mit/brotli/dist/c/enc/compress_fragment_two_pass.c delete
	external/mit/brotli/dist/c/enc/compress_fragment_two_pass.h delete
	external/mit/brotli/dist/c/enc/dictionary_hash.c delete
	external/mit/brotli/dist/c/enc/dictionary_hash.h delete
	external/mit/brotli/dist/c/enc/encode.c         delete
	external/mit/brotli/dist/c/enc/encoder_dict.c   delete
	external/mit/brotli/dist/c/enc/encoder_dict.h   delete
	external/mit/brotli/dist/c/enc/entropy_encode.c delete
	external/mit/brotli/dist/c/enc/entropy_encode.h delete
	external/mit/brotli/dist/c/enc/entropy_encode_static.h delete
	external/mit/brotli/dist/c/enc/fast_log.c       delete
	external/mit/brotli/dist/c/enc/fast_log.h       delete
	external/mit/brotli/dist/c/enc/find_match_length.h delete
	external/mit/brotli/dist/c/enc/hash.h           delete
	external/mit/brotli/dist/c/enc/hash_composite_inc.h delete
	external/mit/brotli/dist/c/enc/hash_forgetful_chain_inc.h delete
	external/mit/brotli/dist/c/enc/hash_longest_match64_inc.h delete
	external/mit/brotli/dist/c/enc/hash_longest_match_inc.h delete
	external/mit/brotli/dist/c/enc/hash_longest_match_quickly_inc.h delete
	external/mit/brotli/dist/c/enc/hash_rolling_inc.h delete
	external/mit/brotli/dist/c/enc/hash_to_binary_tree_inc.h delete
	external/mit/brotli/dist/c/enc/histogram.c      delete
	external/mit/brotli/dist/c/enc/histogram.h      delete
	external/mit/brotli/dist/c/enc/histogram_inc.h  delete
	external/mit/brotli/dist/c/enc/literal_cost.c   delete
	external/mit/brotli/dist/c/enc/literal_cost.h   delete
	external/mit/brotli/dist/c/enc/memory.c         delete
	external/mit/brotli/dist/c/enc/memory.h         delete
	external/mit/brotli/dist/c/enc/metablock.c      delete
	external/mit/brotli/dist/c/enc/metablock.h      delete
	external/mit/brotli/dist/c/enc/metablock_inc.h  delete
	external/mit/brotli/dist/c/enc/params.h         delete
	external/mit/brotli/dist/c/enc/prefix.h         delete
	external/mit/brotli/dist/c/enc/quality.h        delete
	external/mit/brotli/dist/c/enc/utf8_util.c      delete
	external/mit/brotli/dist/c/enc/ringbuffer.h     delete
	external/mit/brotli/dist/c/enc/static_dict.c    delete
	external/mit/brotli/dist/c/enc/static_dict.h    delete
	external/mit/brotli/dist/c/enc/static_dict_lut.h delete
	external/mit/brotli/dist/c/enc/utf8_util.h      delete
	external/mit/brotli/dist/c/enc/write_bits.h     delete
	external/mit/brotli/dist/python/Makefile        delete
	external/mit/brotli/dist/python/README.md       delete
	external/mit/brotli/dist/python/_brotli.cc      delete
	external/mit/brotli/dist/python/bro.py          delete
	external/mit/brotli/dist/python/brotli.py       delete
	external/mit/brotli/dist/python/tests/__init__.py delete
	external/mit/brotli/dist/python/tests/_test_utils.py delete
	external/mit/brotli/dist/python/tests/bro_test.py delete
	external/mit/brotli/dist/python/tests/compress_test.py delete
	external/mit/brotli/dist/python/tests/compressor_test.py delete
	external/mit/brotli/dist/python/tests/decompress_test.py delete
	external/mit/brotli/dist/python/tests/decompressor_test.py delete
	external/mit/brotli/dist/scripts/sources.lst    delete
	external/mit/brotli/dist/tests/Makefile         delete
	external/mit/brotli/dist/tests/compatibility_test.sh delete
	external/mit/brotli/dist/tests/roundtrip_test.sh delete
	external/mit/brotli/dist/CMakeLists.txt         up to 1.1.1.2
	external/mit/brotli/dist/CONTRIBUTING.md        up to 1.1.1.2
	external/mit/brotli/dist/MANIFEST.in            up to 1.1.1.2
	external/mit/brotli/dist/README                 up to 1.1.1.2
	external/mit/brotli/dist/README.md              up to 1.1.1.2
	external/mit/brotli/dist/setup.cfg              up to 1.1.1.2
	external/mit/brotli/dist/setup.py               up to 1.1.1.2
	external/mit/brotli/dist/c/common/constants.c   up to 1.1.1.2
	external/mit/brotli/dist/c/common/constants.h   up to 1.1.1.2
	external/mit/brotli/dist/c/common/context.c     up to 1.1.1.2
	external/mit/brotli/dist/c/common/context.h     up to 1.1.1.2
	external/mit/brotli/dist/c/common/dictionary.c  up to 1.1.1.2
	external/mit/brotli/dist/c/common/dictionary.h  up to 1.1.1.2
	external/mit/brotli/dist/c/common/platform.c    up to 1.1.1.2
	external/mit/brotli/dist/c/common/platform.h    up to 1.2
	external/mit/brotli/dist/c/common/transform.c   up to 1.1.1.2
	external/mit/brotli/dist/c/common/transform.h   up to 1.1.1.2
	external/mit/brotli/dist/c/common/version.h     up to 1.1.1.2
	external/mit/brotli/dist/c/dec/bit_reader.c     up to 1.1.1.2
	external/mit/brotli/dist/c/dec/bit_reader.h     up to 1.1.1.2
	external/mit/brotli/dist/c/dec/decode.c         up to 1.1.1.2
	external/mit/brotli/dist/c/dec/huffman.c        up to 1.1.1.2
	external/mit/brotli/dist/c/dec/huffman.h        up to 1.1.1.2
	external/mit/brotli/dist/c/dec/prefix.h         up to 1.1.1.2
	external/mit/brotli/dist/c/dec/state.c          up to 1.1.1.2
	external/mit/brotli/dist/c/dec/state.h          up to 1.1.1.2
	external/mit/brotli/dist/c/include/brotli/decode.h up to 1.1.1.2
	external/mit/brotli/dist/c/include/brotli/encode.h up to 1.1.1.2
	external/mit/brotli/dist/c/include/brotli/port.h up to 1.1.1.2
	external/mit/brotli/dist/c/include/brotli/types.h up to 1.1.1.2
	external/mit/brotli/dist/c/tools/brotli.c       up to 1.1.1.2
	external/mit/brotli/dist/c/tools/brotli.md      up to 1.1.1.2
	external/mit/brotli/dist/docs/brotli.1          up to 1.1.1.2
	external/mit/brotli/dist/docs/constants.h.3     up to 1.1.1.2
	external/mit/brotli/dist/docs/decode.h.3        up to 1.1.1.2
	external/mit/brotli/dist/docs/encode.h.3        up to 1.1.1.2
	external/mit/brotli/dist/docs/types.h.3         up to 1.1.1.2
	external/mit/brotli/dist/scripts/libbrotlicommon.pc.in up to 1.1.1.2
	external/mit/brotli/dist/scripts/libbrotlidec.pc.in up to 1.1.1.2
	external/mit/brotli/dist/scripts/libbrotlienc.pc.in up to 1.1.1.2

Initial import of brotli 1.2.1, that fixes CVE 2026-111497.
@
text
@d1 6
a6 10
# Available CMake versions:
#  - Ubuntu  20.04 LTS   : 3.16.3
#  - Solaris 11.4 SRU 15 : 3.15
cmake_minimum_required(VERSION 3.15)

# Since this project's version is loaded from other files, this policy
# will help suppress the warning generated by cmake.
# This policy is set because we can't provide "VERSION" in "project" command.
# Use `cmake --help-policy CMP0048` for more information.
cmake_policy(SET CMP0048 NEW)
d9 3
a11 3
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "Setting build type to Release as none was specified")
  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build" FORCE)
a28 14
if (BROTLI_EMSCRIPTEN)
  message(STATUS "Switching to static build for EMSCRIPTEN")
  set(BUILD_SHARED_LIBS OFF)
endif()

# Reflect CMake variable as a build option.
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
set(BROTLI_BUILD_TOOLS ON CACHE BOOL "Build/install CLI tools")
set(BROTLI_BUILD_FOR_PACKAGE OFF CACHE BOOL "Build/install both shared and static libraries")

if (BROTLI_BUILD_FOR_PACKAGE AND NOT BUILD_SHARED_LIBS)
  message(FATAL_ERROR "Both BROTLI_BUILD_FOR_PACKAGE and BUILD_SHARED_LIBS are set")
endif()

d34 1
a34 1
if (NOT DEFINED BROTLI_BUNDLED_MODE)
d37 1
a37 1
  if (BROTLI_PARENT_DIRECTORY)
d42 1
a42 1
endif()  # BROTLI_BUNDLED_MODE
d47 31
a77 6
# Reads macro from .h file; it is expected to be a single-line define.
function(read_macro PATH MACRO OUTPUT)
  file(STRINGS ${PATH} _line REGEX "^#define +${MACRO} +(.+)$")
  string(REGEX REPLACE "^#define +${MACRO} +(.+)$" "\\1" _val "${_line}")
  set(${OUTPUT} ${_val} PARENT_SCOPE)
endfunction(read_macro)
d80 6
a85 3
read_macro("c/common/version.h" "BROTLI_VERSION_MAJOR" BROTLI_VERSION_MAJOR)
read_macro("c/common/version.h" "BROTLI_VERSION_MINOR" BROTLI_VERSION_MINOR)
read_macro("c/common/version.h" "BROTLI_VERSION_PATCH" BROTLI_VERSION_PATCH)
d90 6
a95 3
read_macro("c/common/version.h" "BROTLI_ABI_CURRENT" BROTLI_ABI_CURRENT)
read_macro("c/common/version.h" "BROTLI_ABI_REVISION" BROTLI_ABI_REVISION)
read_macro("c/common/version.h" "BROTLI_ABI_AGE" BROTLI_ABI_AGE)
d103 6
d111 1
a111 1
include(CheckLibraryExists)
d113 10
a122 6
set(LIBM_DEP)
CHECK_LIBRARY_EXISTS(m log2 "" HAVE_LIB_M)
if (HAVE_LIB_M)
  set(LIBM_LIBRARY "m")
  if (NOT BUILD_SHARED_LIBS)
    set(LIBM_DEP "-lm")
d124 6
d131 1
d136 2
a137 14
if (BROTLI_BUILD_FOR_PACKAGE)
  set(BROTLI_SHARED_LIBRARIES brotlienc brotlidec brotlicommon)
  set(BROTLI_STATIC_LIBRARIES brotlienc-static brotlidec-static brotlicommon-static)
  set(BROTLI_LIBRARIES ${BROTLI_SHARED_LIBRARIES} ${LIBM_LIBRARY})
else()  # NOT BROTLI_BUILD_FOR_PACKAGE
  if (BUILD_SHARED_LIBS)
    set(BROTLI_SHARED_LIBRARIES brotlienc brotlidec brotlicommon)
    set(BROTLI_STATIC_LIBRARIES)
  else()  # NOT BUILD_SHARED_LIBS
    set(BROTLI_SHARED_LIBRARIES)
    set(BROTLI_STATIC_LIBRARIES brotlienc brotlidec brotlicommon)
  endif()
  set(BROTLI_LIBRARIES ${BROTLI_SHARED_LIBRARIES} ${BROTLI_STATIC_LIBRARIES} ${LIBM_LIBRARY})
endif()  # BROTLI_BUILD_FOR_PACKAGE
d140 10
a149 4
if (MSVC)
  message(STATUS "Defining _CRT_SECURE_NO_WARNINGS to avoid warnings about security")

  add_definitions(-D_CRT_SECURE_NO_WARNINGS)
d152 7
a158 3
file(GLOB_RECURSE BROTLI_COMMON_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} c/common/*.c)
file(GLOB_RECURSE BROTLI_DEC_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} c/dec/*.c)
file(GLOB_RECURSE BROTLI_ENC_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} c/enc/*.c)
d160 2
a161 3
add_library(brotlicommon ${BROTLI_COMMON_SOURCES})
add_library(brotlidec ${BROTLI_DEC_SOURCES})
add_library(brotlienc ${BROTLI_ENC_SOURCES})
d163 7
a169 4
if (BROTLI_BUILD_FOR_PACKAGE)
  add_library(brotlicommon-static STATIC ${BROTLI_COMMON_SOURCES})
  add_library(brotlidec-static STATIC ${BROTLI_DEC_SOURCES})
  add_library(brotlienc-static STATIC ${BROTLI_ENC_SOURCES})
d172 5
d180 5
a184 7
if (BUILD_SHARED_LIBS)
  foreach(lib ${BROTLI_SHARED_LIBRARIES})
    target_compile_definitions(${lib} PUBLIC "BROTLI_SHARED_COMPILATION" )
    string(TOUPPER "${lib}" LIB)
    set_target_properties (${lib} PROPERTIES DEFINE_SYMBOL "${LIB}_SHARED_COMPILATION")
  endforeach()
endif()  # BUILD_SHARED_LIBS
d186 1
a186 1
foreach(lib ${BROTLI_SHARED_LIBRARIES} ${BROTLI_STATIC_LIBRARIES})
d192 1
a192 1
  if (NOT BROTLI_EMSCRIPTEN)
d195 2
a196 2
  set_property(TARGET ${lib} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${BROTLI_INCLUDE_DIRS}>")
endforeach()  # BROTLI_xxx_LIBRARIES
d198 1
d201 4
d212 1
a212 1
if (BROTLI_PARENT_DIRECTORY)
d218 2
a219 4
if (BROTLI_BUILD_TOOLS)
  add_executable(brotli c/tools/brotli.c)
  target_link_libraries(brotli ${BROTLI_LIBRARIES})
endif()
d222 13
a234 7
if (NOT BROTLI_BUNDLED_MODE)
  if (BROTLI_BUILD_TOOLS)
    install(
      TARGETS brotli
      RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
    )
  endif()
d237 1
a237 1
    TARGETS ${BROTLI_SHARED_LIBRARIES} ${BROTLI_STATIC_LIBRARIES}
d248 1
d252 4
a255 5
# Integration tests, those depend on `brotli` binary
if (NOT BROTLI_DISABLE_TESTS AND BROTLI_BUILD_TOOLS)
  # If we're targeting Windows but not running on Windows, we need Wine
  # to run the tests...
  if (WIN32 AND NOT CMAKE_HOST_WIN32)
d258 1
a258 1
    if (NOT BROTLI_WRAPPER)
d262 2
a263 9
  endif()  # WIN32 emulation
  if (BROTLI_EMSCRIPTEN)
    find_program(BROTLI_WRAPPER NAMES node)
    if (NOT BROTLI_WRAPPER)
      message(STATUS "node not found, disabling tests")
      set(BROTLI_DISABLE_TESTS TRUE)
    endif()
  endif()  # BROTLI_EMSCRIPTEN
endif()  # BROTLI_DISABLE_TESTS
d265 3
a267 4
# NB: BROTLI_DISABLE_TESTS might have changed.
if (NOT BROTLI_DISABLE_TESTS AND BROTLI_BUILD_TOOLS)
  # If our compiler is a cross-compiler that we know about (arm/aarch64),
  # then we need to use qemu to execute the tests.
d285 1
d287 1
d319 1
a319 1
      message(NOTICE "Test file ${INPUT} does not exist; OK on tarball builds; consider running scripts/download_testdata.sh before configuring.")
d329 7
a335 10
    string(REGEX REPLACE "([a-zA-Z0-9\\.]+)\\.compressed(\\.[0-9]+)?$" "\\1" UNCOMPRESSED_INPUT "${INPUT}")
    if (EXISTS ${UNCOMPRESSED_INPUT})
      add_test(NAME "${BROTLI_TEST_PREFIX}compatibility/${INPUT}"
        COMMAND "${CMAKE_COMMAND}"
          -DBROTLI_WRAPPER=${BROTLI_WRAPPER}
          -DBROTLI_WRAPPER_LD_PREFIX=${BROTLI_WRAPPER_LD_PREFIX}
          -DBROTLI_CLI=$<TARGET_FILE:brotli>
          -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}
          -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/run-compatibility-test.cmake)
    endif()
d337 1
a337 1
endif()  # BROTLI_DISABLE_TESTS
d357 1
a357 1
    if (path_length EQUAL value_length AND path STREQUAL value)
d360 1
a360 1
    elseif (path_length GREATER value_length)
d367 1
a367 1
      if (sep STREQUAL "/")
d369 1
a369 1
        if (s STREQUAL value)
a389 1
  string(REGEX REPLACE "@@libm@@" "${LIBM_DEP}" TEXT ${TEXT})
d408 2
a409 1
if (NOT BROTLI_BUNDLED_MODE)
d417 1
a417 8

if (BROTLI_BUILD_TOOLS)
  install(FILES "docs/brotli.1"
    DESTINATION "${CMAKE_INSTALL_FULL_MANDIR}/man1")
endif()

install(FILES docs/constants.h.3 docs/decode.h.3 docs/encode.h.3 docs/types.h.3
  DESTINATION "${CMAKE_INSTALL_FULL_MANDIR}/man3")
d420 2
a421 2
  setup_target_for_coverage(coverage test coverage)
endif()
@


1.1.1.2
log
@Initial import of brotli 1.2.1, that fixes CVE 2026-111497.

also includes enhancements in dictionary handling, static init of
some data to reduce size, and minor other clean ups.

the new go and python code, as well as the ignored C encoder are
not included in this import as we don't use them, and they are
more than half the space.
@
text
@d1 6
a6 10
# Available CMake versions:
#  - Ubuntu  20.04 LTS   : 3.16.3
#  - Solaris 11.4 SRU 15 : 3.15
cmake_minimum_required(VERSION 3.15)

# Since this project's version is loaded from other files, this policy
# will help suppress the warning generated by cmake.
# This policy is set because we can't provide "VERSION" in "project" command.
# Use `cmake --help-policy CMP0048` for more information.
cmake_policy(SET CMP0048 NEW)
d9 3
a11 3
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "Setting build type to Release as none was specified")
  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build" FORCE)
a28 14
if (BROTLI_EMSCRIPTEN)
  message(STATUS "Switching to static build for EMSCRIPTEN")
  set(BUILD_SHARED_LIBS OFF)
endif()

# Reflect CMake variable as a build option.
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
set(BROTLI_BUILD_TOOLS ON CACHE BOOL "Build/install CLI tools")
set(BROTLI_BUILD_FOR_PACKAGE OFF CACHE BOOL "Build/install both shared and static libraries")

if (BROTLI_BUILD_FOR_PACKAGE AND NOT BUILD_SHARED_LIBS)
  message(FATAL_ERROR "Both BROTLI_BUILD_FOR_PACKAGE and BUILD_SHARED_LIBS are set")
endif()

d34 1
a34 1
if (NOT DEFINED BROTLI_BUNDLED_MODE)
d37 1
a37 1
  if (BROTLI_PARENT_DIRECTORY)
d42 1
a42 1
endif()  # BROTLI_BUNDLED_MODE
d47 31
a77 6
# Reads macro from .h file; it is expected to be a single-line define.
function(read_macro PATH MACRO OUTPUT)
  file(STRINGS ${PATH} _line REGEX "^#define +${MACRO} +(.+)$")
  string(REGEX REPLACE "^#define +${MACRO} +(.+)$" "\\1" _val "${_line}")
  set(${OUTPUT} ${_val} PARENT_SCOPE)
endfunction(read_macro)
d80 6
a85 3
read_macro("c/common/version.h" "BROTLI_VERSION_MAJOR" BROTLI_VERSION_MAJOR)
read_macro("c/common/version.h" "BROTLI_VERSION_MINOR" BROTLI_VERSION_MINOR)
read_macro("c/common/version.h" "BROTLI_VERSION_PATCH" BROTLI_VERSION_PATCH)
d90 6
a95 3
read_macro("c/common/version.h" "BROTLI_ABI_CURRENT" BROTLI_ABI_CURRENT)
read_macro("c/common/version.h" "BROTLI_ABI_REVISION" BROTLI_ABI_REVISION)
read_macro("c/common/version.h" "BROTLI_ABI_AGE" BROTLI_ABI_AGE)
d103 6
d111 1
a111 1
include(CheckLibraryExists)
d113 10
a122 6
set(LIBM_DEP)
CHECK_LIBRARY_EXISTS(m log2 "" HAVE_LIB_M)
if (HAVE_LIB_M)
  set(LIBM_LIBRARY "m")
  if (NOT BUILD_SHARED_LIBS)
    set(LIBM_DEP "-lm")
d124 6
d131 1
d136 2
a137 14
if (BROTLI_BUILD_FOR_PACKAGE)
  set(BROTLI_SHARED_LIBRARIES brotlienc brotlidec brotlicommon)
  set(BROTLI_STATIC_LIBRARIES brotlienc-static brotlidec-static brotlicommon-static)
  set(BROTLI_LIBRARIES ${BROTLI_SHARED_LIBRARIES} ${LIBM_LIBRARY})
else()  # NOT BROTLI_BUILD_FOR_PACKAGE
  if (BUILD_SHARED_LIBS)
    set(BROTLI_SHARED_LIBRARIES brotlienc brotlidec brotlicommon)
    set(BROTLI_STATIC_LIBRARIES)
  else()  # NOT BUILD_SHARED_LIBS
    set(BROTLI_SHARED_LIBRARIES)
    set(BROTLI_STATIC_LIBRARIES brotlienc brotlidec brotlicommon)
  endif()
  set(BROTLI_LIBRARIES ${BROTLI_SHARED_LIBRARIES} ${BROTLI_STATIC_LIBRARIES} ${LIBM_LIBRARY})
endif()  # BROTLI_BUILD_FOR_PACKAGE
d140 10
a149 4
if (MSVC)
  message(STATUS "Defining _CRT_SECURE_NO_WARNINGS to avoid warnings about security")

  add_definitions(-D_CRT_SECURE_NO_WARNINGS)
d152 7
a158 3
file(GLOB_RECURSE BROTLI_COMMON_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} c/common/*.c)
file(GLOB_RECURSE BROTLI_DEC_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} c/dec/*.c)
file(GLOB_RECURSE BROTLI_ENC_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} c/enc/*.c)
d160 2
a161 3
add_library(brotlicommon ${BROTLI_COMMON_SOURCES})
add_library(brotlidec ${BROTLI_DEC_SOURCES})
add_library(brotlienc ${BROTLI_ENC_SOURCES})
d163 7
a169 4
if (BROTLI_BUILD_FOR_PACKAGE)
  add_library(brotlicommon-static STATIC ${BROTLI_COMMON_SOURCES})
  add_library(brotlidec-static STATIC ${BROTLI_DEC_SOURCES})
  add_library(brotlienc-static STATIC ${BROTLI_ENC_SOURCES})
d172 5
d180 5
a184 7
if (BUILD_SHARED_LIBS)
  foreach(lib ${BROTLI_SHARED_LIBRARIES})
    target_compile_definitions(${lib} PUBLIC "BROTLI_SHARED_COMPILATION" )
    string(TOUPPER "${lib}" LIB)
    set_target_properties (${lib} PROPERTIES DEFINE_SYMBOL "${LIB}_SHARED_COMPILATION")
  endforeach()
endif()  # BUILD_SHARED_LIBS
d186 1
a186 1
foreach(lib ${BROTLI_SHARED_LIBRARIES} ${BROTLI_STATIC_LIBRARIES})
d192 1
a192 1
  if (NOT BROTLI_EMSCRIPTEN)
d195 2
a196 2
  set_property(TARGET ${lib} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${BROTLI_INCLUDE_DIRS}>")
endforeach()  # BROTLI_xxx_LIBRARIES
d198 1
d201 4
d212 1
a212 1
if (BROTLI_PARENT_DIRECTORY)
d218 2
a219 4
if (BROTLI_BUILD_TOOLS)
  add_executable(brotli c/tools/brotli.c)
  target_link_libraries(brotli ${BROTLI_LIBRARIES})
endif()
d222 13
a234 7
if (NOT BROTLI_BUNDLED_MODE)
  if (BROTLI_BUILD_TOOLS)
    install(
      TARGETS brotli
      RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
    )
  endif()
d237 1
a237 1
    TARGETS ${BROTLI_SHARED_LIBRARIES} ${BROTLI_STATIC_LIBRARIES}
d248 1
d252 4
a255 5
# Integration tests, those depend on `brotli` binary
if (NOT BROTLI_DISABLE_TESTS AND BROTLI_BUILD_TOOLS)
  # If we're targeting Windows but not running on Windows, we need Wine
  # to run the tests...
  if (WIN32 AND NOT CMAKE_HOST_WIN32)
d258 1
a258 1
    if (NOT BROTLI_WRAPPER)
d262 2
a263 9
  endif()  # WIN32 emulation
  if (BROTLI_EMSCRIPTEN)
    find_program(BROTLI_WRAPPER NAMES node)
    if (NOT BROTLI_WRAPPER)
      message(STATUS "node not found, disabling tests")
      set(BROTLI_DISABLE_TESTS TRUE)
    endif()
  endif()  # BROTLI_EMSCRIPTEN
endif()  # BROTLI_DISABLE_TESTS
d265 3
a267 4
# NB: BROTLI_DISABLE_TESTS might have changed.
if (NOT BROTLI_DISABLE_TESTS AND BROTLI_BUILD_TOOLS)
  # If our compiler is a cross-compiler that we know about (arm/aarch64),
  # then we need to use qemu to execute the tests.
d285 1
d287 1
d319 1
a319 1
      message(NOTICE "Test file ${INPUT} does not exist; OK on tarball builds; consider running scripts/download_testdata.sh before configuring.")
d329 7
a335 10
    string(REGEX REPLACE "([a-zA-Z0-9\\.]+)\\.compressed(\\.[0-9]+)?$" "\\1" UNCOMPRESSED_INPUT "${INPUT}")
    if (EXISTS ${UNCOMPRESSED_INPUT})
      add_test(NAME "${BROTLI_TEST_PREFIX}compatibility/${INPUT}"
        COMMAND "${CMAKE_COMMAND}"
          -DBROTLI_WRAPPER=${BROTLI_WRAPPER}
          -DBROTLI_WRAPPER_LD_PREFIX=${BROTLI_WRAPPER_LD_PREFIX}
          -DBROTLI_CLI=$<TARGET_FILE:brotli>
          -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}
          -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/run-compatibility-test.cmake)
    endif()
d337 1
a337 1
endif()  # BROTLI_DISABLE_TESTS
d357 1
a357 1
    if (path_length EQUAL value_length AND path STREQUAL value)
d360 1
a360 1
    elseif (path_length GREATER value_length)
d367 1
a367 1
      if (sep STREQUAL "/")
d369 1
a369 1
        if (s STREQUAL value)
a389 1
  string(REGEX REPLACE "@@libm@@" "${LIBM_DEP}" TEXT ${TEXT})
d408 2
a409 1
if (NOT BROTLI_BUNDLED_MODE)
d417 1
a417 8

if (BROTLI_BUILD_TOOLS)
  install(FILES "docs/brotli.1"
    DESTINATION "${CMAKE_INSTALL_FULL_MANDIR}/man1")
endif()

install(FILES docs/constants.h.3 docs/decode.h.3 docs/encode.h.3 docs/types.h.3
  DESTINATION "${CMAKE_INSTALL_FULL_MANDIR}/man3")
d420 2
a421 2
  setup_target_for_coverage(coverage test coverage)
endif()
@

