-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
118 lines (102 loc) · 2.78 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# cmake_minimum_required(VERSION 3.16)
# cmake_policy(SET CMP0042 NEW)
project(mosquitto VERSION "2.2.0" LANGUAGES C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_EXTENSIONS OFF)
include_directories(deps deps/utilst)
set(C_SRC
actions.c
callbacks.c
connect.c
handle_auth.c
handle_connack.c
handle_disconnect.c
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
loop.c
memory_mosq.c memory_mosq.h
messages_mosq.c messages_mosq.h
misc_mosq.c misc_mosq.h
mosquitto.c mosquitto.h
mosquitto_internal.h
mqtt_protocol.h
net_mosq_ocsp.c net_mosq.c net_mosq.h
options.c
packet_datatypes.c
packet_mosq.c packet_mosq.h
property_mosq.c property_mosq.h
read_handle.c read_handle.h
send_connect.c
send_disconnect.c
send_mosq.c
send_publish.c
send_subscribe.c
send_unsubscribe.c
send_mosq.c send_mosq.h
socks_mosq.c
srv_mosq.c
strings_mosq.c
thread_mosq.c
time_mosq.c
tls_mosq.c
utf8_mosq.c
util_mosq.c util_topic.c util_mosq.h
will_mosq.c will_mosq.h)
set (LIBRARIES ${OPENSSL_LIBRARIES} ${PTHREAD_LIBRARIES})
if (UNIX AND NOT APPLE AND NOT ANDROID)
find_library(LIBRT rt)
if (LIBRT)
set (LIBRARIES ${LIBRARIES} rt)
endif (LIBRT)
endif (UNIX AND NOT APPLE AND NOT ANDROID)
if (WIN32)
set (LIBRARIES ${LIBRARIES} ws2_32)
endif (WIN32)
if (WITH_SRV)
# 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)
endif (WITH_SRV)
add_library(libmosquitto SHARED ${C_SRC})
set_target_properties(libmosquitto PROPERTIES
POSITION_INDEPENDENT_CODE 1
)
target_link_libraries(libmosquitto ${LIBRARIES})
# set_target_properties(libmosquitto PROPERTIES
# OUTPUT_NAME mosquitto
# VERSION ${VERSION}
# SOVERSION 1
# )
install(TARGETS libmosquitto
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
# if (WITH_STATIC_LIBRARIES)
add_library(libmosquitto_static STATIC ${C_SRC})
# if (WITH_PIC)
# set_target_properties(libmosquitto_static PROPERTIES
# POSITION_INDEPENDENT_CODE 1
# )
# endif (WITH_PIC)
target_link_libraries(libmosquitto_static ${LIBRARIES})
# set_target_properties(libmosquitto_static PROPERTIES
# OUTPUT_NAME mosquitto_static
# VERSION ${VERSION}
# )
target_compile_definitions(libmosquitto_static PUBLIC "LIBMOSQUITTO_STATIC")
install(TARGETS libmosquitto_static ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
# endif (WITH_STATIC_LIBRARIES)
# install(FILES ../include/mosquitto.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
# install(FILES ../include/mqtt_protocol.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")