CMake tidy.

pull/2215/head
Roger Light 4 years ago
parent 160950dc73
commit 0a90e62f93

@ -4,35 +4,35 @@
# To configure the build options either use the CMake gui, or run the command # To configure the build options either use the CMake gui, or run the command
# line utility including the "-i" option. # line utility including the "-i" option.
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.10)
cmake_policy(SET CMP0042 NEW)
project(mosquitto)
set (VERSION 2.0.10) set (VERSION 2.0.10)
project(mosquitto
VERSION ${VERSION}
DESCRIPTION "Eclipse Mosquitto"
LANGUAGES C CXX
)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
add_definitions (-DCMAKE -DVERSION=\"${VERSION}\") add_definitions (-DCMAKE -DVERSION=\"${VERSION}\")
if (WIN32) if(WIN32)
add_definitions("-D_CRT_SECURE_NO_WARNINGS") add_definitions("-D_CRT_SECURE_NO_WARNINGS")
add_definitions("-D_CRT_NONSTDC_NO_DEPRECATE") add_definitions("-D_CRT_NONSTDC_NO_DEPRECATE")
endif (WIN32) endif()
if(APPLE) if(APPLE)
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -undefined dynamic_lookup") set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -undefined dynamic_lookup")
endif(APPLE) endif()
include(GNUInstallDirs) include(GNUInstallDirs)
include(CheckIncludeFiles) include(CheckIncludeFiles)
option(WITH_BUNDLED_DEPS "Build with bundled dependencies?" ON) option(WITH_BUNDLED_DEPS "Build with bundled dependencies?" ON)
option(WITH_TLS option(WITH_TLS "Include SSL/TLS support?" ON)
"Include SSL/TLS support?" ON) option(WITH_TLS_PSK "Include TLS-PSK support (requires WITH_TLS)?" ON)
option(WITH_TLS_PSK option(WITH_EC "Include Elliptic Curve support (requires WITH_TLS)?" ON)
"Include TLS-PSK support (requires WITH_TLS)?" ON)
option(WITH_EC
"Include Elliptic Curve support (requires WITH_TLS)?" ON)
if (WITH_TLS) if (WITH_TLS)
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)
add_definitions("-DWITH_TLS") add_definitions("-DWITH_TLS")
@ -44,70 +44,69 @@ if (WITH_TLS)
if (WITH_EC) if (WITH_EC)
add_definitions("-DWITH_EC") add_definitions("-DWITH_EC")
endif (WITH_EC) endif (WITH_EC)
else (WITH_TLS) else()
set (OPENSSL_INCLUDE_DIR "") set (OPENSSL_INCLUDE_DIR "")
endif (WITH_TLS) endif()
option(WITH_UNIX_SOCKETS "Include Unix Domain Socket support?" ON) option(WITH_UNIX_SOCKETS "Include Unix Domain Socket support?" ON)
if (WITH_UNIX_SOCKETS AND NOT WIN32) if(WITH_UNIX_SOCKETS AND NOT WIN32)
add_definitions("-DWITH_UNIX_SOCKETS") add_definitions("-DWITH_UNIX_SOCKETS")
endif (WITH_UNIX_SOCKETS AND NOT WIN32) endif()
option(WITH_SOCKS "Include SOCKS5 support?" ON) option(WITH_SOCKS "Include SOCKS5 support?" ON)
if (WITH_SOCKS) if(WITH_SOCKS)
add_definitions("-DWITH_SOCKS") add_definitions("-DWITH_SOCKS")
endif (WITH_SOCKS) endif()
option(WITH_SRV "Include SRV lookup support?" OFF) option(WITH_SRV "Include SRV lookup support?" OFF)
option(WITH_STATIC_LIBRARIES "Build static versions of the libmosquitto/pp libraries?" 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_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 client library threading support?" ON)
if (WITH_THREADING) if(WITH_THREADING)
add_definitions("-DWITH_THREADING") add_definitions("-DWITH_THREADING")
if (WIN32) if(WIN32)
if (CMAKE_CL_64) if(CMAKE_CL_64)
set (PTHREAD_LIBRARIES C:\\pthreads\\Pre-built.2\\lib\\x64\\pthreadVC2.lib) set (PTHREAD_LIBRARIES C:\\pthreads\\Pre-built.2\\lib\\x64\\pthreadVC2.lib)
else (CMAKE_CL_64) else()
set (PTHREAD_LIBRARIES C:\\pthreads\\Pre-built.2\\lib\\x86\\pthreadVC2.lib) set (PTHREAD_LIBRARIES C:\\pthreads\\Pre-built.2\\lib\\x86\\pthreadVC2.lib)
endif (CMAKE_CL_64) endif()
set (PTHREAD_INCLUDE_DIR C:\\pthreads\\Pre-built.2\\include) set (PTHREAD_INCLUDE_DIR C:\\pthreads\\Pre-built.2\\include)
elseif (ANDROID) elseif(ANDROID)
set (PTHREAD_LIBRARIES "") set (PTHREAD_LIBRARIES "")
set (PTHREAD_INCLUDE_DIR "") set (PTHREAD_INCLUDE_DIR "")
else (WIN32) else()
find_library(LIBPTHREAD pthread) find_library(LIBPTHREAD pthread)
if (LIBPTHREAD) if(LIBPTHREAD)
set (PTHREAD_LIBRARIES pthread) set (PTHREAD_LIBRARIES pthread)
else (LIBPTHREAD) else()
set (PTHREAD_LIBRARIES "") set (PTHREAD_LIBRARIES "")
endif() endif()
set (PTHREAD_INCLUDE_DIR "") set(PTHREAD_INCLUDE_DIR "")
endif (WIN32) endif()
else (WITH_THREADING) else()
set (PTHREAD_LIBRARIES "") set (PTHREAD_LIBRARIES "")
set (PTHREAD_INCLUDE_DIR "") set (PTHREAD_INCLUDE_DIR "")
endif (WITH_THREADING) endif()
option(WITH_DLT "Include DLT support?" OFF) option(WITH_DLT "Include DLT support?" OFF)
message(STATUS "WITH_DLT = ${WITH_DLT}") message(STATUS "WITH_DLT = ${WITH_DLT}")
if (WITH_DLT) if(WITH_DLT)
#find_package(DLT REQUIRED) #find_package(DLT REQUIRED)
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules(DLT "automotive-dlt >= 2.11") pkg_check_modules(DLT "automotive-dlt >= 2.11")
add_definitions("-DWITH_DLT") add_definitions("-DWITH_DLT")
endif (WITH_DLT) endif()
option(WITH_CJSON "Build with cJSON support (required for dynamic security plugin and useful for mosquitto_sub)?" ON) option(WITH_CJSON "Build with cJSON support (required for dynamic security plugin and useful for mosquitto_sub)?" ON)
if (WITH_CJSON) if(WITH_CJSON)
FIND_PACKAGE(cJSON) FIND_PACKAGE(cJSON)
if (CJSON_FOUND) if(CJSON_FOUND)
message(STATUS ${CJSON_FOUND}) message(STATUS ${CJSON_FOUND})
else (CJSON_FOUND) else()
message(STATUS "Optional dependency cJSON not found. Some features will be disabled.") message(STATUS "Optional dependency cJSON not found. Some features will be disabled.")
endif(CJSON_FOUND) endif()
endif() endif()
# ======================================== # ========================================
@ -121,33 +120,33 @@ option(WITH_PLUGINS "Build plugins?" ON)
option(DOCUMENTATION "Build documentation?" ON) option(DOCUMENTATION "Build documentation?" ON)
add_subdirectory(lib) add_subdirectory(lib)
if (WITH_CLIENTS) if(WITH_CLIENTS)
add_subdirectory(client) add_subdirectory(client)
endif (WITH_CLIENTS) endif()
if (WITH_BROKER) if(WITH_BROKER)
add_subdirectory(src) add_subdirectory(src)
endif (WITH_BROKER) endif()
if (WITH_APPS) if(WITH_APPS)
add_subdirectory(apps) add_subdirectory(apps)
endif (WITH_APPS) endif()
if (WITH_PLUGINS) if(WITH_PLUGINS)
add_subdirectory(plugins) add_subdirectory(plugins)
endif (WITH_PLUGINS) endif()
if (DOCUMENTATION) if(DOCUMENTATION)
add_subdirectory(man) add_subdirectory(man)
endif (DOCUMENTATION) endif()
# ======================================== # ========================================
# Install config file # Install config file
# ======================================== # ========================================
if (WITH_BROKER) if(WITH_BROKER)
install(FILES mosquitto.conf aclfile.example pskfile.example pwfile.example DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/mosquitto") install(FILES mosquitto.conf aclfile.example pskfile.example pwfile.example DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/mosquitto")
endif (WITH_BROKER) endif()
# ======================================== # ========================================
# Install pkg-config files # Install pkg-config files

@ -1,11 +1,6 @@
if (WITH_TLS AND CJSON_FOUND) if(WITH_TLS AND CJSON_FOUND)
add_definitions("-DWITH_CJSON") add_definitions("-DWITH_CJSON")
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include
${mosquitto_SOURCE_DIR}/lib ${mosquitto_SOURCE_DIR}/src
${OPENSSL_INCLUDE_DIR} ${STDBOOL_H_PATH} ${STDINT_H_PATH}
${CJSON_INCLUDE_DIRS} ${mosquitto_SOURCE_DIR}/apps/mosquitto_passwd)
link_directories(${CJSON_DIR}) link_directories(${CJSON_DIR})
add_executable(mosquitto_ctrl add_executable(mosquitto_ctrl
@ -22,27 +17,44 @@ if (WITH_TLS AND CJSON_FOUND)
../../src/password_mosq.c ../../src/password_mosq.h ../../src/password_mosq.c ../../src/password_mosq.h
) )
if (WITH_STATIC_LIBRARIES) target_include_directories(mosquitto_ctrl PRIVATE
"${CJSON_INCLUDE_DIRS}"
"${OPENSSL_INCLUDE_DIR}"
"${STDBOOL_H_PATH}"
"${STDINT_H_PATH}"
"${mosquitto_SOURCE_DIR}"
"${mosquitto_SOURCE_DIR}/apps/mosquitto_passwd"
"${mosquitto_SOURCE_DIR}/include"
"${mosquitto_SOURCE_DIR}/lib"
"${mosquitto_SOURCE_DIR}/src"
)
if(WITH_STATIC_LIBRARIES)
target_link_libraries(mosquitto_ctrl libmosquitto_static) target_link_libraries(mosquitto_ctrl libmosquitto_static)
else() else()
target_link_libraries(mosquitto_ctrl libmosquitto) target_link_libraries(mosquitto_ctrl libmosquitto)
endif() endif()
if (UNIX) if(UNIX)
if (APPLE) if(APPLE)
target_link_libraries(mosquitto_ctrl dl) target_link_libraries(mosquitto_ctrl dl)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") elseif(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
# #
elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD") elseif(${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
# #
elseif(QNX) elseif(QNX)
# #
else(APPLE) else()
target_link_libraries(mosquitto_ctrl dl) target_link_libraries(mosquitto_ctrl dl)
endif (APPLE) endif()
endif (UNIX) endif()
target_link_libraries(mosquitto_ctrl ${OPENSSL_LIBRARIES} ${CJSON_LIBRARIES}) target_link_libraries(mosquitto_ctrl
${OPENSSL_LIBRARIES}
${CJSON_LIBRARIES}
)
install(TARGETS mosquitto_ctrl RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") install(TARGETS mosquitto_ctrl
endif (WITH_TLS AND CJSON_FOUND) RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
endif()

@ -1,8 +1,4 @@
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include if(WITH_TLS)
${mosquitto_SOURCE_DIR}/lib ${mosquitto_SOURCE_DIR}/src
${OPENSSL_INCLUDE_DIR} ${STDBOOL_H_PATH} ${STDINT_H_PATH})
if (WITH_TLS)
add_executable(mosquitto_passwd add_executable(mosquitto_passwd
mosquitto_passwd.c mosquitto_passwd.c
get_password.c get_password.h get_password.c get_password.h
@ -12,7 +8,21 @@ if (WITH_TLS)
../../src/password_mosq.c ../../src/password_mosq.h ../../src/password_mosq.c ../../src/password_mosq.h
) )
target_include_directories(mosquitto_passwd PRIVATE
"${OPENSSL_INCLUDE_DIR}"
"${STDBOOL_H_PATH}"
"${STDINT_H_PATH}"
"${mosquitto_SOURCE_DIR}"
"${mosquitto_SOURCE_DIR}/include"
"${mosquitto_SOURCE_DIR}/lib"
"${mosquitto_SOURCE_DIR}/src"
)
target_link_libraries(mosquitto_passwd ${OPENSSL_LIBRARIES}) target_link_libraries(mosquitto_passwd
install(TARGETS mosquitto_passwd RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") ${OPENSSL_LIBRARIES}
endif (WITH_TLS) )
install(TARGETS mosquitto_passwd
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
endif()

@ -1,35 +1,44 @@
set(shared_src client_shared.c client_shared.h client_props.c) set(shared_src client_shared.c client_shared.h client_props.c)
if (WITH_SRV) if(WITH_SRV)
add_definitions("-DWITH_SRV") add_definitions("-DWITH_SRV")
endif (WITH_SRV) endif()
set( CLIENT_INC ${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include set(CLIENT_INC
${STDBOOL_H_PATH} ${STDINT_H_PATH} ${PTHREAD_INCLUDE_DIR} "${OPENSSL_INCLUDE_DIR}"
${OPENSSL_INCLUDE_DIR}) "${PTHREAD_INCLUDE_DIR}"
"${STDBOOL_H_PATH}"
"${STDINT_H_PATH}"
"${mosquitto_SOURCE_DIR}"
"${mosquitto_SOURCE_DIR}/include"
)
set( CLIENT_DIR ${mosquitto_BINARY_DIR}/lib) set(CLIENT_DIR ${mosquitto_BINARY_DIR}/lib)
if (CJSON_FOUND) if(CJSON_FOUND)
add_definitions("-DWITH_CJSON") add_definitions("-DWITH_CJSON")
set( CLIENT_DIR "${CLIENT_DIR};${CJSON_DIR}" ) set(CLIENT_DIR "${CLIENT_DIR};${CJSON_DIR}")
set( CLIENT_INC "${CLIENT_INC};${CJSON_INCLUDE_DIRS}" ) set(CLIENT_INC "${CLIENT_INC};${CJSON_INCLUDE_DIRS}")
endif() endif()
include_directories(${CLIENT_INC})
link_directories(${CLIENT_DIR})
add_executable(mosquitto_pub pub_client.c pub_shared.c ${shared_src}) 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_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}) add_executable(mosquitto_rr rr_client.c pub_shared.c sub_client_output.c ${shared_src})
if (CJSON_FOUND) target_include_directories(mosquitto_pub PRIVATE ${CLIENT_INC})
target_include_directories(mosquitto_sub PRIVATE ${CLIENT_INC})
target_include_directories(mosquitto_rr PRIVATE ${CLIENT_INC})
link_directories(${CLIENT_DIR})
if(CJSON_FOUND)
target_link_libraries(mosquitto_pub ${CJSON_LIBRARIES}) target_link_libraries(mosquitto_pub ${CJSON_LIBRARIES})
target_link_libraries(mosquitto_sub ${CJSON_LIBRARIES}) target_link_libraries(mosquitto_sub ${CJSON_LIBRARIES})
target_link_libraries(mosquitto_rr ${CJSON_LIBRARIES}) target_link_libraries(mosquitto_rr ${CJSON_LIBRARIES})
endif() endif()
if (WITH_STATIC_LIBRARIES) if(WITH_STATIC_LIBRARIES)
target_link_libraries(mosquitto_pub libmosquitto_static) target_link_libraries(mosquitto_pub libmosquitto_static)
target_link_libraries(mosquitto_sub libmosquitto_static) target_link_libraries(mosquitto_sub libmosquitto_static)
target_link_libraries(mosquitto_rr libmosquitto_static) target_link_libraries(mosquitto_rr libmosquitto_static)
@ -39,7 +48,7 @@ else()
target_link_libraries(mosquitto_rr libmosquitto) target_link_libraries(mosquitto_rr libmosquitto)
endif() endif()
if (QNX) if(QNX)
target_link_libraries(mosquitto_pub socket) target_link_libraries(mosquitto_pub socket)
target_link_libraries(mosquitto_sub socket) target_link_libraries(mosquitto_sub socket)
target_link_libraries(mosquitto_rr socket) target_link_libraries(mosquitto_rr socket)

@ -1,17 +1,7 @@
option(WITH_LIB_CPP "Build C++ library?" ON) option(WITH_LIB_CPP "Build C++ library?" ON)
if (WITH_LIB_CPP) if(WITH_LIB_CPP)
add_subdirectory(cpp) add_subdirectory(cpp)
endif (WITH_LIB_CPP) endif()
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/lib
${mosquitto_SOURCE_DIR}/include
${STDBOOL_H_PATH} ${STDINT_H_PATH}
${OPENSSL_INCLUDE_DIR} ${PTHREAD_INCLUDE_DIR})
link_directories(${mosquitto_SOURCE_DIR}/lib)
if (WITH_BUNDLED_DEPS)
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/deps)
endif (WITH_BUNDLED_DEPS)
set(C_SRC set(C_SRC
actions.c actions.c
@ -62,50 +52,74 @@ set(C_SRC
set (LIBRARIES ${OPENSSL_LIBRARIES} ${PTHREAD_LIBRARIES}) set (LIBRARIES ${OPENSSL_LIBRARIES} ${PTHREAD_LIBRARIES})
if (UNIX AND NOT APPLE AND NOT ANDROID) if(UNIX AND NOT APPLE AND NOT ANDROID)
find_library(LIBRT rt) find_library(LIBRT rt)
if (LIBRT) if(LIBRT)
set (LIBRARIES ${LIBRARIES} rt) set (LIBRARIES ${LIBRARIES} rt)
endif (LIBRT) endif()
endif (UNIX AND NOT APPLE AND NOT ANDROID) endif()
if (WIN32) if(WIN32)
set (LIBRARIES ${LIBRARIES} ws2_32) set (LIBRARIES ${LIBRARIES} ws2_32)
endif (WIN32) endif()
if (WITH_SRV) if(WITH_SRV)
# Simple detect c-ares # Simple detect c-ares
find_path(ARES_HEADER ares.h) find_path(ARES_HEADER ares.h)
if (ARES_HEADER) if(ARES_HEADER)
add_definitions("-DWITH_SRV") add_definitions("-DWITH_SRV")
set (LIBRARIES ${LIBRARIES} cares) set (LIBRARIES ${LIBRARIES} cares)
else (ARES_HEADER) else()
message(WARNING "c-ares library not found.") message(WARNING "c-ares library not found.")
endif (ARES_HEADER) endif()
endif (WITH_SRV) endif()
add_library(libmosquitto SHARED ${C_SRC}) add_library(libmosquitto SHARED
set_target_properties(libmosquitto PROPERTIES ${C_SRC}
POSITION_INDEPENDENT_CODE 1
) )
target_include_directories(libmosquitto PRIVATE
"${OPENSSL_INCLUDE_DIR}"
"${PTHREAD_INCLUDE_DIR}"
"${STDBOOL_H_PATH}"
"${STDINT_H_PATH}"
"${mosquitto_SOURCE_DIR}"
"${mosquitto_SOURCE_DIR}/include"
"${mosquitto_SOURCE_DIR}/lib"
)
link_directories("${mosquitto_SOURCE_DIR}/lib")
if(WITH_BUNDLED_DEPS)
target_include_directories(libmosquitto PRIVATE
"${mosquitto_SOURCE_DIR}/deps"
)
endif()
target_link_libraries(libmosquitto ${LIBRARIES}) target_link_libraries(libmosquitto ${LIBRARIES})
set_target_properties(libmosquitto PROPERTIES set_target_properties(libmosquitto PROPERTIES
OUTPUT_NAME mosquitto OUTPUT_NAME mosquitto
VERSION ${VERSION} VERSION ${VERSION}
SOVERSION 1 SOVERSION 1
POSITION_INDEPENDENT_CODE 1
) )
install(TARGETS libmosquitto RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") install(TARGETS libmosquitto
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
if (WITH_STATIC_LIBRARIES) if(WITH_STATIC_LIBRARIES)
add_library(libmosquitto_static STATIC ${C_SRC}) add_library(libmosquitto_static STATIC
if (WITH_PIC) ${C_SRC}
)
if(WITH_PIC)
set_target_properties(libmosquitto_static PROPERTIES set_target_properties(libmosquitto_static PROPERTIES
POSITION_INDEPENDENT_CODE 1 POSITION_INDEPENDENT_CODE 1
) )
endif (WITH_PIC) endif()
target_link_libraries(libmosquitto_static ${LIBRARIES}) target_link_libraries(libmosquitto_static ${LIBRARIES})
@ -115,8 +129,10 @@ if (WITH_STATIC_LIBRARIES)
) )
target_compile_definitions(libmosquitto_static PUBLIC "LIBMOSQUITTO_STATIC") target_compile_definitions(libmosquitto_static PUBLIC "LIBMOSQUITTO_STATIC")
install(TARGETS libmosquitto_static ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}") install(TARGETS libmosquitto_static
endif (WITH_STATIC_LIBRARIES) ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
endif()
install(FILES ../include/mosquitto.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") install(FILES ../include/mosquitto.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(FILES ../include/mqtt_protocol.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") install(FILES ../include/mqtt_protocol.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

@ -1,31 +1,43 @@
include_directories(${mosquitto_SOURCE_DIR}/lib ${mosquitto_SOURCE_DIR}/lib/cpp
${mosquitto_SOURCE_DIR}/include
${STDBOOL_H_PATH} ${STDINT_H_PATH})
link_directories(${mosquitto_BINARY_DIR}/lib)
set(CPP_SRC mosquittopp.cpp mosquittopp.h) set(CPP_SRC mosquittopp.cpp mosquittopp.h)
add_library(mosquittopp SHARED ${CPP_SRC}) add_library(mosquittopp SHARED
${CPP_SRC}
)
set_target_properties(mosquittopp PROPERTIES set_target_properties(mosquittopp PROPERTIES
POSITION_INDEPENDENT_CODE 1 POSITION_INDEPENDENT_CODE 1
) )
target_include_directories(mosquittopp PRIVATE
"${STDBOOL_H_PATH}"
"${STDINT_H_PATH}"
"${mosquitto_SOURCE_DIR}/include"
"${mosquitto_SOURCE_DIR}/lib"
"${mosquitto_SOURCE_DIR}/lib/cpp"
)
link_directories(${mosquitto_BINARY_DIR}/lib)
target_link_libraries(mosquittopp libmosquitto) target_link_libraries(mosquittopp libmosquitto)
set_target_properties(mosquittopp PROPERTIES set_target_properties(mosquittopp PROPERTIES
VERSION ${VERSION} VERSION ${VERSION}
SOVERSION 1 SOVERSION 1
) )
install(TARGETS mosquittopp RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") install(TARGETS mosquittopp
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
if (WITH_STATIC_LIBRARIES) if(WITH_STATIC_LIBRARIES)
add_library(mosquittopp_static STATIC add_library(mosquittopp_static STATIC
${C_SRC} ${C_SRC}
${CPP_SRC} ${CPP_SRC}
) )
if (WITH_PIC) if(WITH_PIC)
set_target_properties(mosquittopp_static PROPERTIES set_target_properties(mosquittopp_static PROPERTIES
POSITION_INDEPENDENT_CODE 1 POSITION_INDEPENDENT_CODE 1
) )
endif (WITH_PIC) endif()
target_link_libraries(mosquittopp_static ${LIBRARIES}) target_link_libraries(mosquittopp_static ${LIBRARIES})
@ -35,7 +47,9 @@ if (WITH_STATIC_LIBRARIES)
) )
target_compile_definitions(mosquittopp_static PUBLIC "LIBMOSQUITTO_STATIC") target_compile_definitions(mosquittopp_static PUBLIC "LIBMOSQUITTO_STATIC")
install(TARGETS mosquittopp_static ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}") install(TARGETS mosquittopp_static
endif (WITH_STATIC_LIBRARIES) ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
endif()
install(FILES mosquittopp.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") install(FILES mosquittopp.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

@ -8,23 +8,23 @@ if(NOT WIN32)
find_program(XSLTPROC xsltproc OPTIONAL) find_program(XSLTPROC xsltproc OPTIONAL)
if(XSLTPROC) if(XSLTPROC)
function(compile_manpage page) function(compile_manpage page)
add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/man/${page} add_custom_command(OUTPUT "${CMAKE_SOURCE_DIR}/man/${page}"
COMMAND xsltproc ${CMAKE_SOURCE_DIR}/man/${page}.xml -o ${CMAKE_SOURCE_DIR}/man/ COMMAND xsltproc "${CMAKE_SOURCE_DIR}/man/${page}.xml" -o "${CMAKE_SOURCE_DIR}/man/"
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/man/${page}.xml) MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/man/${page}.xml")
add_custom_target(${page} ALL DEPENDS ${CMAKE_SOURCE_DIR}/man/${page}) add_custom_target(${page} ALL DEPENDS "${CMAKE_SOURCE_DIR}/man/${page}")
endfunction() endfunction()
compile_manpage("libmosquitto.3")
compile_manpage("mosquitto-tls.7")
compile_manpage("mosquitto.8")
compile_manpage("mosquitto.conf.5")
compile_manpage("mosquitto_ctrl.1") compile_manpage("mosquitto_ctrl.1")
compile_manpage("mosquitto_ctrl_dynsec.1") compile_manpage("mosquitto_ctrl_dynsec.1")
compile_manpage("mosquitto_passwd.1") compile_manpage("mosquitto_passwd.1")
compile_manpage("mosquitto_pub.1") compile_manpage("mosquitto_pub.1")
compile_manpage("mosquitto_sub.1")
compile_manpage("mosquitto_rr.1") compile_manpage("mosquitto_rr.1")
compile_manpage("libmosquitto.3") compile_manpage("mosquitto_sub.1")
compile_manpage("mosquitto.conf.5")
compile_manpage("mosquitto-tls.7")
compile_manpage("mqtt.7") compile_manpage("mqtt.7")
compile_manpage("mosquitto.8")
else() else()
message(FATAL_ERROR "xsltproc not found: manpages cannot be built") message(FATAL_ERROR "xsltproc not found: manpages cannot be built")
endif() endif()
@ -36,12 +36,12 @@ install(FILES
mosquitto_ctrl_dynsec.1 mosquitto_ctrl_dynsec.1
mosquitto_passwd.1 mosquitto_passwd.1
mosquitto_pub.1 mosquitto_pub.1
mosquitto_sub.1
mosquitto_rr.1 mosquitto_rr.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 mosquitto_sub.1
DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
OPTIONAL) OPTIONAL)
install(FILES libmosquitto.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3 OPTIONAL) install(FILES libmosquitto.3 DESTINATION "${CMAKE_INSTALL_MANDIR}/man3" OPTIONAL)
install(FILES mosquitto.conf.5 DESTINATION ${CMAKE_INSTALL_MANDIR}/man5 OPTIONAL) install(FILES mosquitto.conf.5 DESTINATION "${CMAKE_INSTALL_MANDIR}/man5" OPTIONAL)
install(FILES mosquitto-tls.7 mqtt.7 DESTINATION ${CMAKE_INSTALL_MANDIR}/man7 OPTIONAL) install(FILES mosquitto-tls.7 mqtt.7 DESTINATION "${CMAKE_INSTALL_MANDIR}/man7" OPTIONAL)
install(FILES mosquitto.8 DESTINATION ${CMAKE_INSTALL_MANDIR}/man8 OPTIONAL) install(FILES mosquitto.8 DESTINATION "${CMAKE_INSTALL_MANDIR}/man8" OPTIONAL)

@ -1,16 +1,19 @@
if (CJSON_FOUND AND WITH_TLS) if(CJSON_FOUND AND WITH_TLS)
add_definitions("-DWITH_CJSON") add_definitions("-DWITH_CJSON")
set( CLIENT_INC ${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include set(CLIENT_INC
${STDBOOL_H_PATH} ${STDINT_H_PATH} ${PTHREAD_INCLUDE_DIR} "${CJSON_INCLUDE_DIRS}"
${OPENSSL_INCLUDE_DIR} ${mosquitto_SOURCE_DIR}/deps "${OPENSSL_INCLUDE_DIR}"
${mosquitto_SOURCE_DIR}/src "${PTHREAD_INCLUDE_DIR}"
${CJSON_INCLUDE_DIRS} ) "${STDBOOL_H_PATH}"
"${STDINT_H_PATH}"
set( CLIENT_DIR ${mosquitto_BINARY_DIR}/lib ${CJSON_DIR}) "${mosquitto_SOURCE_DIR}"
"${mosquitto_SOURCE_DIR}/deps"
"${mosquitto_SOURCE_DIR}/include"
"${mosquitto_SOURCE_DIR}/src"
)
include_directories(${CLIENT_INC}) set(CLIENT_DIR "${mosquitto_BINARY_DIR}/lib" "${CJSON_DIR}")
link_directories(${CLIENT_DIR} ${mosquitto_SOURCE_DIR})
add_library(mosquitto_dynamic_security SHARED add_library(mosquitto_dynamic_security SHARED
acl.c acl.c
@ -25,17 +28,26 @@ if (CJSON_FOUND AND WITH_TLS)
plugin.c plugin.c
roles.c roles.c
rolelist.c rolelist.c
sub_matches_sub.c) sub_matches_sub.c
)
target_include_directories(mosquitto_dynamic_security PRIVATE
${CLIENT_INC}
)
link_directories(${CLIENT_DIR} "${mosquitto_SOURCE_DIR}")
set_target_properties(mosquitto_dynamic_security PROPERTIES set_target_properties(mosquitto_dynamic_security PROPERTIES
PREFIX ""
POSITION_INDEPENDENT_CODE 1 POSITION_INDEPENDENT_CODE 1
) )
set_target_properties(mosquitto_dynamic_security PROPERTIES PREFIX "")
target_link_libraries(mosquitto_dynamic_security ${CJSON_LIBRARIES}) target_link_libraries(mosquitto_dynamic_security ${CJSON_LIBRARIES})
if(WIN32) if(WIN32)
target_link_libraries(mosquitto_dynamic_security mosquitto) target_link_libraries(mosquitto_dynamic_security mosquitto)
endif(WIN32) endif()
install(TARGETS mosquitto_dynamic_security RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") install(TARGETS mosquitto_dynamic_security
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
endif() endif()

@ -1,7 +1,7 @@
if(NOT WIN32) if(NOT WIN32)
add_subdirectory(add-properties) add_subdirectory(add-properties)
add_subdirectory(message-timestamp) add_subdirectory(message-timestamp)
endif(NOT WIN32) endif()
add_subdirectory(auth-by-ip) add_subdirectory(auth-by-ip)
add_subdirectory(client-properties) add_subdirectory(client-properties)
add_subdirectory(connection-state) add_subdirectory(connection-state)

@ -1,11 +1,18 @@
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include add_library(mosquitto_add_properties SHARED
${STDBOOL_H_PATH} ${STDINT_H_PATH}) mosquitto_add_properties.c
)
target_include_directories(mosquitto_add_properties PRIVATE
"${STDBOOL_H_PATH}"
"${STDINT_H_PATH}"
"${mosquitto_SOURCE_DIR}"
"${mosquitto_SOURCE_DIR}/include"
)
add_library(mosquitto_add_properties SHARED mosquitto_add_properties.c)
set_target_properties(mosquitto_add_properties PROPERTIES set_target_properties(mosquitto_add_properties PROPERTIES
PREFIX ""
POSITION_INDEPENDENT_CODE 1 POSITION_INDEPENDENT_CODE 1
) )
set_target_properties(mosquitto_add_properties PROPERTIES PREFIX "")
# Don't install, these are example plugins only. # Don't install, these are example plugins only.
#install(TARGETS mosquitto_add_properties RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") #install(TARGETS mosquitto_add_properties RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

@ -1,11 +1,18 @@
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include add_library(mosquitto_auth_by_ip SHARED
${OPENSSL_INCLUDE_DIR} ${STDBOOL_H_PATH} ${STDINT_H_PATH}) mosquitto_auth_by_ip.c
)
target_include_directories(mosquitto_auth_by_ip PRIVATE
"${OPENSSL_INCLUDE_DIR}"
"${STDBOOL_H_PATH} ${STDINT_H_PATH}"
"${mosquitto_SOURCE_DIR}"
"${mosquitto_SOURCE_DIR}/include"
)
add_library(mosquitto_auth_by_ip SHARED mosquitto_auth_by_ip.c)
set_target_properties(mosquitto_auth_by_ip PROPERTIES set_target_properties(mosquitto_auth_by_ip PROPERTIES
PREFIX ""
POSITION_INDEPENDENT_CODE 1 POSITION_INDEPENDENT_CODE 1
) )
set_target_properties(mosquitto_auth_by_ip PROPERTIES PREFIX "")
# Don't install, these are example plugins only. # Don't install, these are example plugins only.
#install(TARGETS mosquitto_auth_by_ip RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") #install(TARGETS mosquitto_auth_by_ip RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

@ -1,15 +1,24 @@
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include add_library(mosquitto_client_properties SHARED
${STDBOOL_H_PATH} ${STDINT_H_PATH}) mosquitto_client_properties.c
)
target_include_directories(mosquitto_client_properties PRIVATE
"${STDBOOL_H_PATH}"
"${STDINT_H_PATH}"
"${mosquitto_SOURCE_DIR}"
"${mosquitto_SOURCE_DIR}/include"
)
link_directories(${mosquitto_SOURCE_DIR}) link_directories(${mosquitto_SOURCE_DIR})
add_library(mosquitto_client_properties SHARED mosquitto_client_properties.c)
set_target_properties(mosquitto_client_properties PROPERTIES set_target_properties(mosquitto_client_properties PROPERTIES
PREFIX ""
POSITION_INDEPENDENT_CODE 1 POSITION_INDEPENDENT_CODE 1
) )
set_target_properties(mosquitto_client_properties PROPERTIES PREFIX "")
if(WIN32) if(WIN32)
target_link_libraries(mosquitto_client_properties mosquitto) target_link_libraries(mosquitto_client_properties mosquitto)
endif(WIN32) endif()
# Don't install, these are example plugins only. # Don't install, these are example plugins only.
#install(TARGETS mosquitto_client_properties RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") #install(TARGETS mosquitto_client_properties RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

@ -1,11 +1,18 @@
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include add_library(mosquitto_connection_state SHARED
${STDBOOL_H_PATH} ${STDINT_H_PATH}) mosquitto_connection_state.c
)
target_include_directories(mosquitto_connection_state PRIVATE
"${STDBOOL_H_PATH}"
"${STDINT_H_PATH}"
"${mosquitto_SOURCE_DIR}"
"${mosquitto_SOURCE_DIR}/include"
)
add_library(mosquitto_connection_state SHARED mosquitto_connection_state.c)
set_target_properties(mosquitto_connection_state PROPERTIES set_target_properties(mosquitto_connection_state PROPERTIES
PREFIX ""
POSITION_INDEPENDENT_CODE 1 POSITION_INDEPENDENT_CODE 1
) )
set_target_properties(mosquitto_connection_state PROPERTIES PREFIX "")
# Don't install, these are example plugins only. # Don't install, these are example plugins only.
#install(TARGETS mosquitto_connection_state RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") #install(TARGETS mosquitto_connection_state RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

