From 3163cf2d709e7b021867aec2e811331991ad097a Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Tue, 19 Apr 2016 14:06:01 -0500 Subject: [PATCH 1/6] Only include man subdirectory if the DOCUMENTATION option is on Signed-off-by: Ian Johnson --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f075ab5d..2742f104 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,8 @@ endif (${WITH_SOCKS} STREQUAL ON) option(WITH_SRV "Include SRV lookup support?" OFF) +option(DOCUMENTATION "Build documentation?" ON) + # ======================================== # Include projects # ======================================== @@ -86,7 +88,9 @@ option(WITH_SRV "Include SRV lookup support?" OFF) add_subdirectory(lib) add_subdirectory(client) add_subdirectory(src) -add_subdirectory(man) +if (${DOCUMENTATION} STREQUAL ON) + add_subdirectory(man) +endif (${DOCUMENTATION} STREQUAL ON) # ======================================== # Install config file From 87112a7e21ba8046f4a41d623155198b043508dd Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Tue, 19 Apr 2016 14:08:02 -0500 Subject: [PATCH 2/6] On Mac, we don't want to run /sbin/ldconfig as it doesn't exist Signed-off-by: Ian Johnson --- lib/CMakeLists.txt | 5 +++-- lib/cpp/CMakeLists.txt | 5 +++-- src/CMakeLists.txt | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index fc4c8da7..b2653855 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -90,6 +90,7 @@ set_target_properties(libmosquitto PROPERTIES install(TARGETS libmosquitto RUNTIME DESTINATION ${BINDIR} LIBRARY DESTINATION ${LIBDIR}) install(FILES mosquitto.h DESTINATION ${INCLUDEDIR}) -if (UNIX) +if (UNIX AND NOT APPLE) install(CODE "EXEC_PROGRAM(/sbin/ldconfig)") -endif (UNIX) +endif (UNIX AND NOT APPLE) + diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt index 0a9fd914..2a81c2bf 100644 --- a/lib/cpp/CMakeLists.txt +++ b/lib/cpp/CMakeLists.txt @@ -13,6 +13,7 @@ set_target_properties(mosquittopp PROPERTIES install(TARGETS mosquittopp RUNTIME DESTINATION ${BINDIR} LIBRARY DESTINATION ${LIBDIR}) install(FILES mosquittopp.h DESTINATION ${INCLUDEDIR}) -if (UNIX) +if (UNIX AND NOT APPLE) install(CODE "EXEC_PROGRAM(/sbin/ldconfig)") -endif (UNIX) +endif (UNIX AND NOT APPLE) + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 09ae1f3f..db537c90 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -154,7 +154,8 @@ if (${WITH_TLS} STREQUAL ON) install(TARGETS mosquitto_passwd RUNTIME DESTINATION ${BINDIR} LIBRARY DESTINATION ${LIBDIR}) endif (${WITH_TLS} STREQUAL ON) -if (UNIX) +if (UNIX AND NOT APPLE) install(CODE "EXEC_PROGRAM(/sbin/ldconfig)") -endif (UNIX) +endif (UNIX AND NOT APPLE) + From 13f28d1c1e1014068865d8a5d9247313def9f96e Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Tue, 19 Apr 2016 14:32:23 -0500 Subject: [PATCH 3/6] 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) From 93906b9dfd8ff2fa4e63a6d808f2313627a6f04c Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Tue, 19 Apr 2016 14:34:44 -0500 Subject: [PATCH 4/6] We don't want to add any declaration properties for the static library, as the static library doesn't export or import anything, so when STATIC_LIB is defined the libmosq_EXPORT defines to nothing Signed-off-by: Ian Johnson --- lib/mosquitto.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mosquitto.h b/lib/mosquitto.h index c468a5ca..f1deb3e6 100644 --- a/lib/mosquitto.h +++ b/lib/mosquitto.h @@ -21,7 +21,7 @@ Contributors: extern "C" { #endif -#if defined(WIN32) && !defined(WITH_BROKER) +#if defined(WIN32) && !defined(WITH_BROKER) && !defined(STATIC_LIB) # ifdef libmosquitto_EXPORTS # define libmosq_EXPORT __declspec(dllexport) # else From 3499c094dcf4153553edf8da973b836e3339d181 Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Tue, 19 Apr 2016 16:50:25 -0500 Subject: [PATCH 5/6] Putting the list of files into a variable C_SRC and modiftying the add_library calls to use this variable Signed-off-by: Ian Johnson --- lib/CMakeLists.txt | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index ea2b765a..62668182 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -24,17 +24,7 @@ include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/lib ${OPENSSL_INCLUDE_DIR} ${PTHREAD_INCLUDE_DIR}) link_directories(${mosquitto_SOURCE_DIR}/lib) -add_library(libmosquitto SHARED - handle_connack.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 +set(C_SRC logging_mosq.c logging_mosq.h memory_mosq.c memory_mosq.h messages_mosq.c messages_mosq.h mosquitto.c mosquitto.h @@ -58,27 +48,10 @@ add_library(libmosquitto SHARED util_mosq.c util_mosq.h will_mosq.c will_mosq.h) +add_library(libmosquitto SHARED ${C_SRC} ) + #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) +add_library(libmosquitto_static STATIC ${C_SRC}) set (LIBRARIES ${OPENSSL_LIBRARIES} ${PTHREAD_LIBRARIES}) From a0a0cc3076861c49ff5a7ec4872fc5c538c4a9e4 Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Thu, 21 Apr 2016 09:51:46 -0500 Subject: [PATCH 6/6] Renaming STATIC_LIB -> LIBMOSQUITTO_STATIC Signed-off-by: Ian Johnson --- lib/CMakeLists.txt | 2 +- lib/mosquitto.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 62668182..574a4683 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -89,7 +89,7 @@ set_target_properties(libmosquitto_static PROPERTIES VERSION ${VERSION} ) -target_compile_definitions(libmosquitto_static PUBLIC "STATIC_LIB") +target_compile_definitions(libmosquitto_static PUBLIC "LIBMOSQUITTO_STATIC") install(TARGETS libmosquitto libmosquitto_static RUNTIME DESTINATION ${BINDIR} LIBRARY DESTINATION ${LIBDIR} ARCHIVE DESTINATION ${LIBDIR}) install(FILES mosquitto.h DESTINATION ${INCLUDEDIR}) diff --git a/lib/mosquitto.h b/lib/mosquitto.h index f1deb3e6..b41a94c5 100644 --- a/lib/mosquitto.h +++ b/lib/mosquitto.h @@ -21,7 +21,7 @@ Contributors: extern "C" { #endif -#if defined(WIN32) && !defined(WITH_BROKER) && !defined(STATIC_LIB) +#if defined(WIN32) && !defined(WITH_BROKER) && !defined(LIBMOSQUITTO_STATIC) # ifdef libmosquitto_EXPORTS # define libmosq_EXPORT __declspec(dllexport) # else