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