475672a001a7442cc8ac337218fdf6aa37e40517
[vpp.git] / extras / vom / vom / CMakeLists.txt
1 # Copyright (c) 2018 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 unset (VPPAPICLIENT_LIB)
15 unset (VAPICLIENT_LIB)
16 unset (ACL_FILE)
17 unset (NAT_FILE)
18 unset (L2E_FILE)
19 unset (GBP_FILE)
20 unset (IGMP_FILE)
21 unset (VOM_SOURCES)
22 unset (VOM_HEADERS)
23
24 find_library(VPPAPICLIENT_LIB NAMES vppapiclient REQUIRED)
25 find_path(VPPAPICLIENT_INCLUDE_DIR NAMES vpp-api/client/vppapiclient.h)
26 find_library(VAPICLIENT_LIB NAMES vapiclient REQUIRED)
27 find_path(VAPICLIENT_INCLUDE_DIR NAMES vapi/vapi.hpp)
28
29
30 if(NOT VPPAPICLIENT_INCLUDE_DIR OR NOT VPPAPICLIENT_LIB)
31   message(FATAL_ERROR "Cannot find vppapiclient library and/or headers")
32 endif()
33 if(NOT VAPICLIENT_INCLUDE_DIR OR NOT VAPICLIENT_LIB)
34   message(FATAL_ERROR "Cannot find vapiclient library and/or headers")
35 endif()
36
37 include_directories(${VPPAPICLIENT_INCLUDE_DIR})
38 include_directories(${VAPICLIENT_INCLUDE_DIR})
39 include_directories(${CMAKE_SOURCE_DIR})
40
41 find_file(ACL_FILE NAMES acl.api.vapi.hpp PATH_SUFFIXES vapi)
42 find_file(NAT_FILE NAMES nat.api.vapi.hpp PATH_SUFFIXES vapi)
43 find_file(L2E_FILE NAMES l2e.api.vapi.hpp PATH_SUFFIXES vapi)
44 find_file(GBP_FILE NAMES gbp.api.vapi.hpp PATH_SUFFIXES vapi)
45 find_file(IGMP_FILE NAMES igmp.api.vapi.hpp PATH_SUFFIXES vapi)
46
47 if(ACL_FILE)
48   list(APPEND VOM_SOURCES
49     acl_binding_cmds.cpp
50     acl_binding.cpp
51     acl_ethertype_cmds.cpp
52     acl_ethertype.cpp
53     acl_l2_rule.cpp
54     acl_l3_rule.cpp
55     acl_list_cmds.cpp
56     acl_list.cpp
57     acl_types.cpp
58   )
59 endif()
60
61 if(NAT_FILE)
62   list(APPEND VOM_SOURCES
63     nat_static.cpp
64     nat_static_cmds.cpp
65     nat_binding.cpp
66     nat_binding_cmds.cpp
67   )
68 endif()
69
70 if (L2E_FILE)
71   list(APPEND VOM_SOURCES
72     l2_emulation_cmds.cpp
73     l2_emulation.cpp
74   )
75 endif()
76
77 if(GBP_FILE)
78   list(APPEND VOM_SOURCES
79     gbp_contract_cmds.cpp
80     gbp_contract.cpp
81     gbp_bridge_domain_cmds.cpp
82     gbp_bridge_domain.cpp
83     gbp_endpoint_cmds.cpp
84     gbp_endpoint.cpp
85     gbp_endpoint_group_cmds.cpp
86     gbp_endpoint_group.cpp
87     gbp_ext_itf.cpp
88     gbp_ext_itf_cmds.cpp
89     gbp_recirc_cmds.cpp
90     gbp_recirc.cpp
91     gbp_route_domain_cmds.cpp
92     gbp_route_domain.cpp
93     gbp_rule.cpp
94     gbp_subnet_cmds.cpp
95     gbp_subnet.cpp
96     gbp_vxlan.cpp
97     gbp_vxlan_cmds.cpp
98   )
99 endif()
100
101 if (IGMP_FILE)
102   list(APPEND VOM_SOURCES
103     igmp_binding_cmds.cpp
104     igmp_binding.cpp
105     igmp_listen_cmds.cpp
106     igmp_listen.cpp
107   )
108 endif()
109
110 list(APPEND VOM_SOURCES
111   types.cpp
112   api_types.cpp
113   arp_proxy_binding_cmds.cpp
114   arp_proxy_binding.cpp
115   arp_proxy_config_cmds.cpp
116   arp_proxy_config.cpp
117   bond_group_binding_cmds.cpp
118   bond_group_binding.cpp
119   bond_interface_cmds.cpp
120   bond_interface.cpp
121   bond_member.cpp
122   bridge_domain_cmds.cpp
123   bridge_domain.cpp
124   bridge_domain_arp_entry.cpp
125   bridge_domain_arp_entry_cmds.cpp
126   bridge_domain_entry_cmds.cpp
127   bridge_domain_entry.cpp
128   client_db.cpp
129   cmd.cpp
130   connection.cpp
131   dhcp_client_cmds.cpp
132   dhcp_client.cpp
133   hw_cmds.cpp
134   hw.cpp
135   inspect.cpp
136   interface_cmds.cpp
137   interface.cpp
138   interface_factory.cpp
139   interface_ip6_nd_cmds.cpp
140   interface_span_cmds.cpp
141   interface_span.cpp
142   interface_types.cpp
143   ip_punt_redirect_cmds.cpp
144   ip_punt_redirect.cpp
145   ip_unnumbered_cmds.cpp
146   ip_unnumbered.cpp
147   l2_binding_cmds.cpp
148   l2_binding.cpp
149   l2_xconnect_cmds.cpp
150   l2_xconnect.cpp
151   l3_binding_cmds.cpp
152   l3_binding.cpp
153   lldp_binding_cmds.cpp
154   lldp_binding.cpp
155   lldp_global_cmds.cpp
156   lldp_global.cpp
157   logger.cpp
158   neighbour.cpp
159   neighbour_cmds.cpp
160   object_base.cpp
161   mroute_cmds.cpp
162   om.cpp
163   pipe.cpp
164   pipe_cmds.cpp
165   prefix.cpp
166   ra_config.cpp
167   ra_prefix.cpp
168   route.cpp
169   route_api_types.cpp
170   route_cmds.cpp
171   route_domain.cpp
172   route_domain_cmds.cpp
173   stat_client.cpp
174   stat_reader.cpp
175   sub_interface_cmds.cpp
176   sub_interface.cpp
177   tap_interface.cpp
178   tap_interface_cmds.cpp
179   vxlan_gbp_tunnel_cmds.cpp
180   vxlan_tunnel_cmds.cpp
181   vxlan_tunnel.cpp
182 )
183
184 if(ACL_FILE)
185   list(APPEND VOM_HEADERS
186     acl_binding.hpp
187     acl_ethertype.hpp
188     acl_l2_rule.hpp
189     acl_l3_rule.hpp
190     acl_list.hpp
191     acl_types.hpp
192   )
193 endif()
194
195 if(NAT_FILE)
196   list(APPEND VOM_HEADERS
197     nat_static.hpp
198     nat_binding.hpp
199   )
200 endif()
201
202 if(L2E_FILE)
203   list(APPEND VOM_HEADERS
204     l2_emulation.hpp
205   )
206 endif()
207
208 if(GBP_FILE)
209   list(APPEND VOM_HEADERS
210     gbp_contract.hpp
211     gbp_bridge_domain.hpp
212     gbp_endpoint.hpp
213     gbp_endpoint_group.hpp
214     gbp_ext_itf.hpp
215     gbp_recirc.hpp
216     gbp_route_domain.hpp
217     gbp_rule.hpp
218     gbp_subnet.hpp
219     gbp_vxlan.hpp
220   )
221 endif()
222
223 if(IGMP_FILE)
224   list(APPEND VOM_HEADERS
225     igmp_binding.hpp
226     igmp_listen.hpp
227   )
228 endif()
229
230 list(APPEND VOM_HEADERS
231   arp_proxy_binding.hpp
232   arp_proxy_config.hpp
233   bond_group_binding.hpp
234   bond_interface.hpp
235   bond_member.hpp
236   bridge_domain.hpp
237   bridge_domain_arp_entry.hpp
238   bridge_domain_entry.hpp
239   client_db.hpp
240   cmd.hpp
241   connection.hpp
242   dhcp_client.hpp
243   dump_cmd.hpp
244   enum_base.hpp
245   event_cmd.hpp
246   hw.hpp
247   inspect.hpp
248   interface.hpp
249   interface_cmds.hpp
250   interface_ip6_nd.hpp
251   interface_span.hpp
252   ip_punt_redirect.hpp
253   ip_unnumbered.hpp
254   l2_binding.hpp
255   l2_xconnect.hpp
256   l3_binding.hpp
257   lldp_binding.hpp
258   lldp_global.hpp
259   logger.hpp
260   neighbour.hpp
261   object_base.hpp
262   om.hpp
263   pipe.hpp
264   prefix.hpp
265   ra_config.hpp
266   ra_prefix.hpp
267   route.hpp
268   route_domain.hpp
269   rpc_cmd.hpp
270   singular_db.hpp
271   singular_db_funcs.hpp
272   stat_client.hpp
273   stat_reader.hpp
274   sub_interface.hpp
275   tap_interface.hpp
276   types.hpp
277   api_types.hpp
278   vxlan_tunnel.hpp
279 )
280
281 add_definitions(-Wall -Werror -std=gnu++11)
282
283 add_vpp_library(vom
284   SOURCES ${VOM_SOURCES}
285
286   INSTALL_HEADERS ${VOM_HEADERS}
287
288   LINK_LIBRARIES ${VPPAPICLIENT_LIB} ${VAPICLIENT_LIB} Threads::Threads
289     ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} m rt
290
291   COMPONENT libvom
292 )
293
294 if (Boost_FOUND)
295   if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
296     add_definitions(-stdlib=libstdc++)
297   endif()
298   add_executable(vom_stats_test test_stats.cpp)
299   if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
300     target_link_libraries(vom_stats_test vom stdc++)
301   else()
302     target_link_libraries(vom_stats_test vom)
303   endif()
304 endif()