forked from redboltz/async_mqtt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
150 lines (127 loc) · 5.97 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Copyright Takatoshi Kondo 2022
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
cmake_minimum_required (VERSION 3.13.0)
project(async_mqtt_iface VERSION 4.0.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(ASYNC_MQTT_USE_TLS "Enable building TLS code" OFF)
option(ASYNC_MQTT_USE_WS "Enable building WebSockets code" OFF)
option(ASYNC_MQTT_USE_LOG "Enable building logging code" OFF)
option(ASYNC_MQTT_PRINT_PAYLOAD "Enable output payload when publish packet output" OFF)
option(ASYNC_MQTT_BUILD_UNIT_TESTS "Enable building unit tests" OFF)
option(ASYNC_MQTT_BUILD_SYSTEM_TESTS "Enable building system tests" OFF)
option(ASYNC_MQTT_BUILD_TOOLS "Enable building tools (broker, bench, etc.." OFF)
option(ASYNC_MQTT_BUILD_EXAMPLES "Enable building example applications" OFF)
# Not implemented yet
option(ASYNC_MQTT_USE_STR_CHECK "Enable UTF8 String check" OFF)
# Don't use GNU extensions
set(CMAKE_CXX_EXTENSIONS OFF)
message(STATUS "Setting minimum C++ standard to C++17")
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
if(ASYNC_MQTT_USE_STATIC_BOOST)
message(STATUS "Staticly linking with Boost")
set(Boost_USE_STATIC_LIBS TRUE)
else()
message(STATUS "Dynamically linking with Boost")
set(Boost_USE_STATIC_LIBS FALSE)
endif()
if(ASYNC_MQTT_USE_STATIC_OPENSSL)
message(STATUS "Staticly linking with Openssl")
set(OPENSSL_USE_STATIC_LIBS TRUE)
else()
message(STATUS "Dynamically linking with Openssl")
set(OPENSSL_USE_STATIC_LIBS FALSE)
endif()
set(Boost_USE_MULTITHREADED ON)
find_package(Threads REQUIRED)
if(ASYNC_MQTT_USE_TLS)
message(STATUS "TLS enabled")
else()
message(STATUS "TLS disabled")
endif()
if(ASYNC_MQTT_USE_WS)
message(STATUS "WS enabled")
else()
message(STATUS "WS disabled")
endif()
set(ASYNC_MQTT_BOOST_COMPONENTS)
if(ASYNC_MQTT_USE_LOG)
message(STATUS "Logging enabled")
set(ASYNC_MQTT_BOOST_COMPONENTS log)
else()
message(STATUS "Logging disabled")
endif()
if(ASYNC_MQTT_PRINT_PAYLOAD)
message(STATUS "Print payload enabled")
else()
message(STATUS "Print payload disabled")
endif()
find_package(Boost 1.81.0 REQUIRED COMPONENTS ${ASYNC_MQTT_BOOST_COMPONENTS})
if(ASYNC_MQTT_USE_TLS)
find_package(OpenSSL REQUIRED)
set(ASYNC_MQTT_DEPENDS_OPENSSL "FIND_DEPENDENCY (OpenSSL)")
endif()
#include_directories(include)
set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ON)
add_subdirectory(include)
if(ASYNC_MQTT_BUILD_EXAMPLES)
message(STATUS "Examples enabled")
add_subdirectory(example)
else()
message(STATUS "Examples disabled")
endif()
if(ASYNC_MQTT_BUILD_TOOLS)
message(STATUS "Tools enabled")
add_subdirectory(tool)
else()
message(STATUS "Tools disabled")
endif()
if(ASYNC_MQTT_BUILD_UNIT_TESTS OR ASYNC_MQTT_BUILD_SYSTEM_TESTS)
enable_testing()
add_subdirectory(test)
endif()
# Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
list(APPEND Doxyfile_CONTENT
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "FILE_PATTERNS = *.hpp" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "OUTPUT_DIRECTORY = doc" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "PROJECT_NAME = async_mqtt" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "PROJECT_NUMBER = 4.0.0" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "RECURSIVE = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "PREDEFINED = _DOXYGEN_ ASYNC_MQTT_USE_TLS ASYNC_MQTT_USE_WS" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "INPUT = ${CMAKE_CURRENT_SOURCE_DIR}/include/async_mqtt" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "EXCLUDE = ${CMAKE_CURRENT_SOURCE_DIR}/include/async_mqtt/broker" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "GENERATE_LATEX = NO" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "HIDE_UNDOC_MEMBERS = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "HIDE_UNDOC_CLASSES = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
# COMMAND ${CMAKE_COMMAND} -E echo "HIDE_FRIEND_COMPOUNDS = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
# COMMAND ${CMAKE_COMMAND} -E echo "HIDE_IN_BODY_DOCS = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "CLASS_GRAPH = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "INCLUDE_GRAPH = NO" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "INCLUDED_BY_GRAPH = NO" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "GENERATE_TREEVIEW = YES " >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "DISABLE_INDEX = NO" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "FULL_SIDEBAR = NO" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "HTML_EXTRA_STYLESHEET = ${CMAKE_CURRENT_SOURCE_DIR}/css/doxygen-awesome.css " >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
COMMAND ${CMAKE_COMMAND} -E echo "HTML_COLORSTYLE = LIGHT " >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
)
if(DOXYGEN_DOT_FOUND)
list(APPEND Doxyfile_CONTENT
COMMAND ${CMAKE_COMMAND} -E echo "HAVE_DOT = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
)
endif()
add_custom_target(
doxygen
${Doxyfile_CONTENT}
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
VERBATIM
)
endif()
include(cmake/createcmakeconfig.cmake)