diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 14b94b1..508c5b1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -65,28 +65,29 @@ ENDIF() ADD_LIBRARY(common_obj OBJECT ${common_src}) SET_PROPERTY(TARGET common_obj PROPERTY POSITION_INDEPENDENT_CODE ON) -ADD_EXECUTABLE(MQTTVersion MQTTVersion.c) - -ADD_LIBRARY(paho-mqtt3c SHARED $ MQTTClient.c) -ADD_LIBRARY(paho-mqtt3a SHARED $ MQTTAsync.c) - -TARGET_LINK_LIBRARIES(paho-mqtt3c ${LIBS_SYSTEM}) -TARGET_LINK_LIBRARIES(paho-mqtt3a ${LIBS_SYSTEM}) - -TARGET_LINK_LIBRARIES(MQTTVersion paho-mqtt3a paho-mqtt3c ${LIBS_SYSTEM}) -SET_TARGET_PROPERTIES( - paho-mqtt3c paho-mqtt3a PROPERTIES - VERSION ${CLIENT_VERSION} - SOVERSION ${PAHO_VERSION_MAJOR}) - -INSTALL(TARGETS paho-mqtt3c paho-mqtt3a - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -INSTALL(TARGETS MQTTVersion - RUNTIME DESTINATION tools/paho-mqtt) - -IF (PAHO_BUILD_STATIC) +IF (NOT PAHO_BUILD_STATIC) + ADD_EXECUTABLE(MQTTVersion MQTTVersion.c) + + ADD_LIBRARY(paho-mqtt3c SHARED $ MQTTClient.c) + ADD_LIBRARY(paho-mqtt3a SHARED $ MQTTAsync.c) + + TARGET_LINK_LIBRARIES(paho-mqtt3c ${LIBS_SYSTEM}) + TARGET_LINK_LIBRARIES(paho-mqtt3a ${LIBS_SYSTEM}) + + TARGET_LINK_LIBRARIES(MQTTVersion paho-mqtt3a paho-mqtt3c ${LIBS_SYSTEM}) + SET_TARGET_PROPERTIES( + paho-mqtt3c paho-mqtt3a PROPERTIES + VERSION ${CLIENT_VERSION} + SOVERSION ${PAHO_VERSION_MAJOR}) + + INSTALL(TARGETS paho-mqtt3c paho-mqtt3a + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + INSTALL(TARGETS MQTTVersion + RUNTIME DESTINATION tools/paho-mqtt) +ELSE() + message("Build as static library") ADD_LIBRARY(paho-mqtt3c-static STATIC $ MQTTClient.c) ADD_LIBRARY(paho-mqtt3a-static STATIC $ MQTTAsync.c) @@ -132,22 +133,24 @@ IF (PAHO_WITH_SSL) ADD_LIBRARY(common_ssl_obj OBJECT ${common_src}) SET_PROPERTY(TARGET common_ssl_obj PROPERTY POSITION_INDEPENDENT_CODE ON) SET_PROPERTY(TARGET common_ssl_obj PROPERTY COMPILE_DEFINITIONS "OPENSSL=1") - ADD_LIBRARY(paho-mqtt3cs SHARED $ MQTTClient.c SSLSocket.c) - ADD_LIBRARY(paho-mqtt3as SHARED $ MQTTAsync.c SSLSocket.c) - - TARGET_LINK_LIBRARIES(paho-mqtt3cs ${OPENSSL_LIB} ${OPENSSLCRYPTO_LIB} ${LIBS_SYSTEM}) - TARGET_LINK_LIBRARIES(paho-mqtt3as ${OPENSSL_LIB} ${OPENSSLCRYPTO_LIB} ${LIBS_SYSTEM}) - SET_TARGET_PROPERTIES( - paho-mqtt3cs paho-mqtt3as PROPERTIES - VERSION ${CLIENT_VERSION} - SOVERSION ${PAHO_VERSION_MAJOR} - COMPILE_DEFINITIONS "OPENSSL=1") - INSTALL(TARGETS paho-mqtt3cs paho-mqtt3as - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - - IF (PAHO_BUILD_STATIC) + + IF (NOT PAHO_BUILD_STATIC) + ADD_LIBRARY(paho-mqtt3cs SHARED $ MQTTClient.c SSLSocket.c) + ADD_LIBRARY(paho-mqtt3as SHARED $ MQTTAsync.c SSLSocket.c) + + TARGET_LINK_LIBRARIES(paho-mqtt3cs ${OPENSSL_LIB} ${OPENSSLCRYPTO_LIB} ${LIBS_SYSTEM}) + TARGET_LINK_LIBRARIES(paho-mqtt3as ${OPENSSL_LIB} ${OPENSSLCRYPTO_LIB} ${LIBS_SYSTEM}) + SET_TARGET_PROPERTIES( + paho-mqtt3cs paho-mqtt3as PROPERTIES + VERSION ${CLIENT_VERSION} + SOVERSION ${PAHO_VERSION_MAJOR} + COMPILE_DEFINITIONS "OPENSSL=1") + INSTALL(TARGETS paho-mqtt3cs paho-mqtt3as + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + ELSE() + message("Build as static library") ADD_LIBRARY(paho-mqtt3cs-static STATIC $ MQTTClient.c SSLSocket.c) ADD_LIBRARY(paho-mqtt3as-static STATIC $ MQTTAsync.c SSLSocket.c)