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.

104 lines
3.8KB

  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 (PkgConfig REQUIRED)
  17. pkg_check_modules (libssl REQUIRED libssl libcrypto)
  18. # -lpthread is only there for debugging (gdb & errno)
  19. # -lrt is only for glibc < 2.17
  20. list (APPEND project_libraries ${libssl_LIBRARIES} rt pthread)
  21. include_directories (${libssl_INCLUDE_DIRS})
  22. link_directories (${libssl_LIBRARY_DIRS})
  23. # Generate a configuration file
  24. include (GNUInstallDirs)
  25. set (plugin_dir ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME})
  26. configure_file (${PROJECT_SOURCE_DIR}/config.h.in ${PROJECT_BINARY_DIR}/config.h)
  27. include_directories (${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR})
  28. # Project source files
  29. set (common_sources siphash.c)
  30. set (common_headers ${PROJECT_BINARY_DIR}/config.h)
  31. add_custom_command (OUTPUT kike-replies.c kike.msg
  32. COMMAND ${PROJECT_SOURCE_DIR}/kike-gen-replies.sh
  33. > kike-replies.c < ${PROJECT_SOURCE_DIR}/kike-replies
  34. DEPENDS ${PROJECT_SOURCE_DIR}/kike-replies
  35. COMMENT "Generating files from the list of server numerics")
  36. set_source_files_properties (${PROJECT_BINARY_DIR}/kike-replies.c
  37. PROPERTIES HEADER_FILE_ONLY TRUE)
  38. # Build
  39. add_executable (zyklonb zyklonb.c ${common_sources} ${common_headers})
  40. target_link_libraries (zyklonb ${project_libraries})
  41. add_executable (kike kike.c kike-replies.c ${common_sources} ${common_headers})
  42. target_link_libraries (kike ${project_libraries})
  43. # Installation
  44. install (TARGETS zyklonb kike DESTINATION ${CMAKE_INSTALL_BINDIR})
  45. install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
  46. foreach (plugin coin eval script youtube ${plugins})
  47. install (FILES plugins/${plugin} DESTINATION ${plugin_dir})
  48. endforeach (plugin)
  49. # Generate documentation from program help
  50. find_program (HELP2MAN_EXECUTABLE help2man)
  51. if (NOT HELP2MAN_EXECUTABLE)
  52. message (FATAL_ERROR "help2man not found")
  53. endif (NOT HELP2MAN_EXECUTABLE)
  54. foreach (page zyklonb kike)
  55. set (page_output "${PROJECT_BINARY_DIR}/${page}.1")
  56. list (APPEND project_MAN_PAGES "${page_output}")
  57. add_custom_command (OUTPUT ${page_output}
  58. COMMAND ${HELP2MAN_EXECUTABLE} -N --no-discard-stderr # FIXME
  59. "${PROJECT_BINARY_DIR}/${page}" -o ${page_output}
  60. DEPENDS ${page}
  61. COMMENT "Generating man page for ${page}" VERBATIM)
  62. endforeach (page)
  63. add_custom_target (docs ALL DEPENDS ${project_MAN_PAGES})
  64. foreach (page ${project_MAN_PAGES})
  65. string (REGEX MATCH "\\.([0-9])" manpage_suffix "${page}")
  66. install (FILES "${page}"
  67. DESTINATION "${CMAKE_INSTALL_MANDIR}/man${CMAKE_MATCH_1}")
  68. endforeach (page)
  69. # CPack
  70. set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Experimental IRC bot & daemon")
  71. set (CPACK_PACKAGE_VERSION ${project_VERSION})
  72. set (CPACK_PACKAGE_VENDOR "Premysl Janouch")
  73. set (CPACK_PACKAGE_CONTACT "Přemysl Janouch <p.janouch@gmail.com>")
  74. set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
  75. set (CPACK_GENERATOR "TGZ;ZIP")
  76. set (CPACK_PACKAGE_FILE_NAME
  77. "${PROJECT_NAME}-${project_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
  78. set (CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}-${project_VERSION}")
  79. set (CPACK_SOURCE_GENERATOR "TGZ;ZIP")
  80. set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git;/build;/CMakeLists.txt.user")
  81. set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${project_VERSION}")
  82. set (CPACK_SET_DESTDIR TRUE)
  83. include (CPack)