@ -1,11 +1,19 @@
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include add_library(mosquitto_message_timestamp SHARED
${OPENSSL_INCLUDE_DIR} ${STDBOOL_H_PATH} ${STDINT_H_PATH}) mosquitto_message_timestamp.c
)
target_include_directories(mosquitto_message_timestamp PRIVATE
"${OPENSSL_INCLUDE_DIR}"
"${STDBOOL_H_PATH}"
"${STDINT_H_PATH}"
"${mosquitto_SOURCE_DIR}"
"${mosquitto_SOURCE_DIR}/include"
)
add_library(mosquitto_message_timestamp SHARED mosquitto_message_timestamp.c)
set_target_properties(mosquitto_message_timestamp PROPERTIES set_target_properties(mosquitto_message_timestamp PROPERTIES
PREFIX ""
POSITION_INDEPENDENT_CODE 1 POSITION_INDEPENDENT_CODE 1
) )
set_target_properties(mosquitto_message_timestamp PROPERTIES PREFIX "")
# Don't install, these are example plugins only. # Don't install, these are example plugins only.
#install(TARGETS mosquitto_message_timestamp RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") #install(TARGETS mosquitto_message_timestamp RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

@ -1,15 +1,24 @@
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/include add_library(mosquitto_payload_modification SHARED
${OPENSSL_INCLUDE_DIR} ${STDBOOL_H_PATH} ${STDINT_H_PATH}) mosquitto_payload_modification.c
)
target_include_directories(mosquitto_payload_modification PRIVATE
"${OPENSSL_INCLUDE_DIR}"
"${STDBOOL_H_PATH}"
"${STDINT_H_PATH}"
"${mosquitto_SOURCE_DIR}"
"${mosquitto_SOURCE_DIR}/include"
)
link_directories(${mosquitto_SOURCE_DIR}) link_directories(${mosquitto_SOURCE_DIR})
add_library(mosquitto_payload_modification SHARED mosquitto_payload_modification.c)
set_target_properties(mosquitto_payload_modification PROPERTIES set_target_properties(mosquitto_payload_modification PROPERTIES
PREFIX ""
POSITION_INDEPENDENT_CODE 1 POSITION_INDEPENDENT_CODE 1
) )
set_target_properties(mosquitto_payload_modification PROPERTIES PREFIX "")
if(WIN32) if(WIN32)
target_link_libraries(mosquitto_payload_modification mosquitto) target_link_libraries(mosquitto_payload_modification mosquitto)
endif(WIN32) endif()
# Don't install, these are example plugins only. # Don't install, these are example plugins only.
#install(TARGETS mosquitto_payload_modification RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") #install(TARGETS mosquitto_payload_modification RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

