mosquitto/lib/CMakeLists.txt

114 lines
2.7 KiB
CMake
Raw Normal View History

option(WITH_STATIC_LIBRARIES "Build static versions of the libmosquitto/pp libraries?" OFF)
option(WITH_PIC "Build the static library with PIC (Position Independent Code) enabled archives?" OFF)
2014-05-07 22:27:00 +00:00
add_subdirectory(cpp)
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/lib
${mosquitto_SOURCE_DIR}/src/deps
2014-05-07 22:27:00 +00:00
${STDBOOL_H_PATH} ${STDINT_H_PATH}
${OPENSSL_INCLUDE_DIR} ${PTHREAD_INCLUDE_DIR})
link_directories(${mosquitto_SOURCE_DIR}/lib)
set(C_SRC
actions.c
callbacks.c
connect.c
2018-10-25 11:44:41 +00:00
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
2014-05-07 22:27:00 +00:00
memory_mosq.c memory_mosq.h
messages_mosq.c messages_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
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
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
socks_mosq.c
2014-05-07 22:27:00 +00:00
srv_mosq.c
thread_mosq.c
time_mosq.c
tls_mosq.c
utf8_mosq.c
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)
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)
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)
endif (WITH_SRV)
2014-05-07 22:27:00 +00:00
add_library(libmosquitto SHARED ${C_SRC})
set_target_properties(libmosquitto PROPERTIES
POSITION_INDEPENDENT_CODE 1
)
target_link_libraries(libmosquitto ${LIBRARIES})
2014-05-07 22:27:00 +00:00
set_target_properties(libmosquitto PROPERTIES
OUTPUT_NAME mosquitto
VERSION ${VERSION}
SOVERSION 1
)
install(TARGETS libmosquitto 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
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 mosquitto.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")