Commit | Line | Data |
---|---|---|
6cb16c21 KK |
1 | # Project |
2 | project(libasyncio) | |
3 | set(VERSION 0.2) | |
4 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}") | |
5 | ||
6 | # CMake | |
7 | set(CMAKE_COLOR_MAKEFILE ON) | |
8 | cmake_minimum_required(VERSION 2.6 FATAL_ERROR) | |
9 | ||
10 | # Source package generation | |
11 | set(CPACK_SOURCE_GENERATOR TGZ) | |
12 | set(CPACK_SOURCE_IGNORE_FILES "~$;\\\\.git;build;build-rpm") | |
13 | set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION}") | |
14 | ||
15 | # Find external packages | |
16 | include(FindPkgConfig) | |
17 | ||
18 | option(WITH_LIBI2NCOMMON OFF) | |
19 | if(WITH_LIBI2NCOMMON) | |
20 | pkg_check_modules(LIBI2NCOMMON REQUIRED libi2ncommon) | |
21 | include_directories(${LIBI2NCOMMON_INCLUDE_DIRS}) | |
22 | link_directories(${LIBI2NCOMMON_LIBRARY_DIRS}) | |
23 | elseif(WITH_LIBI2NCOMMON) | |
24 | message(STATUS "[!] Building *without* libi2ncommon support. [!]") | |
25 | endif(WITH_LIBI2NCOMMON) | |
26 | ||
27 | find_package(Boost 1.34 REQUIRED COMPONENTS signals unit_test_framework) | |
28 | include_directories(${Boost_INCLUDE_DIRS}) | |
29 | ||
30 | option(WITH_LIBT2N OFF) | |
31 | if(WITH_LIBT2N) | |
32 | pkg_check_modules(LIBT2N REQUIRED libt2n) | |
33 | include_directories(${LIBT2N_INCLUDE_DIRS}) | |
34 | link_directories(${LIBT2N_LIBRARY_DIRS}) | |
35 | set(T2NDIRS glue_t2n) | |
36 | elseif(WITH_LIBT2N) | |
37 | message(STATUS "[!] Building *without* libt2n support. [!]") | |
38 | endif(WITH_LIBT2N) | |
39 | ||
40 | # Documentation | |
41 | find_package(Doxygen) | |
42 | if(DOXYGEN_FOUND) | |
43 | # Find doxy config | |
44 | message(STATUS "Doxygen found.") | |
45 | set(DOXY_DIR "${CMAKE_SOURCE_DIR}/doc") | |
46 | set(DOXY_CONFIG "${DOXY_DIR}/Doxyfile.in") | |
47 | ||
48 | # Copy doxy.config.in | |
49 | configure_file("${DOXY_CONFIG}" "${CMAKE_BINARY_DIR}/doxy.config") | |
50 | ||
51 | # Create doc directory | |
52 | add_custom_command( | |
53 | OUTPUT ${CMAKE_BINARY_DIR}/doc | |
54 | COMMAND rm -rf ${CMAKE_BINARY_DIR}/doc/{html,man} | |
55 | COMMAND mkdir -p ${CMAKE_BINARY_DIR}/doc | |
56 | DEPENDS utils asyncio ${T2NDIRS} unittest | |
57 | ) | |
58 | ||
59 | # Run doxygen | |
60 | add_custom_command( | |
61 | OUTPUT ${CMAKE_BINARY_DIR}/doc/html/index.html | |
62 | COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_BINARY_DIR}/doxy.config" | |
63 | DEPENDS "${CMAKE_BINARY_DIR}/doxy.config" "${CMAKE_BINARY_DIR}/doc" | |
64 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/doc | |
65 | ) | |
66 | ||
67 | add_custom_target(docs ALL DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html) | |
68 | ||
69 | message(STATUS "Generating API documentation with Doxygen.") | |
70 | else(DOXYGEN_FOUND) | |
71 | message(STATUS "Not generating API documentation.") | |
72 | endif(DOXYGEN_FOUND) | |
73 | ||
74 | # Spec file | |
75 | configure_file(${CMAKE_SOURCE_DIR}/libasyncio.spec.in ${CMAKE_SOURCE_DIR}/libasyncio.spec @ONLY) | |
76 | ||
77 | # Config file | |
78 | configure_file(${CMAKE_SOURCE_DIR}/asyncio_config.hpp.in.cmake ${CMAKE_BINARY_DIR}/asyncio_config.hpp) | |
79 | include_directories(BEFORE ${CMAKE_BINARY_DIR}) | |
80 | ||
81 | # PkgConfig output | |
82 | set(prefix ${CMAKE_INSTALL_PREFIX}) | |
83 | set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin) | |
84 | set(includedir ${CMAKE_INSTALL_PREFIX}/include) | |
85 | set(libdir ${CMAKE_INSTALL_PREFIX}/lib) | |
86 | ||
87 | # PkgConfig files | |
88 | configure_file(${CMAKE_SOURCE_DIR}/asyncio/libasyncio.pc.in ${CMAKE_BINARY_DIR}/asyncio/libasyncio.pc @ONLY) | |
89 | configure_file(${CMAKE_SOURCE_DIR}/utils/libasyncio_utils.pc.in ${CMAKE_BINARY_DIR}/utils/libasyncio_utils.pc @ONLY) | |
90 | configure_file(${CMAKE_SOURCE_DIR}/glue_t2n/libasyncio_t2n.pc.in ${CMAKE_BINARY_DIR}/glue_t2n/libasyncio_t2n.pc @ONLY) | |
91 | ||
92 | install(FILES ${CMAKE_BINARY_DIR}/asyncio/libasyncio.pc DESTINATION lib/pkgconfig) | |
93 | install(FILES ${CMAKE_BINARY_DIR}/utils/libasyncio_utils.pc DESTINATION lib/pkgconfig) | |
94 | install(FILES ${CMAKE_BINARY_DIR}/glue_t2n/libasyncio_t2n.pc DESTINATION lib/pkgconfig) | |
95 | ||
96 | # Subdirectories | |
97 | set(CPACK_SET_DESTDIR "ON") | |
98 | add_subdirectory(utils) | |
99 | add_subdirectory(asyncio) | |
100 | if(${WITH_LIBT2N}) | |
101 | add_subdirectory(${T2NDIRS}) | |
102 | endif(${WITH_LIBT2N}) | |
103 | add_subdirectory(unittest) | |
104 | ||
105 | include(CPack) |