CMakeLists.txt 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Copyright 2007 - 2021, Alan Antonuk and the rabbitmq-c contributors.
  2. # SPDX-License-Identifier: mit
  3. if(WIN32)
  4. set(PLATFORM_DIR win32)
  5. else()
  6. set(PLATFORM_DIR unix)
  7. endif()
  8. add_library(tools-common OBJECT)
  9. target_sources(tools-common PRIVATE
  10. common.h
  11. common.c)
  12. if(WIN32)
  13. target_sources(tools-common PRIVATE
  14. win32/compat.h
  15. win32/compat.c)
  16. endif()
  17. if(ENABLE_SSL_SUPPORT)
  18. target_compile_definitions(tools-common PRIVATE -DWITH_SSL=1)
  19. endif()
  20. target_include_directories(tools-common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
  21. target_link_libraries(tools-common PRIVATE rabbitmq::rabbitmq PUBLIC popt::popt)
  22. add_executable(amqp-publish publish.c)
  23. target_link_libraries(amqp-publish PRIVATE tools-common rabbitmq::rabbitmq)
  24. add_executable(amqp-get get.c)
  25. target_link_libraries(amqp-get PRIVATE tools-common rabbitmq::rabbitmq)
  26. add_executable(amqp-consume consume.c ${PLATFORM_DIR}/process.h ${PLATFORM_DIR}/process.c)
  27. target_include_directories(amqp-consume PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${PLATFORM_DIR})
  28. target_link_libraries(amqp-consume PRIVATE tools-common rabbitmq::rabbitmq)
  29. add_executable(amqp-declare-queue declare_queue.c)
  30. target_link_libraries(amqp-declare-queue PRIVATE tools-common rabbitmq::rabbitmq)
  31. add_executable(amqp-delete-queue delete_queue.c)
  32. target_link_libraries(amqp-delete-queue PRIVATE tools-common rabbitmq::rabbitmq)
  33. install(TARGETS amqp-publish amqp-get amqp-consume amqp-declare-queue amqp-delete-queue
  34. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  35. COMPONENT rabbitmq-c-tools)
  36. if (BUILD_TOOLS_DOCS)
  37. set(DOCS_SRCS
  38. doc/amqp-consume.xml
  39. doc/amqp-declare-queue.xml
  40. doc/amqp-delete-queue.xml
  41. doc/amqp-get.xml
  42. doc/amqp-publish.xml
  43. doc/librabbitmq-tools.xml
  44. )
  45. file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc)
  46. set(XMLTO_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/doc/man-date.ent)
  47. STRING(TIMESTAMP BUILD_DATE "%Y-%m-%d" UTC)
  48. add_custom_command(
  49. OUTPUT ${XMLTO_DEPENDS}
  50. COMMAND echo ${BUILD_DATE} > ${XMLTO_DEPENDS}
  51. VERBATIM
  52. )
  53. set(XMLTO_COMMAND_ARGS --skip-validation --searchpath "${CMAKE_CURRENT_BINARY_DIR}/doc")
  54. XMLTO(${DOCS_SRCS}
  55. MODES man
  56. ALL)
  57. foreach(file ${XMLTO_FILES_man})
  58. get_filename_component(fileExt ${file} EXT)
  59. string( REGEX REPLACE "^[.]" "" fileExt ${fileExt} )
  60. install(
  61. FILES ${file}
  62. DESTINATION ${CMAKE_INSTALL_MANDIR}/man${fileExt}
  63. COMPONENT rabbitmq-c-tool-docs
  64. )
  65. endforeach()
  66. endif()