Add tap-hosts.c.
[obnox/wireshark/wip.git] / CMakeLists.txt
1 # CMakeLists.txt
2 #
3 # $Id$
4 #
5 # Wireshark - Network traffic analyzer
6 # By Gerald Combs <gerald@wireshark.org>
7 # Copyright 1998 Gerald Combs
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License
11 # as published by the Free Software Foundation; either version 2
12 # of the License, or (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 #
23
24 project(Wireshark C)
25
26 cmake_minimum_required(VERSION 2.6)
27 set(CMAKE_BACKWARDS_COMPATIBILITY 2.6)
28
29 # Needs to be set after cmake_minimum_required or cmake_policy(VERSION)
30 #if(COMMAND cmake_policy)
31 #       cmake_policy(SET CMP0015 NEW)
32 #endif(COMMAND cmake_policy)
33
34 # set(PROJECT_VERSION "1.3.4-rc5")
35 # set(PROJECT_VERSION "1.3.4rc5")
36 # set(PROJECT_VERSION "1.3.4")
37 # If not set, copy over Wireshark version from configure.in AC_INIT
38 if(NOT PROJECT_VERSION)
39         file(STRINGS
40                 ${CMAKE_SOURCE_DIR}/configure.in
41                 VERSIONLINE
42                 REGEX "\\(wireshark, .*\\)"
43         )
44         string(REGEX REPLACE ".*\\(wireshark, (.*)\\).*"
45                 "\\1"
46                 PROJECT_VERSION
47                 ${VERSIONLINE}
48         )
49 endif()
50 string(REGEX REPLACE "([0-9]+)\\..*"
51         "\\1"
52         PROJECT_MAJOR_VERSION
53         ${PROJECT_VERSION}
54 )
55 string(REGEX REPLACE ".*\\.([0-9]+)\\..*"
56         "\\1"
57         PROJECT_MINOR_VERSION
58         ${PROJECT_VERSION}
59 )
60 string(REGEX REPLACE ".*\\..*\\.([0-9]+).*"
61         "\\1"
62         PROJECT_PATCH_VERSION
63         ${PROJECT_VERSION}
64 )
65 string(REGEX REPLACE ".*\\..*\\.[0-9]+(.*)"
66         "\\1"
67         PROJECT_VERSION_EXTENSION
68         ${PROJECT_VERSION}
69 )
70 message(STATUS "V: ${PROJECT_VERSION}, MaV: ${PROJECT_MAJOR_VERSION}, MiV: ${PROJECT_MINOR_VERSION}, PL: ${PROJECT_PATCH_VERSION}, EV: ${PROJECT_VERSION_EXTENSION}.")
71
72 #Where to find local cmake scripts
73 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
74 INCLUDE(UseLemon)
75 INCLUDE(UseMakeDissectorReg)
76 INCLUDE(UseMakeTapReg)
77
78 # Under linux the release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG
79
80 # Enable with: "make VERBOSE=1"
81 set(CMAKE_VERBOSE_MAKEFILE OFF)
82
83 #Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ...
84 include(CMakeInstallDirs)
85
86 include_directories(
87         ${CMAKE_BINARY_DIR}
88         ${CMAKE_SOURCE_DIR}
89         ${CMAKE_SOURCE_DIR}/epan
90         ${CMAKE_SOURCE_DIR}/tools/lemon
91         ${CMAKE_SOURCE_DIR}/wiretap
92 )
93
94 #Where to put libraries
95 if(NOT LIBRARY_OUTPUT_PATH)
96         set(LIBRARY_OUTPUT_PATH ${Wireshark_BINARY_DIR}/lib CACHE INTERNAL
97                    "Single output directory for building all libraries.")
98 endif()
99
100
101 include(CMakeOptions.txt)
102
103
104 set(WIRESHARK_C_FLAGS
105         -O2
106         -Wall
107         -W
108         -Wextra
109         -Wdeclaration-after-statement
110         -Wendif-labels
111         -Wpointer-arith
112         -Wno-pointer-sign
113         -Warray-bounds
114         -Wcast-align
115         -Wformat-security
116         -Wold-style-definition
117         -fexcess-precision=fast
118 )
119
120 set(WIRESHARK_EXTRA_C_FLAGS
121         -pedantic
122         -Woverflow
123         -Wlogical-op
124         -Wno-overlength-strings
125         -fstrict-overflow -Wstrict-overflow=4
126         -Wunreachable-code
127         -Wunsafe-loop-optimizations
128         -Wno-long-long
129         -Wbad-function-cast
130         -Wcast-qual
131         -Waddress
132         -Warray-bounds
133         -Wattributes
134         -Wdiv-by-zero
135         -Wformat-security
136         -Wignored-qualifiers
137         -Wpragmas
138         -Wredundant-decls
139         -Wvla
140         -Wc++-compat
141         -Wjump-misses-init
142         # packet-ncp2222.inc prevents this from going into all warnings
143         -Wwrite-strings
144         # GLib blocks this for now.
145         -Wstrict-prototypes
146         # All the registration functions block these for now.
147         -Wmissing-prototypes
148         -Wmissing-declarations
149         # Problem with packet-afs.c
150         -Wshadow
151         # More cleanup needed for this on LP64
152         -Wshorten-64-to-32
153 )
154
155 if(ENABLE_EXTRA_GCC_CHECKS)   # This overrides -Werror
156         set(WIRESHARK_C_FLAGS ${WIRESHARK_C_FLAGS} ${WIRESHARK_EXTRA_C_FLAGS})
157 endif()
158
159 add_definitions(
160         -DHAVE_CONFIG_H
161         -DPACKAGE=\"wireshark\"
162 )
163
164 # Counterhack to work around some cache magic in CHECK_C_SOURCE_COMPILES
165 include(CheckCCompilerFlag)
166 set(C 0)
167 # Sigh: Have to use THIS_FLAG instead of ${F} for some reason
168 foreach(THIS_FLAG ${WIRESHARK_C_FLAGS})
169         set(F WS_C_FLAG_${C})
170         set(${F} ${THIS_FLAG})
171         set(V WS_C_FLAG_VALID${C})
172         check_c_compiler_flag(${${F}} ${V})
173         if (${${V}})
174                 add_definitions(${${F}})
175         endif()
176         math(EXPR C "${C} + 1")
177 endforeach()
178
179 if(NOT DISABLE_WERROR AND NOT ENABLE_EXTRA_GCC_CHECKS)
180         check_c_compiler_flag(-Werror WERROR)
181 else()
182         set(WERROR 0)
183 endif()
184
185 if(CMAKE_COMPILER_IS_GNUCC)
186         add_definitions( -D_U_=__attribute__\(\(unused\)\) )
187 else()
188         add_definitions( -D_U_=\"\" )
189 endif()
190
191 set(WIRESHARK_LD_FLAGS
192         -Wl,--as-needed
193         # -flto
194         # -fwhopr
195         # -fwhole-program
196 )
197
198 include(CheckCLinkerFlag)
199 set(C 0)
200 # Sigh: Have to use THIS_FLAG instead of ${F} for some reason
201 foreach(THIS_FLAG ${WIRESHARK_LD_FLAGS})
202         set(F WS_LD_FLAG_${C})
203         set(${F} ${THIS_FLAG})
204         set(V WS_LD_FLAG_VALID${C})
205         check_c_linker_flag(${${F}} ${V})
206         if (${${V}})
207                 set(WS_LINK_FLAGS ${WS_LINK_FLAGS} ${${F}})
208         endif()
209         math(EXPR C "${C} + 1")
210 endforeach()
211
212 if(ENABLE_STATIC)
213   set(LINK_MODE_LIB STATIC)
214   set(LINK_MODE_MODULE STATIC)
215 else()
216   set(LINK_MODE_LIB SHARED)
217   set(LINK_MODE_MODULE MODULE)
218 endif()
219
220 # The packagelist is doing some magic:  If we add XXX to the packagelist, we
221 # - may optionally set XXX_OPTIONS to pass to the find_package command
222 # - will call FindXXX.cmake
223 # - return found libraries in XXX_LIBRARIES
224 # - return found include in XXX_INCLUDE_DIRS
225 # - set HAVE_XXX
226
227 #The minimum package list
228 set(PACKAGELIST GLIB2 GMODULE2 PCAP M LEX YACC Perl SH PythonInterp)
229 set(GLIB2_FIND_REQUIRED)
230 set(GLIB2_MIN_VERSION 2.14.0)
231 set(PCAP_REQUIRED)
232 set(M_REQUIRED)
233
234 set(PACKAGELIST ${PACKAGELIST} HtmlViewer)
235
236 #Build the gui ?
237 if(BUILD_wireshark)
238         if(ENABLE_GTK3)
239                 set(PACKAGELIST ${PACKAGELIST} GTK3)
240                 set(UI_MANAGER ON)
241         else()
242                 set(PACKAGELIST ${PACKAGELIST} GTK2)
243                 set(GTK2_OPTIONS COMPONENTS gtk)
244                 set(GTK2_FIND_VERSION 2.12)
245                 set(GTK2_DEBUG false)
246         endif()
247 endif()
248
249 if(BUILD_dumpcap)
250         set(PACKAGELIST ${PACKAGELIST} GTHREAD2)
251         set(GHTREAD2_REQUIRED)
252 endif()
253
254 # SMI SNMP
255 if(ENABLE_SMI)
256         set(PACKAGELIST ${PACKAGELIST} SMI)
257 endif()
258
259 # GNU crypto
260 if(ENABLE_GCRYPT)
261         set(PACKAGELIST ${PACKAGELIST} GCRYPT)
262 endif()
263
264 # GNU SSL/TLS support
265 if(ENABLE_GNUTLS)
266         set(PACKAGELIST ${PACKAGELIST} GNUTLS)
267 endif()
268
269 # Regular expressions lib
270 if(ENABLE_PCRE)
271         set(PACKAGELIST ${PACKAGELIST} PCRE)
272 endif()
273
274 # Kerberos
275 if(ENABLE_KERBEROS)
276         set(PACKAGELIST ${PACKAGELIST} KERBEROS)
277 endif()
278
279 # Portable audio
280 if(ENABLE_PORTAUDIO)
281         set(PACKAGELIST ${PACKAGELIST} PORTAUDIO)
282 endif()
283
284
285 # Prefer c-ares over adns
286 if(ENABLE_CARES)        # C Asynchronouse resolver
287         set(PACKAGELIST ${PACKAGELIST} CARES)
288 elseif(ENABLE_ADNS)     # Gnu asynchronous DNS
289         set(PACKAGELIST ${PACKAGELIST} ADNS)
290 endif()
291
292 # Zlib compression
293 if(ENABLE_ZLIB)
294         set(PACKAGELIST ${PACKAGELIST} ZLIB)
295 endif()
296
297 # Lua 5.1 dissectors
298 if(ENABLE_LUA)
299         set(PACKAGELIST ${PACKAGELIST} LUA)
300 endif()
301
302 # GeoIP address resolving
303 if(ENABLE_GEOIP)
304         set(PACKAGELIST ${PACKAGELIST} GEOIP)
305 endif()
306
307 # Capabilities
308 if(ENABLE_CAP)
309         set(PACKAGELIST ${PACKAGELIST} CAP)
310 endif()
311
312 if(ENABLE_PYTHON)
313         set(PACKAGELIST ${PACKAGELIST} PYTHON)
314 endif()
315
316 set(PACKAGELIST ${PACKAGELIST} YAPP)
317
318 set(PACKAGELIST ${PACKAGELIST} POD)
319
320
321 set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
322
323 #Let's loop the package list
324 foreach(PACKAGE ${PACKAGELIST})
325         if(${PACKAGE}_OPTIONS)
326                 find_package(${PACKAGE} ${${PACKAGE}_OPTIONS})
327         elseif(${PACKAGE}_REQUIRED)
328                 find_package(${PACKAGE} REQUIRED)
329         else()
330                 find_package(${PACKAGE})
331         endif()
332         message(${PACKAGE}_FOUND)
333         if (${PACKAGE}_FOUND)
334                 set(HAVE_LIB${PACKAGE} 1)
335                 include_directories(${${PACKAGE}_INCLUDE_DIRS})
336                 message(STATUS "${PACKAGE} includes: ${${PACKAGE}_INCLUDE_DIRS}")
337                 message(STATUS "${PACKAGE} libs: ${${PACKAGE}_LIBRARIES}")
338         endif()
339 endforeach()
340
341 #packaging
342 include(CPackConfig.txt)
343
344 if(HAVE_LIBPYTHON)
345         set(HAVE_PYTHON 1)
346         set(PYTHON_DIR "${CMAKE_INSTALL_PREFIX}/lib/wireshark/python/${CPACK_PACKAGE_VERSION}")
347 endif()
348 if(HAVE_LIBLUA)
349         set(HAVE_LUA_H 1)
350         set(HAVE_LUA_5_1 1)
351 endif()
352 if(HAVE_LIBKERBEROS)
353         set(HAVE_KERBEROS 1)
354         # HAVE_HEIMDAL_KERBEROS
355         set(HAVE_MIT_KERBEROS 1)
356         set(HAVE_KEYTYPE_ARCFOUR_56 1)
357 endif()
358 if(HAVE_LIBGEOIP)
359         set(HAVE_GEOIP 1)
360 endif()
361 if(HAVE_LIBCARES)
362         set(HAVE_C_ARES 1)
363 endif()
364 if(HAVE_LIBADNS)
365         set(HAVE_GNU_ADNS 1)
366 endif()
367 if(ENABLE_AIRPCAP)
368         set(HAVE_AIRPCAP 1)
369 endif()
370 # No matter which version of GTK is present
371 if(GTK2_FOUND OR GTK3_FOUND)
372         set(GTK_FOUND ON)
373 endif()
374 # That's the name autofoo uses
375 if(HAVE_LIBZLIB)
376         set(HAVE_LIBZ 1)
377 endif()
378
379 include(ConfigureChecks.cmake)
380
381 #Big or little endian ?
382 include(TestBigEndian)
383 test_big_endian(WORDS_BIGENDIAN)
384
385 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
386
387 if(ENABLE_PLUGINS)
388         set(HAVE_PLUGINS 1)
389         set(PLUGIN_DIR="${DATAFILE_DIR}/plugins/${CPACK_PACKAGE_VERSION}")
390         set(PLUGIN_SRC_DIRS
391                 plugins/asn1
392                 plugins/docsis
393                 plugins/ethercat
394                 plugins/giop
395                 plugins/gryphon
396                 plugins/irda
397                 plugins/m2m
398                 plugins/mate
399                 plugins/opcua
400                 plugins/profinet
401                 plugins/stats_tree
402                 plugins/unistim
403                 plugins/wimax
404                 plugins/wimaxasncp
405         )
406 # It seems this stuff doesn't build with autofoo either...
407 #       if(YAPP_FOUND)
408 #               set(PLUGIN_SRC_DIRS
409 #                       ${PLUGIN_SRC_DIRS}
410 #                       plugins/tpg
411 #               )
412 #       endif()
413 else()
414         set(PLUGIN_SRC_DIRS )
415 endif()
416
417 foreach(PLUGIN_DIR ${PLUGIN_SRC_DIRS})
418         add_subdirectory( ${PLUGIN_DIR} )
419 endforeach()
420
421 add_subdirectory( codecs )
422 add_subdirectory( epan )
423 add_subdirectory( tools/lemon )
424 add_subdirectory( wiretap )
425 add_subdirectory( wsutil )
426
427 if(BUILD_wireshark AND GTK_FOUND)
428         add_subdirectory( gtk )
429 endif()
430
431 # Basedir where to install guides
432 set(DOC_DIR "$ENV{docdir}")
433 message(STATUS "docdir: ${DOC_DIR}")
434
435 if(ENABLE_GUIDES)
436         add_subdirectory( docbook )
437 endif()
438
439 if(ENABLE_PCAP_NG_DEFAULT)
440         set(PCAP_NG_DEFAULT 1)
441 endif()
442
443 if(ENABLE_THREADS)
444         set(USE_THREADS 1)
445 endif()
446
447 #Platform specific
448 if(UNIX)
449         set(WS_VAR_IMPORT "extern")
450 endif()
451
452 if(APPLE)
453 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
454         set(HAVE_OS_X_FRAMEWORKS 1)
455         FIND_LIBRARY (APPLE_CORE_SERVICES_LIBRARY CoreServices)
456         FIND_LIBRARY (APPLE_COCOA_LIBRARY Cocoa)
457 endif()
458
459 if(WIN32)
460         add_definitions(-D_NEED_VAR_IMPORT_)
461         set(WS_VAR_IMPORT "__declspec(dllimport) extern")
462         set(WS_MSVC_NORETURN "__declspec(noreturn)")
463
464         # Disable deprecation
465         if(MSVC80 OR MSVC90)
466                 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
467         endif()
468 else()
469         set(WS_MSVC_NORETURN " ")
470 endif()
471
472 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
473
474 include(FeatureSummary)
475 #SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ]
476 PRINT_ENABLED_FEATURES()
477 PRINT_DISABLED_FEATURES()
478
479 link_directories(
480         ${CMAKE_BINARY_DIR}/gtk
481         ${CMAKE_BINARY_DIR}/codecs
482         ${CMAKE_BINARY_DIR}/epan
483         ${CMAKE_BINARY_DIR}/wiretap
484         ${CMAKE_BINARY_DIR}/wsutil
485 )
486
487 ADD_CUSTOM_TARGET(
488         svnversion ALL
489         COMMAND ${PERL}
490                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
491                 ${CMAKE_CURRENT_SOURCE_DIR}
492         DEPENDS
493                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
494 )
495
496 ADD_CUSTOM_COMMAND(
497         OUTPUT  svnversion.h
498         COMMAND ${PERL}
499                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
500                 ${CMAKE_CURRENT_SOURCE_DIR}
501         DEPENDS
502                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
503 )
504
505 register_tap_files(tshark-tap-register.c
506         ${TSHARK_TAP_SRC}
507 )
508
509 ADD_CUSTOM_COMMAND(
510         OUTPUT  ps.c
511         COMMAND ${PYTHON_EXECUTABLE}
512                 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
513                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
514                 ps.c
515         DEPENDS
516                 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
517                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
518 )
519
520 if(UNIX)
521         set(PLATFORM_SRC
522                 capture-pcap-util-unix.c
523         )
524 endif()
525
526 if(WIN32)
527         set(PLATFORM_SRC
528                 capture-wpcap.c capture_wpcap_packet.c
529         )
530 endif()
531
532 set(WTAP_PLUGIN_SOURCES
533         epan/plugins.c
534         epan/report_err.c
535         epan/filesystem.c
536 )
537
538 set(SHARK_COMMON_CAPTURE_SRC
539         capture_errs.c
540         capture_ifinfo.c
541         capture_ui_utils.c
542 )
543
544 set(WIRESHARK_COMMON_SRC
545         ${PLATFORM_SRC}
546         capture-pcap-util.c
547         cfile.c
548         clopts_common.c
549         disabled_protos.c
550         frame_data_sequence.c
551         packet-range.c
552         print.c
553         ps.c
554         svnversion.h
555         sync_pipe_write.c
556         timestats.c
557         util.c
558         tap-megaco-common.c
559         tap-rtp-common.c
560         version_info.c
561 )
562
563 set(TSHARK_TAP_SRC
564         tap-afpstat.c
565         tap-ansi_astat.c
566         tap-bootpstat.c
567         tap-camelcounter.c
568         tap-camelsrt.c
569         tap-comparestat.c
570         tap-dcerpcstat.c
571         tap-diameter-avp.c
572         tap-funnel.c
573         tap-gsm_astat.c
574         tap-h225counter.c
575         tap-h225rassrt.c
576         tap-hosts.c
577         tap-httpstat.c
578         tap-icmpstat.c
579         tap-icmpv6stat.c
580         tap-iostat.c
581         tap-iousers.c
582         tap-macltestat.c
583         tap-mgcpstat.c
584         tap-megacostat.c
585         tap-protocolinfo.c
586         tap-protohierstat.c
587         tap-radiusstat.c
588         tap-rlcltestat.c
589         tap-rpcstat.c
590         tap-rpcprogs.c
591         tap-rtp.c
592         tap-rtspstat.c
593         tap-scsistat.c
594         tap-sctpchunkstat.c
595         tap-sipstat.c
596         tap-smbsids.c
597         tap-smbstat.c
598         tap-stats_tree.c
599         tap-sv.c
600         tap-wspstat.c
601 )
602
603 set(INSTALL_DIRS
604         diameter
605         docbook
606         dtds
607         help
608         radius
609         tpncp
610         wimaxasncp
611 )
612
613 set(INSTALL_FILES
614         ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
615         COPYING
616         ${CMAKE_BINARY_DIR}/capinfos.html
617         cfilters
618         colorfilters
619         dfilters
620         ${CMAKE_BINARY_DIR}/dftest.html
621         ${CMAKE_BINARY_DIR}/dumpcap.html
622         ${CMAKE_BINARY_DIR}/editcap.html
623         ${CMAKE_BINARY_DIR}/idl2wrs.html
624         ipmap.html
625         manuf
626         ${CMAKE_BINARY_DIR}/mergecap.html
627         pdml2html.xsl
628         ${CMAKE_BINARY_DIR}/randpkt.html
629         ${CMAKE_BINARY_DIR}/rawshark.html
630         services
631         smi_modules
632         ${CMAKE_BINARY_DIR}/text2pcap.html
633         ${CMAKE_BINARY_DIR}/tshark.html
634         ${CMAKE_BINARY_DIR}/wireshark-filter.html
635         ${CMAKE_BINARY_DIR}/wireshark.html
636         docbook/ws.css
637 )
638
639 set(LIBEPAN_LIBS
640 #               @NSL_LIBS@      # -lnsl
641 #               @SOCKET_LIBS@   # -lsocket
642 #               @SSL_LIBS@      # -lcrypto
643                 epan
644 #               $(plugin_ldadd) # in case of static
645                 ${PCRE_LIBRARIES}
646                 ${PCAP_LIBRARIES}
647                 ${CARES_LIBRARIES}
648                 ${ADNS_LIBRARIES}
649                 ${KERBEROS_LIBRARIES}
650                 ${LUA_LIBRARIES}
651                 ${PYTHON_LIBRARIES}
652                 ${GEOIP_LIBRARIES}
653                 ${GCRYPT_LIBRARIES}
654                 ${GNUTLS_LIBRARIES}
655                 ${SMI_LIBRARIES}
656                 ${ZLIB_LIBRARIES}
657                 ${M_LIBRARIES}
658 )
659
660 if(BUILD_wireshark AND GTK_FOUND)
661         set(wireshark_LIBS
662                 ui
663                 ${GTK2_LIBRARIES}
664                 ${GTK3_LIBRARIES}
665                 codecs
666                 ${PORTAUDIO_LIBRARIES}
667                 ${LIBEPAN_LIBS}
668                 ${APPLE_CORE_SERVICES_LIBRARY}
669                 ${APPLE_COCOA_LIBRARY}
670         )
671         set(wireshark_FILES
672                 airpcap_loader.c
673                 alert_box.c
674                 capture.c
675                 capture_info.c
676                 capture_opts.c
677                 capture_sync.c
678                 color_filters.c
679                 file.c
680                 fileset.c
681                 filters.c
682                 g711.c
683                 merge.c
684                 proto_hier_stats.c
685                 summary.c
686                 tempfile.c
687                 u3.c
688                 ${SHARK_COMMON_CAPTURE_SRC}
689                 ${WIRESHARK_COMMON_SRC}
690         )
691         add_executable(wireshark ${wireshark_FILES})
692         add_dependencies(wireshark svnversion)
693         set_target_properties(wireshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
694         target_link_libraries(wireshark ${wireshark_LIBS})
695         install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
696 endif()
697
698 if(BUILD_tshark)
699         set(tshark_LIBS
700                 ${LIBEPAN_LIBS}
701                 ${APPLE_COCOA_LIBRARY}
702         )
703         set(tshark_FILES
704                 capture_opts.c
705                 capture_sync.c
706                 tempfile.c
707                 tshark-tap-register.c
708                 tshark.c
709                 ${TSHARK_TAP_SRC}
710                 ${SHARK_COMMON_CAPTURE_SRC}
711                 ${WIRESHARK_COMMON_SRC}
712         )
713         add_executable(tshark ${tshark_FILES})
714         add_dependencies(tshark svnversion)
715         set_target_properties(tshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
716         target_link_libraries(tshark ${tshark_LIBS})
717         install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
718 endif()
719
720 if(BUILD_rawshark)
721         set(rawshark_LIBS
722                 ${LIBEPAN_LIBS}
723                 ${APPLE_COCOA_LIBRARY}
724         )
725         set(rawshark_FILES
726                 ${WIRESHARK_COMMON_SRC}
727                 rawshark.c
728         )
729         add_executable(rawshark ${rawshark_FILES})
730         add_dependencies(rawshark svnversion)
731         set_target_properties(rawshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
732         target_link_libraries(rawshark ${rawshark_LIBS})
733         install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
734 endif()
735
736 if(BUILD_dftest)
737         set(dftest_LIBS
738                 ${LIBEPAN_LIBS}
739         )
740         set(dftest_FILES
741                 dftest.c
742                 util.c
743         )
744         add_executable(dftest ${dftest_FILES})
745         set_target_properties(dftest PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
746         target_link_libraries(dftest ${dftest_LIBS})
747         install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
748 endif()
749
750 if(BUILD_randpkt)
751         set(randpkt_LIBS
752                 wiretap
753                 ${M_LIBRARIES}
754                 ${PCAP_LIBRARIES}
755 #               @SOCKET_LIBS@
756 #               @NSL_LIBS@
757                 ${CARES_LIBRARIES}
758                 ${ADNS_LIBRARIES}
759                 ${ZLIB_LIBRARIES}
760         )
761         set(randpkt_FILES
762                 randpkt.c
763         )
764         add_executable(randpkt ${randpkt_FILES})
765         set_target_properties(randpkt PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
766         target_link_libraries(randpkt ${randpkt_LIBS})
767         install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
768 endif()
769
770 if(BUILD_text2pcap)
771         set(text2pcap_LIBS
772                 wiretap
773                 ${M_LIBRARIES}
774                 ${ZLIB_LIBRARIES}
775         )
776         set(text2pcap_CLEAN_FILES
777                 text2pcap.c
778         )
779         set(text2pcap_FILES
780                 ${text2pcap_CLEAN_FILES}
781         )
782         add_lex_files(text2pcap_FILES
783                 text2pcap-scanner.l
784         )
785         add_executable(text2pcap ${text2pcap_FILES})
786         add_dependencies(text2pcap svnversion)
787         set_target_properties(text2pcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
788         target_link_libraries(text2pcap ${text2pcap_LIBS})
789         install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
790 endif()
791
792 if(BUILD_mergecap)
793         set(mergecap_LIBS
794                 wiretap
795                 ${ZLIB_LIBRARIES}
796         )
797         set(mergecap_FILES
798                 mergecap.c
799                 merge.c
800                 svnversion.h
801         )
802         add_executable(mergecap ${mergecap_FILES})
803         add_dependencies(mergecap svnversion)
804         set_target_properties(mergecap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
805         target_link_libraries(mergecap ${mergecap_LIBS})
806         install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
807 endif()
808
809 if(BUILD_capinfos)
810         set(capinfos_LIBS
811                 wiretap
812                 ${ZLIB_LIBRARIES}
813                 ${GCRYPT_LIBRARIES}
814                 ${APPLE_COCOA_LIBRARY}
815         )
816         set(capinfos_FILES
817                 capinfos.c
818                 ${WTAP_PLUGIN_SOURCES}
819         )
820         add_executable(capinfos ${capinfos_FILES})
821         add_dependencies(capinfos svnversion)
822         set_target_properties(capinfos PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
823         target_link_libraries(capinfos ${capinfos_LIBS})
824         install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
825 endif()
826
827 if(BUILD_editcap)
828         set(editcap_LIBS
829                 wiretap
830                 ${ZLIB_LIBRARIES}
831         )
832         set(editcap_FILES
833                 editcap.c
834                 epan/crypt/crypt-md5.c
835                 epan/nstime.c
836                 ${WTAP_PLUGIN_SOURCES}
837         )
838         add_executable(editcap ${editcap_FILES})
839         add_dependencies(editcap svnversion)
840         set_target_properties(editcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
841         target_link_libraries(editcap ${editcap_LIBS})
842         install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
843 endif()
844
845 if(BUILD_dumpcap)
846         set(dumpcap_LIBS
847 #               @INET_NTOP_LO@
848                 wsutil
849                 ${PCAP_LIBRARIES}
850                 ${CAP_LIBRARIES}
851 #               @SOCKET_LIBS@
852 #               @NSL_LIBS@
853                 ${GLIB2_LIBRARIES}
854                 ${GTHREAD2_LIBRARIES}
855                 ${ZLIB_LIBRARIES}
856                 ${APPLE_COCOA_LIBRARY}
857         )
858         set(dumpcap_FILES
859                 svnversion.h
860                 capture_opts.c
861                 capture-pcap-util.c
862                 capture_stop_conditions.c
863                 clopts_common.c
864                 conditions.c
865                 dumpcap.c
866                 pcapio.c
867                 ringbuffer.c
868                 sync_pipe_write.c
869                 tempfile.c
870                 version_info.c
871                 ${PLATFORM_SRC}
872         )
873         add_executable(dumpcap ${dumpcap_FILES})
874         add_dependencies(dumpcap svnversion)
875         set_target_properties(dumpcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
876         target_link_libraries(dumpcap ${dumpcap_LIBS})
877         install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
878 endif()
879
880 ADD_CUSTOM_COMMAND(
881         OUTPUT  ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
882         COMMAND ${PERL}
883                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
884                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
885                 < ${CMAKE_SOURCE_DIR}/AUTHORS
886                 > ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
887         DEPENDS
888                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
889                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
890                 ${CMAKE_SOURCE_DIR}/AUTHORS
891 )
892
893 ADD_CUSTOM_COMMAND(
894         OUTPUT  ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
895                 ${CMAKE_BINARY_DIR}/wireshark.pod
896         COMMAND ${PERL}
897                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
898                 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
899                 < ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
900                 > ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
901         COMMAND cat
902                 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
903                 ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
904                 > ${CMAKE_BINARY_DIR}/wireshark.pod
905         DEPENDS
906                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
907                 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
908                 ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
909                 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
910 )
911
912 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/capinfos 1 )
913 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dftest 1 )
914 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dumpcap 1 )
915 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/editcap 1 )
916 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/idl2wrs 1 )
917 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/mergecap 1 )
918 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/randpkt 1 )
919 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/rawshark 1 )
920 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/text2pcap 1 )
921 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/tshark 1 )
922 pod2manhtml( wireshark 1 )
923 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/wireshark-filter 4 )
924
925 add_custom_target(
926         auxiliary ALL
927         DEPENDS
928                 AUTHORS-SHORT
929                 capinfos.html
930                 dftest.html
931                 dumpcap.html
932                 editcap.html
933                 idl2wrs.html
934                 mergecap.html
935                 randpkt.html
936                 rawshark.html
937                 text2pcap.html
938                 tshark.html
939                 wireshark.html
940                 wireshark-filter.html
941 )
942
943 set(MAN1_FILES
944         ${CMAKE_BINARY_DIR}/capinfos.1
945         ${CMAKE_BINARY_DIR}/dftest.1
946         ${CMAKE_BINARY_DIR}/dumpcap.1
947         ${CMAKE_BINARY_DIR}/editcap.1
948         ${CMAKE_BINARY_DIR}/idl2wrs.1
949         ${CMAKE_BINARY_DIR}/mergecap.1
950         ${CMAKE_BINARY_DIR}/randpkt.1
951         ${CMAKE_BINARY_DIR}/rawshark.1
952         ${CMAKE_BINARY_DIR}/text2pcap.1
953         ${CMAKE_BINARY_DIR}/tshark.1
954         ${CMAKE_BINARY_DIR}/wireshark.1
955 )
956
957 set(MAN4_FILES
958         ${CMAKE_BINARY_DIR}/wireshark-filter.4
959 )
960
961 set(CLEAN_FILES
962         ${wireshark_FILES}
963         ${tshark_FILES}
964         ${rawshark_FILES}
965         ${dftest_FILES}
966         ${randpkt_FILES}
967         ${text2pcap_CLEAN_FILES}
968         ${mergecap_FILES}
969         ${capinfos_FILES}
970         ${editcap_FILES}
971         ${dumpcap_FILES}
972 )
973
974 if (WERROR)
975         set_source_files_properties(
976                 ${CLEAN_FILES}
977                 PROPERTIES
978                 COMPILE_FLAGS -Werror
979         )
980 endif()
981
982 install(
983         FILES
984                 ${INSTALL_FILES}
985         DESTINATION
986                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
987 )
988
989 install(
990         FILES
991                 ${MAN1_FILES}
992         DESTINATION
993                 ${CMAKE_INSTALL_MANDIR}/man1
994 )
995
996 install(
997         FILES
998                 ${MAN4_FILES}
999         DESTINATION
1000                 ${CMAKE_INSTALL_MANDIR}/man4
1001 )
1002
1003 install(
1004         DIRECTORY
1005                 ${INSTALL_DIRS}
1006         DIRECTORY_PERMISSIONS
1007                 OWNER_EXECUTE OWNER_WRITE OWNER_READ
1008                 GROUP_EXECUTE GROUP_READ
1009                 WORLD_EXECUTE WORLD_READ
1010         DESTINATION
1011                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
1012         PATTERN ".svn" EXCLUDE
1013         PATTERN "Makefile.*" EXCLUDE
1014         PATTERN "faq.py" EXCLUDE
1015 )