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.

142 lines
5.0KB

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