forked from EVerest/libocpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
191 lines (158 loc) · 6.36 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
cmake_minimum_required(VERSION 3.14)
project(builder
VERSION 0.1
DESCRIPTION "A example builder for libocpp and libtimer"
LANGUAGES CXX
)
set(JSON_BUILD_TESTS OFF CACHE INTERNAL "Build JSON tests")
set(JSON_MultipleHeaders ON CACHE INTERNAL "Build JSON multi header config")
set(BUILD_TESTS OFF CACHE INTERNAL "Build tests")
set(BUILD_EXAMPLES OFF CACHE INTERNAL "Build examples")
set(BUILD_TZ_LIB ON CACHE INTERNAL "")
set(HAS_REMOTE_API 0 CACHE INTERNAL "")
set(USE_AUTOLOAD 0 CACHE INTERNAL "")
set(USE_SYSTEM_TZ_DB ON CACHE INTERNAL "")
set(JSON_VALIDATOR_INSTALL OFF CACHE INTERNAL "")
set(JSON_VALIDATOR_BUILD_TESTS OFF CACHE INTERNAL "")
set(JSON_VALIDATOR_BUILD_EXAMPLES OFF CACHE INTERNAL "")
set(JSON_VALIDATOR_BUILD_SHARED_LIBS ON CACHE INTERNAL "")
macro(find_date_library)
message(STATUS "Using FetchContent for date library")
set(EXTERNAL_DATE_NAME date)
set(EXTERNAL_DATE_URL https://github.com/HowardHinnant/date.git)
set(EXTERNAL_DATE_TAG v3.0.1)
FetchContent_Declare(
${EXTERNAL_DATE_NAME}
GIT_REPOSITORY ${EXTERNAL_DATE_URL}
GIT_TAG ${EXTERNAL_DATE_TAG}
)
FetchContent_MakeAvailable(${EXTERNAL_DATE_NAME})
endmacro()
macro(find_everest_cmake)
message(STATUS "Using FetchContent for everest-cmake")
set(EXTERNAL_EVEREST_CMAKE_NAME everest-cmake)
set(EXTERNAL_EVEREST_CMAKE_URL https://github.com/EVerest/everest-cmake.git)
set(EXTERNAL_EVEREST_CMAKE_TAG v0.1.0)
message(STATUS "Fetching everest cmake")
FetchContent_Declare(
${EXTERNAL_EVEREST_CMAKE_NAME}
GIT_REPOSITORY ${EXTERNAL_EVEREST_CMAKE_URL}
GIT_TAG ${EXTERNAL_EVEREST_CMAKE_TAG}
)
FetchContent_MakeAvailable(${EXTERNAL_EVEREST_CMAKE_NAME})
# Add the cmake directory to the module path
# this is needed because some submodules (everest-timer and everest-log) still need to find the cmake module using "find_package"
set(${EXTERNAL_EVEREST_CMAKE_NAME}_DIR ${CMAKE_BINARY_DIR}/_deps/${EXTERNAL_EVEREST_CMAKE_NAME}-src)
_find_package(everest-cmake REQUIRED PATHS ${everest-cmake_DIR})
endmacro()
macro(find_nlohmann_json)
message(STATUS "Using FetchContent for nlohmann_json library")
set(EXTERNAL_JSON_NAME nlohmann_json)
set(EXTERNAL_JSON_URL https://github.com/nlohmann/json.git)
set(EXTERNAL_JSON_TAG v3.11.2)
FetchContent_Declare(
${EXTERNAL_JSON_NAME}
GIT_REPOSITORY ${EXTERNAL_JSON_URL}
GIT_TAG ${EXTERNAL_JSON_TAG}
)
FetchContent_MakeAvailable(${EXTERNAL_JSON_NAME})
endmacro()
macro(find_nlohmann_json_schema_validator)
message(STATUS "Using FetchContent for nlohmann_json_schema library")
set(EXTERNAL_JSON_SCHEMA_NAME nlohmann_json_schema_validator)
set(EXTERNAL_JSON_SCHEMA_URL https://github.com/pboettch/json-schema-validator)
set(EXTERNAL_JSON_SCHEMA_TAG 2.2.0)
FetchContent_Declare(
${EXTERNAL_JSON_SCHEMA_NAME}
GIT_REPOSITORY ${EXTERNAL_JSON_SCHEMA_URL}
GIT_TAG ${EXTERNAL_JSON_SCHEMA_TAG}
)
FetchContent_MakeAvailable(${EXTERNAL_JSON_SCHEMA_NAME})
endmacro()
macro(find_websocketpp)
message(STATUS "Using FetchContent for websocketpp library")
set(EXTERNAL_WEBSOCKET_NAME websocketpp)
set(EXTERNAL_WEBSOCKET_URL https://github.com/zaphoyd/websocketpp.git)
set(EXTERNAL_WEBSOCKET_TAG 0.8.2)
FetchContent_Declare(
${EXTERNAL_WEBSOCKET_NAME}
GIT_REPOSITORY ${EXTERNAL_WEBSOCKET_URL}
GIT_TAG ${EXTERNAL_WEBSOCKET_TAG}
)
FetchContent_MakeAvailable(${EXTERNAL_WEBSOCKET_NAME})
add_library(websocketpp::websocketpp INTERFACE IMPORTED)
set_target_properties(websocketpp::websocketpp PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${websocketpp_SOURCE_DIR}")
endmacro()
macro(find_fsm)
message(STATUS "Using FetchContent for fsm library")
set(EXTERNAL_FSM_NAME fsm)
set(EXTERNAL_FSM_URL https://github.com/EVerest/libfsm.git)
set(EXTERNAL_FSM_TAG v0.2.0)
FetchContent_Declare(
${EXTERNAL_FSM_NAME}
GIT_REPOSITORY ${EXTERNAL_FSM_URL}
GIT_TAG ${EXTERNAL_FSM_TAG}
)
FetchContent_MakeAvailable(${EXTERNAL_FSM_NAME})
endmacro()
macro(find_everest_timer)
message(STATUS "Using FetchContent for everest-timer library")
set(EXTERNAL_EVEREST_TIMER_NAME everest-timer)
set(EXTERNAL_EVEREST_TIMER_URL https://github.com/EVerest/libtimer.git)
set(EXTERNAL_EVEREST_TIMER_TAG v0.1.1)
FetchContent_Declare(
${EXTERNAL_EVEREST_TIMER_NAME}
GIT_REPOSITORY ${EXTERNAL_EVEREST_TIMER_URL}
GIT_TAG ${EXTERNAL_EVEREST_TIMER_TAG}
)
FetchContent_MakeAvailable(${EXTERNAL_EVEREST_TIMER_NAME})
endmacro()
macro(find_everest_log)
message(STATUS "Using FetchContent for everest-log library")
set(EXTERNAL_EVEREST_LOG_NAME everest-log)
set(EXTERNAL_EVEREST_LOG_URL https://github.com/EVerest/liblog.git)
set(EXTERNAL_EVEREST_LOG_TAG v0.1.0)
FetchContent_Declare(
${EXTERNAL_EVEREST_LOG_NAME}
GIT_REPOSITORY ${EXTERNAL_EVEREST_LOG_URL}
GIT_TAG ${EXTERNAL_EVEREST_LOG_TAG}
)
FetchContent_MakeAvailable(${EXTERNAL_EVEREST_LOG_NAME})
endmacro()
macro(find_package PACKAGE_NAME)
message(STATUS "FIND PACKAGE ${PACKAGE_NAME}")
if("${PACKAGE_NAME}" STREQUAL "date")
find_date_library()
elseif("${PACKAGE_NAME}" STREQUAL "everest-cmake")
find_everest_cmake()
elseif("${PACKAGE_NAME}" STREQUAL "nlohmann_json")
find_nlohmann_json()
elseif("${PACKAGE_NAME}" STREQUAL "nlohmann_json_schema_validator")
find_nlohmann_json_schema_validator()
elseif("${PACKAGE_NAME}" STREQUAL "websocketpp")
find_websocketpp()
elseif("${PACKAGE_NAME}" STREQUAL "fsm")
find_fsm()
elseif("${PACKAGE_NAME}" STREQUAL "everest-timer")
find_everest_timer()
elseif("${PACKAGE_NAME}" STREQUAL "everest-log")
find_everest_log()
else()
message(STATUS "Using regular findpackage for ${PACKAGE_NAME}")
_find_package(${ARGV})
endif()
endmacro()
include(FetchContent)
set(EXTERNAL_OCPP_NAME libocpp)
set(EXTERNAL_OCPP_URL https://github.com/EVerest/libocpp.git)
set(EXTERNAL_OCPP_TAG main)
set(DISABLE_EDM ON CACHE INTERNAL "")
set(LIBOCPP16_BUILD_EXAMPLES ON CACHE INTERNAL "")
# Fetch libocpp
FetchContent_Declare(
${EXTERNAL_OCPP_NAME}
GIT_REPOSITORY ${EXTERNAL_OCPP_URL}
GIT_TAG ${EXTERNAL_OCPP_TAG}
)
# Find the libocpp package
FetchContent_MakeAvailable(${EXTERNAL_OCPP_NAME})