From 13f28d1c1e1014068865d8a5d9247313def9f96e Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Tue, 19 Apr 2016 14:32:23 -0500 Subject: [PATCH] Adding the static library target, libmosquitto_static, to CMakeLists.txt so it gets installed, and when compiled STATIC_LIB gets defined for only the static library Signed-off-by: Ian Johnson --- lib/CMakeLists.txt | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index b2653855..ea2b765a 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -58,6 +58,28 @@ add_library(libmosquitto SHARED util_mosq.c util_mosq.h will_mosq.c will_mosq.h) +#target for building static version of library +add_library(libmosquitto_static STATIC + logging_mosq.c logging_mosq.h + memory_mosq.c memory_mosq.h + messages_mosq.c messages_mosq.h + mosquitto.c mosquitto.h + mosquitto_internal.h + mqtt3_protocol.h + net_mosq.c net_mosq.h + read_handle.c read_handle.h + read_handle_client.c + read_handle_shared.c + send_client_mosq.c + send_mosq.c send_mosq.h + socks_mosq.c + srv_mosq.c + thread_mosq.c + time_mosq.c + tls_mosq.c + util_mosq.c util_mosq.h + will_mosq.c will_mosq.h) + set (LIBRARIES ${OPENSSL_LIBRARIES} ${PTHREAD_LIBRARIES}) if (UNIX AND NOT APPLE) @@ -81,13 +103,22 @@ endif (${WITH_SRV} STREQUAL ON) target_link_libraries(libmosquitto ${LIBRARIES}) +target_link_libraries(libmosquitto_static ${LIBRARIES}) + set_target_properties(libmosquitto PROPERTIES OUTPUT_NAME mosquitto VERSION ${VERSION} SOVERSION 1 ) -install(TARGETS libmosquitto RUNTIME DESTINATION ${BINDIR} LIBRARY DESTINATION ${LIBDIR}) +set_target_properties(libmosquitto_static PROPERTIES + OUTPUT_NAME mosquitto + VERSION ${VERSION} +) + +target_compile_definitions(libmosquitto_static PUBLIC "STATIC_LIB") + +install(TARGETS libmosquitto libmosquitto_static RUNTIME DESTINATION ${BINDIR} LIBRARY DESTINATION ${LIBDIR} ARCHIVE DESTINATION ${LIBDIR}) install(FILES mosquitto.h DESTINATION ${INCLUDEDIR}) if (UNIX AND NOT APPLE)