forked from stratum/stratum
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
146 lines (124 loc) · 3.99 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
# CMake build file for stratum project
#
# Copyright 2022-2024 Intel Corporation
# SPDX-License-Identifier: Apache 2.0
cmake_minimum_required(VERSION 3.15)
project(stratum LANGUAGES CXX)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
# SDE_INSTALL_DIR
set(SDE_INSTALL_DIR "$ENV{SDE_INSTALL}" CACHE PATH
"SDE install directory")
if(NOT EXISTS "${SDE_INSTALL_DIR}")
message(FATAL_ERROR "SDE_INSTALL_DIR (SDE_INSTALL) not defined!")
endif()
# DEPEND_INSTALL_DIR
set(DEPEND_INSTALL_DIR "$ENV{DEPEND_INSTALL}" CACHE PATH
"Dependencies install directory")
if(NOT EXISTS "${DEPEND_INSTALL_DIR}")
message(FATAL_ERROR "DEPEND_INSTALL_DIR (DEPEND_INSTALL) not defined!")
endif()
list(APPEND CMAKE_PREFIX_PATH ${DEPEND_INSTALL_DIR})
endif()
# Suppress "warning: attribute ignored" on ABSL_MUST_USE_RESULT [[nodiscard]]
add_compile_options(-Wno-attributes)
add_subdirectory(stratum)
###########################
# add_stratum_object_libs #
###########################
function(add_stratum_object_libs _TGT)
target_sources(${_TGT} PRIVATE
$<TARGET_OBJECTS:stratum_glue_o>
$<TARGET_OBJECTS:stratum_glue_status_o>
$<TARGET_OBJECTS:stratum_hal_lib_common_o>
$<TARGET_OBJECTS:stratum_hal_lib_p4_o>
$<TARGET_OBJECTS:stratum_hal_lib_phal_o>
$<TARGET_OBJECTS:stratum_lib_o>
$<TARGET_OBJECTS:stratum_lib_p4runtime_o>
$<TARGET_OBJECTS:stratum_lib_security_o>
$<TARGET_OBJECTS:stratum_lib_utils_o>
$<TARGET_OBJECTS:stratum_main_o>
$<TARGET_OBJECTS:stratum_public_lib_o>
$<TARGET_OBJECTS:stratum_tdi_common_o>
$<TARGET_OBJECTS:stratum_tdi_target_o>
$<TARGET_OBJECTS:stratum_yang_parse_tree_o>
)
endfunction(add_stratum_object_libs)
#########################
# add_stratum_libraries #
#########################
# Abseil libraries
function(add_stratum_abseil_libs _TGT)
target_link_libraries(${_TGT} PUBLIC
absl::strings
absl::synchronization
absl::graphcycles_internal
absl::stacktrace
absl::symbolize
absl::malloc_internal
absl::debugging_internal
absl::demangle_internal
absl::time
absl::strings_internal
absl::throw_delegate
absl::base
absl::spinlock_wait
absl::int128
absl::raw_logging_internal
absl::log_severity
absl::civil_time
absl::time_zone
absl::status
absl::cord
absl::exponential_biased
absl::str_format_internal
absl::hash
absl::raw_hash_set
absl::city
absl::bad_optional_access
absl::bad_variant_access
)
if(absl_VERSION VERSION_GREATER_EQUAL 20230125)
target_link_libraries(${_TGT} PUBLIC absl::log_internal_check_op)
endif()
endfunction()
# Google libraries
function(add_stratum_google_libs _TGT)
target_link_libraries(${_TGT} PUBLIC
gflags::gflags_shared
glog::glog
gRPC::gpr
gRPC::grpc
gRPC::grpc++
protobuf::libprotobuf
)
endfunction()
# Protobuf libraries
function(add_stratum_proto_libs _TGT)
target_link_libraries(${_TGT} PUBLIC
openconfig_proto
stratum_proto
gnmi_proto
google_rpc_proto
p4runtime_proto
)
endfunction()
function(add_stratum_libraries _TGT)
add_stratum_abseil_libs(${_TGT})
add_stratum_google_libs(${_TGT})
add_stratum_proto_libs(${_TGT})
target_link_libraries(${_TGT} PUBLIC pthread)
endfunction()
#####################
# libstratum_static #
#####################
add_library(stratum_static STATIC)
add_stratum_object_libs(stratum_static)
add_stratum_libraries(stratum_static)
target_include_directories(stratum_static PUBLIC ${STRATUM_INCLUDES})
#####################
# libstratum_shared #
#####################
add_library(stratum_shared SHARED)
add_stratum_object_libs(stratum_shared)
add_stratum_libraries(stratum_shared)
target_include_directories(stratum_shared PUBLIC ${STRATUM_INCLUDES})