Compile broker against pthreads if threading enabled.

This allows plugins to *carefully* use threads.
This commit is contained in:
Roger A. Light
2022-04-01 13:48:26 +01:00
parent 8a9d8ece37
commit b922c13509
4 changed files with 18 additions and 1 deletions
+1 -1
View File
@@ -71,7 +71,7 @@ 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)
option(WITH_THREADING "Include threading support?" ON)
if(WITH_THREADING)
add_definitions("-DWITH_THREADING")
endif()
+8
View File
@@ -65,6 +65,14 @@ if(WITH_TLS AND CJSON_FOUND)
${CJSON_LIBRARIES}
)
if (WITH_THREADING AND NOT WIN32)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(mosquitto_ctrl PRIVATE Threads::Threads)
endif()
install(TARGETS mosquitto_ctrl
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
+2
View File
@@ -269,6 +269,8 @@ ifeq ($(WITH_TLS),yes)
endif
ifeq ($(WITH_THREADING),yes)
BROKER_CFLAGS:=$(BROKER_CFLAGS) -pthread
BROKER_LDFLAGS:=$(BROKER_LDFLAGS) -pthread
LIB_CFLAGS:=$(LIB_CFLAGS) -pthread
LIB_CPPFLAGS:=$(LIB_CPPFLAGS) -DWITH_THREADING
LIB_LDFLAGS:=$(LIB_LDFLAGS) -pthread
+7
View File
@@ -240,6 +240,13 @@ target_link_libraries(mosquitto
${MOSQ_LIBS}
)
if (WITH_THREADING AND NOT WIN32)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(mosquitto PRIVATE Threads::Threads)
endif()
if(WIN32)
set_target_properties(mosquitto PROPERTIES
ENABLE_EXPORTS 1