Skip to content

Commit

Permalink
Fix WITH_STATIC_LIBRARIES using CMake on Windows
Browse files Browse the repository at this point in the history
Closes #1369. Thanks to TimmvonderMehden
  • Loading branch information
ralight committed Sep 17, 2019
1 parent a415d41 commit 04cf0cd
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Expand Up @@ -50,6 +50,9 @@ endif (WITH_SOCKS)

option(WITH_SRV "Include SRV lookup support?" OFF)

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)

option(WITH_THREADING "Include client library threading support?" ON)
if (WITH_THREADING)
add_definitions("-DWITH_THREADING")
Expand Down
1 change: 1 addition & 0 deletions ChangeLog.txt
Expand Up @@ -4,6 +4,7 @@ Broker:

Build:
- Fix missing function warnings on NetBSD.
- Fix WITH_STATIC_LIBRARIES using CMake on Windows. Closes #1369.


1.6.4 - 20190801
Expand Down
13 changes: 9 additions & 4 deletions client/CMakeLists.txt
Expand Up @@ -13,10 +13,15 @@ add_executable(mosquitto_pub pub_client.c pub_shared.c ${shared_src})
add_executable(mosquitto_sub sub_client.c sub_client_output.c ${shared_src})
add_executable(mosquitto_rr rr_client.c pub_shared.c sub_client_output.c ${shared_src})


target_link_libraries(mosquitto_pub libmosquitto)
target_link_libraries(mosquitto_sub libmosquitto)
target_link_libraries(mosquitto_rr libmosquitto)
if (WITH_STATIC_LIBRARIES)
target_link_libraries(mosquitto_pub libmosquitto_static)
target_link_libraries(mosquitto_sub libmosquitto_static)
target_link_libraries(mosquitto_rr libmosquitto_static)
else()
target_link_libraries(mosquitto_pub libmosquitto)
target_link_libraries(mosquitto_sub libmosquitto)
target_link_libraries(mosquitto_rr libmosquitto)
endif()

if (QNX)
target_link_libraries(mosquitto_pub socket)
Expand Down
4 changes: 1 addition & 3 deletions lib/CMakeLists.txt
@@ -1,5 +1,3 @@
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)
add_subdirectory(cpp)

include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/lib
Expand Down Expand Up @@ -102,7 +100,7 @@ if (WITH_STATIC_LIBRARIES)
target_link_libraries(libmosquitto_static ${LIBRARIES})

set_target_properties(libmosquitto_static PROPERTIES
OUTPUT_NAME mosquitto
OUTPUT_NAME mosquitto_static
VERSION ${VERSION}
)

Expand Down
2 changes: 1 addition & 1 deletion lib/cpp/CMakeLists.txt
Expand Up @@ -29,7 +29,7 @@ if (WITH_STATIC_LIBRARIES)
target_link_libraries(mosquittopp_static ${LIBRARIES})

set_target_properties(mosquittopp_static PROPERTIES
OUTPUT_NAME mosquittopp
OUTPUT_NAME mosquittopp_static
VERSION ${VERSION}
)

Expand Down
2 changes: 1 addition & 1 deletion lib/cpp/mosquittopp.h
Expand Up @@ -17,7 +17,7 @@ and the Eclipse Distribution License is available at
#ifndef MOSQUITTOPP_H
#define MOSQUITTOPP_H

#ifdef _WIN32
#if defined(_WIN32) && !defined(LIBMOSQUITTO_STATIC)
# ifdef mosquittopp_EXPORTS
# define mosqpp_EXPORT __declspec(dllexport)
# else
Expand Down

0 comments on commit 04cf0cd

Please sign in to comment.