2020-03-27 21:57:06 +00:00
|
|
|
option(WITH_LIB_CPP "Build C++ library?" ON)
|
|
|
|
if (WITH_LIB_CPP)
|
|
|
|
add_subdirectory(cpp)
|
|
|
|
endif (WITH_LIB_CPP)
|
2014-05-07 22:27:00 +00:00
|
|
|
|
|
|
|
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/lib
|
|
|
|
${STDBOOL_H_PATH} ${STDINT_H_PATH}
|
|
|
|
${OPENSSL_INCLUDE_DIR} ${PTHREAD_INCLUDE_DIR})
|
|
|
|
link_directories(${mosquitto_SOURCE_DIR}/lib)
|
|
|
|
|
2020-01-22 11:30:25 +00:00
|
|
|
if (WITH_BUNDLED_DEPS)
|
|
|
|
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/src/deps)
|
|
|
|
endif (WITH_BUNDLED_DEPS)
|
|
|
|
|
2016-05-31 04:26:47 +00:00
|
|
|
set(C_SRC
|
2018-04-11 14:04:17 +00:00
|
|
|
actions.c
|
|
|
|
callbacks.c
|
|
|
|
connect.c
|
2018-10-25 11:44:41 +00:00
|
|
|
handle_auth.c
|
2016-05-31 04:26:47 +00:00
|
|
|
handle_connack.c
|
2018-11-22 18:07:52 +00:00
|
|
|
handle_disconnect.c
|
2016-05-31 04:26:47 +00:00
|
|
|
handle_ping.c
|
|
|
|
handle_pubackcomp.c
|
|
|
|
handle_publish.c
|
|
|
|
handle_pubrec.c
|
|
|
|
handle_pubrel.c
|
|
|
|
handle_suback.c
|
|
|
|
handle_unsuback.c
|
|
|
|
helpers.c
|
|
|
|
logging_mosq.c logging_mosq.h
|
2018-04-11 14:04:17 +00:00
|
|
|
loop.c
|
2014-05-07 22:27:00 +00:00
|
|
|
memory_mosq.c memory_mosq.h
|
|
|
|
messages_mosq.c messages_mosq.h
|
2020-02-04 16:05:58 +00:00
|
|
|
misc_mosq.c misc_mosq.h
|
2014-05-07 22:27:00 +00:00
|
|
|
mosquitto.c mosquitto.h
|
|
|
|
mosquitto_internal.h
|
2018-08-29 21:26:16 +00:00
|
|
|
mqtt_protocol.h
|
2017-06-09 13:52:50 +00:00
|
|
|
net_mosq_ocsp.c net_mosq.c net_mosq.h
|
2018-04-11 14:04:17 +00:00
|
|
|
options.c
|
2018-10-03 09:23:58 +00:00
|
|
|
packet_datatypes.c
|
2015-04-29 20:23:59 +00:00
|
|
|
packet_mosq.c packet_mosq.h
|
2019-03-05 14:01:29 +00:00
|
|
|
property_mosq.c property_mosq.h
|
2014-05-07 22:27:00 +00:00
|
|
|
read_handle.c read_handle.h
|
2016-03-06 22:30:17 +00:00
|
|
|
send_connect.c
|
|
|
|
send_disconnect.c
|
|
|
|
send_mosq.c
|
|
|
|
send_publish.c
|
|
|
|
send_subscribe.c
|
|
|
|
send_unsubscribe.c
|
2014-05-07 22:27:00 +00:00
|
|
|
send_mosq.c send_mosq.h
|
2014-09-29 23:56:57 +00:00
|
|
|
socks_mosq.c
|
2014-05-07 22:27:00 +00:00
|
|
|
srv_mosq.c
|
|
|
|
thread_mosq.c
|
|
|
|
time_mosq.c
|
|
|
|
tls_mosq.c
|
2016-06-20 21:56:01 +00:00
|
|
|
utf8_mosq.c
|
2018-10-10 16:52:41 +00:00
|
|
|
util_mosq.c util_topic.c util_mosq.h
|
2014-05-07 22:27:00 +00:00
|
|
|
will_mosq.c will_mosq.h)
|
|
|
|
|
|
|
|
set (LIBRARIES ${OPENSSL_LIBRARIES} ${PTHREAD_LIBRARIES})
|
|
|
|
|
|
|
|
if (UNIX AND NOT APPLE)
|
2017-01-24 22:01:16 +00:00
|
|
|
find_library(LIBRT rt)
|
|
|
|
if (LIBRT)
|
|
|
|
set (LIBRARIES ${LIBRARIES} rt)
|
|
|
|
endif (LIBRT)
|
2014-05-07 22:27:00 +00:00
|
|
|
endif (UNIX AND NOT APPLE)
|
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
set (LIBRARIES ${LIBRARIES} ws2_32)
|
|
|
|
endif (WIN32)
|
|
|
|
|
2019-01-10 15:51:34 +00:00
|
|
|
if (WITH_SRV)
|
2014-07-22 09:02:36 +00:00
|
|
|
# Simple detect c-ares
|
|
|
|
find_path(ARES_HEADER ares.h)
|
|
|
|
if (ARES_HEADER)
|
|
|
|
add_definitions("-DWITH_SRV")
|
|
|
|
set (LIBRARIES ${LIBRARIES} cares)
|
|
|
|
else (ARES_HEADER)
|
|
|
|
message(WARNING "c-ares library not found.")
|
|
|
|
endif (ARES_HEADER)
|
2019-01-10 15:51:34 +00:00
|
|
|
endif (WITH_SRV)
|
2014-05-07 22:27:00 +00:00
|
|
|
|
2018-01-06 22:42:13 +00:00
|
|
|
add_library(libmosquitto SHARED ${C_SRC})
|
|
|
|
set_target_properties(libmosquitto PROPERTIES
|
2016-05-31 06:06:37 +00:00
|
|
|
POSITION_INDEPENDENT_CODE 1
|
|
|
|
)
|
|
|
|
|
2016-05-31 04:52:04 +00:00
|
|
|
target_link_libraries(libmosquitto ${LIBRARIES})
|
2016-04-19 19:32:23 +00:00
|
|
|
|
2014-05-07 22:27:00 +00:00
|
|
|
set_target_properties(libmosquitto PROPERTIES
|
|
|
|
OUTPUT_NAME mosquitto
|
|
|
|
VERSION ${VERSION}
|
|
|
|
SOVERSION 1
|
|
|
|
)
|
|
|
|
|
2019-04-30 13:33:18 +00:00
|
|
|
install(TARGETS libmosquitto RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
2016-05-31 04:52:04 +00:00
|
|
|
|
2019-01-10 15:51:34 +00:00
|
|
|
if (WITH_STATIC_LIBRARIES)
|
2018-01-06 22:42:13 +00:00
|
|
|
add_library(libmosquitto_static STATIC ${C_SRC})
|
2019-01-10 15:51:34 +00:00
|
|
|
if (WITH_PIC)
|
2018-01-06 22:42:13 +00:00
|
|
|
set_target_properties(libmosquitto_static PROPERTIES
|
|
|
|
POSITION_INDEPENDENT_CODE 1
|
|
|
|
)
|
2019-01-10 15:51:34 +00:00
|
|
|
endif (WITH_PIC)
|
2016-05-31 04:52:04 +00:00
|
|
|
|
|
|
|
target_link_libraries(libmosquitto_static ${LIBRARIES})
|
|
|
|
|
|
|
|
set_target_properties(libmosquitto_static PROPERTIES
|
2019-08-06 11:01:29 +00:00
|
|
|
OUTPUT_NAME mosquitto_static
|
2016-05-31 04:52:04 +00:00
|
|
|
VERSION ${VERSION}
|
|
|
|
)
|
2016-04-19 19:32:23 +00:00
|
|
|
|
2016-05-31 04:52:04 +00:00
|
|
|
target_compile_definitions(libmosquitto_static PUBLIC "LIBMOSQUITTO_STATIC")
|
2019-04-26 14:51:48 +00:00
|
|
|
install(TARGETS libmosquitto_static ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
2019-01-10 15:51:34 +00:00
|
|
|
endif (WITH_STATIC_LIBRARIES)
|
2016-04-19 19:32:23 +00:00
|
|
|
|
2019-04-26 14:51:48 +00:00
|
|
|
install(FILES mosquitto.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|