Skip to content

Commit

Permalink
Fix comparison of boolean values in CMake build.
Browse files Browse the repository at this point in the history
Closes #1101. Thanks to Mojca Miklavec and Andrew L. Moore.
  • Loading branch information
ralight committed Feb 8, 2019
1 parent f6943b0 commit 70c4097
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 47 deletions.
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ option(WITH_TLS_PSK
"Include TLS-PSK support (requires WITH_TLS)?" ON)
option(WITH_EC
"Include Elliptic Curve support (requires WITH_TLS)?" ON)
if (${WITH_TLS} STREQUAL ON)
if (WITH_TLS)
find_package(OpenSSL REQUIRED)
add_definitions("-DWITH_TLS")

Expand All @@ -62,19 +62,19 @@ if (${WITH_TLS} STREQUAL ON)
if (${WITH_EC} STREQUAL ON)
add_definitions("-DWITH_EC")
endif (${WITH_EC} STREQUAL ON)
else (${WITH_TLS} STREQUAL ON)
else (WITH_TLS)
set (OPENSSL_INCLUDE_DIR "")
endif (${WITH_TLS} STREQUAL ON)
endif (WITH_TLS)

option(WITH_SOCKS "Include SOCKS5 support?" ON)
if (${WITH_SOCKS} STREQUAL ON)
if (WITH_SOCKS)
add_definitions("-DWITH_SOCKS")
endif (${WITH_SOCKS} STREQUAL ON)
endif (WITH_SOCKS)

option(WITH_SRV "Include SRV lookup support?" OFF)

option(WITH_THREADING "Include client library threading support?" ON)
if (${WITH_THREADING} STREQUAL ON)
if (WITH_THREADING)
add_definitions("-DWITH_THREADING")
if (WIN32)
if (CMAKE_CL_64)
Expand All @@ -92,10 +92,10 @@ if (${WITH_THREADING} STREQUAL ON)
endif()
set (PTHREAD_INCLUDE_DIR "")
endif (WIN32)
else (${WITH_THREADING} STREQUAL ON)
else (WITH_THREADING)
set (PTHREAD_LIBRARIES "")
set (PTHREAD_INCLUDE_DIR "")
endif (${WITH_THREADING} STREQUAL ON)
endif (WITH_THREADING)

option(DOCUMENTATION "Build documentation?" ON)

Expand All @@ -106,9 +106,9 @@ option(DOCUMENTATION "Build documentation?" ON)
add_subdirectory(lib)
add_subdirectory(client)
add_subdirectory(src)
if (${DOCUMENTATION} STREQUAL ON)
if (DOCUMENTATION)
add_subdirectory(man)
endif (${DOCUMENTATION} STREQUAL ON)
endif (DOCUMENTATION)

# ========================================
# Install config file
Expand Down
7 changes: 7 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
1.5.6 - 201901xx
================

Build:
- Fix comparison of boolean values in CMake build. Closes #1101.


1.5.5 - 20181211
================

Expand Down
4 changes: 2 additions & 2 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ link_directories(${mosquitto_BINARY_DIR}/lib)

set(shared_src client_shared.c client_shared.h)

if (${WITH_SRV} STREQUAL ON)
if (WITH_SRV)
add_definitions("-DWITH_SRV")
endif (${WITH_SRV} STREQUAL ON)
endif (WITH_SRV)

add_executable(mosquitto_pub pub_client.c ${shared_src})
add_executable(mosquitto_sub sub_client.c sub_client_output.c ${shared_src})
Expand Down
12 changes: 6 additions & 6 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ if (WIN32)
set (LIBRARIES ${LIBRARIES} ws2_32)
endif (WIN32)

if (${WITH_SRV} STREQUAL ON)
if (WITH_SRV)
# Simple detect c-ares
find_path(ARES_HEADER ares.h)
if (ARES_HEADER)
Expand All @@ -69,7 +69,7 @@ if (${WITH_SRV} STREQUAL ON)
else (ARES_HEADER)
message(WARNING "c-ares library not found.")
endif (ARES_HEADER)
endif (${WITH_SRV} STREQUAL ON)
endif (WITH_SRV)

