-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
139 lines (118 loc) · 6.15 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
cmake_minimum_required(VERSION 3.9)
project(PMQ)
set(CMAKE_CXX_STANDARD 17)
add_definitions(-DRESTAPI )
add_definitions(-DBOOST_LOG_DYN_LINK)
find_package( Boost REQUIRED COMPONENTS system program_options unit_test_framework log )
find_package( cpprestsdk REQUIRED )
find_package( OpenSSL REQUIRED )
if(OPENSSL_FOUND)
message(STATUS "OpenSSL Version: ${OPENSSL_VERSION} ${OPENSSL_INCLUDE_DIR} ${OPENSSL_LIBRARIES}")
list(LENGTH ${OPENSSL_LIBRARIES} ${COUNT} )
if(APPLE AND COUNT EQUAL 0)
include_directories(/usr/local/Cellar/[email protected]/1.1.1k/)
list(APPEND LIB_LIST /usr/local/Cellar/[email protected]/1.1.1k/lib/libssl.dylib)
list(APPEND LIB_LIST /usr/local/Cellar/[email protected]/1.1.1k/lib/libcrypto.dylib)
message(STATUS " APPLE OpenSSL Version:${OPENSSL_LIBRARIES} ${OPENSSL_INCLUDE_DIR} ${LIB_LIST}")
else()
include_directories(${OPENSSL_INCLUDE_DIR})
list(APPEND LIB_LIST ${OPENSSL_LIBRARIES})
message(STATUS "OpenSSL Version: ${OPENSSL_VERSION} ${OPENSSL_INCLUDE_DIR} ${OPENSSL_LIBRARIES}")
endif()
endif()
find_package( yaml-cpp REQUIRED )
find_package( Boost REQUIRED COMPONENTS system program_options unit_test_framework log )
if(yaml-cpp_FOUND)
if(NOT DEFINED ${YAML_CPP_LIBRARIES})
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(YAML_CPP_LIBRARIES /usr/local/lib/libyaml-cpp.a)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if( EXISTS "/usr/local/lib64/libyaml-cpp.a")
set(YAML_CPP_LIBRARIES /usr/local/lib64/libyaml-cpp.a)
else(EXISTS "/usr/local/lib64/libyaml-cpp.a")
if( ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(YAML_CPP_LIBRARIES /usr/local/lib/libyaml-cpp.a)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
endif(EXISTS "/usr/local/lib64/libyaml-cpp.a")
endif(NOT DEFINED ${YAML_CPP_LIBRARIES})
endif(yaml-cpp_FOUND)
include_directories(${PROJECT_BINARY_DIR} ${OPENSSL_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} )
add_library(pmqttclient STATIC lib/client_api/messenger.cpp lib/client_api/messenger.hpp)
add_library(pmqtt STATIC lib/mqtt/control_packet_type.hpp
lib/mqtt/mqtt_message.hpp lib/mqtt/mqtt_types.hpp lib/mqtt/mqtt_message.cpp
lib/mqtt/mqtt_package.cpp lib/mqtt/mqtt_package.hpp lib/mqtt/mqtt_connect.cpp lib/mqtt/mqtt_connect.hpp
lib/mqtt/mqtt_publish.cpp lib/mqtt/mqtt_publish.hpp lib/mqtt/mqtt_static_package.hpp
lib/mqtt/mqtt_subscribe.cpp lib/mqtt/mqtt_subscribe.hpp lib/mqtt/pmqtt.hpp lib/exception/mqtt_exception.hpp
lib/mqtt/mqtt_connection_info.hpp lib/exception/mqtt_bad_header_exception.hpp lib/mqtt/mqtt_visitor.hpp
lib/container/subscriber.cpp lib/container/subscriber.hpp
lib/network/tls_socket.hpp lib/network/socket_functions.hpp lib/qos/qos_handler.hpp lib/qos/qos_zero_handler.cpp
lib/qos/qos_zero_handler.hpp lib/qos/qos_one_handler.cpp lib/qos/qos_one_handler.hpp lib/qos/qos_two_handler.cpp
lib/qos/qos_two_handler.hpp lib/qos/qos_handler_factory.cpp lib/qos/qos_handler_factory.hpp lib/mqtt/message.hpp
lib/mqtt/message.cpp lib/mqtt/mqtt_types.cpp lib/detail/mqtt_message_processor.hpp
lib/detail/mqtt_message_processor.cpp lib/detail/utf8.hpp lib/exception/login_exception.hpp)
add_library(pmq_obj_lib OBJECT lib/exception/acceptor_exception.hpp
lib/exception/bad_connection_exception.hpp
lib/exception/config_exception.hpp
lib/server/server.cpp
lib/server/server.hpp
lib/server/null_deleter.hpp
lib/server/PMQConfigure.hpp
lib/server/security.hpp
lib/server/startup_configuration.hpp
lib/network/socket.hpp
lib/exception/socket_exception.hpp
lib/rest/http_rest_server.hpp
lib/rest/http_rest_server.cpp
lib/network/client_factory.hpp
lib/network/tcp_client_factory.hpp
lib/network/tcp_client_factory.cpp
lib/network/ssl_client_factory.hpp
lib/network/ssl_client_factory.cpp
lib/network/connection_factory.hpp
lib/server/client_handler.hpp
lib/server/client_handler.cpp
lib/storage/storage.hpp
lib/storage/in_memory_storage.hpp
lib/storage/in_memory_storage.cpp
lib/exception/bad_connection_exception.hpp
lib/rest/rest_api.hpp lib/server/startup_configuration.cpp
lib/server/client_creator.hpp
lib/server/login/login_handler.hpp
lib/server/login/login_allow_anonymous_handler.hpp
lib/server/login/login_allow_anonymous_handler.cpp
lib/server/login/login_handler.cpp
lib/server/login/login_factory.hpp
lib/server/login/login_factory.cpp
lib/container/subscriber_container.cpp
lib/container/subscriber_container.hpp
lib/detail/string.cpp
lib/container/subscriber_node.hpp
lib/container/subscriber_node.cpp
lib/detail/string.hpp
lib/rest/rest_handler.hpp
lib/rest/route_handler.hpp
lib/rest/route_handler.cpp
lib/module/config_module.hpp
lib/module/transformation_module.hpp
lib/module/transformation_identity.hpp)
add_executable(PMQ src/main.cpp $<TARGET_OBJECTS:pmq_obj_lib> )
target_link_libraries(PMQ ${OPENSSL_LIBRARIES} ${Boost_LIBRARIES} ${YAML_CPP_LIBRARIES} pmqtt ${Boost_LIBRARIES} cpprestsdk::cpprest ${LIB_LIST} )
### TEST
#include(CMakeFunctions/add_test_executable.txt)
#add_test_executable(test_server test/test_server.cpp)
#add_test_executable(test_login_handler test/test_login_handler.cpp)
#add_test_executable(test_login_factory test/test_login_factory.cpp)
#add_test_executable(test_subscriber_container test/test_subscriber_container.cpp)
#add_test_executable(test_utf8 test/test_utf8.cpp)
#add_test_executable(test_http_rest_server test/test_http_rest_server.cpp)
#add_test_executable(test_server_main test/test_server_main.cpp)
### install
install(TARGETS PMQ EXPORT PMQ RUNTIME DESTINATION bin)
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "7")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-all")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "pmqtt")
set(CPACK_PACKAGE_DESCRIPTION "MQTT Message Broker")
include(CPack)