-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
254 lines (220 loc) · 9.1 KB
/
CMakeLists.txt
File metadata and controls
254 lines (220 loc) · 9.1 KB
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
cmake_minimum_required(VERSION 3.16)
project(everest-core
VERSION 2026.02.0
DESCRIPTION "The open operating system for e-mobility charging stations"
LANGUAGES CXX C
)
find_package(everest-cmake 0.5
COMPONENTS bundling
PATHS ../everest-cmake
NO_DEFAULT_PATH
)
find_package(everest-cmake 0.5
COMPONENTS bundling
)
if (NOT everest-cmake_FOUND)
message(STATUS "Retrieving everest-cmake using FetchContent")
include(FetchContent)
FetchContent_Declare(
everest-cmake
GIT_REPOSITORY https://github.com/EVerest/everest-cmake.git
GIT_TAG main
)
FetchContent_MakeAvailable(everest-cmake)
set(everest-cmake_DIR "${everest-cmake_SOURCE_DIR}")
set(everest-cmake_FIND_COMPONENTS "bundling")
include("${everest-cmake_SOURCE_DIR}/everest-cmake-config.cmake")
endif()
# make own cmake modules available
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# test whether linking with libatomic is required on some platforms
include(CheckAtomic)
if(HAVE_CXX_ATOMICS_WITH_LIB OR HAVE_CXX_ATOMICS64_WITH_LIB)
set(ATOMIC_LIBS "atomic")
else()
set(ATOMIC_LIBS "")
endif()
# test whether we are building on a musl based system.
# On these we need to increase the stack size as it is very low by default
option(USING_MUSL "Using musl" OFF)
find_program(LDD_EXECUTABLE ldd)
find_program(LS_EXECUTABLE ls)
if(LDD_EXECUTABLE AND LS_EXECUTABLE)
# we use ls as a testing executable as it is very likely to exist on any system. ldd prints the dynamic linked libraries
# of the given executable, if musl is used it will print it as a linked object
execute_process(COMMAND ${LDD_EXECUTABLE} ${LS_EXECUTABLE} OUTPUT_VARIABLE LDD_LS_OUTPUT ERROR_QUIET)
if(LDD_LS_OUTPUT MATCHES "musl")
message(STATUS "MUSL detected, increasing stack size to 8MiB")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,stack-size=8388608")
set(USING_MUSL ON)
endif()
else()
if(NOT LDD_EXECUTABLE)
message(WARNING "ldd not found, skipping musl detection")
endif()
if(NOT LS_EXECUTABLE)
message(WARNING "ls not found, skipping musl detection")
endif()
endif()
option(CREATE_SYMLINKS "Create symlinks to javascript modules and auxillary files - for development purposes" OFF)
option(CMAKE_RUN_CLANG_TIDY "Run clang-tidy" OFF)
option(ISO15118_2_GENERATE_AND_INSTALL_CERTIFICATES "Automatically generate and install certificates for development purposes" ON)
option(EVEREST_ENABLE_RUN_SCRIPT_GENERATION "Enables the generation of run scripts (convenience scripts for starting available configurations)" ON)
option(EVEREST_BUILD_DOCS "Build EVerest documentation" OFF)
option(EVEREST_SKIP_BUILD_API_DOC "Skip building the async API html doc for the EVerest API" OFF)
option(${PROJECT_NAME}_BUILD_TESTING "Build unit tests, used if included as dependency" OFF)
option(BUILD_TESTING "Build unit tests, used if standalone project" OFF)
option(EVEREST_ENABLE_COMPILE_WARNINGS "Enable compile warnings set in the EVEREST_COMPILE_OPTIONS flag" OFF)
option(EVEREST_ENABLE_GLOBAL_COMPILE_WARNINGS "Enable compile warnings set in the EVEREST_COMPILE_OPTIONS flag globally" OFF)
option(EVEREST_ENABLE_DEBUG_BUILD "Enable debug build" OFF)
option(EVEREST_BUILD_APPLICATIONS "Build applications like drivers for the EVerest stable API" ON)
option(EVEREST_LIBS_ONLY "Only build libraries, skip modules/applications/config" OFF)
set(EVEREST_INCLUDE_LIBS "" CACHE STRING "Semicolon-separated allowlist of libraries to build (empty = all)")
set(EVEREST_EXCLUDE_LIBS "" CACHE STRING "Semicolon-separated blocklist of libraries to skip")
# list of compile options that are passed to modules if EVEREST_ENABLE_COMPILE_WARNINGS=ON
# generated code has functions often not used
set(EVEREST_COMPILE_OPTIONS "-Wall;-Wno-unused-function" CACHE STRING "A list of compile options used for building modules")
if(EVEREST_ENABLE_GLOBAL_COMPILE_WARNINGS)
add_compile_options(${EVEREST_COMPILE_OPTIONS})
endif()
if((${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME} OR ${PROJECT_NAME}_BUILD_TESTING) AND BUILD_TESTING)
set(EVEREST_CORE_BUILD_TESTING ON)
set(everest-framework_BUILD_TESTING ON)
set(ISO15118_BUILD_TESTING ON)
set(ocpp_BUILD_TESTING ON)
set(LIBEVSE_SECURITY_BUILD_TESTING ON)
set(everest-evse_security_BUILD_TESTING ON)
set(everest-sqlite_BUILD_TESTING ON)
set(everest-timer_BUILD_TESTING ON)
set(everest-log_BUILD_TESTING ON)
set(IEEE2030_BUILD_TESTING ON)
endif()
# This is a flag for building development tests, but not necessarily to run them, for expample in case
# tests requires hardware.
option(BUILD_DEV_TESTS "Build dev tests" OFF)
ev_setup_cmake_variables_python_wheel()
option(${PROJECT_NAME}_INSTALL_EV_CLI_IN_PYTHON_VENV "Install ev-cli in python venv instead of using system" ON)
set(${PROJECT_NAME}_PYTHON_VENV_PATH "${CMAKE_BINARY_DIR}/venv" CACHE PATH "Path to python venv")
ev_setup_python_executable(
USE_PYTHON_VENV ${${PROJECT_NAME}_USE_PYTHON_VENV}
PYTHON_VENV_PATH ${${PROJECT_NAME}_PYTHON_VENV_PATH}
)
# Already include CTest here to allow it to find tests defined in subdirectories like lib and modules
if(EVEREST_CORE_BUILD_TESTING)
include(CTest)
if (NOT CMAKE_BUILD_TYPE)
if(EVEREST_ENABLE_DEBUG_BUILD)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE)
else()
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Build type" FORCE)
endif()
endif()
endif()
include(ev-define-dependency)
include(ev-lib-dependencies)
if(NOT EVEREST_LIBS_ONLY)
include("module-dependencies.cmake")
endif()
# this policy allows us to continue using the removed FindBoost module for now
if(POLICY CMP0167)
cmake_policy(SET CMP0167 OLD)
endif()
find_package(Boost
COMPONENTS
filesystem
program_options
thread
REQUIRED
)
include(compatibility/boost)
set(everest-framework_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/everest/framework)
set(everest-framework_BINARY_DIR ${CMAKE_BINARY_DIR}/lib/everest/framework)
set(EVEREST_SCHEMA_DIR ${everest-framework_SOURCE_DIR}/schemas)
set(everest-sqlite_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/everest/sqlite)
if(NOT DEFINED EVEREST_ENABLE_PY_SUPPORT)
set(EVEREST_ENABLE_PY_SUPPORT ON CACHE BOOL "Enable EVerest Python support" FORCE)
endif()
if(NOT DISABLE_EDM)
# FIXME (aw): this implicit definition for child projects is hacky
set(THIRD_PARTY_APP_DST "${CMAKE_INSTALL_LIBEXECDIR}/everest/3rd_party")
# edm
add_subdirectory(applications/dependency_manager)
evc_setup_edm()
if(EVEREST_DEPENDENCY_ENABLED_SDBUS_CPP AND NOT TARGET SDBusCpp::sdbus-c++)
add_library(SDBusCpp::sdbus-c++ ALIAS sdbus-c++)
endif()
# ev-cli and everest-testing
if(NOT EVEREST_LIBS_ONLY)
add_subdirectory(applications/utils)
endif()
else()
if(NOT EVEREST_LIBS_ONLY)
find_package(PalSigslot REQUIRED)
find_package(libnfc-nci REQUIRED)
find_package(pugixml REQUIRED)
find_package(CURL 7.84.0 REQUIRED)
find_package(ftxui 6 QUIET) # optional, if not available BringUp module will not be built
find_package(sdbus-c++ REQUIRED)
endif()
find_package(ryml REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(fmt REQUIRED)
find_package(date REQUIRED)
find_package(OpenSSL 3 REQUIRED)
endif()
if(EVEREST_BUILD_DOCS)
add_subdirectory(docs)
endif()
if(EVEREST_LIBS_ONLY)
# ev-targets provides ev_register_library_target() used by some libraries
include(ev-targets)
else()
include(ev-project-bootstrap)
ev_add_project()
# create MF_ROOT_CA if not available
if (ISO15118_2_GENERATE_AND_INSTALL_CERTIFICATES)
file(TOUCH config/certs/ca/mf/MF_ROOT_CA.pem)
endif()
endif()
add_subdirectory(lib)
if(NOT EVEREST_LIBS_ONLY)
# config
# FIXME (aw): this should be optional
add_subdirectory(config)
if(EVEREST_BUILD_APPLICATIONS)
add_subdirectory(applications)
endif()
ev_install_project()
endif()
# configure clang-tidy if requested
if(CMAKE_RUN_CLANG_TIDY)
message("Enabling clang-tidy")
set(CMAKE_CXX_CLANG_TIDY clang-tidy)
endif()
# build doxygen documentation if doxygen is available
find_package(Doxygen)
if(DOXYGEN_FOUND)
set( DOXYGEN_OUTPUT_DIRECTORY dist/docs )
doxygen_add_docs(doxygen-${PROJECT_NAME} everest.js include lib src)
endif()
# testing
if(EVEREST_CORE_BUILD_TESTING AND NOT EVEREST_LIBS_ONLY)
add_subdirectory(tests)
else()
message("Not running unit tests")
endif()
if(NOT EVEREST_LIBS_ONLY)
# convenience target for integration tests
add_custom_target(install_everest_testing
COMMAND
if [ -z "${CPM_PACKAGE_everest-utils_SOURCE_DIR}" ] \;
then echo "Could not determine location of everest-utils, please install everest-testing manually!" \;
else echo "Found everest-utils at ${CPM_PACKAGE_everest-utils_SOURCE_DIR}" \;
${Python3_EXECUTABLE} -m pip install -e "${CPM_PACKAGE_everest-utils_SOURCE_DIR}/everest-testing" \;
fi\;
DEPENDS
everestpy_pip_install_dist
COMMENT
"Installing dependencies for testing EVerest"
)
endif()