1 cmake_minimum_required(VERSION 2.8.8)
6 if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
7 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall")
8 elseif(WIN32 AND NOT CYGWIN)
9 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /W2")
12 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
13 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
15 option(BUILD_SHARED_LIBS "Enable shared libraries" ON)
17 option(TNG_BUILD_FORTRAN "Build Fortran compatible library and examples for testing" OFF)
19 option(TNG_BUILD_EXAMPLES "Build examples showing usage of the TNG API" ON)
20 option(TNG_BUILD_TEST "Build TNG testing binary." ON)
21 option(TNG_BUILD_COMPRESSION_TESTS "Build tests of the TNG compression library" OFF)
23 find_package(ZLIB QUIET)
24 option(TNG_BUILD_WITH_ZLIB "Build TNG with zlib compression" ${ZLIB_FOUND})
26 include(CheckIncludeFile)
27 check_include_file(inttypes.h HAVE_INTTYPES_H)
29 include(BuildTNG.cmake)
30 tng_get_source_list(TNG_SOURCES TNG_COMPILE_DEFS)
32 tng_set_source_properties(WITH_ZLIB ${ZLIB_FOUND})
35 list(APPEND EXTRA_LIBRARIES ${ZLIB_LIBRARIES})
39 list(APPEND EXTRA_LIBRARIES m)
42 add_library(tng_io ${TNG_SOURCES})
44 target_link_libraries(tng_io ${EXTRA_LIBRARIES})
46 set_target_properties(tng_io PROPERTIES VERSION ${TNG_IO_VERSION} SOVERSION ${TNG_MAJOR_VERSION})
48 # Create the tng_ioConfig.cmake and tng_ioConfigVersion.cmake files for the install tree
49 set(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include")
50 configure_file( src/lib/tng_io-config.cmake.in
51 "${CMAKE_CURRENT_BINARY_DIR}/cmake/tng_io-config.cmake" @ONLY)
52 configure_file( src/lib/tng_io-configVersion.cmake.in
53 "${CMAKE_CURRENT_BINARY_DIR}/cmake/tng_io-configVersion.cmake" @ONLY)
55 # Use GNUInstallDirst to set paths on multiarch systems
56 include(GNUInstallDirs)
58 # Install the tng_ioConfig.cmake and tng_ioConfigVersion.cmake
60 "${CMAKE_CURRENT_BINARY_DIR}/cmake/tng_io-config.cmake"
61 "${CMAKE_CURRENT_BINARY_DIR}/cmake/tng_io-configVersion.cmake"
62 DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/tng_io")
64 install(TARGETS tng_io
65 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
66 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
68 install(FILES include/tng/tng_io.h include/tng/tng_io_fwd.h ${CMAKE_CURRENT_BINARY_DIR}/include/tng/version.h
69 DESTINATION include/tng)
71 #-- Add an Option to toggle the generation of the API documentation
72 option(TNG_BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentation" OFF)
73 if(TNG_BUILD_DOCUMENTATION)
75 if (NOT DOXYGEN_FOUND)
77 "Doxygen is needed to build the documentation. Please install it correctly")
79 #-- Configure the Template Doxyfile for our specific project
80 configure_file(Doxyfile.in
81 ${PROJECT_BINARY_DIR}/Doxyfile @ONLY IMMEDIATE)
82 #-- Add a custom target to run Doxygen when ever the project is built
83 add_custom_target (Docs ALL
84 COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile
85 SOURCES ${PROJECT_BINARY_DIR}/Doxyfile)
86 # IF you do NOT want the documentation to be generated EVERY time you build the project
87 # then leave out the 'ALL' keyword from the above command.
89 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Documentation/
90 DESTINATION share/tng/doc)