mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-09-20 23:03:55 +08:00
Compile broker against pthreads if threading enabled.
This allows plugins to *carefully* use threads.
This commit is contained in:
+1
-1
@@ -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()
|
||||
|
||||
@@ -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}"
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user