Experimental IRC client, daemon and bot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
4.3KB

  1. project (ZyklonB C)
  2. cmake_minimum_required (VERSION 2.8.5)
  3. # Moar warnings
  4. if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUC)
  5. # -Wunused-function is pretty annoying here, as everything is static
  6. set (CMAKE_C_FLAGS "-std=c99 -Wall -Wextra -Wno-unused-function")
  7. endif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUC)
  8. # Version
  9. set (project_VERSION_MAJOR "0")
  10. set (project_VERSION_MINOR "1")
  11. set (project_VERSION_PATCH "0")
  12. set (project_VERSION "${project_VERSION_MAJOR}")
  13. set (project_VERSION "${project_VERSION}.${project_VERSION_MINOR}")
  14. set (project_VERSION "${project_VERSION}.${project_VERSION_PATCH}")
  15. # Dependencies
  16. find_package (Curses)
  17. find_package (PkgConfig REQUIRED)
  18. pkg_check_modules (libssl REQUIRED libssl libcrypto)
  19. pkg_check_modules (ncursesw ncursesw)
  20. # -lpthread is only there for debugging (gdb & errno)
  21. # -lrt is only for glibc < 2.17
  22. list (APPEND project_libraries ${libssl_LIBRARIES} rt pthread)
  23. include_directories (${libssl_INCLUDE_DIRS})
  24. link_directories (${libssl_LIBRARY_DIRS})
  25. if (ncursesw_FOUND)
  26. list (APPEND project_libraries ${ncursesw_LIBRARIES})
  27. include_directories (${ncursesw_INCLUDE_DIRS})
  28. elseif (CURSES_FOUND)
  29. list (APPEND project_libraries ${CURSES_LIBRARY})
  30. include_directories (${CURSES_INCLUDE_DIR})
  31. else (CURSES_FOUND)
  32. message (SEND_ERROR "Curses not found")
  33. endif (ncursesw_FOUND)
  34. # Generate a configuration file
  35. include (GNUInstallDirs)
  36. set (plugin_dir ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME})
  37. configure_file (${PROJECT_SOURCE_DIR}/config.h.in ${PROJECT_BINARY_DIR}/config.h)
  38. include_directories (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR})
  39. # Project source files
  40. set (common_sources)
  41. set (common_headers ${PROJECT_BINARY_DIR}/config.h)
  42. add_custom_command (OUTPUT kike-replies.c kike.msg
  43. COMMAND ${PROJECT_SOURCE_DIR}/kike-gen-replies.sh
  44. > kike-replies.c < ${PROJECT_SOURCE_DIR}/kike-replies
  45. DEPENDS ${PROJECT_SOURCE_DIR}/kike-replies
  46. COMMENT "Generating files from the list of server numerics")
  47. set_source_files_properties (${PROJECT_BINARY_DIR}/kike-replies.c
  48. PROPERTIES HEADER_FILE_ONLY TRUE)
  49. # Build
  50. add_executable (zyklonb zyklonb.c ${common_sources} ${common_headers})
  51. target_link_libraries (zyklonb ${project_libraries})
  52. add_executable (degesch degesch.c ${common_sources} ${common_headers})
  53. target_link_libraries (degesch ${project_libraries} readline)
  54. add_executable (kike kike.c kike-replies.c ${common_sources} ${common_headers})
  55. target_link_libraries (kike ${project_libraries})
  56. # Installation
  57. install (TARGETS zyklonb degesch kike DESTINATION ${CMAKE_INSTALL_BINDIR})
  58. install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
  59. foreach (plugin coin eval script youtube ${plugins})
  60. install (FILES plugins/${plugin} DESTINATION ${plugin_dir})
  61. endforeach (plugin)
  62. # Generate documentation from program help
  63. find_program (HELP2MAN_EXECUTABLE help2man)
  64. if (NOT HELP2MAN_EXECUTABLE)
  65. message (FATAL_ERROR "help2man not found")
  66. endif (NOT HELP2MAN_EXECUTABLE)
  67. foreach (page zyklonb degesch kike)
  68. set (page_output "${PROJECT_BINARY_DIR}/${page}.1")
  69. list (APPEND project_MAN_PAGES "${page_output}")
  70. add_custom_command (OUTPUT ${page_output}
  71. COMMAND ${HELP2MAN_EXECUTABLE} -N
  72. "${PROJECT_BINARY_DIR}/${page}" -o ${page_output}
  73. DEPENDS ${page}
  74. COMMENT "Generating man page for ${page}" VERBATIM)
  75. endforeach (page)
  76. add_custom_target (docs ALL DEPENDS ${project_MAN_PAGES})
  77. foreach (page ${project_MAN_PAGES})
  78. string (REGEX MATCH "\\.([0-9])" manpage_suffix "${page}")
  79. install (FILES "${page}"
  80. DESTINATION "${CMAKE_INSTALL_MANDIR}/man${CMAKE_MATCH_1}")
  81. endforeach (page)
  82. # CPack
  83. set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Experimental IRC bot, client and daemon")
  84. set (CPACK_PACKAGE_VERSION ${project_VERSION})
  85. set (CPACK_PACKAGE_VENDOR "Premysl Janouch")
  86. set (CPACK_PACKAGE_CONTACT "Přemysl Janouch <p.janouch@gmail.com>")
  87. set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
  88. set (CPACK_GENERATOR "TGZ;ZIP")
  89. set (CPACK_PACKAGE_FILE_NAME
  90. "${PROJECT_NAME}-${project_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
  91. set (CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}-${project_VERSION}")
  92. set (CPACK_SOURCE_GENERATOR "TGZ;ZIP")
  93. set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git;/build;/CMakeLists.txt.user")
  94. set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${project_VERSION}")
  95. set (CPACK_SET_DESTDIR TRUE)
  96. include (CPack)