-
Notifications
You must be signed in to change notification settings - Fork 33
/
CMakeLists.txt
111 lines (97 loc) · 3.57 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
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
project(AqaraHub VERSION 0.1.0 LANGUAGES C CXX)
include(GNUInstallDirs)
if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
conan_basic_setup(TARGETS)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror")
set(CMAKE_CXX_STANDARD 14)
find_package(Threads REQUIRED)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost 1.60.0 COMPONENTS system program_options log coroutine unit_test_framework REQUIRED)
# STLab library
find_path(STLAB_INCLUDE_DIRS NAMES stlab/version.hpp PATHS ${CMAKE_SOURCE_DIR}/submodules/stlab-libraries/)
if(NOT STLAB_INCLUDE_DIRS)
message(FATAL_ERROR "STLab Libraries not found")
else()
message(STATUS "STLab Libraries found at: ${STLAB_INCLUDE_DIRS}")
endif()
add_library(stlab INTERFACE)
target_include_directories(stlab INTERFACE ${STLAB_INCLUDE_DIRS})
# MQTT_CPP
find_path(MQTT_CPP_INCLUDE_DIRS NAMES mqtt/client.hpp PATHS ${CMAKE_SOURCE_DIR}/submodules/mqtt_cpp/include)
if(NOT MQTT_CPP_INCLUDE_DIRS)
message(FATAL_ERROR "MQTT_CPP not found")
else()
message(STATUS "MQTT_CPP found at: ${MQTT_CPP_INCLUDE_DIRS}")
endif()
add_library(mqtt_cpp INTERFACE)
target_include_directories(mqtt_cpp INTERFACE ${MQTT_CPP_INCLUDE_DIRS})
find_package(OpenSSL REQUIRED)
target_link_libraries(mqtt_cpp INTERFACE OpenSSL::SSL)
find_path(TAO_JSON_INCLUDE_DIRS NAMES tao/json.hpp PATHS ${CMAKE_SOURCE_DIR}/submodules/taocpp-json/include)
if(NOT TAO_JSON_INCLUDE_DIRS)
message(FATAL_ERROR "taocpp-json not found")
else()
message(STATUS "taocpp-json found at: ${TAO_JSON_INCLUDE_DIRS}")
endif()
add_library(taocpp_json INTERFACE)
target_include_directories(taocpp_json INTERFACE ${TAO_JSON_INCLUDE_DIRS})
add_library(taocpp::json ALIAS taocpp_json)
# std::auto_ptr doesn't exist in C++17, so disable it just in case.
add_definitions(-DBOOST_NO_AUTO_PTR)
add_library(common
src/asio_executor.cpp
src/clusterdb/cluster_db.cpp
src/coro.cpp
src/dynamic_encoding/common.cpp
src/dynamic_encoding/decoding.cpp
src/dynamic_encoding/encoding.cpp
src/logging.cpp
src/mqtt_wrapper.cpp
src/uri_parser.cpp
src/zcl/encoding.cpp
src/zcl/zcl.cpp
src/zcl/zcl_endpoint.cpp
src/znp/znp.cpp
src/znp/znp_api.cpp
src/znp/znp_port.cpp
)
target_include_directories(common PUBLIC "src")
target_link_libraries(common stlab)
target_link_libraries(common mqtt_cpp)
target_link_libraries(common Boost::boost)
target_link_libraries(common Boost::system)
target_link_libraries(common Boost::log)
target_link_libraries(common Boost::program_options)
target_link_libraries(common Boost::coroutine)
target_link_libraries(common Threads::Threads)
target_link_libraries(common taocpp::json)
add_executable(AqaraHub
src/main.cpp
)
target_include_directories(AqaraHub PUBLIC "src")
target_link_libraries(AqaraHub common)
install(TARGETS AqaraHub
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES clusters.info DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/AqaraHub/)
install(FILES AqaraHub.service DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/system/)
add_executable(tests
tests/cluster_db.cpp
tests/coro.cpp
tests/dynamic_encoding.cpp
tests/main.cpp
tests/mqtt_wrapper.cpp
tests/template_lookup.cpp
tests/uri_parser.cpp
tests/uri_parser.cpp
tests/variant_encoding.cpp
)
target_link_libraries(tests common)
target_include_directories(tests PUBLIC "src")
target_include_directories(tests PUBLIC "include")
#target_compile_definitions(tests PUBLIC -DBOOST_TEST_DYN_LINK)
target_link_libraries(tests Boost::unit_test_framework)