cmake_minimum_required(VERSION 2.8.8)

project(TNG_IO)


if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
    set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall")
elseif(WIN32)
    set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /W2")
endif()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

option(TNG_BUILD_FORTRAN "Build Fortran compatible library and examples for testing" OFF)
option(TNG_BUILD_EXAMPLES "Build examples showing usage of the TNG API" OFF)
option(TNG_BUILD_TEST "Build TNG testing binary." OFF)
option(TNG_BUILD_COMPRESSION_TESTS "Build tests of the TNG compression library" OFF)

option(TNG_BUILD_OWN_ZLIB "Build and use the internal zlib library" ON)
if(NOT TNG_BUILD_OWN_ZLIB)
  find_package(ZLIB QUIET)
endif()

if (ZLIB_FOUND AND NOT TNG_BUILD_OWN_ZLIB)
  list(APPEND EXTRA_LIBRARIES ${ZLIB_LIBRARIES})
  include_directories(${ZLIB_INCLUDE_DIRS})
  set(BUILD_OWN_ZLIB OFF)
else()
  set(BUILD_OWN_ZLIB ON)
endif()

include(CheckIncludeFile)
check_include_file(inttypes.h   HAVE_INTTYPES_H)

include(BuildTNG.cmake)
tng_get_source_list(${BUILD_OWN_ZLIB} TNG_SOURCES TNG_COMPILE_DEFS)

add_library(tng_io OBJECT ${TNG_SOURCES})

