2ea84d9faa8d160d19baa2c1f8864c640bfa7bb9
[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_list.cpp
54     acl_l2_rule.cpp
55     acl_l3_list.cpp
56     acl_l3_rule.cpp
57     acl_list_cmds.cpp
58     acl_types.cpp
59   )
60 endif()
61
62 if(NAT_FILE)
63   list(APPEND VOM_SOURCES
64     nat_static.cpp
65     nat_static_cmds.cpp
66     nat_binding.cpp
67     nat_binding_cmds.cpp
68   )
69 endif()
70
71 if (L2E_FILE)
72   list(APPEND VOM_SOURCES
73     l2_emulation_cmds.cpp
74     l2_emulation.cpp
75   )
76 endif()
77
78 if(GBP_FILE)
79   list(APPEND VOM_SOURCES
80     gbp_contract_cmds.cpp
81     gbp_contract.cpp
82     gbp_bridge_domain_cmds.cpp
83     gbp_bridge_domain.cpp
84     gbp_endpoint_cmds.cpp
85     gbp_endpoint.cpp
86     gbp_endpoint_group_cmds.cpp
87     gbp_endpoint_group.cpp
88     gbp_ext_itf.cpp
89     gbp_ext_itf_cmds.cpp
90     gbp_recirc_cmds.cpp
91     gbp_recirc.cpp
92     gbp_route_domain_cmds.cpp
93     gbp_route_domain.cpp
94     gbp_rule.cpp
95     gbp_subnet_cmds.cpp
96     gbp_subnet.cpp
97     gbp_types.hpp
98     gbp_vxlan.cpp
99     gbp_vxlan_cmds.cpp
100   )
101 endif()
102
103 if (IGMP_FILE)
104   list(APPEND VOM_SOURCES
105     igmp_binding_cmds.cpp
106     igmp_binding.cpp
107     igmp_listen_cmds.cpp
108     igmp_listen.cpp
109   )
110 endif()
111
112 list(APPEND VOM_SOURCES
113   types.cpp
114   api_types.cpp
115   arp_proxy_binding_cmds.cpp
116   arp_proxy_binding.cpp
117   arp_proxy_config_cmds.cpp
118   arp_proxy_config.cpp
119   bond_group_binding_cmds.cpp
120   bond_group_binding.cpp
121   bond_interface_cmds.cpp
122   bond_interface.cpp
123   bond_member.cpp
124   bridge_domain_cmds.cpp
125   bridge_domain.cpp
126   bridge_domain_arp_entry.cpp
127   bridge_domain_arp_entry_cmds.cpp
128   bridge_domain_entry_cmds.cpp
129   bridge_domain_entry.cpp
130   client_db.cpp
131   cmd.cpp
132   connection.cpp
133   dhcp_client_cmds.cpp
134   dhcp_client.cpp
135   hw_cmds.cpp
136   hw.cpp
137   inspect.cpp
138   interface_cmds.cpp
139   interface.cpp
140   interface_factory.cpp
141   interface_ip6_nd_cmds.cpp
142   interface_span_cmds.cpp
143   interface_span.cpp
144   interface_types.cpp
145   ip_punt_redirect_cmds.cpp
146   ip_punt_redirect.cpp
147   ip_unnumbered_cmds.cpp
148   ip_unnumbered.cpp
149   l2_binding_cmds.cpp
150   l2_binding.cpp
151   l2_vtr.cpp
152   l2_vtr_cmds.cpp
153   l2_xconnect_cmds.cpp
154   l2_xconnect.cpp
155   l3_binding_cmds.cpp
156   l3_binding.cpp
157   lldp_binding_cmds.cpp
158   lldp_binding.cpp
159   lldp_global_cmds.cpp
160   lldp_global.cpp
161   logger.cpp
162   neighbour.cpp
163   neighbour_cmds.cpp
164   object_base.cpp
165   mroute_cmds.cpp
166   om.cpp
167   pipe.cpp
168   pipe_cmds.cpp
169   prefix.cpp
170   qos_map.cpp
171   qos_map_cmds.cpp
172   qos_mark.cpp
173   qos_mark_cmds.cpp
174   qos_record.cpp
175   qos_record_cmds.cpp
176   qos_types.cpp
177   qos_types_api.cpp
178   ra_config.cpp
179   ra_prefix.cpp
180   route.cpp
181   route_api_types.cpp
182   route_cmds.cpp
183   route_domain.cpp
184   route_domain_cmds.cpp
185   stat_client.cpp
186   stat_reader.cpp
187   sub_interface_cmds.cpp
188   sub_interface.cpp
189   tap_interface.cpp
190   tap_interface_cmds.cpp
191   vxlan_gbp_tunnel_cmds.cpp
192   vxlan_tunnel_cmds.cpp
193   vxlan_tunnel.cpp
194 )
195
196 if(ACL_FILE)
197   list(APPEND VOM_HEADERS
198     acl_binding.hpp
199     acl_ethertype.hpp
200     acl_l2_rule.hpp
201     acl_l3_rule.hpp
202     acl_l3_list.hpp
203     acl_l2_list.hpp
204     acl_types.hpp
205   )
206 endif()
207
208 if(NAT_FILE)
209   list(APPEND VOM_HEADERS
210     nat_static.hpp
211     nat_binding.hpp
212   )
213 endif()
214
215 if(L2E_FILE)
216   list(APPEND VOM_HEADERS
217     l2_emulation.hpp
218   )
219 endif()
220
221 if(GBP_FILE)
222   list(APPEND VOM_HEADERS
223     gbp_contract.hpp
224     gbp_bridge_domain.hpp
225     gbp_endpoint.hpp
226     gbp_endpoint_group.hpp
227     gbp_ext_itf.hpp
228     gbp_recirc.hpp
229     gbp_route_domain.hpp
230     gbp_rule.hpp
231     gbp_subnet.hpp
232     gbp_types.hpp
233     gbp_vxlan.hpp
234   )
235 endif()
236
237 if(IGMP_FILE)
238   list(APPEND VOM_HEADERS
239     igmp_binding.hpp
240     igmp_listen.hpp
241   )
242 endif()
243
244 list(APPEND VOM_HEADERS
245   arp_proxy_binding.hpp
246   arp_proxy_config.hpp
247   bond_group_binding.hpp
248   bond_interface.hpp
249   bond_member.hpp
250   bridge_domain.hpp
251   bridge_domain_arp_entry.hpp
252   bridge_domain_entry.hpp
253   client_db.hpp
254   cmd.hpp
255   connection.hpp
256   dhcp_client.hpp
257   dump_cmd.hpp
258   enum_base.hpp
259   event_cmd.hpp
260   hw.hpp
261   inspect.hpp
262   interface.hpp
263   interface_cmds.hpp
264   interface_ip6_nd.hpp
265   interface_span.hpp
266   ip_punt_redirect.hpp
267   ip_unnumbered.hpp
268   l2_binding.hpp
269   l2_vtr.hpp
270   l2_xconnect.hpp
271   l3_binding.hpp
272   lldp_binding.hpp
273   lldp_global.hpp
274   logger.hpp
275   neighbour.hpp
276   object_base.hpp
277   om.hpp
278   pipe.hpp
279   prefix.hpp
280   qos_map.hpp
281   qos_mark.hpp
282   qos_record.hpp
283   qos_types.hpp
284   ra_config.hpp
285   ra_prefix.hpp
286   route.hpp
287   route_domain.hpp
288   rpc_cmd.hpp
289   singular_db.hpp
290   singular_db_funcs.hpp
291   stat_client.hpp
292   stat_reader.hpp
293   sub_interface.hpp
294   tap_interface.hpp
295   types.hpp
296   api_types.hpp
297   vxlan_tunnel.hpp
298 )
299
300 add_definitions(-Wall -Werror -std=gnu++11)
301 add_library(vom SHARED ${VOM_SOURCES})
302 if (VOM_LIB_VERSION)
303   set_target_properties(vom PROPERTIES SOVERSION ${VOM_LIB_VERSION})
304 endif()
305 target_link_libraries(vom ${VPPAPICLIENT_LIB} ${VAPICLIENT_LIB} Threads::Threads
306     ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} m rt)
307 install(TARGETS vom DESTINATION lib COMPONENT vom)
308 install(FILES ${VOM_HEADERS} DESTINATION include/vom COMPONENT vom)
309
310 if (Boost_FOUND)
311   if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
312     add_definitions(-stdlib=libstdc++)
313   endif()
314   add_executable(vom_stats_test test_stats.cpp)
315   if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
316     target_link_libraries(vom_stats_test vom stdc++)
317   else()
318     target_link_libraries(vom_stats_test vom)
319   endif()
320 endif()