Skip to content

Commit

Permalink
Adding the static library target, libmosquitto_static, to CMakeLists.…
Browse files Browse the repository at this point in the history
…txt so it gets installed, and when compiled STATIC_LIB gets defined for only the static library

Signed-off-by: Ian Johnson <[email protected]>
  • Loading branch information
Ian Johnson committed Apr 19, 2016
1 parent 87112a7 commit 13f28d1
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 13f28d1

Please sign in to comment.