nat: Final NAT44 EI/ED split patch
[vpp.git] / src / plugins / nat / 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 set(CMAKE_VERBOSE_MAKEFILE ON)
15
16 add_vpp_library(nat
17   SOURCES
18   lib/ipfix_logging.c
19   lib/nat_syslog.c
20   lib/alloc.c
21   lib/lib.c
22
23   INSTALL_HEADERS
24   lib/ipfix_logging.h
25   lib/nat_syslog.h
26   lib/alloc.h
27   lib/lib.h
28 )
29
30 add_vpp_plugin(nat
31   SOURCES
32   nat44-ed/nat44_ed.c
33   nat44-ed/nat44_ed_api.c
34   nat44-ed/nat44_ed_in2out.c
35   nat44-ed/nat44_ed_out2in.c
36   nat44-ed/nat44_ed_cli.c
37   nat44-ed/nat44_ed_format.c
38   nat44-ed/nat44_ed_affinity.c
39   nat44-ed/nat44_ed_handoff.c
40   nat44-ed/nat44_ed_classify.c
41
42   MULTIARCH_SOURCES
43   nat44-ed/nat44_ed_in2out.c
44   nat44-ed/nat44_ed_out2in.c
45   nat44-ed/nat44_ed_handoff.c
46   nat44-ed/nat44_ed_classify.c
47
48   API_FILES
49   nat44-ed/nat44_ed.api
50   lib/nat_types.api
51
52   LINK_LIBRARIES nat
53 )
54
55 add_vpp_plugin(nat44_ei
56   SOURCES
57   nat44-ei/nat44_ei.c
58   nat44-ei/nat44_ei_ha.c
59   nat44-ei/nat44_ei_cli.c
60   nat44-ei/nat44_ei_api.c
61   nat44-ei/nat44_ei_dpo.c
62   nat44-ei/nat44_ei_in2out.c
63   nat44-ei/nat44_ei_out2in.c
64   nat44-ei/nat44_ei_handoff.c
65   nat44-ei/nat44_ei_hairpinning.c
66
67   MULTIARCH_SOURCES
68   nat44-ei/nat44_ei_in2out.c
69   nat44-ei/nat44_ei_out2in.c
70   nat44-ei/nat44_ei_hairpinning.c
71
72   API_FILES
73   nat44-ei/nat44_ei.api
74   lib/nat_types.api
75
76   LINK_LIBRARIES nat
77 )
78
79 add_vpp_plugin(dslite
80   SOURCES
81   dslite/dslite_api.c
82   dslite/dslite_dpo.c
83   dslite/dslite.c
84   dslite/dslite_in2out.c
85   dslite/dslite_out2in.c
86   dslite/dslite_cli.c
87   dslite/dslite_ce_encap.c
88   dslite/dslite_ce_decap.c
89
90   MULTIARCH_SOURCES
91   dslite/dslite_ce_decap.c
92   dslite/dslite_ce_encap.c
93   dslite/dslite_in2out.c
94   dslite/dslite_out2in.c
95
96   API_FILES
97   dslite/dslite.api
98
99   LINK_LIBRARIES nat
100 )
101
102 add_vpp_plugin(nat66
103   SOURCES
104   nat66/nat66.c
105   nat66/nat66_cli.c
106   nat66/nat66_api.c
107   nat66/nat66_in2out.c
108   nat66/nat66_out2in.c
109
110   MULTIARCH_SOURCES
111   nat66/nat66_in2out.c
112   nat66/nat66_out2in.c
113
114   API_FILES
115   nat66/nat66.api
116   lib/nat_types.api
117
118   LINK_LIBRARIES nat
119 )
120
121 add_vpp_plugin(det44
122   SOURCES
123   det44/det44.c
124   det44/det44_cli.c
125   det44/det44_api.c
126   det44/det44_in2out.c
127   det44/det44_out2in.c
128
129   MULTIARCH_SOURCES
130   det44/det44_in2out.c
131   det44/det44_out2in.c
132
133   API_FILES
134   det44/det44.api
135   lib/nat_types.api
136
137   LINK_LIBRARIES nat
138 )
139
140 add_vpp_plugin(nat64
141   SOURCES
142   nat64/nat64.c
143   nat64/nat64_db.c
144   nat64/nat64_cli.c
145   nat64/nat64_api.c
146   nat64/nat64_in2out.c
147   nat64/nat64_out2in.c
148
149   MULTIARCH_SOURCES
150   nat64/nat64_in2out.c
151   nat64/nat64_out2in.c
152
153   API_FILES
154   nat64/nat64.api
155   lib/nat_types.api
156
157   LINK_LIBRARIES nat
158 )
159
160 add_vpp_plugin(pnat
161   SOURCES
162   pnat/pnat.c
163   pnat/pnat_node.c
164   pnat/pnat_cli.c
165   pnat/pnat_api.c
166
167   MULTIARCH_SOURCES
168   pnat/pnat_node.c
169
170   API_FILES
171   pnat/pnat.api
172 )
173
174 # Unit tests
175 add_vpp_executable(test_pnat
176   SOURCES
177   pnat/pnat_test.c
178   pnat/pnat_node.c
179   pnat/pnat.c
180   ../../vnet/ip/ip_checksum.c
181   LINK_LIBRARIES vppinfra vlib
182   NO_INSTALL
183 )
184
185 if("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.13" AND "${CMAKE_C_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang")
186   set(TARGET_NAME test_pnat)
187   set(COV_SOURCES ${CMAKE_SOURCE_DIR}/plugins/nat/pnat/pnat.c ${CMAKE_SOURCE_DIR}/plugins/nat/pnat/pnat_node.h ${CMAKE_SOURCE_DIR}/plugins/nat/pnat/pnat_node.c)
188
189   message("Building with llvm Code Coverage Tools ${TARGET_NAME}")
190   target_compile_options(${TARGET_NAME} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
191   target_link_options(${TARGET_NAME} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
192   target_compile_options(${TARGET_NAME} PRIVATE -fsanitize=address)
193   target_link_options(${TARGET_NAME} PRIVATE -fsanitize=address)
194
195   # llvm-cov
196   add_custom_target(${TARGET_NAME}-ccov-preprocessing
197     COMMAND LLVM_PROFILE_FILE=${TARGET_NAME}.profraw $<TARGET_FILE:${TARGET_NAME}>
198     COMMAND llvm-profdata merge -sparse ${TARGET_NAME}.profraw -o ${TARGET_NAME}.profdata
199     DEPENDS ${TARGET_NAME})
200
201   add_custom_target(${TARGET_NAME}-ccov-show
202     COMMAND llvm-cov show $<TARGET_FILE:${TARGET_NAME}> -instr-profile=${TARGET_NAME}.profdata -show-line-counts-or-regions ${COV_SOURCES}
203     DEPENDS ${TARGET_NAME}-ccov-preprocessing)
204
205   add_custom_target(${TARGET_NAME}-ccov-report
206     COMMAND llvm-cov report -show-functions $<TARGET_FILE:${TARGET_NAME}> -instr-profile=${TARGET_NAME}.profdata ${COV_SOURCES}
207     DEPENDS ${TARGET_NAME}-ccov-preprocessing)
208
209   add_custom_target(${TARGET_NAME}-ccov
210     COMMAND llvm-cov show $<TARGET_FILE:${TARGET_NAME}> -instr-profile=${TARGET_NAME}.profdata -show-line-counts-or-regions -output-dir=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET_NAME}-llvm-cov -format="html" ${COV_SOURCES}
211     DEPENDS ${TARGET_NAME}-ccov-preprocessing)
212
213   add_custom_command(TARGET ${TARGET_NAME}-ccov POST_BUILD
214     COMMAND ;
215     COMMENT "Open ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET_NAME}-llvm-cov/index.html in your browser to view the coverage report."
216 )
217 endif()