| 1 | # Project |
| 2 | project(libasyncio) |
| 3 | set(VERSION 0.3) |
| 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 "Build with libi2ncommon support" OFF) |
| 19 | if(WITH_LIBI2NCOMMON) |
| 20 | message(STATUS "[!] Building *with* libi2ncommon support. [!]") |
| 21 | pkg_check_modules(LIBI2NCOMMON REQUIRED libi2ncommon) |
| 22 | include_directories(${LIBI2NCOMMON_INCLUDE_DIRS}) |
| 23 | link_directories(${LIBI2NCOMMON_LIBRARY_DIRS}) |
| 24 | else(WITH_LIBI2NCOMMON) |
| 25 | message(STATUS "[!] Building *without* libi2ncommon support. [!]") |
| 26 | endif(WITH_LIBI2NCOMMON) |
| 27 | |
| 28 | find_package(Boost 1.34 REQUIRED COMPONENTS unit_test_framework) |
| 29 | include_directories(${Boost_INCLUDE_DIRS}) |
| 30 | |
| 31 | option(WITH_LIBT2N "Build with libt2n support" OFF) |
| 32 | if(WITH_LIBT2N) |
| 33 | message(STATUS "[!] Building *with* libt2n support. [!]") |
| 34 | pkg_check_modules(LIBT2N REQUIRED libt2n) |
| 35 | include_directories(${LIBT2N_INCLUDE_DIRS}) |
| 36 | link_directories(${LIBT2N_LIBRARY_DIRS}) |
| 37 | add_subdirectory(glue_t2n) |
| 38 | else(WITH_LIBT2N) |
| 39 | message(STATUS "[!] Building *without* libt2n support. [!]") |
| 40 | endif(WITH_LIBT2N) |
| 41 | |
| 42 | # Documentation |
| 43 | find_package(Doxygen) |
| 44 | if(DOXYGEN_FOUND) |
| 45 | # Find doxy config |
| 46 | message(STATUS "Doxygen found.") |
| 47 | set(DOXY_DIR "${CMAKE_SOURCE_DIR}/doc") |
| 48 | set(DOXY_CONFIG "${DOXY_DIR}/Doxyfile.in") |
| 49 | set(top_srcdir ${CMAKE_SOURCE_DIR}) |
| 50 | |
| 51 | # Copy doxy.config.in |
| 52 | configure_file("${DOXY_CONFIG}" "${CMAKE_BINARY_DIR}/doxy.config") |
| 53 | |
| 54 | # Create doc directory |
| 55 | add_custom_command( |
| 56 | OUTPUT ${CMAKE_BINARY_DIR}/doc |
| 57 | COMMAND rm -rf ${CMAKE_BINARY_DIR}/doc/{html,man} |
| 58 | COMMAND mkdir -p ${CMAKE_BINARY_DIR}/doc |
| 59 | DEPENDS utils asyncio ${T2NDIRS} unittest |
| 60 | ) |
| 61 | |
| 62 | # Run doxygen |
| 63 | add_custom_command( |
| 64 | OUTPUT ${CMAKE_BINARY_DIR}/doc/html/index.html |
| 65 | COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_BINARY_DIR}/doxy.config" |
| 66 | DEPENDS "${CMAKE_BINARY_DIR}/doxy.config" "${CMAKE_BINARY_DIR}/doc" |
| 67 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/doc |
| 68 | ) |
| 69 | |
| 70 | add_custom_target(docs ALL DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html) |
| 71 | |
| 72 | message(STATUS "Generating API documentation with Doxygen.") |
| 73 | else(DOXYGEN_FOUND) |
| 74 | message(STATUS "Not generating API documentation.") |
| 75 | endif(DOXYGEN_FOUND) |
| 76 | |
| 77 | # Spec file |
| 78 | configure_file(${CMAKE_SOURCE_DIR}/libasyncio.spec.in ${CMAKE_SOURCE_DIR}/libasyncio.spec @ONLY) |
| 79 | |
| 80 | # Check include files and availability of libraries for config file |
| 81 | include(CheckIncludeFiles) |
| 82 | |
| 83 | if(Boost_FOUND) |
| 84 | set(HAVE_BOOST 1) |
| 85 | endif() |
| 86 | if(Boost_UNIT_TEST_FRAMEWORK_FOUND) |
| 87 | set(HAVE_BOOST_UNIT_TEST_FRAMEWORK 1) |
| 88 | endif() |
| 89 | if(LIBI2NCOMMON_FOUND) |
| 90 | set(HAVE_LIBI2NCOMMON 1) |
| 91 | endif() |
| 92 | if(LIBT2N_FOUND) |
| 93 | set(HAVE_LIBT2N 1) |
| 94 | endif() |
| 95 | check_include_files(dlfcn.h HAVE_DLFCN_H) |
| 96 | check_include_files(inttypes.h HAVE_INTTYPES_H) |
| 97 | check_include_files(memory.h HAVE_MEMORY_H) |
| 98 | check_include_files(stdint.h HAVE_STDINT_H) |
| 99 | check_include_files(stdlib.h HAVE_STDLIB_H) |
| 100 | check_include_files(strings.h HAVE_STRINGS_H) |
| 101 | check_include_files(string.h HAVE_STRING_H) |
| 102 | check_include_files(sys/stat.h HAVE_SYS_STAT_H) |
| 103 | check_include_files(sys/types.h HAVE_SYS_TYPES_H) |
| 104 | check_include_files(unistd.h HAVE_UNISTD_H) |
| 105 | set(STDC_HEADER_NAMES |
| 106 | assert.h |
| 107 | ctype.h |
| 108 | errno.h |
| 109 | float.h |
| 110 | limits.h |
| 111 | locale.h |
| 112 | math.h |
| 113 | setjmp.h |
| 114 | signal.h |
| 115 | stdarg.h |
| 116 | stddef.h |
| 117 | stdio.h |
| 118 | stdlib.h |
| 119 | string.h |
| 120 | time.h |
| 121 | ) |
| 122 | check_include_files("${STDC_HEADER_NAMES}" STDC_HEADERS) |
| 123 | |
| 124 | # Config file |
| 125 | # configure_file(${CMAKE_SOURCE_DIR}/asyncio_config.hpp.in.cmake ${CMAKE_BINARY_DIR}/asyncio_config.hpp) |
| 126 | # include_directories(BEFORE ${CMAKE_BINARY_DIR}) |
| 127 | configure_file(${CMAKE_SOURCE_DIR}/asyncio_config.hpp.in.cmake ${CMAKE_SOURCE_DIR}/asyncio/asyncio_config.hpp) |
| 128 | # include_directories(BEFORE ${CMAKE_SOURCE_DIR}/asyncio) |
| 129 | |
| 130 | # PkgConfig output |
| 131 | set(prefix ${CMAKE_INSTALL_PREFIX}) |
| 132 | set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin) |
| 133 | set(includedir ${CMAKE_INSTALL_PREFIX}/include) |
| 134 | set(libdir ${CMAKE_INSTALL_PREFIX}/lib) |
| 135 | |
| 136 | # PkgConfig files |
| 137 | configure_file(${CMAKE_SOURCE_DIR}/asyncio/libasyncio.pc.in ${CMAKE_BINARY_DIR}/asyncio/libasyncio.pc @ONLY) |
| 138 | configure_file(${CMAKE_SOURCE_DIR}/utils/libasyncio_utils.pc.in ${CMAKE_BINARY_DIR}/utils/libasyncio_utils.pc @ONLY) |
| 139 | configure_file(${CMAKE_SOURCE_DIR}/glue_t2n/libasyncio_t2n.pc.in ${CMAKE_BINARY_DIR}/glue_t2n/libasyncio_t2n.pc @ONLY) |
| 140 | |
| 141 | install(FILES ${CMAKE_BINARY_DIR}/asyncio/libasyncio.pc DESTINATION lib/pkgconfig) |
| 142 | install(FILES ${CMAKE_BINARY_DIR}/utils/libasyncio_utils.pc DESTINATION lib/pkgconfig) |
| 143 | install(FILES ${CMAKE_BINARY_DIR}/glue_t2n/libasyncio_t2n.pc DESTINATION lib/pkgconfig) |
| 144 | |
| 145 | # Subdirectories |
| 146 | set(CPACK_SET_DESTDIR "ON") |
| 147 | add_subdirectory(utils) |
| 148 | add_subdirectory(asyncio) |
| 149 | add_subdirectory(unittest) |
| 150 | |
| 151 | include(CPack) |