Skip to content

Commit

Permalink
Cmake fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Apr 22, 2024
1 parent bc58c6f commit 99e0ae7
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,123 +78,123 @@ add_executable(mosquitto

CHECK_INCLUDE_FILES(sys/event.h HAVE_SYS_EVENT_H)
if(HAVE_SYS_EVENT_H)
target_compile_definitions(mosquitto "WITH_KQUEUE")
target_compile_definitions(mosquitto PRIVATE "WITH_KQUEUE")
endif()

find_path(HAVE_SYS_EPOLL_H sys/epoll.h)
if(HAVE_SYS_EPOLL_H)
target_compile_definitions(mosquitto "WITH_EPOLL")
target_compile_definitions(mosquitto PRIVATE "WITH_EPOLL")
endif()

option(INC_BRIDGE_SUPPORT
"Include bridge support for connecting to other brokers?" ON)
if(INC_BRIDGE_SUPPORT)
target_sources(mosquitto bridge.c)
target_compile_definitions(mosquitto "WITH_BRIDGE")
target_sources(mosquitto PRIVATE bridge.c)
target_compile_definitions(mosquitto PRIVATE "WITH_BRIDGE")
endif()


option(USE_LIBWRAP "Include tcp-wrappers support?" OFF)

if(USE_LIBWRAP)
target_sources(mosquitto wrap)
target_compile_definitions(mosquitto "WITH_WRAP")
target_compile_definitions(mosquitto PRIVATE "WITH_WRAP")
endif()

option(INC_DB_UPGRADE "Include database upgrade support? (recommended)" ON)

option(INC_MEMTRACK "Include memory tracking support?" ON)
if(INC_MEMTRACK)
target_compile_definitions(mosquitto "WITH_MEMORY_TRACKING")
target_compile_definitions(mosquitto PRIVATE "WITH_MEMORY_TRACKING")
endif()

option(WITH_PERSISTENCE "Include persistence support?" ON)
if(WITH_PERSISTENCE)
target_compile_definitions(mosquitto "WITH_PERSISTENCE")
target_compile_definitions(mosquitto PRIVATE "WITH_PERSISTENCE")
endif()

option(WITH_SYS_TREE "Include $SYS tree support?" ON)
if(WITH_SYS_TREE)
target_compile_definitions(mosquitto "WITH_SYS_TREE")
target_compile_definitions(mosquitto PRIVATE "WITH_SYS_TREE")
endif()

option(WITH_ADNS "Include ADNS support?" OFF)

if(CMAKE_SYSTEM_NAME STREQUAL Linux)
option(WITH_SYSTEMD "Include systemd support?" OFF)
if(WITH_SYSTEMD)
target_compile_definitions(mosquitto "WITH_SYSTEMD")
target_compile_definitions(mosquitto PRIVATE "WITH_SYSTEMD")
find_library(SYSTEMD_LIBRARY systemd)
target_link_libraries(mosquitto ${SYSTEMD_LIBRARY})
target_link_libraries(mosquitto PRIVATE ${SYSTEMD_LIBRARY})
endif()
endif()

option(STATIC_WEBSOCKETS "Use the static libwebsockets library?" OFF)

option(WITH_CONTROL "Include $CONTROL topic support?" ON)
if(WITH_CONTROL)
target_compile_definitions(mosquitto "WITH_CONTROL")
target_compile_definitions(mosquitto PRIVATE "WITH_CONTROL")
endif()

if(ARGON2_FOUND)
target_link_libraries(mosquitto argon2)
target_link_libraries(mosquitto PRIVATE argon2)
endif()

if(WIN32 OR CYGWIN)
target_sources(mosquitto service.c)
target_sources(mosquitto PRIVATE service.c)
endif()

target_compile_definitions (-DWITH_BROKER)
target_compile_definitions(mosquitto PRIVATE "WITH_BROKER")

if(WITH_TLS)
target_link_libraries(mosquitto OpenSSL::SSL)
target_link_libraries(mosquitto PRIVATE OpenSSL::SSL)
endif()
# Check for getaddrinfo_a
include(CheckLibraryExists)
check_library_exists(anl getaddrinfo_a "" HAVE_GETADDRINFO_A)
if(HAVE_GETADDRINFO_A AND WITH_ADNS)
target_compile_definitions(mosquitto "WITH_ADNS")
target_compile_definitions(mosquitto "HAVE_GETADDRINFO_A")
target_link_libraries(mosquitto anl)
target_compile_definitions(mosquitto PRIVATE "WITH_ADNS")
target_compile_definitions(mosquitto PRIVATE "HAVE_GETADDRINFO_A")
target_link_libraries(mosquitto PRIVATE anl)
endif()


if(UNIX)
if(APPLE)
target_link_libraries(mosquitto dl m)
target_link_libraries(mosquitto PRIVATE dl m)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
target_link_libraries(mosquitto m)
target_link_libraries(mosquitto PRIVATE m)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
target_link_libraries(mosquitto m)
target_link_libraries(mosquitto PRIVATE m)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Haiku")
target_link_libraries(mosquitto m network)
target_link_libraries(mosquitto PRIVATE m network)
elseif(QNX)
target_link_libraries(mosquitto m socket)
target_link_libraries(mosquitto PRIVATE m socket)
else()
target_link_libraries(mosquitto dl m)
target_link_libraries(mosquitto PRIVATE dl m)
find_library(LIBRT rt)
if(LIBRT)
target_link_libraries(mosquitto rt)
target_link_libraries(mosquitto PRIVATE rt)
endif()
endif()
endif()

if(WIN32)
target_link_libraries(mosquitto ws2_32)
target_link_libraries(mosquitto PRIVATE ws2_32)
endif()

if(WITH_WEBSOCKETS)
if(WITH_WEBSOCKETS_BUILTIN)
target_compile_definitions(mosquitto "WITH_WEBSOCKETS=WS_IS_BUILTIN")
target_sources(mosquitto ${mosquitto_SOURCE_DIR}/deps/picohttpparser/picohttpparser.c)
target_compile_definitions(mosquitto PRIVATE "WITH_WEBSOCKETS=WS_IS_BUILTIN")
target_sources(mosquitto PRIVATE ${mosquitto_SOURCE_DIR}/deps/picohttpparser/picohttpparser.c)
else()
find_package(libwebsockets)
target_compile_definitions(mosquitto "WITH_WEBSOCKETS=WS_IS_LWS")
target_compile_definitions(mosquitto PRIVATE "WITH_WEBSOCKETS=WS_IS_LWS")
endif()
endif()

if (ANDROID)
target_link_libraries(mosquitto log)
target_link_libraries(mosquitto PRIVATE log)
endif (ANDROID)

if(WITH_WEBSOCKETS)
Expand All @@ -203,20 +203,20 @@ if(WITH_WEBSOCKETS)
"${mosquitto_SOURCE_DIR}/deps/picohttpparser")
else()
if(STATIC_WEBSOCKETS)
target_link_libraries(mosquitto websockets_static)
target_link_libraries(mosquitto PRIVATE websockets_static)
if(WIN32)
target_link_libraries(mosquitto iphlpapi)
target_link_libraries(mosquitto PRIVATE iphlpapi)
endif()
else(STATIC_WEBSOCKETS)
target_link_libraries(mosquitto websockets)
target_link_libraries(mosquitto PRIVATE websockets)
endif()
endif()
endif()

if(WITH_DLT)
message(STATUS "DLT_LIBDIR = ${DLT_LIBDIR}")
target_link_directories(mosquitto PRIVATE ${DLT_LIBDIR})
target_link_libraries(mosquitto ${DLT_LIBRARIES})
target_link_libraries(mosquitto PRIVATE ${DLT_LIBRARIES})
target_compile_definitions(mosquitto PRIVATE "WITH_DLT")
endif()

Expand Down

0 comments on commit 99e0ae7

Please sign in to comment.