Fix a -Wformat-truncation warning with gcc-8
[gromacs/tng.git] / CMakeLists.txt
blobbc6f8fd5aa0cbcbe97671ef1c3296a1018178cd2
1 cmake_minimum_required(VERSION 3.1)
3 project(TNG_IO C)
5 if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
6     set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall")
7 elseif(WIN32)
8     set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /W2")
9 endif()
11 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
12 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
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 option(TNG_BUILD_OWN_ZLIB "Build and use the internal zlib library" OFF)
24 if(NOT TNG_BUILD_OWN_ZLIB)
25   find_package(ZLIB QUIET)
26 endif()
28 include(CheckIncludeFile)
29 check_include_file(inttypes.h   HAVE_INTTYPES_H)
31 include(BuildTNG.cmake)
32 if (ZLIB_FOUND AND NOT TNG_BUILD_OWN_ZLIB)
33   add_tng_io_library(tng_io)
34 else()
35   add_tng_io_library(tng_io OWN_ZLIB)
36 endif()
38 # Use GNUInstallDirs to set paths on multiarch systems
39 include(GNUInstallDirs)
41 # Create the tng_ioConfig.cmake and tng_ioConfigVersion.cmake files for the install tree
42 configure_file(              src/lib/tng_io-config.cmake.in
43   "${CMAKE_CURRENT_BINARY_DIR}/cmake/tng_io-config.cmake" @ONLY)
44 configure_file(              src/lib/tng_io-configVersion.cmake.in
45   "${CMAKE_CURRENT_BINARY_DIR}/cmake/tng_io-configVersion.cmake" @ONLY)
47 install(TARGETS tng_io
48         EXPORT tng_io
49         LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
50         ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
52 install(EXPORT tng_io FILE tng_io.cmake
53         NAMESPACE tng_io::
54         DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/tng_io")
56 install(FILES
57         "${CMAKE_CURRENT_BINARY_DIR}/cmake/tng_io-config.cmake"
58         "${CMAKE_CURRENT_BINARY_DIR}/cmake/tng_io-configVersion.cmake"
59         DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/tng_io")
61 install(FILES
62         include/tng/tng_io.h include/tng/tng_io_fwd.h
63         ${CMAKE_CURRENT_BINARY_DIR}/include/tng/version.h
64         DESTINATION include/tng)
66 #-- Add an Option to toggle the generation of the API documentation
67 option(TNG_BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentation" OFF)
68 if(TNG_BUILD_DOCUMENTATION)
69   find_package(Doxygen)
70   if (NOT DOXYGEN_FOUND)
71     message(FATAL_ERROR
72       "Doxygen is needed to build the documentation. Please install it correctly")
73   endif()
74   #-- Configure the Template Doxyfile for our specific project
75   configure_file(Doxyfile.in
76                  ${PROJECT_BINARY_DIR}/Doxyfile  @ONLY IMMEDIATE)
77   #-- Add a custom target to run Doxygen when ever the project is built
78   add_custom_target (Docs ALL
79                                         COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile
80                                         SOURCES ${PROJECT_BINARY_DIR}/Doxyfile)
81   # IF you do NOT want the documentation to be generated EVERY time you build the project
82   # then leave out the 'ALL' keyword from the above command.
84   install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Documentation/
85       DESTINATION share/tng/doc)
86 endif()
88 add_subdirectory(src)