-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
195 lines (167 loc) · 5.59 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
192
193
194
cmake_minimum_required(VERSION 3.13)
cmake_policy(VERSION 3.13)
##############################################################################################################
project(fty-pack VERSION 1.0.0)
########################################################################################################################
find_package(fty-cmake PATHS ${CMAKE_BINARY_DIR})
########################################################################################################################
option(WITH_PROTOBUF "Using protobuf provider" ON)
option(WITH_ZCONFIG "Using zconfig provider" ON)
########################################################################################################################
set(sources)
set(defs)
set(libs)
if (WITH_PROTOBUF)
find_package(Protobuf QUIET)
if (NOT Protobuf_FOUND OR NOT Protobuf_PROTOC_EXECUTABLE)
message(FATAL_ERROR "You tried to compile with protobuf support, but protobuf was not found, please install \
libprotobuf-dev \
libprotoc-dev \
protobuf-compiler ")
endif()
list(APPEND sources src/providers/protobuf.cpp)
list(APPEND defs -DWITH_PROTOBUF)
list(APPEND libs protobuf::libprotobuf)
endif()
if (WITH_ZCONFIG)
resolve(czmq)
list(APPEND sources src/providers/zconfig.cpp)
list(APPEND defs -DWITH_ZCONFIG)
list(APPEND libs czmq)
endif()
########################################################################################################################
etn_target(shared ${PROJECT_NAME}
PUBLIC
pack/pack.h
pack/attribute.h
pack/list.h
pack/map.h
pack/value.h
pack/enum.h
pack/node.h
pack/types.h
pack/serialization.h
pack/proto-map.h
pack/visitor.h
pack/variant.h
pack/magic-enum.h
SOURCES
src/node.cpp
src/attribute.cpp
src/providers/yaml.cpp
src/providers/json.cpp
src/providers/utils.h
src/providers/utils.cpp
${sources}
PREPROCESSOR ${defs}
USES_PUBLIC
fty-utils
USES
yaml-cpp
nlohmann_json::nlohmann_json
${libs}
)
##############################################################################################################
if (WITH_PROTOBUF)
add_subdirectory(protoc)
include(protoc/cmake/protogen.cmake)
endif()
##############################################################################################################
#if (WITH_PROTOBUF)
# etn_test_target(${PROJECT_NAME}
# SOURCES
# tests/main.cpp
# tests/simple.cpp
# tests/list.cpp
# tests/nested.cpp
# tests/enums.cpp
# tests/map.cpp
# tests/include.cpp
# tests/child.cpp
# tests/variant.cpp
# tests/json.cpp
# tests/options.cpp
# PREPROCESSOR
# -DCATCH_CONFIG_FAST_COMPILE
# SUBDIR
# tests
# )
# if (TARGET ${PROJECT_NAME}-test)
# fty_protogen(
# TARGET ${PROJECT_NAME}-test
# WORKDIR tests
# PROTO
# tests/examples/example1.proto
# tests/examples/example2.proto
# tests/examples/example3.proto
# tests/examples/example4.proto
# tests/examples/example5.proto
# tests/examples/example6.proto
# tests/examples/example7.proto
# tests/examples/example8.proto
# )
# endif()
# if (TARGET ${PROJECT_NAME}-coverage)
# fty_protogen(
# TARGET ${PROJECT_NAME}-coverage
# WORKDIR tests
# PROTO
# tests/examples/example1.proto
# tests/examples/example2.proto
# tests/examples/example3.proto
# tests/examples/example4.proto
# tests/examples/example5.proto
# tests/examples/example6.proto
# tests/examples/example7.proto
# tests/examples/example8.proto
# )
# endif()
#endif()
if (BUILD_TESTING AND WITH_PROTOBUF)
etn_test(${PROJECT_NAME}-test
SOURCES
tests/main.cpp
tests/simple.cpp
tests/list.cpp
tests/nested.cpp
tests/enums.cpp
tests/map.cpp
tests/include.cpp
tests/child.cpp
tests/variant.cpp
tests/json.cpp
tests/options.cpp
PREPROCESSOR -DCATCH_CONFIG_FAST_COMPILE
USES
${PROJECT_NAME}
Catch2::Catch2
)
fty_protogen(
TARGET ${PROJECT_NAME}-test
WORKDIR tests
PROTO
tests/examples/example1.proto
tests/examples/example2.proto
tests/examples/example3.proto
tests/examples/example4.proto
tests/examples/example5.proto
tests/examples/example6.proto
tests/examples/example7.proto
tests/examples/example8.proto
)
etn_coverage(${PROJECT_NAME}-test SUBDIR tests)
fty_protogen(
TARGET ${PROJECT_NAME}-test-coverage
WORKDIR tests
PROTO
tests/examples/example1.proto
tests/examples/example2.proto
tests/examples/example3.proto
tests/examples/example4.proto
tests/examples/example5.proto
tests/examples/example6.proto
tests/examples/example7.proto
tests/examples/example8.proto
)
endif()
##############################################################################################################