#============================================================================
# zlib - original at src/lib/zlib
#============================================================================

set(ZLIB_ORIG_H)
set(ZLIB_STATIC)
set(ZLIB_SHARED)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
    ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)

list(APPEND ZLIB_ORIG_H ${CMAKE_CURRENT_BINARY_DIR}/zconf.h zlib.h)

list(APPEND ZLIB_ORIG_H crc32.h deflate.h inffast.h
                        inffixed.h inflate.h inftrees.h trees.h zutil.h)

list(APPEND ZLIB_ORIG_C adler32.c crc32.c deflate.c
                        inflate.c infback.c inftrees.c
                        inffast.c trees.c zutil.c)

set(ZLIB_ORIG_CORE ${ZLIB_ORIG_C} ${ZLIB_ORIG_H})

if(BUILD_STATIC_CDF)
  add_library(zlibstatic-orig OBJECT ${ZLIB_ORIG_CORE})
  target_compile_definitions(zlibstatic-orig PRIVATE Z_PREFIX)
  set_target_properties(zlibstatic-orig PROPERTIES POSITION_INDEPENDENT_CODE OFF)
  target_include_directories(zlibstatic-orig PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
  target_include_directories(zlibstatic-orig PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
endif()

if(BUILD_SHARED_CDF)
  add_library(zlib-orig OBJECT ${ZLIB_ORIG_CORE})
  target_compile_definitions(zlib-orig PRIVATE Z_PREFIX)
  set_target_properties(zlib-orig PROPERTIES POSITION_INDEPENDENT_CODE ON)
  target_include_directories(zlib-orig PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
  target_include_directories(zlib-orig PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
endif()

