Update TNG build system
[alexxy/gromacs.git] / src / external / tng_io / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.8)
2
3 project(TNG_IO)
4
5
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")
10 endif()
11
12 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
13 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
14
15 option(BUILD_SHARED_LIBS "Enable shared libraries" ON)
16
17 option(TNG_BUILD_FORTRAN "Build Fortran compatible library and examples for testing" OFF)
18
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)
22
23 find_package(ZLIB QUIET)
24 option(TNG_BUILD_WITH_ZLIB "Build TNG with zlib compression" ${ZLIB_FOUND})
25
26 include(CheckIncludeFile)
27 check_include_file(inttypes.h   HAVE_INTTYPES_H)
28
29 include(BuildTNG.cmake)
30 tng_get_source_list(TNG_SOURCES TNG_COMPILE_DEFS)
31
32 tng_set_source_properties(WITH_ZLIB ${ZLIB_FOUND})
33
34 if (ZLIB_FOUND)
35   list(APPEND EXTRA_LIBRARIES ${ZLIB_LIBRARIES})
36 endif()
37
38 if (UNIX)
39   list(APPEND EXTRA_LIBRARIES m)
40 endif()
41
42 add_library(tng_io ${TNG_SOURCES})
43
44 target_link_libraries(tng_io ${EXTRA_LIBRARIES})
45
46 set_target_properties(tng_io PROPERTIES VERSION ${TNG_IO_VERSION} SOVERSION ${TNG_MAJOR_VERSION})
47
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)
54
55 # Use GNUInstallDirst to set paths on multiarch systems
56 include(GNUInstallDirs)
57
58 # Install the tng_ioConfig.cmake and tng_ioConfigVersion.cmake
59 install(FILES
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")
63
64 install(TARGETS tng_io
65         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
66         ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
67
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)
70
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)
74   find_package(Doxygen)
75   if (NOT DOXYGEN_FOUND)
76     message(FATAL_ERROR
77       "Doxygen is needed to build the documentation. Please install it correctly")
78   endif()
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.
88
89   install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Documentation/
90       DESTINATION share/tng/doc)
91 endif()
92
93 add_subdirectory(src)
94