CMakeLists.txt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. option(WITH_LIB_CPP "Build C++ library?" ON)
  2. if (WITH_LIB_CPP)
  3. add_subdirectory(cpp)
  4. endif (WITH_LIB_CPP)
  5. include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/lib
  6. ${mosquitto_SOURCE_DIR}/include
  7. ${STDBOOL_H_PATH} ${STDINT_H_PATH}
  8. ${OPENSSL_INCLUDE_DIR} ${PTHREAD_INCLUDE_DIR})
  9. link_directories(${mosquitto_SOURCE_DIR}/lib)
  10. if (WITH_BUNDLED_DEPS)
  11. include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/deps)
  12. endif (WITH_BUNDLED_DEPS)
  13. set(C_SRC
  14. actions.c
  15. callbacks.c
  16. connect.c
  17. handle_auth.c
  18. handle_connack.c
  19. handle_disconnect.c
  20. handle_ping.c
  21. handle_pubackcomp.c
  22. handle_publish.c
  23. handle_pubrec.c
  24. handle_pubrel.c
  25. handle_suback.c
  26. handle_unsuback.c
  27. helpers.c
  28. logging_mosq.c logging_mosq.h
  29. loop.c
  30. memory_mosq.c memory_mosq.h
  31. messages_mosq.c messages_mosq.h
  32. misc_mosq.c misc_mosq.h
  33. mosquitto.c ../include/mosquitto.h
  34. mosquitto_internal.h
  35. ../include/mqtt_protocol.h
  36. net_mosq_ocsp.c net_mosq.c net_mosq.h
  37. options.c
  38. packet_datatypes.c
  39. packet_mosq.c packet_mosq.h
  40. property_mosq.c property_mosq.h
  41. read_handle.c read_handle.h
  42. send_connect.c
  43. send_disconnect.c
  44. send_mosq.c
  45. send_publish.c
  46. send_subscribe.c
  47. send_unsubscribe.c
  48. send_mosq.c send_mosq.h
  49. socks_mosq.c
  50. srv_mosq.c
  51. strings_mosq.c
  52. thread_mosq.c
  53. time_mosq.c
  54. tls_mosq.c
  55. utf8_mosq.c
  56. util_mosq.c util_topic.c util_mosq.h
  57. will_mosq.c will_mosq.h)
  58. set (LIBRARIES ${OPENSSL_LIBRARIES} ${PTHREAD_LIBRARIES})
  59. if (UNIX AND NOT APPLE AND NOT ANDROID)
  60. find_library(LIBRT rt)
  61. if (LIBRT)
  62. set (LIBRARIES ${LIBRARIES} rt)
  63. endif (LIBRT)
  64. endif (UNIX AND NOT APPLE AND NOT ANDROID)
  65. if (WIN32)
  66. set (LIBRARIES ${LIBRARIES} ws2_32)
  67. endif (WIN32)
  68. if (WITH_SRV)
  69. # Simple detect c-ares
  70. find_path(ARES_HEADER ares.h)
  71. if (ARES_HEADER)
  72. add_definitions("-DWITH_SRV")
  73. set (LIBRARIES ${LIBRARIES} cares)
  74. else (ARES_HEADER)
  75. message(WARNING "c-ares library not found.")
  76. endif (ARES_HEADER)
  77. endif (WITH_SRV)
  78. add_library(libmosquitto SHARED ${C_SRC})
  79. set_target_properties(libmosquitto PROPERTIES
  80. POSITION_INDEPENDENT_CODE 1
  81. )
  82. target_link_libraries(libmosquitto ${LIBRARIES})
  83. set_target_properties(libmosquitto PROPERTIES
  84. OUTPUT_NAME mosquitto
  85. VERSION ${VERSION}
  86. SOVERSION 1
  87. )
  88. install(TARGETS libmosquitto RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
  89. if (WITH_STATIC_LIBRARIES)
  90. add_library(libmosquitto_static STATIC ${C_SRC})
  91. if (WITH_PIC)
  92. set_target_properties(libmosquitto_static PROPERTIES
  93. POSITION_INDEPENDENT_CODE 1
  94. )
  95. endif (WITH_PIC)
  96. target_link_libraries(libmosquitto_static ${LIBRARIES})
  97. set_target_properties(libmosquitto_static PROPERTIES
  98. OUTPUT_NAME mosquitto_static
  99. VERSION ${VERSION}
  100. )
  101. target_compile_definitions(libmosquitto_static PUBLIC "LIBMOSQUITTO_STATIC")
  102. install(TARGETS libmosquitto_static ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
  103. endif (WITH_STATIC_LIBRARIES)
  104. install(FILES ../include/mosquitto.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
  105. install(FILES ../include/mqtt_protocol.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")