Skip to content

Commit

Permalink
Fix mosquitto_pub -l if compiled using cmake.
Browse files Browse the repository at this point in the history
Since dde005e mosquito_pub is throwing error
that 'threading support has not been compiled' when compiled using cmake.
It looks like WITH_THREADING flag is not set at top level Makefile and used
only in lib/ directory, so library is correctly compiled with threading.
But for client this flag is undefined, so it gives error on '-l' option.

This commit moves part related to WITH_THREADING flag out of lib/CMakeLists.txt
to top levele CMakeLists.txt, so it could be accessible to all subdirectories.

Signed-off-by: Marek Wodzinski <[email protected]>
  • Loading branch information
majekw authored and ralight committed Oct 23, 2018
1 parent 0a9ee5b commit 7f1419e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,30 @@ endif (${WITH_SOCKS} STREQUAL ON)

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

option(WITH_THREADING "Include client library threading support?" ON)
if (${WITH_THREADING} STREQUAL ON)
add_definitions("-DWITH_THREADING")
if (WIN32)
if (CMAKE_CL_64)
set (PTHREAD_LIBRARIES C:\\pthreads\\Pre-built.2\\lib\\x64\\pthreadVC2.lib)
else (CMAKE_CL_64)
set (PTHREAD_LIBRARIES C:\\pthreads\\Pre-built.2\\lib\\x86\\pthreadVC2.lib)
endif (CMAKE_CL_64)
set (PTHREAD_INCLUDE_DIR C:\\pthreads\\Pre-built.2\\include)
else (WIN32)
find_library(LIBPTHREAD pthread)
if (LIBPTHREAD)
set (PTHREAD_LIBRARIES pthread)
else (LIBPTHREAD)
set (PTHREAD_LIBRARIES "")
endif()
set (PTHREAD_INCLUDE_DIR "")
endif (WIN32)
else (${WITH_THREADING} STREQUAL ON)
set (PTHREAD_LIBRARIES "")
set (PTHREAD_INCLUDE_DIR "")
endif (${WITH_THREADING} STREQUAL ON)

option(DOCUMENTATION "Build documentation?" ON)

# ========================================
Expand Down
3 changes: 3 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Library:
- Fix memory leak that occurred if mosquitto_reconnect() was used when TLS
errors were present. Closes #592.

Build:
- Fix clients not being compiled with threading support when using CMake.
Closes #983.

1.5.3 - 20180925
================
Expand Down
2 changes: 1 addition & 1 deletion client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/lib
${STDBOOL_H_PATH} ${STDINT_H_PATH})
${STDBOOL_H_PATH} ${STDINT_H_PATH} ${PTHREAD_INCLUDE_DIR})
link_directories(${mosquitto_BINARY_DIR}/lib)

set(shared_src client_shared.c client_shared.h)
Expand Down
24 changes: 0 additions & 24 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,6 @@ option(WITH_STATIC_LIBRARIES "Build static versions of the libmosquitto/pp libra
option(WITH_PIC "Build the static library with PIC (Position Independent Code) enabled archives?" OFF)
add_subdirectory(cpp)

option(WITH_THREADING "Include client library threading support?" ON)
if (${WITH_THREADING} STREQUAL ON)
add_definitions("-DWITH_THREADING")
if (WIN32)
if (CMAKE_CL_64)
set (PTHREAD_LIBRARIES C:\\pthreads\\Pre-built.2\\lib\\x64\\pthreadVC2.lib)
else (CMAKE_CL_64)
set (PTHREAD_LIBRARIES C:\\pthreads\\Pre-built.2\\lib\\x86\\pthreadVC2.lib)
endif (CMAKE_CL_64)
set (PTHREAD_INCLUDE_DIR C:\\pthreads\\Pre-built.2\\include)
else (WIN32)
find_library(LIBPTHREAD pthread)
if (LIBPTHREAD)
set (PTHREAD_LIBRARIES pthread)
else (LIBPTHREAD)
set (PTHREAD_LIBRARIES "")
endif()
set (PTHREAD_INCLUDE_DIR "")
endif (WIN32)
else (${WITH_THREADING} STREQUAL ON)
set (PTHREAD_LIBRARIES "")
set (PTHREAD_INCLUDE_DIR "")
endif (${WITH_THREADING} STREQUAL ON)

include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/lib
${STDBOOL_H_PATH} ${STDINT_H_PATH}
${OPENSSL_INCLUDE_DIR} ${PTHREAD_INCLUDE_DIR})
Expand Down

0 comments on commit 7f1419e

Please sign in to comment.