<commit_before>cmake_minimum_required(VERSION 2.8.11)

project(Zopfli)

#
# Library version
#
set(ZOPFLI_VERSION_MAJOR 1)
set(ZOPFLI_VERSION_MINOR 0)
set(ZOPFLI_VERSION_PATCH 2)
set(ZOPFLI_VERSION "${ZOPFLI_VERSION_MAJOR}.${ZOPFLI_VERSION_MINOR}.${ZOPFLI_VERSION_PATCH}")

option(BUILD_SHARED_LIBS "Build Zopfli with shared libraries" OFF)
option(ZOPFLI_BUILD_INSTALL "Add Zopfli install target" ON)

if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Release)
endif()

if(MSVC)
  add_definitions(/D_CRT_SECURE_NO_WARNINGS)
endif()

set(zopflilib_src
  src/zopfli/blocksplitter.c
  src/zopfli/cache.c
  src/zopfli/deflate.c
  src/zopfli/gzip_container.c
  src/zopfli/hash.c
  src/zopfli/katajainen.c
  src/zopfli/lz77.c
  src/zopfli/squeeze.c
  src/zopfli/tree.c
  src/zopfli/util.c
  src/zopfli/zlib_container.c
  src/zopfli/zopfli_lib.c
)

set(zopflipnglib_src
  src/zopflipng/zopflipng_lib.cc
)

set (lodepng_src
  src/zopflipng/lodepng/lodepng.cpp
  src/zopflipng/lodepng/lodepng_util.cpp
)

#
# libzopfli object files shared by both libraries
#
add_library(zopflilib_obj OBJECT
  ${zopflilib_src}
)
if(BUILD_SHARED_LIBS)
  set_property(TARGET zopflilib_obj PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()

#
# libzopfli
#
add_library(libzopfli
  $<TARGET_OBJECTS:zopflilib_obj>
)
set_target_properties(libzopfli PROPERTIES
  OUTPUT_NAME zopfli
  VERSION ${ZOPFLI_VERSION}
  SOVERSION ${ZOPFLI_VERSION_MAJOR}
)
if(UNIX)
  target_link_libraries(libzopfli m)
endif()

#
# libzopflipng
#
add_library(libzopflipng
  ${zopflipnglib_src}
  ${lodepng_src}
  $<TARGET_OBJECTS:zopflilib_obj>
)
set_target_properties(libzopflipng PROPERTIES
  OUTPUT_NAME zopflipng
  VERSION ${ZOPFLI_VERSION}
  SOVERSION ${ZOPFLI_VERSION_MAJOR}
)

#
# zopfli
#
add_executable(zopfli src/zopfli/zopfli_bin.c)
target_link_libraries(zopfli libzopfli)

#<commit_msg>Add include directory to library targets<commit_after>cmake_minimum_required(VERSION 2.8.11)

project(Zopfli)

#
# Library version
#
set(ZOPFLI_VERSION_MAJOR 1)
set(ZOPFLI_VERSION_MINOR 0)
set(ZOPFLI_VERSION_PATCH 2)
set(ZOPFLI_VERSION "${ZOPFLI_VERSION_MAJOR}.${ZOPFLI_VERSION_MINOR}.${ZOPFLI_VERSION_PATCH}")

option(BUILD_SHARED_LIBS "Build Zopfli with shared libraries" OFF)
option(ZOPFLI_BUILD_INSTALL "Add Zopfli install target" ON)

if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Release)
endif()

if(MSVC)
  add_definitions(/D_CRT_SECURE_NO_WARNINGS)
endif()

set(zopflilib_src
  src/zopfli/blocksplitter.c
  src/zopfli/cache.c
  src/zopfli/deflate.c
  src/zopfli/gzip_container.c
  src/zopfli/hash.c
  src/zopfli/katajainen.c
  src/zopfli/lz77.c
  src/zopfli/squeeze.c
  src/zopfli/tree.c
  src/zopfli/util.c
  src/zopfli/zlib_container.c
  src/zopfli/zopfli_lib.c
)

set(zopflipnglib_src
  src/zopflipng/zopflipng_lib.cc
)

set (lodepng_src
  src/zopflipng/lodepng/lodepng.cpp
  src/zopflipng/lodepng/lodepng_util.cpp
)

#
# libzopfli object files shared by both libraries
#
add_library(zopflilib_obj OBJECT
  ${zopflilib_src}
)
if(BUILD_SHARED_LIBS)
  set_property(TARGET zopflilib_obj PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()

#
# libzopfli
#
add_library(libzopfli
  $<TARGET_OBJECTS:zopflilib_obj>
)
target_include_directories(libzopfli INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src/zopfli")
set_target_properties(libzopfli PROPERTIES
  OUTPUT_NAME zopfli
  VERSION ${ZOPFLI_VERSION}
  SOVERSION ${ZOPFLI_VERSION_MAJOR}
)
if(UNIX)
  target_link_libraries(libzopfli m)
endif()

#
# libzopflipng
#
add_library(libzopflipng
  ${zopflipnglib_src}
  ${lodepng_src}
  $<TARGET_OBJECTS:zopflilib_obj>
)
target_include_directories(libzopflipng INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src/zopflipng")
set_target_properties(libzopflipng PROPERTIES
  OUTPUT_NAME zopflipng
  VERSION ${ZOPFLI_VERSION}
  SOVERSION ${ZOPFLI_VERSION_MAJOR}
)

#
# zopfli
#
add_executable(zopfli src/zopfli/zopfli_bin.c)
target_link_libraries(zopfli libzopfli)

#
{'fraction_non_alphanumeric': 0.09631728045325778, 'fraction_numerical': 0.004635591037857327, 'mean_word_length': 6.412213740458015, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4174671', 'n_tokens_mistral': 1846, 'n_tokens_neox': 1737, 'n_words': 217}