]> The Tcpdump Group git mirrors - tcpdump/blob - CMakeLists.txt
Add install and uninstall support for CMake.
[tcpdump] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.6)
2
3 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
4
5 project(tcpdump)
6 set(LIBRARY_NAME netdissect)
7
8 ###################################################################
9 # Parameters
10 ###################################################################
11
12 option(WITH_SMI "Build with libsmi, if available" ON)
13 option(ENABLE_SMB "Build with the SMB dissector" ON)
14
15 #
16 # By default, build universal with the appropriate set of architectures
17 # for the OS on which we're doing the build.
18 #
19 if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
20 #
21 # Get the major version of Darwin.
22 #
23 string(REGEX MATCH "^([0-9]+)" SYSTEM_VERSION_MAJOR "${CMAKE_SYSTEM_VERSION}")
24
25 if(SYSTEM_VERSION_MAJOR EQUAL 9)
26 #
27 # Leopard. Build for x86 and 32-bit PowerPC, with
28 # x86 first. (That's what Apple does.)
29 #
30 set(CMAKE_OSX_ARCHITECTURES "i386;ppc")
31 elseif(SYSTEM_VERSION_MAJOR EQUAL 10)
32 #
33 # Snow Leopard. Build for x86-64 and x86, with
34 # x86-64 first. (That's what Apple does.)
35 #
36 set(CMAKE_OSX_ARCHITECTURES "x86_64;i386")
37 endif()
38 endif()
39
40 ###################################################################
41 # Versioning
42 ###################################################################
43
44 # Get, parse, format and set tcpdump's version string from
45 # [tcpdump_root]/VERSION for later use.
46
47 # Get MAJOR, MINOR, PATCH & SUFFIX
48 file(STRINGS ${tcpdump_SOURCE_DIR}/VERSION
49 PACKAGE_VERSION
50 LIMIT_COUNT 1 # Read only the first line
51 )
52
53 ######################################
54 # Project settings
55 ######################################
56
57 add_definitions(-DHAVE_CONFIG_H)
58
59 include_directories(
60 ${CMAKE_CURRENT_BINARY_DIR}
61 ${tcpdump_SOURCE_DIR}
62 )
63
64 if(MSVC)
65 add_definitions(-D__STDC__)
66 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
67 endif(MSVC)
68
69 if(MSVC)
70 if (USE_STATIC_RT)
71 MESSAGE(STATUS "Use STATIC runtime")
72 set(NAME_RT MT)
73 set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT")
74 set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
75 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
76 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
77
78 set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
79 set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
80 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
81 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
82 else (USE_STATIC_RT)
83 MESSAGE(STATUS "Use DYNAMIC runtime")
84 set(NAME_RT MD)
85 set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MD")
86 set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD")
87 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
88 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
89
90 set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MD")
91 set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MD")
92 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MD")
93 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MDd")
94 endif (USE_STATIC_RT)
95 endif(MSVC)
96
97 ###################################################################
98 # Detect available platform features
99 ###################################################################
100
101 include(CMakePushCheckState)
102 include(CheckIncludeFile)
103 include(CheckIncludeFiles)
104 include(CheckFunctionExists)
105 include(CheckSymbolExists)
106 include(CheckStructHasMember)
107 include(CheckTypeSize)
108
109 #
110 # Header files.
111 #
112 check_include_file(fcntl.h HAVE_FCNTL_H)
113 check_include_file(rpc/rpc.h HAVE_RPC_RPC_H)
114 check_include_file(rpc/rpcent.h HAVE_RPC_RPCENT_H)
115 check_include_file(netdnet/dnetdb.h HAVE_NETDNET_DNETDB_H)
116 check_include_files(net/pfvar.h HAVE_NET_PFVAR_H)
117 if(HAVE_NET_PFVAR_H)
118 check_include_files(net/if_pflog.h HAVE_NET_IF_PFLOG_H)
119 if(HAVE_NET_IF_PFLOG_H)
120 set(LOCALSRC print-pflog.c ${LOCALSRC})
121 endif(HAVE_NET_IF_PFLOG_H)
122 endif(HAVE_NET_PFVAR_H)
123
124 #
125 # You are in a twisty little maze of UN*Xes, all different.
126 # Some might not have ether_ntohost().
127 # Some might have it and declare it in <net/ethernet.h>.
128 # Some might have it and declare it in <netinet/ether.h>
129 # Some might have it and declare it in <sys/ethernet.h>.
130 # Some might have it and declare it in <arpa/inet.h>.
131 # Some might have it and declare it in <netinet/if_ether.h>.
132 # Some might have it and not declare it in any header file.
133 #
134 # Before you is a C compiler.
135 #
136 check_function_exists(ether_ntohost HAVE_ETHER_NTOHOST)
137 if(HAVE_ETHER_NTOHOST)
138 #
139 # OK, we have ether_ntohost(). We don't check whether it's buggy,
140 # as we assume any system that has CMake is likely to be new enough
141 # that, if it has ether_ntohost(), whatever bug is checked for in
142 # autotools is fixed; we just decide to use it.
143 #
144 set(USE_ETHER_NTOHOST TRUE)
145
146 #
147 # Is it declared in <net/ethernet.h>?
148 #
149 # This test fails if we don't have <net/ethernet.h> or if we do
150 # but it doesn't declare ether_ntohost().
151 #
152 check_symbol_exists(ether_ntohost net/ethernet.h NET_ETHERNET_H_DECLARES_ETHER_NTOHOST)
153 if(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST)
154 #
155 # Yes - we have it declared.
156 #
157 set(HAVE_DECL_ETHER_NTOHOST TRUE)
158 endif()
159 #
160 # Did that succeed?
161 #
162 if(NOT HAVE_DECL_ETHER_NTOHOST)
163 #
164 # No - how about <netinet/ether.h>, as on Linux?
165 #
166 # This test fails if we don't have <netinet/ether.h>
167 # or if we do but it doesn't declare ether_ntohost().
168 #
169 check_symbol_exists(ether_ntohost netinet/ether.h NETINET_ETHER_H_DECLARES_ETHER_NTOHOST)
170 if(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST)
171 #
172 # Yes - we have it declared.
173 #
174 set(HAVE_DECL_ETHER_NTOHOST TRUE)
175 endif()
176 endif()
177 #
178 # Did that succeed?
179 #
180 if(NOT HAVE_DECL_ETHER_NTOHOST)
181 #
182 # No - how about <sys/ethernet.h>, as on Solaris 10 and later?
183 #
184 # This test fails if we don't have <sys/ethernet.h>
185 # or if we do but it doesn't declare ether_ntohost().
186 #
187 check_symbol_exists(ether_ntohost sys/ethernet.h SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST)
188 if(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST)
189 #
190 # Yes - we have it declared.
191 #
192 set(HAVE_DECL_ETHER_NTOHOST TRUE)
193 endif()
194 endif()
195 #
196 # Did that succeed?
197 #
198 if(NOT HAVE_DECL_ETHER_NTOHOST)
199 #
200 # No, how about <arpa/inet.h>, as on AIX?
201 #
202 # This test fails if we don't have <arpa/inet.h>
203 # or if we do but it doesn't declare ether_ntohost().
204 #
205 check_symbol_exists(ether_ntohost arpa/inet.h ARPA_INET_H_DECLARES_ETHER_NTOHOST)
206 if(ARPA_INET_H_DECLARES_ETHER_NTOHOST)
207 #
208 # Yes - we have it declared.
209 #
210 set(HAVE_DECL_ETHER_NTOHOST TRUE)
211 endif()
212 endif()
213 #
214 # Did that succeed?
215 #
216 if(NOT HAVE_DECL_ETHER_NTOHOST)
217 #
218 # No, how about <netinet/if_ether.h>?
219 # On some platforms, it requires <net/if.h> and
220 # <netinet/in.h>, and we always include it with
221 # both of them, so test it with both of them.
222 #
223 # This test fails if we don't have <netinet/if_ether.h>
224 # and the headers we include before it, or if we do but
225 # <netinet/if_ether.h> doesn't declare ether_ntohost().
226 #
227 check_symbol_exists(ether_ntohost "sys/types.h;sys/socket.h;net/if.h;netinet/in.h;netinet/if_ether.h" NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST)
228 if(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST)
229 #
230 # Yes - we have it declared.
231 #
232 set(HAVE_DECL_ETHER_NTOHOST TRUE)
233 endif()
234 endif()
235 #
236 # After all that, is ether_ntohost() declared?
237 #
238 if(NOT HAVE_DECL_ETHER_NTOHOST)
239 #
240 # No, we'll have to declare it ourselves.
241 # Do we have "struct ether_addr" if we include<netinet/if_ether.h>?
242 #
243 check_struct_has_member("struct ether_addr" octet "sys/types.h;sys/socket.h;net/if.h;netinet/in.h;netinet/if_ether.h" HAVE_STRUCT_ETHER_ADDR)
244 endif()
245 endif()
246
247 #
248 # As the autoconf manual says, AC_HEADER_TIME is obsolete, as all UN*Xes
249 # let you include both time.h and sys/time.h, so just say we can.
250 #
251 check_include_file(bitypes.h HAVE_SYS_BITYPES_H)
252 check_include_file(limits.h HAVE_LIMITS_H)
253
254 #
255 # Check whether we have pcap/pcap-inttypes.h.
256 # If we do, we use that to get the C99 types defined.
257 #
258 check_include_file(pcap/pcap-inttypes.h HAVE_PCAP_PCAP_INTTYPES_H)
259
260 #
261 # Check for some headers introduced in later versions of libpcap
262 # and used by some printers.
263 #
264 # Those headers might use the {u_}intN_t types, so we must include
265 # netdissect-stdinc.h first.
266 #
267 cmake_push_check_state()
268 set(CMAKE_EXTRA_INCLUDE_FILES netdissect-stdinc.h)
269 check_include_file(pcap/bluetooth.h HAVE_PCAP_BLUETOOTH_H)
270 check_include_file(pcap/nflog.h HAVE_PCAP_NFLOG_H)
271 cmake_pop_check_state()
272
273 #
274 # Functions.
275 #
276 check_function_exists(strlcat HAVE_STRLCAT)
277 check_function_exists(strlcpy HAVE_STRLCPY)
278 check_function_exists(strdup HAVE_STRDUP)
279 check_function_exists(strsep HAVE_STRSEP)
280 check_function_exists(getservent HAVE_GETSERVENT)
281 check_function_exists(getopt_long HAVE_GETOPT_LONG)
282 check_function_exists(vsnprintf HAVE_VSNPRINTF)
283 check_function_exists(snprintf HAVE_SNPRINTF)
284 check_function_exists(fork HAVE_FORK)
285 check_function_exists(vfork HAVE_VFORK)
286 check_function_exists(strftime HAVE_STRFTIME)
287 check_function_exists(setlinebuf HAVE_SETLINEBUF)
288
289 check_function_exists(getrpcbynumber HAVE_GETRPCBYNUMBER)
290 if(NOT HAVE_GETRPCBYNUMBER)
291 cmake_push_check_state()
292 set(CMAKE_REQUIRED_LIBRARIES nsl)
293 check_function_exists(getrpcbynumber HAVE_GETRPCBYNUMBER)
294 cmake_pop_check_state()
295 endif(NOT HAVE_GETRPCBYNUMBER)
296
297 #
298 # Data types.
299 #
300 # XXX - there's no check_struct() macro that's like check_struct_has_member()
301 # except that it only checks for the existence of the structure type,
302 # so we use check_struct_has_member() and look for ss_family.
303 #
304 check_struct_has_member("struct sockaddr_storage" ss_family sys/socket.h HAVE_SOCKADDR_STORAGE)
305 set(CMAKE_EXTRA_INCLUDE_FILES unistd.h sys/socket.h)
306 check_type_size("socklen_t" SOCKLEN_T)
307 set(CMAKE_EXTRA_INCLUDE_FILES unistd.h)
308
309 #
310 # Check for IPv6 support.
311 # We just check for AF_INET6 and struct in6_addr.
312 #
313 cmake_push_check_state()
314 if(WIN32)
315 set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h ws2tcpip.h)
316 check_symbol_exists(AF_INET6 "sys/types.h;ws2tcpip.h" HAVE_AF_INET6)
317 else(WIN32)
318 set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h sys/socket.h netinet/in.h)
319 check_symbol_exists(AF_INET6 "sys/types.h;sys/socket.h;netinet/in.h" HAVE_AF_INET6)
320 endif(WIN32)
321 check_type_size("struct in6_addr" HAVE_STRUCT_IN6_ADDR)
322 cmake_pop_check_state()
323 if(HAVE_AF_INET6 AND HAVE_STRUCT_IN6_ADDR)
324 set(HAVE_OS_IPV6_SUPPORT TRUE)
325 endif(HAVE_AF_INET6 AND HAVE_STRUCT_IN6_ADDR)
326
327 #
328 # Structure fields.
329 #
330 check_struct_has_member("struct sockaddr" sa_len sys/socket.h HAVE_SOCKADDR_SA_LEN)
331
332 ######################################
333 # External dependencies
334 ######################################
335
336 #
337 # libsmi.
338 #
339 if(WITH_SMI)
340 find_package(SMI)
341 if(SMI_FOUND)
342 set(USE_LIBSMI ON)
343 endif(SMI_FOUND)
344 endif(WITH_SMI)
345
346 #
347 # libpcap/WinPcap.
348 # First find it, then check for functions in it.
349 #
350 find_package(PCAP REQUIRED)
351
352 #
353 # Check for various functions in libpcap/WinPcap.
354 #
355 include_directories(${PCAP_INCLUDE_DIR})
356 cmake_push_check_state()
357 set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY})
358
359 #
360 # Check for "pcap_list_datalinks()" and use a substitute version if
361 # it's not present. If it is present, check for "pcap_free_datalinks()";
362 # if it's not present, we don't replace it for now. (We could do so
363 # on UN*X, but not on Windows, where hilarity ensues if a program
364 # built with one version of the MSVC support library tries to free
365 # something allocated by a library built with another version of
366 # the MSVC support library.)
367 #
368 check_function_exists(pcap_list_datalinks HAVE_PCAP_LIST_DATALINKS)
369 if(HAVE_PCAP_LIST_DATALINKS)
370 check_function_exists(pcap_free_datalinks HAVE_PCAP_FREE_DATALINKS)
371 endif(HAVE_PCAP_LIST_DATALINKS)
372
373 #
374 # Check for "pcap_datalink_name_to_val()", and use a substitute
375 # version if it's not present. If it is present, check for
376 # "pcap_datalink_val_to_description()", and if we don't have it,
377 # use a substitute version.
378 #
379 check_function_exists(pcap_datalink_name_to_val HAVE_PCAP_DATALINK_NAME_TO_VAL)
380 if(HAVE_PCAP_DATALINK_NAME_TO_VAL)
381 check_function_exists(pcap_datalink_val_to_description HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION)
382 endif(HAVE_PCAP_DATALINK_NAME_TO_VAL)
383
384 #
385 # Check for "pcap_set_datalink()"; you can't substitute for it if
386 # it's absent (it has hooks into libpcap), so just define the
387 # HAVE_ value if it's there.
388 #
389 check_function_exists(pcap_set_datalink HAVE_PCAP_SET_DATALINK)
390
391 #
392 # Check for "pcap_breakloop()"; you can't substitute for it if
393 # it's absent (it has hooks into the live capture routines),
394 # so just define the HAVE_ value if it's there.
395 #
396 check_function_exists(pcap_breakloop HAVE_PCAP_BREAKLOOP)
397
398 #
399 # Check for "pcap_dump_ftell()"; we use a substitute version
400 # if it's not present.
401 #
402 check_function_exists(pcap_dump_ftell HAVE_PCAP_DUMP_FTELL)
403
404 #
405 # Do we have the new open API? Check for pcap_create, and assume that,
406 # if we do, we also have pcap_activate() and the other new routines
407 # introduced in libpcap 1.0.0.
408 #
409 check_function_exists(pcap_create HAVE_PCAP_CREATE)
410 if(HAVE_PCAP_CREATE)
411 #
412 # OK, do we have pcap_set_tstamp_type? If so, assume we have
413 # pcap_list_tstamp_types and pcap_free_tstamp_types as well.
414 #
415 check_function_exists(pcap_set_tstamp_type HAVE_PCAP_SET_TSTAMP_TYPE)
416
417 #
418 # And do we have pcap_set_tstamp_precision? If so, we assume
419 # we also have pcap_open_offline_with_tstamp_precision.
420 #
421 check_function_exists(pcap_set_tstamp_precision HAVE_PCAP_SET_TSTAMP_PRECISION)
422 endif(HAVE_PCAP_CREATE)
423
424 #
425 # Check for a miscellaneous collection of functions which we use
426 # if we have them.
427 #
428 check_function_exists(pcap_findalldevs HAVE_PCAP_FINDALLDEVS)
429 if(HAVE_PCAP_FINDALLDEVS)
430 #
431 # Check for libpcap having pcap_findalldevs() but the pcap.h header
432 # not having pcap_if_t; some versions of Mac OS X shipped with pcap.h
433 # from 0.6 and libpcap 0.8, so that libpcap had pcap_findalldevs but
434 # pcap.h didn't have pcap_if_t.
435 #
436 cmake_push_check_state()
437 set(CMAKE_EXTRA_INCLUDE_FILES pcap.h)
438 check_type_size(pcap_if_t PCAP_IF_T)
439 cmake_pop_check_state()
440 endif(HAVE_PCAP_FINDALLDEVS)
441 check_function_exists(pcap_dump_flush HAVE_PCAP_DUMP_FLUSH)
442 check_function_exists(pcap_lib_version HAVE_PCAP_LIB_VERSION)
443 if(NOT HAVE_PCAP_LIB_VERSION)
444 # Check for the pcap_version string variable and set HAVE_PCAP_VERSION
445 endif(NOT HAVE_PCAP_LIB_VERSION)
446 check_function_exists(pcap_setdirection HAVE_PCAP_SETDIRECTION)
447 check_function_exists(pcap_set_immediate_mode HAVE_PCAP_SET_IMMEDIATE_MODE)
448 check_function_exists(pcap_dump_ftell64 HAVE_PCAP_DUMP_FTELL64)
449 check_function_exists(pcap_open HAVE_PCAP_OPEN)
450 check_function_exists(pcap_findalldevs_ex HAVE_PCAP_FINDALLDEVS_EX)
451
452 #
453 # Check for special debugging functions
454 #
455 check_function_exists(pcap_set_parser_debug HAVE_PCAP_SET_PARSER_DEBUG)
456 if(NOT HAVE_PCAP_SET_PARSER_DEBUG)
457 # Check whether libpcap defines pcap_debug or yydebug
458 endif(NOT HAVE_PCAP_SET_PARSER_DEBUG)
459
460 check_function_exists(pcap_set_optimizer_debug HAVE_PCAP_SET_OPTIMIZER_DEBUG)
461 check_function_exists(bpf_dump HAVE_BPF_DUMP)
462
463 cmake_pop_check_state()
464
465 ######################################
466 # Input files
467 ######################################
468
469 set(NETDISSECT_SOURCE_LIST_C
470 addrtoname.c
471 addrtostr.c
472 af.c
473 ascii_strcasecmp.c
474 checksum.c
475 cpack.c
476 gmpls.c
477 gmt2local.c
478 in_cksum.c
479 ipproto.c
480 l2vpn.c
481 machdep.c
482 nlpid.c
483 oui.c
484 parsenfsfh.c
485 print.c
486 print-802_11.c
487 print-802_15_4.c
488 print-ah.c
489 print-ahcp.c
490 print-aodv.c
491 print-aoe.c
492 print-ap1394.c
493 print-arcnet.c
494 print-arp.c
495 print-ascii.c
496 print-atalk.c
497 print-atm.c
498 print-babel.c
499 print-beep.c
500 print-bfd.c
501 print-bgp.c
502 print-bootp.c
503 print-bt.c
504 print-calm-fast.c
505 print-carp.c
506 print-cdp.c
507 print-cfm.c
508 print-chdlc.c
509 print-cip.c
510 print-cnfp.c
511 print-dccp.c
512 print-decnet.c
513 print-dhcp6.c
514 print-domain.c
515 print-dtp.c
516 print-dvmrp.c
517 print-eap.c
518 print-egp.c
519 print-eigrp.c
520 print-enc.c
521 print-esp.c
522 print-ether.c
523 print-fddi.c
524 print-forces.c
525 print-fr.c
526 print-frag6.c
527 print-ftp.c
528 print-geneve.c
529 print-geonet.c
530 print-gre.c
531 print-hncp.c
532 print-hsrp.c
533 print-http.c
534 print-icmp.c
535 print-icmp6.c
536 print-igmp.c
537 print-igrp.c
538 print-ip.c
539 print-ip6.c
540 print-ip6opts.c
541 print-ipcomp.c
542 print-ipfc.c
543 print-ipnet.c
544 print-ipx.c
545 print-isakmp.c
546 print-isoclns.c
547 print-juniper.c
548 print-krb.c
549 print-l2tp.c
550 print-lane.c
551 print-ldp.c
552 print-lisp.c
553 print-llc.c
554 print-lldp.c
555 print-lmp.c
556 print-loopback.c
557 print-lspping.c
558 print-lwapp.c
559 print-lwres.c
560 print-m3ua.c
561 print-medsa.c
562 print-mobile.c
563 print-mobility.c
564 print-mpcp.c
565 print-mpls.c
566 print-mptcp.c
567 print-msdp.c
568 print-msnlb.c
569 print-nflog.c
570 print-nfs.c
571 print-nsh.c
572 print-ntp.c
573 print-null.c
574 print-olsr.c
575 print-openflow-1.0.c
576 print-openflow.c
577 print-ospf.c
578 print-ospf6.c
579 print-otv.c
580 print-pgm.c
581 print-pim.c
582 print-pktap.c
583 print-ppi.c
584 print-ppp.c
585 print-pppoe.c
586 print-pptp.c
587 print-radius.c
588 print-raw.c
589 print-resp.c
590 print-rip.c
591 print-ripng.c
592 print-rpki-rtr.c
593 print-rrcp.c
594 print-rsvp.c
595 print-rt6.c
596 print-rtsp.c
597 print-rx.c
598 print-sctp.c
599 print-sflow.c
600 print-sip.c
601 print-sl.c
602 print-sll.c
603 print-slow.c
604 print-smtp.c
605 print-snmp.c
606 print-stp.c
607 print-sunatm.c
608 print-sunrpc.c
609 print-symantec.c
610 print-syslog.c
611 print-tcp.c
612 print-telnet.c
613 print-tftp.c
614 print-timed.c
615 print-tipc.c
616 print-token.c
617 print-udld.c
618 print-udp.c
619 print-usb.c
620 print-vjc.c
621 print-vqp.c
622 print-vrrp.c
623 print-vtp.c
624 print-vxlan.c
625 print-vxlan-gpe.c
626 print-wb.c
627 print-zephyr.c
628 print-zeromq.c
629 netdissect.c
630 signature.c
631 strtoaddr.c
632 util-print.c
633 )
634
635 if(ENABLE_SMB)
636 #
637 # We allow the SMB dissector to be omitted.
638 #
639 set(NETDISSECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C}
640 print-smb.c
641 smbutil.c)
642 endif(ENABLE_SMB)
643
644 #
645 # Replace missing functions
646 #
647 foreach(FUNC strlcat strlcpy strdup strsep getservent getopt_long)
648 string(TOUPPER ${FUNC} FUNC_UPPERCASE)
649 set(HAVE_FUNC_UPPERCASE HAVE_${FUNC_UPPERCASE})
650 if(NOT ${HAVE_FUNC_UPPERCASE})
651 set(NETDISSECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C} missing/${FUNC}.c)
652 endif()
653 endforeach()
654 if(NOT HAVE_VSNPRINTF OR NOT HAVE_SNPRINTF)
655 set(NETDISSECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C} missing/snprintf.c)
656 endif(NOT HAVE_VSNPRINTF OR NOT HAVE_SNPRINTF)
657
658 add_library(netdissect STATIC
659 ${NETDISSECT_SOURCE_LIST_C}
660 )
661
662 set(TCPDUMP_SOURCE_LIST_C tcpdump.c)
663
664 if(NOT HAVE_BPF_DUMP)
665 set(TCPDUMP_SOURCE_LIST_C ${TCPDUMP_SOURCE_LIST_C} bpf_dump.c)
666 endif(NOT HAVE_BPF_DUMP)
667 if(NOT HAVE_PCAP_DUMP_FTELL)
668 set(TCPDUMP_SOURCE_LIST_C ${TCPDUMP_SOURCE_LIST_C} missing/pcap_dump_ftell.c)
669 endif(NOT HAVE_PCAP_DUMP_FTELL)
670
671 if(NOT HAVE_PCAP_LIST_DATALINKS)
672 set(TCPDUMP_SOURCE_LIST_C ${TCPDUMP_SOURCE_LIST_C} missing/datalinks.c)
673 endif(NOT HAVE_PCAP_LIST_DATALINKS)
674
675 if((NOT HAVE_PCAP_DATALINK_NAME_TO_VAL) OR (NOT HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION))
676 set(TCPDUMP_SOURCE_LIST_C ${TCPDUMP_SOURCE_LIST_C} missing/dlnames.c)
677 endif((NOT HAVE_PCAP_DATALINK_NAME_TO_VAL) OR (NOT HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION))
678
679 set(PROJECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C} ${TCPDUMP_SOURCE_LIST_C})
680
681 file(GLOB PROJECT_SOURCE_LIST_H
682 *.h
683 )
684
685 source_group("Source Files" FILES ${PROJECT_SOURCE_LIST_C})
686 source_group("Header Files" FILES ${PROJECT_SOURCE_LIST_H})
687
688 ######################################
689 # Register targets
690 ######################################
691
692 add_executable(tcpdump ${TCPDUMP_SOURCE_LIST_C})
693 target_link_libraries(tcpdump netdissect ${PCAP_LIBRARY} ${SMI_LIBRARY})
694
695 ######################################
696 # Write out the config.h file
697 ######################################
698
699 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
700
701 ######################################
702 # Install tcpdump and man pages
703 ######################################
704
705 #
706 # "Define GNU standard installation directories", which actually
707 # are also defined, to some degree, by autotools, and at least
708 # some of which are general UN*X conventions.
709 #
710 include(GNUInstallDirs)
711
712 set(MAN1 tcpdump.1)
713
714 if(WIN32)
715 # XXX TODO where to install on Windows?
716 else(WIN32)
717 install(TARGETS tcpdump DESTINATION sbin)
718 endif(WIN32)
719
720 # On UN*X, and on Windows when not using MSVC, process man pages and
721 # arrange that they be installed.
722 if(NOT MSVC)
723 #
724 # Man pages.
725 #
726 install(FILES ${MAN1} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
727 endif(NOT MSVC)
728
729 # uninstall target
730 configure_file(
731 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
732 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
733 IMMEDIATE @ONLY)
734
735 add_custom_target(uninstall
736 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)