forked from facebook/fboss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
589 lines (534 loc) · 13.2 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
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
cmake_minimum_required(VERSION 3.8)
option(WITH_ASAN "Turn ON address sanitizer build options" OFF)
if ($ENV{WITH_ASAN})
message(STATUS "ENV WITH_ASAN is set")
set (WITH_ASAN ON)
endif()
if (WITH_ASAN)
message(STATUS "Building WITH_ASAN")
endif()
option(BENCHMARK_INSTALL "Installation of benchmark test binaries" OFF)
if ($ENV{BENCHMARK_INSTALL})
message(STATUS "ENV BENCHMARK_INSTALL is set")
set (BENCHMARK_INSTALL ON)
endif()
if (BENCHMARK_INSTALL)
message(STATUS "Configured to install benchmark binaries")
endif()
option(BUILD_SAI_FAKE "Build sai binaries for fake_sai" OFF)
if ($ENV{BUILD_SAI_FAKE})
message(STATUS "ENV BUILD_SAI_FAKE is set")
set (BUILD_SAI_FAKE ON)
endif()
option(BUILD_SAI_FAKE_BENCHMARKS "Build benchmarks binaries for fake_sai" OFF)
if ($ENV{BUILD_SAI_FAKE_BENCHMARKS})
message(STATUS "ENV BUILD_SAI_FAKE_BENCHMARKS is set")
set (BUILD_SAI_FAKE_BENCHMARKS ON)
endif()
if (BUILD_SAI_FAKE_BENCHMARKS)
message(STATUS "Building benchmarks binaries for fake_sai")
endif()
option(SKIP_ALL_INSTALL "Installation of fboss binaries" OFF)
if ($ENV{SKIP_ALL_INSTALL})
message(STATUS "ENV SKIP_ALL_INSTALL is set")
set (SKIP_ALL_INSTALL ON)
endif()
if (SKIP_ALL_INSTALL)
install(FILES README.md DESTINATION .)
macro (install)
message(STATUS "Skipping installing ${ARGV} fboss artifact")
_install(${ARGV} EXCLUDE_FROM_ALL)
endmacro ()
endif()
option(SAI_TAJO_IMPL "Build SAI api with tajo extensions" OFF)
if ($ENV{SAI_TAJO_IMPL})
message(STATUS "ENV SAI_TAJO_IMPL is set")
set (SAI_TAJO_IMPL ON)
endif()
option(SAI_BRCM_IMPL "Build SAI api with BRCM-SAI extensions" OFF)
if ($ENV{SAI_BRCM_IMPL})
message(STATUS "ENV SAI_BRCM_IMPL is set")
set (SAI_BRCM_IMPL ON)
endif()
option(BUILD_SAI_FAKE_LINK_TEST "Building of SAI Fake Link Test binaries" OFF)
if ($ENV{BUILD_SAI_FAKE_LINK_TEST})
message(STATUS "ENV BUILD_SAI_FAKE_LINK_TEST is set")
set (BUILD_SAI_FAKE_LINK_TEST ON)
endif()
option(BUILD_FBOSS_CLI "Build FBOSS CLI" OFF)
if ($ENV{BUILD_FBOSS_CLI})
message(STATUS "ENV BUILD_FBOSS_CLI is set")
set (BUILD_FBOSS_CLI ON)
endif()
if (BUILD_SAI_FAKE_LINK_TEST)
message(STATUS "Configured to build SAI Fake Link Test binaries")
endif()
if (SAI_BRCM_IMPL)
# TODO (skhare) IS_OSS_BRCM_SAI is only a short-term change to unblock.
# Refactor/fix the code and then remove this flag.
add_definitions (-DIS_OSS_BRCM_SAI=true)
# Build for BCM DNX by default. For XGS, set the ENV variable SAI_SDK_VERSION
# to build for BCM XGS.
set(SAI_SDK_VERSION "SAI_VERSION_10_0_EA_DNX_ODP")
set(SAI_VER_MAJOR "1")
set(SAI_VER_MINOR "12")
set(SAI_VER_RELEASE "0")
else()
set(SAI_VER_MAJOR "1")
set(SAI_VER_MINOR "7")
set(SAI_VER_RELEASE "1")
endif()
if (NOT "$ENV{SAI_SDK_VERSION}" STREQUAL "")
message(STATUS "ENV SAI_SDK_VERSION is set to $ENV{SAI_SDK_VERSION}")
set(SAI_SDK_VERSION "$ENV{SAI_SDK_VERSION}")
endif()
message(STATUS "Building for SAI_SDK_VERSION: ${SAI_SDK_VERSION}")
if (NOT "${SAI_SDK_VERSION}" STREQUAL "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D${SAI_SDK_VERSION}")
endif()
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message(STATUS "Building for SAI Spec ${SAI_VER_MAJOR}.${SAI_VER_MINOR}.${SAI_VER_RELEASE}")
set(SAI_VER_SUFFIX "${SAI_VER_MAJOR}.${SAI_VER_MINOR}.${SAI_VER_RELEASE}")
set(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/build/fbcode_builder/CMake"
${CMAKE_MODULE_PATH})
set (CMAKE_MODULE_PATH
"${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if (POLICY CMP0054)
# Enable CMP0054 to indicate that we want the new safer if() argument behavior
cmake_policy(SET CMP0054 NEW)
endif()
project(FBOSS)
include(CMakeParseArguments)
set(CMAKE_CXX_STANDARD 17)
set(CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
if (WITH_ASAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -static-libasan")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize-recover=all")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-address-use-after-scope")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize=alignment")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize=null")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize=vptr")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libasan")
endif()
include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_BUILD_DIR})
find_package(GTest REQUIRED)
include_directories(
${GTEST_INCLUDE_DIRS}
)
find_package(GMock MODULE REQUIRED)
find_package(gflags REQUIRED)
include_directories(${GFLAGS_INCLUDE_DIR})
find_package(Glog REQUIRED)
include_directories(${GLOG_INCLUDE_DIRS})
find_package(folly CONFIG REQUIRED)
include_directories(${FOLLY_INCLUDE_DIR})
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
find_package(fb303 CONFIG REQUIRED)
find_package(fizz CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
find_package(wangle CONFIG REQUIRED)
find_package(FBThrift CONFIG REQUIRED)
include_directories(${FB303_INCLUDE_DIR})
find_path(FATAL_INCLUDE_DIR NAMES fatal/portability.h)
include_directories(${FATAL_INCLUDE_DIR})
find_library(NLOHMANN_JSON nlohmann-json)
find_path(NLOHMANN_JSON_INCLUDE_DIRS NAMES nlohmann/json.hpp)
include_directories(${NLOHMANN_JSON_INCLUDE_DIRS})
find_package(Python3 COMPONENTS Interpreter Development)
include_directories(${Python3_INCLUDE_DIR})
find_path(SAI_INCLUDE_DIR NAMES sai.h)
include_directories(${SAI_INCLUDE_DIR})
message(STATUS "Found SAI_INCLUDE_DIR: ${SAI_INCLUDE_DIR}")
find_library(LIBNL nl-3)
find_path(LIBNL_INCLUDE_DIR NAMES libnl3/netlink/socket.h)
include_directories(${LIBNL_INCLUDE_DIR})
include_directories(${LIBNL_INCLUDE_DIR}/libnl3)
find_library(IPROUTE2 netlink)
find_path(IPROUTE2_INCLUDE_DIR NAMES libnetlink.h)
include_directories(${IPROUTE2_INCLUDE_DIR})
find_library(YAML-CPP yaml-cpp)
find_path(YAML-CPP_INCLUDE_DIR NAMES yaml-cpp/yaml.h)
include_directories(${YAML-CPP_INCLUDE_DIR})
message(STATUS "Found YAML-CPP_INCLUDE_DIR: ${YAML-CPP_INCLUDE_DIR}")
find_library(YAML yaml)
find_path(YAML_INCLUDE_DIR NAMES yaml.h)
include_directories(${YAML_INCLUDE_DIR})
message(STATUS "Found YAML_INCLUDE_DIR: ${YAML_INCLUDE_DIR}")
# Generate thrift deps and libraries
include(FBThriftCppLibrary)
# Thrift libraries
add_fbthrift_cpp_library(
fb303_cpp2
common/fb303/if/fb303.thrift
SERVICES
FacebookService
OPTIONS
json
reflection
)
add_fbthrift_cpp_library(
network_address_cpp2
common/network/if/Address.thrift
OPTIONS
json
reflection
)
add_fbthrift_cpp_library(
mpls_cpp2
fboss/agent/if/mpls.thrift
OPTIONS
json
reflection
)
add_fbthrift_cpp_library(
fboss_common_cpp2
fboss/lib/if/fboss_common.thrift
OPTIONS
json
reflection
)
add_fbthrift_cpp_library(
switch_config_cpp2
fboss/agent/switch_config.thrift
OPTIONS
json
reflection
DEPENDS
common_cpp2
fboss_common_cpp2
mpls_cpp2
)
add_fbthrift_cpp_library(
agent_config_cpp2
fboss/agent/agent_config.thrift
OPTIONS
json
reflection
DEPENDS
platform_config_cpp2
switch_config_cpp2
)
add_fbthrift_cpp_library(
platform_config_cpp2
fboss/agent/platform_config.thrift
OPTIONS
json
reflection
DEPENDS
bcm_config_cpp2
asic_config_cpp2
phy_cpp2
)
add_fbthrift_cpp_library(
switch_state_cpp2
fboss/agent/switch_state.thrift
OPTIONS
json
reflection
DEPENDS
switch_config_cpp2
phy_cpp2
ctrl_cpp2
)
add_fbthrift_cpp_library(
prbs_cpp2
fboss/lib/phy/prbs.thrift
OPTIONS
json
reflection
)
add_fbthrift_cpp_library(
transceiver_cpp2
fboss/qsfp_service/if/transceiver.thrift
OPTIONS
json
reflection
DEPENDS
prbs_cpp2
)
add_fbthrift_cpp_library(
qsfp_config_cpp2
fboss/qsfp_service/if/qsfp_service_config.thrift
OPTIONS
json
reflection
DEPENDS
transceiver_cpp2
switch_config_cpp2
)
add_fbthrift_cpp_library(
qsfp_state_cpp2
fboss/qsfp_service/if/qsfp_state.thrift
OPTIONS
json
reflection
DEPENDS
qsfp_config_cpp2
phy_cpp2
transceiver_cpp2
)
add_fbthrift_cpp_library(
qsfp_stats_cpp2
fboss/qsfp_service/if/qsfp_stats.thrift
OPTIONS
json
reflection
DEPENDS
hardware_stats_cpp2
phy_cpp2
transceiver_cpp2
)
add_fbthrift_cpp_library(
sensor_service_stats_cpp2
fboss/platform/sensor_service/sensor_service_stats.thrift
OPTIONS
json
reflection
DEPENDS
sensor_service_cpp2
)
add_fbthrift_cpp_library(
phy_cpp2
fboss/lib/phy/phy.thrift
SERVICES
FbossCommonPhyCtrl
OPTIONS
json
reflection
DEPENDS
switch_config_cpp2
transceiver_cpp2
fboss_cpp2
fb303_cpp2
)
add_fbthrift_cpp_library(
optic_cpp2
fboss/agent/if/optic.thrift
OPTIONS
json
reflection
DEPENDS
transceiver_cpp2
)
add_fbthrift_cpp_library(
fboss_cpp2
fboss/agent/if/fboss.thrift
OPTIONS
json
reflection
)
add_fbthrift_cpp_library(
sflow_cpp2
fboss/agent/if/sflow.thrift
OPTIONS
json
)
add_fbthrift_cpp_library(
common_cpp2
fboss/agent/if/common.thrift
OPTIONS
json
reflection
DEPENDS
mpls_cpp2
network_address_cpp2
)
add_fbthrift_cpp_library(
product_info_cpp2
fboss/agent/if/product_info.thrift
OPTIONS
json
reflection
)
add_fbthrift_cpp_library(
hardware_stats_cpp2
fboss/agent/hw/hardware_stats.thrift
OPTIONS
json
visitation
reflection
DEPENDS
mka_structs_cpp2
)
add_fbthrift_cpp_library(
ctrl_cpp2
fboss/agent/if/ctrl.thrift
SERVICES
FbossCtrl
NeighborListenerClient
OPTIONS
json
reflection
DEPENDS
fboss_cpp2
fb303_cpp2
mpls_cpp2
network_address_cpp2
optic_cpp2
platform_config_cpp2
hardware_stats_cpp2
product_info_cpp2
transceiver_cpp2
common_cpp2
phy_cpp2
OPTIONS
json
)
add_fbthrift_cpp_library(
packet_stream_cpp2
fboss/agent/if/packet_stream.thrift
SERVICES
PacketStream
DEPENDS
fb303_cpp2
)
add_fbthrift_cpp_library(
bcm_config_cpp2
fboss/agent/hw/bcm/bcm_config.thrift
OPTIONS
json
reflection
)
add_fbthrift_cpp_library(
asic_config_cpp2
fboss/agent/hw/sai/config/asic_config.thrift
OPTIONS
json
reflection
)
add_fbthrift_cpp_library(
mka_structs_cpp2
fboss/mka_service/if/mka_structs.thrift
OPTIONS
json
reflection
)
add_fbthrift_cpp_library(
agent_stats_cpp2
fboss/agent/agent_stats.thrift
OPTIONS
json
reflection
DEPENDS
hardware_stats_cpp2
)
add_fbthrift_cpp_library(
i2c_controller_stats_cpp2
fboss/lib/i2c/i2c_controller_stats.thrift
)
add_fbthrift_cpp_library(
led_mapping_cpp2
fboss/lib/led/led_mapping.thrift
OPTIONS
json
reflection
)
add_fbthrift_cpp_library(
bsp_platform_mapping_cpp2
fboss/lib/bsp/bsp_platform_mapping.thrift
OPTIONS
json
reflection
DEPENDS
led_mapping_cpp2
)
add_fbthrift_cpp_library(
qsfp_cpp2
fboss/qsfp_service/if/qsfp.thrift
SERVICES
QsfpService
OPTIONS
json
DEPENDS
fb303_cpp2
ctrl_cpp2
fboss_cpp2
transceiver_cpp2
switch_config_cpp2
mpls_cpp2
mka_structs_cpp2
hardware_stats_cpp2
)
add_fbthrift_cpp_library(
hw_ctrl_cpp2
fboss/agent/if/hw_ctrl.thrift
SERVICES
FbossHwCtrl
DEPENDS
ctrl_cpp2
)
add_fbthrift_cpp_library(
sai_ctrl_cpp2
fboss/agent/hw/sai/switch/sai_ctrl.thrift
SERVICES
SaiCtrl
DEPENDS
ctrl_cpp2
hw_ctrl_cpp2
)
add_fbthrift_cpp_library(
hw_test_ctrl_cpp2
fboss/agent/hw/hw_test_ctrl.thrift
SERVICES
HwTestCtrl
DEPENDS
ctrl_cpp2
)
add_fbthrift_cpp_library(
sai_test_ctrl_cpp2
fboss/agent/hw/sai/hw_test/sai_test_ctrl.thrift
SERVICES
SaiTestCtrl
DEPENDS
ctrl_cpp2
hw_test_ctrl_cpp2
)
add_fbthrift_cpp_library(
multiswitch_ctrl_cpp2
fboss/agent/if/multiswitch_ctrl.thrift
SERVICES
MultiSwitchCtrl
DEPENDS
ctrl_cpp2
fsdb_oper_cpp2
)
find_library(USB usb-1.0)
find_path(USB_INCLUDE_DIR NAMES libusb-1.0/libusb.h)
include_directories(${USB_INCLUDE_DIR})
find_library(NETLINK3 nl-3)
find_library(NETLINKROUTE3 nl-route-3 libnl-route-3.a nl-route-3)
find_library(CURL curl)
find_path(CURL_INCLUDE_DIR NAMES curl/curl.h)
include_directories(${CURL_INCLUDE_DIR})
find_library(MNL mnl)
find_library(SODIUM sodium)
find_library(RE2 re2)
find_path(RE2_INCLUDE_DIR NAMES re2/re2.h)
include_directories(${RE2_INCLUDE_DIR})
find_library(EXPRTK exprtk)
find_path(EXPRTK_INCLUDE_DIR NAMES exprtk.hpp)
include_directories(${EXPRTK_INCLUDE_DIR})
# OSS is still using C++17. Use following flag to allow internal build
# to use C++20 features. Remove the below flag once OSS start using C++20.
add_definitions (-DIS_OSS_CPP17=true)
# Unit Testing
add_definitions (-DIS_OSS=true)
find_package(Threads REQUIRED)
enable_testing()
# Build all cmake files under cmake/*cmake
file(GLOB cmakeFiles ${CMAKE_CURRENT_SOURCE_DIR}/cmake/*.cmake)
foreach(cmakeFile ${cmakeFiles})
message(status " INCLUDE ${cmakeFile}")
INCLUDE(${cmakeFile})
endforeach(cmakeFile)