forked from EVerest/everest-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
177 lines (146 loc) · 4.92 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
cmake_minimum_required(VERSION 3.14)
project(everest-framework
VERSION 0.4.1
DESCRIPTION "The open operating system for e-mobility charging stations"
LANGUAGES CXX C
)
find_package(everest-cmake 0.1 REQUIRED
PATHS ../everest-cmake
)
# options
option(BUILD_TESTING "Run unit tests" OFF)
option(FRAMEWORK_INSTALL "Install the library (shared data might be installed anyway)" ${EVC_MAIN_PROJECT})
option(CMAKE_RUN_CLANG_TIDY "Run clang-tidy" OFF)
option(EVEREST_ENABLE_JS_SUPPORT "Enable everestjs for JavaScript modules" ON)
option(EVEREST_ENABLE_PY_SUPPORT "Enable everestpy for Python modules" ON)
# make own cmake modules available
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# dependencies
find_package(Boost
COMPONENTS
program_options
system
thread
REQUIRED
)
if(NOT DISABLE_EDM)
evc_setup_edm()
# In EDM mode, we can't install exports (because the dependencies usually do not install their exports)
set(FRAMEWORK_INSTALL OFF)
# FIXME (aw): libwebsockets/ninja clean doesn't delete recursivly ..
set_property(
TARGET websockets_shared
APPEND
PROPERTY ADDITIONAL_CLEAN_FILES "${libwebsockets_BINARY_DIR}/include/libwebsockets"
)
# FIXME (aw): libwebsockets enum-int-mismatch FIX
# see https://github.com/warmcat/libwebsockets/pull/2824
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 13.0)
target_compile_options(websockets_shared PRIVATE -Wno-error=enum-int-mismatch)
endif()
# FIXME (aw): pboetch json validator doesn't want to install itself :(
install(TARGETS nlohmann_json_schema_validator
EXPORT nlohmann_json_schema_validatorTargets
)
# FIXME (aw): add catch2's cmake folder
list(APPEND CMAKE_MODULE_PATH "${Catch2_SOURCE_DIR}/contrib")
else()
find_package(date REQUIRED)
find_package(ryml REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(nlohmann_json_schema_validator REQUIRED)
find_package(libwebsockets REQUIRED)
find_package(fmt REQUIRED)
find_package(everest-log REQUIRED)
if (BUILD_TESTING)
find_package(Catch2 REQUIRED)
endif()
include(find-mqttc)
endif()
set(EVEREST_FRAMEWORK_GENERATED_INC_DIR ${PROJECT_BINARY_DIR}/generated)
configure_file(
include/compile_time_settings.hpp.in
${EVEREST_FRAMEWORK_GENERATED_INC_DIR}/everest/compile_time_settings.hpp
)
# library code
add_subdirectory(lib)
# executable code
add_subdirectory(src)
# auxillary files
add_subdirectory(schemas)
# everest javascript wrapper
if (EVEREST_ENABLE_JS_SUPPORT)
add_subdirectory(everestjs)
endif()
# everest python wrapper
if (EVEREST_ENABLE_PY_SUPPORT)
add_subdirectory(everestpy)
endif()
# FIXME (aw): should this be installed or not? Right now it is needed for the
# current packaging approach
install(TARGETS framework
EXPORT framework-targets
LIBRARY
)
# packaging
if (FRAMEWORK_INSTALL)
install(
DIRECTORY include/
DESTINATION include/everest
)
install(
FILES ${EVEREST_FRAMEWORK_GENERATED_INC_DIR}/everest/compile_time_settings.hpp
DESTINATION include/everest
)
evc_setup_package(
NAME everest-framework
EXPORT framework-targets
NAMESPACE everest
ADDITIONAL_CONTENT
"find_package(nlohmann_json REQUIRED)"
"find_package(nlohmann_json_schema_validator REQUIRED)"
"find_package(everest-timer REQUIRED)"
"find_package(everest-log REQUIRED)"
"find_package(fmt REQUIRED)"
"find_package(date REQUIRED)"
"set(EVEREST_SCHEMA_DIR \"@PACKAGE_EVEREST_SCHEMA_DIR@\")"
PATH_VARS
EVEREST_SCHEMA_DIR "${CMAKE_INSTALL_DATADIR}/everest/schemas"
)
endif ()
# testing
# FIXME (aw): move testing logic into tests/CMakeLists.txt
if(BUILD_TESTING)
include(CTest)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE)
evc_include(CodeCoverage)
append_coverage_compiler_flags()
add_subdirectory(tests)
setup_target_for_coverage_gcovr_html(
NAME gcovr_coverage
EXECUTABLE ctest --output-on-failure
EXCLUDE "${CMAKE_SOURCE_DIR}/tests" "${CMAKE_BINARY_DIR}"
DEPENDENCIES tests everest
)
setup_target_for_coverage_lcov(
NAME lcov_coverage
EXECUTABLE ctest --output-on-failure
EXCLUDE "${CMAKE_SOURCE_DIR}/tests" "${CMAKE_BINARY_DIR}"
DEPENDENCIES tests everest
)
else()
message("Not running unit tests")
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)
else()
message("Doxygen is needed to generate documentation")
endif()