Adding DOCUMENTATION flag to the CMakeLists.txt
[libt2n] / CMakeLists.txt
CommitLineData
ab2a4234
KK
1# Project
2project(libt2n)
4bf435eb 3set(VERSION 0.8)
ab2a4234
KK
4set(PROTOCOL_VERSION 1) # protocol version used (integers, increase version if incompatible)
5set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
6
7# CMake
8set(CMAKE_COLOR_MAKEFILE ON)
9cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
10
11# Source package generation
12set(CPACK_SOURCE_GENERATOR TGZ)
13set(CPACK_SOURCE_IGNORE_FILES "~$;\\\\.git;build;build-rpm")
14set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION}")
15
8192a7a0
TJ
16# "make dist" target
17set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${VERSION})
18add_custom_target(dist
19 COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
20 | bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
21 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
22
ab2a4234
KK
23# Find external packages
24include(FindPkgConfig)
25
26find_package(Boost 1.33 REQUIRED COMPONENTS serialization unit_test_framework)
27include_directories(${Boost_INCLUDE_DIRS})
28
29pkg_check_modules(XMLPP REQUIRED libxml++-2.6>=2.8.1)
30include_directories(${XMLPP_INCLUDE_DIRS})
31link_directories(${XMLPP_LIBRARY_DIRS})
32
33# Documentation
d717a064 34option(DOCUMENTATION "Generate API documentation with Doxygen" ON)
ab2a4234 35find_package(Doxygen)
d717a064 36if(DOXYGEN_FOUND AND DOCUMENTATION)
ab2a4234
KK
37 # Find doxy config
38 message(STATUS "Doxygen found.")
39 set(DOXY_DIR "${CMAKE_SOURCE_DIR}/doc")
40 set(DOXY_CONFIG "${DOXY_DIR}/Doxyfile.in")
41
42 # Copy doxy.config.in
ccb4d3d3 43 set(top_srcdir ${CMAKE_SOURCE_DIR})
ab2a4234
KK
44 configure_file("${DOXY_CONFIG}" "${CMAKE_BINARY_DIR}/doxy.config")
45
46 # Create doc directory
47 add_custom_command(
48 OUTPUT ${CMAKE_BINARY_DIR}/doc
49 COMMAND rm -rf ${CMAKE_BINARY_DIR}/doc/{html,man}
50 COMMAND mkdir -p ${CMAKE_BINARY_DIR}/doc
51 DEPENDS codegen examples examples-codegen src test
52 )
53
54 # Run doxygen
55 add_custom_command(
56 OUTPUT ${CMAKE_BINARY_DIR}/doc/html/index.html
57 COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_BINARY_DIR}/doxy.config"
58 DEPENDS "${CMAKE_BINARY_DIR}/doxy.config" "${CMAKE_BINARY_DIR}/doc"
59 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/doc
60 )
61
62 add_custom_target(docs ALL DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html)
63
64 message(STATUS "Generating API documentation with Doxygen.")
d717a064 65else(DOXYGEN_FOUND AND DOCUMENTATION)
ab2a4234 66 message(STATUS "Not generating API documentation.")
d717a064 67endif(DOXYGEN_FOUND AND DOCUMENTATION)
ab2a4234
KK
68
69# Spec file
70configure_file(${CMAKE_SOURCE_DIR}/libt2n.spec.in ${CMAKE_SOURCE_DIR}/libt2n.spec @ONLY)
71
72# Check include files and availability of libraries for config file
73include(CheckIncludeFiles)
74
75if(Boost_FOUND)
76 set(HAVE_BOOST 1)
77endif()
78if(Boost_SERIALIZATION_FOUND)
79 set(HAVE_BOOST_SERIALIZATION 1)
80endif()
81if(Boost_UNIT_TEST_FRAMEWORK_FOUND)
82 set(HAVE_BOOST_UNIT_TEST_FRAMEWORK 1)
83endif()
84check_include_files(dlfcn.h HAVE_DLFCN_H)
85check_include_files(inttypes.h HAVE_INTTYPES_H)
86check_include_files(memory.h HAVE_MEMORY_H)
87check_include_files(stdint.h HAVE_STDINT_H)
88check_include_files(stdlib.h HAVE_STDLIB_H)
89check_include_files(strings.h HAVE_STRINGS_H)
90check_include_files(string.h HAVE_STRING_H)
91check_include_files(sys/stat.h HAVE_SYS_STAT_H)
92check_include_files(sys/types.h HAVE_SYS_TYPES_H)
93check_include_files(unistd.h HAVE_UNISTD_H)
94set(STDC_HEADER_NAMES
95 assert.h
96 ctype.h
97 errno.h
98 float.h
99 limits.h
100 locale.h
101 math.h
102 setjmp.h
103 signal.h
104 stdarg.h
105 stddef.h
106 stdio.h
107 stdlib.h
108 string.h
109 time.h
110)
111check_include_files("${STDC_HEADER_NAMES}" STDC_HEADERS)
112
113# Config file
114configure_file(${CMAKE_SOURCE_DIR}/config.h.in.cmake ${CMAKE_BINARY_DIR}/config.h)
115include_directories(BEFORE ${CMAKE_BINARY_DIR})
116
117# PkgConfig output
118set(prefix ${CMAKE_INSTALL_PREFIX})
119set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
120set(includedir ${CMAKE_INSTALL_PREFIX}/include)
121set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
122set(bindir ${exec_prefix})
123set(datadir ${CMAKE_INSTALL_PREFIX}/share)
124
125# PkgConfig files
126configure_file(${CMAKE_SOURCE_DIR}/libt2n.pc.in ${CMAKE_BINARY_DIR}/libt2n.pc @ONLY)
127install(FILES ${CMAKE_BINARY_DIR}/libt2n.pc DESTINATION lib/pkgconfig)
128
129# Installation of scripts
7ba38527 130install(PROGRAMS libt2n-gccxml.sh DESTINATION bin)
ab2a4234
KK
131
132# Subdirectories
133set(CPACK_SET_DESTDIR "ON")
134add_subdirectory(src)
135add_subdirectory(test)
ab2a4234 136add_subdirectory(codegen)
7ba38527
KK
137add_subdirectory(examples EXCLUDE_FROM_ALL)
138add_subdirectory(examples-codegen EXCLUDE_FROM_ALL)
ab2a4234
KK
139
140include(CPack)