add_library(libmosquitto SHARED ${C_SRC})
set_target_properties(libmosquitto PROPERTIES
Expand All @@ -86,13 +86,13 @@ set_target_properties(libmosquitto PROPERTIES

install(TARGETS libmosquitto RUNTIME DESTINATION "${BINDIR}" LIBRARY DESTINATION "${LIBDIR}")

if (${WITH_STATIC_LIBRARIES} STREQUAL ON)
if (WITH_STATIC_LIBRARIES)
add_library(libmosquitto_static STATIC ${C_SRC})
if (${WITH_PIC} STREQUAL ON)
if (WITH_PIC)
set_target_properties(libmosquitto_static PROPERTIES
POSITION_INDEPENDENT_CODE 1
)
endif (${WITH_PIC} STREQUAL ON)
endif (WITH_PIC)

target_link_libraries(libmosquitto_static ${LIBRARIES})

Expand All @@ -103,7 +103,7 @@ if (${WITH_STATIC_LIBRARIES} STREQUAL ON)

target_compile_definitions(libmosquitto_static PUBLIC "LIBMOSQUITTO_STATIC")
install(TARGETS libmosquitto_static RUNTIME DESTINATION "${BINDIR}" ARCHIVE DESTINATION "${LIBDIR}")
endif (${WITH_STATIC_LIBRARIES} STREQUAL ON)
endif (WITH_STATIC_LIBRARIES)

install(FILES mosquitto.h DESTINATION "${INCLUDEDIR}")

Expand Down
8 changes: 4 additions & 4 deletions lib/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ set_target_properties(mosquittopp PROPERTIES
)
install(TARGETS mosquittopp RUNTIME DESTINATION "${BINDIR}" LIBRARY DESTINATION "${LIBDIR}")

if (${WITH_STATIC_LIBRARIES} STREQUAL ON)
if (WITH_STATIC_LIBRARIES)
add_library(mosquittopp_static STATIC
${C_SRC}
${CPP_SRC}
)
if (${WITH_PIC} STREQUAL ON)
if (WITH_PIC)
set_target_properties(mosquittopp_static PROPERTIES
POSITION_INDEPENDENT_CODE 1
)
endif (${WITH_PIC} STREQUAL ON)
endif (WITH_PIC)

target_link_libraries(mosquittopp_static ${LIBRARIES})

Expand All @@ -35,7 +35,7 @@ if (${WITH_STATIC_LIBRARIES} STREQUAL ON)

target_compile_definitions(mosquittopp_static PUBLIC "LIBMOSQUITTO_STATIC")
install(TARGETS mosquittopp_static RUNTIME DESTINATION "${BINDIR}" ARCHIVE DESTINATION "${LIBDIR}")
endif (${WITH_STATIC_LIBRARIES} STREQUAL ON)
endif (WITH_STATIC_LIBRARIES)

install(FILES mosquittopp.h DESTINATION "${INCLUDEDIR}")

Expand Down
48 changes: 23 additions & 25 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,62 +52,62 @@ set (MOSQ_SRCS


option(WITH_BUNDLED_DEPS "Build with bundled dependencies?" ON)
if (${WITH_BUNDLED_DEPS} STREQUAL ON)
if (WITH_BUNDLED_DEPS)
include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/src/deps)
endif (${WITH_BUNDLED_DEPS} STREQUAL ON)
endif (WITH_BUNDLED_DEPS)

option(INC_BRIDGE_SUPPORT
"Include bridge support for connecting to other brokers?" ON)
if (${INC_BRIDGE_SUPPORT} STREQUAL ON)
if (INC_BRIDGE_SUPPORT)
set (MOSQ_SRCS ${MOSQ_SRCS} bridge.c)
add_definitions("-DWITH_BRIDGE")
endif (${INC_BRIDGE_SUPPORT} STREQUAL ON)
endif (INC_BRIDGE_SUPPORT)


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

if (${USE_LIBWRAP} STREQUAL ON)
if (USE_LIBWRAP)
set (MOSQ_LIBS ${MOSQ_LIBS} wrap)
add_definitions("-DWITH_WRAP")
endif (${USE_LIBWRAP} STREQUAL ON)
endif (USE_LIBWRAP)

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

option(INC_MEMTRACK
"Include memory tracking support?" ON)
if (${INC_MEMTRACK} STREQUAL ON)
if (INC_MEMTRACK)
add_definitions("-DWITH_MEMORY_TRACKING")
endif (${INC_MEMTRACK} STREQUAL ON)
endif (INC_MEMTRACK)

option(WITH_PERSISTENCE
"Include persistence support?" ON)
if (${WITH_PERSISTENCE} STREQUAL ON)
if (WITH_PERSISTENCE)
add_definitions("-DWITH_PERSISTENCE")
endif (${WITH_PERSISTENCE} STREQUAL ON)
endif (WITH_PERSISTENCE)

option(WITH_SYS_TREE
"Include $SYS tree support?" ON)
if (${WITH_SYS_TREE} STREQUAL ON)
if (WITH_SYS_TREE)
add_definitions("-DWITH_SYS_TREE")
endif (${WITH_SYS_TREE} STREQUAL ON)
endif (WITH_SYS_TREE)

if (CMAKE_SYSTEM_NAME STREQUAL Linux)
option(WITH_SYSTEMD
"Include systemd support?" OFF)
if (${WITH_SYSTEMD} STREQUAL ON)
if (WITH_SYSTEMD)
add_definitions("-DWITH_SYSTEMD")
find_library(SYSTEMD_LIBRARY systemd)
set (MOSQ_LIBS ${MOSQ_LIBS} ${SYSTEMD_LIBRARY})
endif (${WITH_SYSTEMD} STREQUAL ON)
endif (WITH_SYSTEMD)
endif (CMAKE_SYSTEM_NAME STREQUAL Linux)

option(WITH_WEBSOCKETS "Include websockets support?" OFF)
option(STATIC_WEBSOCKETS "Use the static libwebsockets library?" OFF)
if (${WITH_WEBSOCKETS} STREQUAL ON )
if (WITH_WEBSOCKETS)
add_definitions("-DWITH_WEBSOCKETS")
endif (${WITH_WEBSOCKETS} STREQUAL ON)
endif (WITH_WEBSOCKETS)

if (WIN32 OR CYGWIN)
set (MOSQ_SRCS ${MOSQ_SRCS} service.c)
Expand Down Expand Up @@ -144,17 +144,17 @@ if (WIN32)
set (MOSQ_LIBS ${MOSQ_LIBS} ws2_32)
endif (WIN32)

if (${WITH_WEBSOCKETS} STREQUAL ON)
if (${STATIC_WEBSOCKETS} STREQUAL ON)
if (WITH_WEBSOCKETS)
if (STATIC_WEBSOCKETS)
set (MOSQ_LIBS ${MOSQ_LIBS} websockets_static)
if (WIN32)
set (MOSQ_LIBS ${MOSQ_LIBS} iphlpapi)
link_directories(${mosquitto_SOURCE_DIR})
endif (WIN32)
else (${STATIC_WEBSOCKETS} STREQUAL ON)
else (STATIC_WEBSOCKETS)
set (MOSQ_LIBS ${MOSQ_LIBS} websockets)
endif (${STATIC_WEBSOCKETS} STREQUAL ON)
endif (${WITH_WEBSOCKETS} STREQUAL ON)
endif (STATIC_WEBSOCKETS)
endif (WITH_WEBSOCKETS)

# Simple detect libuuid
if(NOT APPLE)
Expand All @@ -179,14 +179,12 @@ endif (UNIX)
install(TARGETS mosquitto RUNTIME DESTINATION "${SBINDIR}" LIBRARY DESTINATION "${LIBDIR}")
install(FILES mosquitto_broker.h mosquitto_plugin.h DESTINATION "${INCLUDEDIR}")

if (${WITH_TLS} STREQUAL ON)
if (WITH_TLS)
add_executable(mosquitto_passwd mosquitto_passwd.c)
target_link_libraries(mosquitto_passwd ${OPENSSL_LIBRARIES})
install(TARGETS mosquitto_passwd RUNTIME DESTINATION "${BINDIR}" LIBRARY DESTINATION "${LIBDIR}")
endif (${WITH_TLS} STREQUAL ON)
endif (WITH_TLS)

if (UNIX AND NOT APPLE)
install(CODE "EXEC_PROGRAM(/sbin/ldconfig)")
endif (UNIX AND NOT APPLE)


0 comments on commit 70c4097

Please sign in to comment.