-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
83 lines (66 loc) · 2.32 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
###################################################
# Copyright (c) Gaia Platform Authors
#
# Use of this source code is governed by the MIT
# license that can be found in the LICENSE.txt file
# or at https://opensource.org/licenses/MIT.
###################################################
cmake_minimum_required(VERSION 3.16)
# Set the project name.
project(mqtt)
set(CMAKE_CXX_STANDARD 17)
# We need pthreads support.
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
include(FetchContent)
# Checkout lifthttp library (to make HTTP requests).
FetchContent_Declare(
lifthttp
GIT_REPOSITORY https://github.com/jbaldwin/liblifthttp.git
GIT_TAG v2021.2
)
FetchContent_MakeAvailable(lifthttp)
# Clang-8 (which gaiat is based on) doesn't like noexcept with default.
# This is a workaround to remove the "noexcept" keyword and make gaiat happy.
# Reference: https://stackoverflow.com/a/29483269/1214125
file(READ ${lifthttp_SOURCE_DIR}/inc/lift/response.hpp response_data)
string(REPLACE "noexcept" "" response_data "${response_data}")
file(WRITE ${lifthttp_SOURCE_DIR}/inc/lift/response.hpp "${response_data}")
file(READ ${lifthttp_SOURCE_DIR}/inc/lift/request.hpp request_data)
string(REPLACE "noexcept" "" request_data "${request_data}")
file(WRITE ${lifthttp_SOURCE_DIR}/inc/lift/request.hpp "${request_data}")
# Checkout JSON library.
FetchContent_Declare(
json
URL https://github.com/nlohmann/json/releases/download/v3.10.5/json.tar.xz)
FetchContent_MakeAvailable(json)
include("/opt/gaia/cmake/gaia.cmake")
set(MQTT_DDL ${PROJECT_SOURCE_DIR}/gaia/mqtt.ddl)
set(MQTT_RULESET ${PROJECT_SOURCE_DIR}/gaia/mqtt.ruleset)
# --- Generate EDC from DDL---
process_schema(
DDL_FILE ${MQTT_DDL}
DATABASE_NAME mqtt
)
# -- Translate ruleset into CPP --
translate_ruleset(
RULESET_FILE ${MQTT_RULESET}
CLANG_PARAMS
-I ${lifthttp_SOURCE_DIR}/inc
-I ${json_SOURCE_DIR}/include
)
add_executable(mqtt
src/main.cpp
src/utils.cpp
)
find_package(aws-crt-cpp REQUIRED)
target_add_gaia_generated_sources(mqtt)
target_include_directories(mqtt
PUBLIC
${PROJECT_SOURCE_DIR}/include
PRIVATE
${GAIA_INC}
)
target_link_directories(mqtt PRIVATE ${GAIA_LIB})
target_link_libraries(mqtt PRIVATE ${GAIA_LIB} AWS::aws-crt-cpp lifthttp nlohmann_json::nlohmann_json Threads::Threads)