mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-09-28 16:14:35 +08:00
Update threaded builds.
Most specifically use -pthread instead of -lpthread.
This commit is contained in:
@@ -74,24 +74,6 @@ option(WITH_PIC "Build the static library with PIC (Position Independent Code) e
|
||||
option(WITH_THREADING "Include client library threading support?" ON)
|
||||
if(WITH_THREADING)
|
||||
add_definitions("-DWITH_THREADING")
|
||||
if(WIN32)
|
||||
set (PTHREAD_LIBRARIES "")
|
||||
set (PTHREAD_INCLUDE_DIR "")
|
||||
elseif(ANDROID)
|
||||
set (PTHREAD_LIBRARIES "")
|
||||
set (PTHREAD_INCLUDE_DIR "")
|
||||
else()
|
||||
find_library(LIBPTHREAD pthread)
|
||||
if(LIBPTHREAD)
|
||||
set (PTHREAD_LIBRARIES pthread)
|
||||
else()
|
||||
set (PTHREAD_LIBRARIES "")
|
||||
endif()
|
||||
set(PTHREAD_INCLUDE_DIR "")
|
||||
endif()
|
||||
else()
|
||||
set (PTHREAD_LIBRARIES "")
|
||||
set (PTHREAD_INCLUDE_DIR "")
|
||||
endif()
|
||||
|
||||
option(WITH_DLT "Include DLT support?" OFF)
|
||||
|
||||
+21
-13
@@ -6,7 +6,6 @@ endif()
|
||||
|
||||
set(CLIENT_INC
|
||||
"${OPENSSL_INCLUDE_DIR}"
|
||||
"${PTHREAD_INCLUDE_DIR}"
|
||||
"${STDBOOL_H_PATH}"
|
||||
"${STDINT_H_PATH}"
|
||||
"${mosquitto_SOURCE_DIR}"
|
||||
@@ -33,6 +32,15 @@ target_include_directories(mosquitto_pub PRIVATE ${CLIENT_INC})
|
||||
target_include_directories(mosquitto_sub PRIVATE ${CLIENT_INC})
|
||||
target_include_directories(mosquitto_rr PRIVATE ${CLIENT_INC})
|
||||
|
||||
if (WITH_THREADING AND NOT WIN32)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
target_link_libraries(mosquitto_pub PRIVATE Threads::Threads)
|
||||
target_link_libraries(mosquitto_sub PRIVATE Threads::Threads)
|
||||
target_link_libraries(mosquitto_rr PRIVATE Threads::Threads)
|
||||
endif()
|
||||
|
||||
if(WITH_BUNDLED_DEPS)
|
||||
target_include_directories(mosquitto_sub PRIVATE "${mosquitto_SOURCE_DIR}/deps")
|
||||
target_include_directories(mosquitto_rr PRIVATE "${mosquitto_SOURCE_DIR}/deps")
|
||||
@@ -42,25 +50,25 @@ link_directories(${CLIENT_DIR})
|
||||
|
||||
|
||||
if(CJSON_FOUND)
|
||||
target_link_libraries(mosquitto_pub ${CJSON_LIBRARIES})
|
||||
target_link_libraries(mosquitto_sub ${CJSON_LIBRARIES})
|
||||
target_link_libraries(mosquitto_rr ${CJSON_LIBRARIES})
|
||||
target_link_libraries(mosquitto_pub PRIVATE ${CJSON_LIBRARIES})
|
||||
target_link_libraries(mosquitto_sub PRIVATE ${CJSON_LIBRARIES})
|
||||
target_link_libraries(mosquitto_rr PRIVATE ${CJSON_LIBRARIES})
|
||||
endif()
|
||||
|
||||
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)
|
||||
target_link_libraries(mosquitto_pub PRIVATE libmosquitto_static)
|
||||
target_link_libraries(mosquitto_sub PRIVATE libmosquitto_static)
|
||||
target_link_libraries(mosquitto_rr PRIVATE libmosquitto_static)
|
||||
else()
|
||||
target_link_libraries(mosquitto_pub libmosquitto)
|
||||
target_link_libraries(mosquitto_sub libmosquitto)
|
||||
target_link_libraries(mosquitto_rr libmosquitto)
|
||||
target_link_libraries(mosquitto_pub PRIVATE libmosquitto)
|
||||
target_link_libraries(mosquitto_sub PRIVATE libmosquitto)
|
||||
target_link_libraries(mosquitto_rr PRIVATE libmosquitto)
|
||||
endif()
|
||||
|
||||
if(QNX)
|
||||
target_link_libraries(mosquitto_pub socket)
|
||||
target_link_libraries(mosquitto_sub socket)
|
||||
target_link_libraries(mosquitto_rr socket)
|
||||
target_link_libraries(mosquitto_pub PRIVATE socket)
|
||||
target_link_libraries(mosquitto_sub PRIVATE socket)
|
||||
target_link_libraries(mosquitto_rr PRIVATE socket)
|
||||
endif()
|
||||
|
||||
install(TARGETS mosquitto_pub RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
|
||||
@@ -269,10 +269,13 @@ ifeq ($(WITH_TLS),yes)
|
||||
endif
|
||||
|
||||
ifeq ($(WITH_THREADING),yes)
|
||||
LIB_LIBADD:=$(LIB_LIBADD) -lpthread
|
||||
LIB_CFLAGS:=$(LIB_CFLAGS) -pthread
|
||||
LIB_CPPFLAGS:=$(LIB_CPPFLAGS) -DWITH_THREADING
|
||||
LIB_LDFLAGS:=$(LIB_LDFLAGS) -pthread
|
||||
CLIENT_CFLAGS:=$(CLIENT_CFLAGS) -pthread
|
||||
CLIENT_CPPFLAGS:=$(CLIENT_CPPFLAGS) -DWITH_THREADING
|
||||
STATIC_LIB_DEPS:=$(STATIC_LIB_DEPS) -lpthread
|
||||
CLIENT_LDFLAGS:=$(CLIENT_LDFLAGS) -pthread
|
||||
STATIC_LIB_DEPS:=$(STATIC_LIB_DEPS) -pthread
|
||||
endif
|
||||
|
||||
ifeq ($(WITH_SOCKS),yes)
|
||||
|
||||
+10
-6
@@ -54,11 +54,11 @@ set(C_SRC
|
||||
util_mosq.c util_topic.c util_mosq.h
|
||||
will_mosq.c will_mosq.h)
|
||||
|
||||
if (WIN32)
|
||||
if (WITH_THREADING AND WIN32)
|
||||
list(APPEND C_SRC "../common/winthread_mosq.c" "../common/winthread_mosq.h")
|
||||
endif()
|
||||
|
||||
set (LIBRARIES ${OPENSSL_LIBRARIES} ${PTHREAD_LIBRARIES})
|
||||
set (LIBRARIES ${OPENSSL_LIBRARIES})
|
||||
|
||||
if(UNIX AND NOT APPLE AND NOT ANDROID)
|
||||
find_library(LIBRT rt)
|
||||
@@ -103,7 +103,6 @@ endif()
|
||||
|
||||
target_include_directories(libmosquitto PRIVATE
|
||||
"${OPENSSL_INCLUDE_DIR}"
|
||||
"${PTHREAD_INCLUDE_DIR}"
|
||||
"${STDBOOL_H_PATH}"
|
||||
"${STDINT_H_PATH}"
|
||||
"${mosquitto_SOURCE_DIR}"
|
||||
@@ -120,8 +119,14 @@ if(WITH_BUNDLED_DEPS)
|
||||
)
|
||||
endif()
|
||||
|
||||
if (WITH_THREADING AND NOT WIN32)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
target_link_libraries(libmosquitto ${LIBRARIES})
|
||||
target_link_libraries(libmosquitto PRIVATE Threads::Threads)
|
||||
endif()
|
||||
|
||||
target_link_libraries(libmosquitto PRIVATE ${LIBRARIES})
|
||||
|
||||
set_target_properties(libmosquitto PROPERTIES
|
||||
OUTPUT_NAME mosquitto
|
||||
@@ -144,11 +149,10 @@ if(WITH_STATIC_LIBRARIES)
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(libmosquitto_static ${LIBRARIES})
|
||||
target_link_libraries(libmosquitto_static PRIVATE ${LIBRARIES})
|
||||
|
||||
target_include_directories(libmosquitto_static PRIVATE
|
||||
"${OPENSSL_INCLUDE_DIR}"
|
||||
"${PTHREAD_INCLUDE_DIR}"
|
||||
"${STDBOOL_H_PATH}"
|
||||
"${STDINT_H_PATH}"
|
||||
"${mosquitto_SOURCE_DIR}"
|
||||
|
||||
+10
-2
@@ -18,7 +18,15 @@ target_include_directories(mosquittopp PRIVATE
|
||||
|
||||
link_directories(${mosquitto_BINARY_DIR}/lib)
|
||||
|
||||
target_link_libraries(mosquittopp libmosquitto)
|
||||
target_link_libraries(mosquittopp PRIVATE libmosquitto)
|
||||
|
||||
if (WITH_THREADING AND NOT WIN32)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
target_link_libraries(mosquittopp PRIVATE Threads::Threads)
|
||||
endif()
|
||||
|
||||
set_target_properties(mosquittopp PROPERTIES
|
||||
VERSION ${VERSION}
|
||||
SOVERSION 1
|
||||
@@ -48,7 +56,7 @@ if(WITH_STATIC_LIBRARIES)
|
||||
"${mosquitto_SOURCE_DIR}/lib/cpp"
|
||||
)
|
||||
|
||||
target_link_libraries(mosquittopp_static ${LIBRARIES})
|
||||
target_link_libraries(mosquittopp_static PRIVATE ${LIBRARIES})
|
||||
|
||||
set_target_properties(mosquittopp_static PROPERTIES
|
||||
OUTPUT_NAME mosquittopp_static
|
||||
|
||||
@@ -4,7 +4,6 @@ if(CJSON_FOUND AND WITH_TLS)
|
||||
set(CLIENT_INC
|
||||
"${CJSON_INCLUDE_DIRS}"
|
||||
"${OPENSSL_INCLUDE_DIR}"
|
||||
"${PTHREAD_INCLUDE_DIR}"
|
||||
"${STDBOOL_H_PATH}"
|
||||
"${STDINT_H_PATH}"
|
||||
"${mosquitto_SOURCE_DIR}"
|
||||
|
||||
@@ -2,7 +2,6 @@ if(SQLITE3_FOUND AND CJSON_FOUND)
|
||||
add_definitions("-DWITH_CJSON")
|
||||
set(CLIENT_INC
|
||||
"${SQLITE3_INCLUDE_DIRS}"
|
||||
"${PTHREAD_INCLUDE_DIR}"
|
||||
"${STDBOOL_H_PATH}"
|
||||
"${STDINT_H_PATH}"
|
||||
"${mosquitto_SOURCE_DIR}"
|
||||
|
||||
Reference in New Issue
Block a user