@ -1,7 +1,3 @@
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/src
${mosquitto_SOURCE_DIR}/include ${mosquitto_SOURCE_DIR}/lib
${OPENSSL_INCLUDE_DIR} ${STDBOOL_H_PATH} ${STDINT_H_PATH})
set (MOSQ_SRCS set (MOSQ_SRCS
../lib/alias_mosq.c ../lib/alias_mosq.h ../lib/alias_mosq.c ../lib/alias_mosq.h
bridge.c bridge_topic.c bridge.c bridge_topic.c
@ -71,110 +67,100 @@ set (MOSQ_SRCS
../lib/utf8_mosq.c ../lib/utf8_mosq.c
websockets.c websockets.c
will_delay.c will_delay.c
../lib/will_mosq.c ../lib/will_mosq.h) ../lib/will_mosq.c ../lib/will_mosq.h
)
CHECK_INCLUDE_FILES(sys/event.h HAVE_SYS_EVENT_H) CHECK_INCLUDE_FILES(sys/event.h HAVE_SYS_EVENT_H)
if (HAVE_SYS_EVENT_H) if(HAVE_SYS_EVENT_H)
add_definitions("-DWITH_KQUEUE") add_definitions("-DWITH_KQUEUE")
endif (HAVE_SYS_EVENT_H) endif()
if (WITH_BUNDLED_DEPS)
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/deps)
endif (WITH_BUNDLED_DEPS)
find_path(HAVE_SYS_EPOLL_H sys/epoll.h) find_path(HAVE_SYS_EPOLL_H sys/epoll.h)
if (HAVE_SYS_EPOLL_H) if(HAVE_SYS_EPOLL_H)
add_definitions("-DWITH_EPOLL") add_definitions("-DWITH_EPOLL")
endif() endif()
option(INC_BRIDGE_SUPPORT option(INC_BRIDGE_SUPPORT
"Include bridge support for connecting to other brokers?" ON) "Include bridge support for connecting to other brokers?" ON)
if (INC_BRIDGE_SUPPORT) if(INC_BRIDGE_SUPPORT)
set (MOSQ_SRCS ${MOSQ_SRCS} bridge.c) set (MOSQ_SRCS ${MOSQ_SRCS} bridge.c)
add_definitions("-DWITH_BRIDGE") add_definitions("-DWITH_BRIDGE")
endif (INC_BRIDGE_SUPPORT) endif()
option(USE_LIBWRAP option(USE_LIBWRAP "Include tcp-wrappers support?" OFF)
"Include tcp-wrappers support?" OFF)
if (USE_LIBWRAP) if(USE_LIBWRAP)
set (MOSQ_LIBS ${MOSQ_LIBS} wrap) set (MOSQ_LIBS ${MOSQ_LIBS} wrap)
add_definitions("-DWITH_WRAP") add_definitions("-DWITH_WRAP")
endif (USE_LIBWRAP) endif()
option(INC_DB_UPGRADE option(INC_DB_UPGRADE "Include database upgrade support? (recommended)" ON)
"Include database upgrade support? (recommended)" ON)
option(INC_MEMTRACK option(INC_MEMTRACK "Include memory tracking support?" ON)
"Include memory tracking support?" ON) if(INC_MEMTRACK)
if (INC_MEMTRACK)
add_definitions("-DWITH_MEMORY_TRACKING") add_definitions("-DWITH_MEMORY_TRACKING")
endif (INC_MEMTRACK) endif()
option(WITH_PERSISTENCE option(WITH_PERSISTENCE "Include persistence support?" ON)
"Include persistence support?" ON) if(WITH_PERSISTENCE)
if (WITH_PERSISTENCE)
add_definitions("-DWITH_PERSISTENCE") add_definitions("-DWITH_PERSISTENCE")
endif (WITH_PERSISTENCE) endif()
option(WITH_SYS_TREE option(WITH_SYS_TREE "Include $SYS tree support?" ON)
"Include $SYS tree support?" ON) if(WITH_SYS_TREE)
if (WITH_SYS_TREE)
add_definitions("-DWITH_SYS_TREE") add_definitions("-DWITH_SYS_TREE")
endif (WITH_SYS_TREE) endif()
option(WITH_ADNS option(WITH_ADNS "Include ADNS support?" OFF)
"Include ADNS support?" OFF)
if (CMAKE_SYSTEM_NAME STREQUAL Linux) if(CMAKE_SYSTEM_NAME STREQUAL Linux)
option(WITH_SYSTEMD option(WITH_SYSTEMD "Include systemd support?" OFF)
"Include systemd support?" OFF) if(WITH_SYSTEMD)
if (WITH_SYSTEMD)
add_definitions("-DWITH_SYSTEMD") add_definitions("-DWITH_SYSTEMD")
find_library(SYSTEMD_LIBRARY systemd) find_library(SYSTEMD_LIBRARY systemd)
set (MOSQ_LIBS ${MOSQ_LIBS} ${SYSTEMD_LIBRARY}) set (MOSQ_LIBS ${MOSQ_LIBS} ${SYSTEMD_LIBRARY})
endif (WITH_SYSTEMD) endif()
endif (CMAKE_SYSTEM_NAME STREQUAL Linux) endif()
option(WITH_WEBSOCKETS "Include websockets support?" OFF) option(WITH_WEBSOCKETS "Include websockets support?" OFF)
option(STATIC_WEBSOCKETS "Use the static libwebsockets library?" OFF) option(STATIC_WEBSOCKETS "Use the static libwebsockets library?" OFF)
if (WITH_WEBSOCKETS) if(WITH_WEBSOCKETS)
find_package(libwebsockets) find_package(libwebsockets)
add_definitions("-DWITH_WEBSOCKETS") add_definitions("-DWITH_WEBSOCKETS")
endif (WITH_WEBSOCKETS) endif()
option(WITH_CONTROL "Include $CONTROL topic support?" ON) option(WITH_CONTROL "Include $CONTROL topic support?" ON)
if (WITH_CONTROL) if(WITH_CONTROL)
add_definitions("-DWITH_CONTROL") add_definitions("-DWITH_CONTROL")
endif (WITH_CONTROL) endif()
if (WIN32 OR CYGWIN) if(WIN32 OR CYGWIN)
set (MOSQ_SRCS ${MOSQ_SRCS} service.c) set (MOSQ_SRCS ${MOSQ_SRCS} service.c)
endif (WIN32 OR CYGWIN) endif()
add_definitions (-DWITH_BROKER) add_definitions (-DWITH_BROKER)
if (WITH_DLT) if(WITH_DLT)
message(STATUS "DLT_LIBDIR = ${DLT_LIBDIR}") message(STATUS "DLT_LIBDIR = ${DLT_LIBDIR}")
link_directories(${DLT_LIBDIR}) link_directories(${DLT_LIBDIR})
set (MOSQ_LIBS ${MOSQ_LIBS} ${DLT_LIBRARIES}) set (MOSQ_LIBS ${MOSQ_LIBS} ${DLT_LIBRARIES})
endif (WITH_DLT) endif()
set (MOSQ_LIBS ${MOSQ_LIBS} ${OPENSSL_LIBRARIES}) set (MOSQ_LIBS ${MOSQ_LIBS} ${OPENSSL_LIBRARIES})
# Check for getaddrinfo_a # Check for getaddrinfo_a
include(CheckLibraryExists) include(CheckLibraryExists)
check_library_exists(anl getaddrinfo_a "" HAVE_GETADDRINFO_A) check_library_exists(anl getaddrinfo_a "" HAVE_GETADDRINFO_A)
if (HAVE_GETADDRINFO_A AND WITH_ADNS) if(HAVE_GETADDRINFO_A AND WITH_ADNS)
add_definitions("-DWITH_ADNS") add_definitions("-DWITH_ADNS")
add_definitions(-DHAVE_GETADDRINFO_A) add_definitions(-DHAVE_GETADDRINFO_A)
set (MOSQ_LIBS ${MOSQ_LIBS} anl) set (MOSQ_LIBS ${MOSQ_LIBS} anl)
endif (HAVE_GETADDRINFO_A AND WITH_ADNS) endif()
if (UNIX) if(UNIX)
if (APPLE) if(APPLE)
set (MOSQ_LIBS ${MOSQ_LIBS} dl m) set (MOSQ_LIBS ${MOSQ_LIBS} dl m)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") elseif (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
set (MOSQ_LIBS ${MOSQ_LIBS} m) set (MOSQ_LIBS ${MOSQ_LIBS} m)
@ -182,44 +168,71 @@ if (UNIX)
set (MOSQ_LIBS ${MOSQ_LIBS} m) set (MOSQ_LIBS ${MOSQ_LIBS} m)
elseif(QNX) elseif(QNX)
set(MOSQ_LIBS ${MOSQ_LIBS} m socket) set(MOSQ_LIBS ${MOSQ_LIBS} m socket)
else(APPLE) else()
set (MOSQ_LIBS ${MOSQ_LIBS} dl m) set (MOSQ_LIBS ${MOSQ_LIBS} dl m)
find_library(LIBRT rt) find_library(LIBRT rt)
if (LIBRT) if(LIBRT)
set (MOSQ_LIBS ${MOSQ_LIBS} rt) set (MOSQ_LIBS ${MOSQ_LIBS} rt)
endif (LIBRT) endif()
endif (APPLE) endif()
endif (UNIX) endif()
if (WIN32) if(WIN32)
set (MOSQ_LIBS ${MOSQ_LIBS} ws2_32) set (MOSQ_LIBS ${MOSQ_LIBS} ws2_32)
endif (WIN32) endif()
if (WITH_WEBSOCKETS) if(WITH_WEBSOCKETS)
if (STATIC_WEBSOCKETS) if(STATIC_WEBSOCKETS)
set (MOSQ_LIBS ${MOSQ_LIBS} websockets_static) set (MOSQ_LIBS ${MOSQ_LIBS} websockets_static)
if (WIN32) if(WIN32)
set (MOSQ_LIBS ${MOSQ_LIBS} iphlpapi) set (MOSQ_LIBS ${MOSQ_LIBS} iphlpapi)
link_directories(${mosquitto_SOURCE_DIR}) link_directories(${mosquitto_SOURCE_DIR})
endif (WIN32) endif(IN32)
else (STATIC_WEBSOCKETS) else(STATIC_WEBSOCKETS)
set (MOSQ_LIBS ${MOSQ_LIBS} websockets) set (MOSQ_LIBS ${MOSQ_LIBS} websockets)
endif (STATIC_WEBSOCKETS) endif()
endif (WITH_WEBSOCKETS) endif()
add_executable(mosquitto ${MOSQ_SRCS}) add_executable(mosquitto ${MOSQ_SRCS})
target_link_libraries(mosquitto ${MOSQ_LIBS})
if (WIN32) target_include_directories(mosquitto PRIVATE
set_target_properties(mosquitto PROPERTIES ENABLE_EXPORTS 1) "${OPENSSL_INCLUDE_DIR}"
endif (WIN32) "${STDBOOL_H_PATH}"
"${STDINT_H_PATH}"
if (UNIX) "${mosquitto_SOURCE_DIR}"
if (APPLE) "${mosquitto_SOURCE_DIR}/include"
set_target_properties(mosquitto PROPERTIES LINK_FLAGS "-Wl,-exported_symbols_list -Wl,${mosquitto_SOURCE_DIR}/src/linker-macosx.syms") "${mosquitto_SOURCE_DIR}/lib"
else (APPLE) "${mosquitto_SOURCE_DIR}/src"
set_target_properties(mosquitto PROPERTIES LINK_FLAGS "-Wl,-dynamic-list=${mosquitto_SOURCE_DIR}/src/linker.syms") )
endif (APPLE) if(WITH_BUNDLED_DEPS)
endif (UNIX) target_include_directories(mosquitto PRIVATE
"${mosquitto_SOURCE_DIR}/deps"
install(TARGETS mosquitto RUNTIME DESTINATION "${CMAKE_INSTALL_SBINDIR}") )
endif()
target_link_libraries(mosquitto
${MOSQ_LIBS}
)
if(WIN32)
set_target_properties(mosquitto PROPERTIES
ENABLE_EXPORTS 1
)
endif()
if(UNIX)
if(APPLE)
set_target_properties(mosquitto PROPERTIES
LINK_FLAGS "-Wl,-exported_symbols_list -Wl,${mosquitto_SOURCE_DIR}/src/linker-macosx.syms"
)
else()
set_target_properties(mosquitto PROPERTIES
LINK_FLAGS "-Wl,-dynamic-list=${mosquitto_SOURCE_DIR}/src/linker.syms"
)
endif()
endif()
install(TARGETS mosquitto
RUNTIME DESTINATION "${CMAKE_INSTALL_SBINDIR}"
)
install(FILES ../include/mosquitto_broker.h ../include/mosquitto_plugin.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") install(FILES ../include/mosquitto_broker.h ../include/mosquitto_plugin.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

Loading…
Cancel
Save