Move packet-sercosiii.c to be a builtin dissector.
[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 # Disable this later. Alternative: "make VERBOSE=1"
81 set(CMAKE_VERBOSE_MAKEFILE ON)
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.4.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         set(PACKAGELIST ${PACKAGELIST} GTK2)
239         set(GTK2_OPTIONS COMPONENTS gtk)
240         set(GTK2_DEBUG false)
241 endif()
242
243 if(BUILD_dumpcap)
244         set(PACKAGELIST ${PACKAGELIST} GTHREAD2)
245         set(GHTREAD2_REQUIRED)
246 endif()
247
248 # SMI SNMP
249 if(ENABLE_SMI)
250         set(PACKAGELIST ${PACKAGELIST} SMI)
251 endif()
252
253 # GNU crypto
254 if(ENABLE_GCRYPT)
255         set(PACKAGELIST ${PACKAGELIST} GCRYPT)
256 endif()
257
258 # GNU SSL/TLS support
259 if(ENABLE_GNUTLS)
260         set(PACKAGELIST ${PACKAGELIST} GNUTLS)
261 endif()
262
263 # Regular expressions lib
264 if(ENABLE_PCRE)
265         set(PACKAGELIST ${PACKAGELIST} PCRE)
266 endif()
267
268 # Kerberos
269 if(ENABLE_KERBEROS)
270         set(PACKAGELIST ${PACKAGELIST} KERBEROS)
271 endif()
272
273 # Portable audio
274 if(ENABLE_PORTAUDIO)
275         set(PACKAGELIST ${PACKAGELIST} PORTAUDIO)
276 endif()
277
278
279 # Prefer c-ares over adns
280 if(ENABLE_CARES)        # C Asynchronouse resolver
281         set(PACKAGELIST ${PACKAGELIST} CARES)
282 elseif(ENABLE_ADNS)     # Gnu asynchronous DNS
283         set(PACKAGELIST ${PACKAGELIST} ADNS)
284 endif()
285
286 # Zlib compression
287 if(ENABLE_ZLIB)
288         set(PACKAGELIST ${PACKAGELIST} ZLIB)
289 endif()
290
291 # Lua 5.1 dissectors
292 if(ENABLE_LUA)
293         set(PACKAGELIST ${PACKAGELIST} LUA)
294 endif()
295
296 # GeoIP address resolving
297 if(ENABLE_GEOIP)
298         set(PACKAGELIST ${PACKAGELIST} GEOIP)
299 endif()
300
301 # Capabilities
302 if(ENABLE_CAP)
303         set(PACKAGELIST ${PACKAGELIST} CAP)
304 endif()
305
306 if(ENABLE_PYTHON)
307         set(PACKAGELIST ${PACKAGELIST} PYTHON)
308 endif()
309
310 set(PACKAGELIST ${PACKAGELIST} YAPP)
311
312 set(PACKAGELIST ${PACKAGELIST} POD)
313
314
315 set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
316
317 #Let's loop the package list
318 foreach(PACKAGE ${PACKAGELIST})
319         if(${PACKAGE}_OPTIONS)
320                 find_package(${PACKAGE} ${${PACKAGE}_OPTIONS})
321         elseif(${PACKAGE}_REQUIRED)
322                 find_package(${PACKAGE} REQUIRED)
323         else()
324                 find_package(${PACKAGE})
325         endif()
326         message(${PACKAGE}_FOUND)
327         if (${PACKAGE}_FOUND)
328                 set(HAVE_LIB${PACKAGE} 1)
329                 include_directories(${${PACKAGE}_INCLUDE_DIRS})
330                 message(STATUS "${PACKAGE} includes: ${${PACKAGE}_INCLUDE_DIRS}")
331                 message(STATUS "${PACKAGE} libs: ${${PACKAGE}_LIBRARIES}")
332         endif()
333 endforeach()
334
335 #packaging
336 include(CPackConfig.txt)
337
338 if(HAVE_LIBPYTHON)
339         set(HAVE_PYTHON 1)
340         set(PYTHON_DIR "${CMAKE_INSTALL_PREFIX}/lib/wireshark/python/${CPACK_PACKAGE_VERSION}")
341 endif()
342 if(HAVE_LIBLUA)
343         set(HAVE_LUA_H 1)
344         set(HAVE_LUA_5_1 1)
345 endif()
346 if(HAVE_LIBKERBEROS)
347         set(HAVE_KERBEROS 1)
348         # HAVE_HEIMDAL_KERBEROS
349         set(HAVE_MIT_KERBEROS 1)
350         set(HAVE_KEYTYPE_ARCFOUR_56 1)
351 endif()
352 if(HAVE_LIBGEOIP)
353         set(HAVE_GEOIP 1)
354 endif()
355 if(HAVE_LIBCARES)
356         set(HAVE_C_ARES 1)
357 endif()
358 if(HAVE_LIBADNS)
359         set(HAVE_GNU_ADNS 1)
360 endif()
361 if(ENABLE_AIRPCAP)
362         set(HAVE_AIRPCAP 1)
363 endif()
364 # That's the name autofoo uses
365 if(HAVE_LIBZLIB)
366         set(HAVE_LIBZ 1)
367 endif()
368
369 include(ConfigureChecks.cmake)
370
371 #Big or little endian ?
372 include(TestBigEndian)
373 test_big_endian(WORDS_BIGENDIAN)
374
375 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
376
377 if(ENABLE_PLUGINS)
378         set(HAVE_PLUGINS 1)
379         set(PLUGIN_DIR="${DATAFILE_DIR}/plugins/${CPACK_PACKAGE_VERSION}")
380         set(PLUGIN_SRC_DIRS
381                 plugins/asn1
382                 plugins/docsis
383                 plugins/ethercat
384                 plugins/giop
385                 plugins/gryphon
386                 plugins/interlink
387                 plugins/irda
388                 plugins/m2m
389                 plugins/mate
390                 plugins/opcua
391                 plugins/profinet
392                 plugins/stats_tree
393                 plugins/unistim
394                 plugins/wimax
395                 plugins/wimaxasncp
396         )
397 # It seems this stuff doesn't build with autofoo either...
398 #       if(YAPP_FOUND)
399 #               set(PLUGIN_SRC_DIRS
400 #                       ${PLUGIN_SRC_DIRS}
401 #                       plugins/tpg
402 #               )
403 #       endif()
404 else()
405         set(PLUGIN_SRC_DIRS )
406 endif()
407
408 foreach(PLUGIN_DIR ${PLUGIN_SRC_DIRS})
409         add_subdirectory( ${PLUGIN_DIR} )
410 endforeach()
411
412 add_subdirectory( codecs )
413 add_subdirectory( epan )
414 add_subdirectory( tools/lemon )
415 add_subdirectory( wiretap )
416 add_subdirectory( wsutil )
417
418 if(BUILD_wireshark AND GTK2_FOUND)
419         add_subdirectory( gtk )
420 endif()
421
422 # Basedir where to install guides
423 set(DOC_DIR "$ENV{docdir}")
424 message(STATUS "docdir: ${DOC_DIR}")
425
426 if(ENABLE_GUIDES)
427         add_subdirectory( docbook )
428 endif()
429
430 #Platform specific
431 if(UNIX)
432         set(WS_VAR_IMPORT "extern")
433 endif()
434
435 if(APPLE)
436 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
437         set(HAVE_OS_X_FRAMEWORKS 1)
438         FIND_LIBRARY (APPLE_CORE_SERVICES_LIBRARY CoreServices)
439         FIND_LIBRARY (APPLE_COCOA_LIBRARY Cocoa)
440 endif()
441
442 if(WIN32)
443         add_definitions(-D_NEED_VAR_IMPORT_)
444         set(WS_VAR_IMPORT "__declspec(dllimport) extern")
445         set(WS_MSVC_NORETURN "__declspec(noreturn)")
446
447         # Disable deprecation
448         if(MSVC80 OR MSVC90)
449                 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
450         endif()
451 else()
452         set(WS_MSVC_NORETURN " ")
453 endif()
454
455 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
456
457 include(FeatureSummary)
458 #SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ]
459 PRINT_ENABLED_FEATURES()
460 PRINT_DISABLED_FEATURES()
461
462 link_directories(
463         ${CMAKE_BINARY_DIR}/gtk
464         ${CMAKE_BINARY_DIR}/codecs
465         ${CMAKE_BINARY_DIR}/epan
466         ${CMAKE_BINARY_DIR}/wiretap
467         ${CMAKE_BINARY_DIR}/wsutil
468 )
469
470 ADD_CUSTOM_TARGET(
471         svnversion ALL
472         COMMAND ${PERL}
473                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
474                 ${CMAKE_CURRENT_SOURCE_DIR}
475         DEPENDS
476                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
477 )
478
479 ADD_CUSTOM_COMMAND(
480         OUTPUT  svnversion.h
481         COMMAND ${PERL}
482                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
483                 ${CMAKE_CURRENT_SOURCE_DIR}
484         DEPENDS
485                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
486 )
487
488 register_tap_files(tshark-tap-register.c
489         ${TSHARK_TAP_SRC}
490 )
491
492 ADD_CUSTOM_COMMAND(
493         OUTPUT  ps.c
494         COMMAND ${PYTHON_EXECUTABLE}
495                 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
496                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
497                 ps.c
498         DEPENDS
499                 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
500                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
501 )
502
503 if(UNIX)
504         set(PLATFORM_SRC
505                 capture-pcap-util-unix.c
506         )
507 endif()
508
509 if(WIN32)
510         set(PLATFORM_SRC
511                 capture-wpcap.c capture_wpcap_packet.c
512         )
513 endif()
514
515 set(WTAP_PLUGIN_SOURCES
516         epan/plugins.c
517         epan/report_err.c
518         epan/filesystem.c
519 )
520
521 set(SHARK_COMMON_CAPTURE_SRC
522         capture_errs.c
523         capture_ifinfo.c
524         capture_ui_utils.c
525 )
526
527 set(WIRESHARK_COMMON_SRC
528         ${PLATFORM_SRC}
529         capture-pcap-util.c
530         cfile.c
531         clopts_common.c
532         disabled_protos.c
533         frame_data_sequence.c
534         packet-range.c
535         print.c
536         ps.c
537         svnversion.h
538         sync_pipe_write.c
539         timestats.c
540         util.c
541         tap-megaco-common.c
542         tap-rtp-common.c
543         version_info.c
544 )
545
546 set(TSHARK_TAP_SRC
547         tap-afpstat.c
548         tap-ansi_astat.c
549         tap-bootpstat.c
550         tap-camelcounter.c
551         tap-camelsrt.c
552         tap-comparestat.c
553         tap-dcerpcstat.c
554         tap-diameter-avp.c
555         tap-funnel.c
556         tap-gsm_astat.c
557         tap-h225counter.c
558         tap-h225rassrt.c
559         tap-httpstat.c
560         tap-icmpstat.c
561         tap-icmpv6stat.c
562         tap-iostat.c
563         tap-iousers.c
564         tap-mgcpstat.c
565         tap-megacostat.c
566         tap-protocolinfo.c
567         tap-protohierstat.c
568         tap-radiusstat.c
569         tap-rpcstat.c
570         tap-rpcprogs.c
571         tap-rtp.c
572         tap-scsistat.c
573         tap-sctpchunkstat.c
574         tap-sipstat.c
575         tap-smbsids.c
576         tap-smbstat.c
577         tap-stats_tree.c
578         tap-sv.c
579         tap-wspstat.c
580 )
581
582 set(INSTALL_DIRS
583         diameter
584         docbook
585         dtds
586         help
587         radius
588         tpncp
589         wimaxasncp
590 )
591
592 set(INSTALL_FILES
593         ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
594         COPYING
595         ${CMAKE_BINARY_DIR}/capinfos.html
596         cfilters
597         colorfilters
598         dfilters
599         ${CMAKE_BINARY_DIR}/dftest.html
600         ${CMAKE_BINARY_DIR}/dumpcap.html
601         ${CMAKE_BINARY_DIR}/editcap.html
602         ${CMAKE_BINARY_DIR}/idl2wrs.html
603         ipmap.html
604         manuf
605         ${CMAKE_BINARY_DIR}/mergecap.html
606         pdml2html.xsl
607         ${CMAKE_BINARY_DIR}/randpkt.html
608         ${CMAKE_BINARY_DIR}/rawshark.html
609         services
610         smi_modules
611         ${CMAKE_BINARY_DIR}/text2pcap.html
612         ${CMAKE_BINARY_DIR}/tshark.html
613         ${CMAKE_BINARY_DIR}/wireshark-filter.html
614         ${CMAKE_BINARY_DIR}/wireshark.html
615         docbook/ws.css
616 )
617
618 set(LIBEPAN_LIBS
619 #               @NSL_LIBS@      # -lnsl
620 #               @SOCKET_LIBS@   # -lsocket
621 #               @SSL_LIBS@      # -lcrypto
622                 epan
623 #               $(plugin_ldadd) # in case of static
624                 ${PCRE_LIBRARIES}
625                 ${PCAP_LIBRARIES}
626                 ${CARES_LIBRARIES}
627                 ${ADNS_LIBRARIES}
628                 ${KERBEROS_LIBRARIES}
629                 ${LUA_LIBRARIES}
630                 ${PYTHON_LIBRARIES}
631                 ${GEOIP_LIBRARIES}
632                 ${GCRYPT_LIBRARIES}
633                 ${GNUTLS_LIBRARIES}
634                 ${SMI_LIBRARIES}
635                 ${ZLIB_LIBRARIES}
636                 ${M_LIBRARIES}
637 )
638
639 if(BUILD_wireshark AND GTK2_FOUND)
640         set(wireshark_LIBS
641                 ui
642                 ${GTK2_LIBRARIES}
643                 codecs
644                 ${PORTAUDIO_LIBRARIES}
645                 ${LIBEPAN_LIBS}
646                 ${APPLE_CORE_SERVICES_LIBRARY}
647                 ${APPLE_COCOA_LIBRARY}
648         )
649         set(wireshark_FILES
650                 airpcap_loader.c
651                 alert_box.c
652                 capture.c
653                 capture_info.c
654                 capture_opts.c
655                 capture_sync.c
656                 color_filters.c
657                 file.c
658                 fileset.c
659                 filters.c
660                 g711.c
661                 merge.c
662                 proto_hier_stats.c
663                 summary.c
664                 tempfile.c
665                 u3.c
666                 ${SHARK_COMMON_CAPTURE_SRC}
667                 ${WIRESHARK_COMMON_SRC}
668         )
669         add_executable(wireshark ${wireshark_FILES})
670         add_dependencies(wireshark svnversion)
671         set_target_properties(wireshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
672         target_link_libraries(wireshark ${wireshark_LIBS})
673         install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
674 endif()
675
676 if(BUILD_tshark)
677         set(tshark_LIBS
678                 ${LIBEPAN_LIBS}
679                 ${APPLE_COCOA_LIBRARY}
680         )
681         set(tshark_FILES
682                 capture_opts.c
683                 capture_sync.c
684                 tempfile.c
685                 tshark-tap-register.c
686                 tshark.c
687                 ${TSHARK_TAP_SRC}
688                 ${SHARK_COMMON_CAPTURE_SRC}
689                 ${WIRESHARK_COMMON_SRC}
690         )
691         add_executable(tshark ${tshark_FILES})
692         add_dependencies(tshark svnversion)
693         set_target_properties(tshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
694         target_link_libraries(tshark ${tshark_LIBS})
695         install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
696 endif()
697
698 if(BUILD_rawshark)
699         set(rawshark_LIBS
700                 ${LIBEPAN_LIBS}
701                 ${APPLE_COCOA_LIBRARY}
702         )
703         set(rawshark_FILES
704                 ${WIRESHARK_COMMON_SRC}
705                 rawshark.c
706         )
707         add_executable(rawshark ${rawshark_FILES})
708         add_dependencies(rawshark svnversion)
709         set_target_properties(rawshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
710         target_link_libraries(rawshark ${rawshark_LIBS})
711         install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
712 endif()
713
714 if(BUILD_dftest)
715         set(dftest_LIBS
716                 ${LIBEPAN_LIBS}
717         )
718         set(dftest_FILES
719                 dftest.c
720                 util.c
721         )
722         add_executable(dftest ${dftest_FILES})
723         set_target_properties(dftest PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
724         target_link_libraries(dftest ${dftest_LIBS})
725         install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
726 endif()
727
728 if(BUILD_randpkt)
729         set(randpkt_LIBS
730                 wiretap
731                 ${M_LIBRARIES}
732                 ${PCAP_LIBRARIES}
733 #               @SOCKET_LIBS@
734 #               @NSL_LIBS@
735                 ${CARES_LIBRARIES}
736                 ${ADNS_LIBRARIES}
737                 ${ZLIB_LIBRARIES}
738         )
739         set(randpkt_FILES
740                 randpkt.c
741         )
742         add_executable(randpkt ${randpkt_FILES})
743         set_target_properties(randpkt PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
744         target_link_libraries(randpkt ${randpkt_LIBS})
745         install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
746 endif()
747
748 if(BUILD_text2pcap)
749         set(text2pcap_LIBS
750                 wiretap
751                 ${M_LIBRARIES}
752                 ${ZLIB_LIBRARIES}
753         )
754         set(text2pcap_CLEAN_FILES
755                 text2pcap.c
756         )
757         set(text2pcap_FILES
758                 ${text2pcap_CLEAN_FILES}
759         )
760         add_lex_files(text2pcap_FILES
761                 text2pcap-scanner.l
762         )
763         add_executable(text2pcap ${text2pcap_FILES})
764         add_dependencies(text2pcap svnversion)
765         set_target_properties(text2pcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
766         target_link_libraries(text2pcap ${text2pcap_LIBS})
767         install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
768 endif()
769
770 if(BUILD_mergecap)
771         set(mergecap_LIBS
772                 wiretap
773                 ${ZLIB_LIBRARIES}
774         )
775         set(mergecap_FILES
776                 mergecap.c
777                 merge.c
778                 svnversion.h
779         )
780         add_executable(mergecap ${mergecap_FILES})
781         add_dependencies(mergecap svnversion)
782         set_target_properties(mergecap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
783         target_link_libraries(mergecap ${mergecap_LIBS})
784         install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
785 endif()
786
787 if(BUILD_capinfos)
788         set(capinfos_LIBS
789                 wiretap
790                 ${ZLIB_LIBRARIES}
791                 ${GCRYPT_LIBRARIES}
792                 ${APPLE_COCOA_LIBRARY}
793         )
794         set(capinfos_FILES
795                 capinfos.c
796                 ${WTAP_PLUGIN_SOURCES}
797         )
798         add_executable(capinfos ${capinfos_FILES})
799         add_dependencies(capinfos svnversion)
800         set_target_properties(capinfos PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
801         target_link_libraries(capinfos ${capinfos_LIBS})
802         install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
803 endif()
804
805 if(BUILD_editcap)
806         set(editcap_LIBS
807                 wiretap
808                 ${ZLIB_LIBRARIES}
809         )
810         set(editcap_FILES
811                 editcap.c
812                 epan/crypt/crypt-md5.c
813                 epan/nstime.c
814                 ${WTAP_PLUGIN_SOURCES}
815         )
816         add_executable(editcap ${editcap_FILES})
817         add_dependencies(editcap svnversion)
818         set_target_properties(editcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
819         target_link_libraries(editcap ${editcap_LIBS})
820         install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
821 endif()
822
823 if(BUILD_dumpcap)
824         set(dumpcap_LIBS
825 #               @INET_NTOP_LO@
826                 wsutil
827                 ${PCAP_LIBRARIES}
828                 ${CAP_LIBRARIES}
829 #               @SOCKET_LIBS@
830 #               @NSL_LIBS@
831                 ${GLIB2_LIBRARIES}
832                 ${GTHREAD2_LIBRARIES}
833                 ${ZLIB_LIBRARIES}
834                 ${APPLE_COCOA_LIBRARY}
835         )
836         set(dumpcap_FILES
837                 svnversion.h
838                 capture_opts.c
839                 capture-pcap-util.c
840                 capture_stop_conditions.c
841                 clopts_common.c
842                 conditions.c
843                 dumpcap.c
844                 pcapio.c
845                 ringbuffer.c
846                 sync_pipe_write.c
847                 tempfile.c
848                 version_info.c
849                 ${PLATFORM_SRC}
850         )
851         add_executable(dumpcap ${dumpcap_FILES})
852         add_dependencies(dumpcap svnversion)
853         set_target_properties(dumpcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
854         target_link_libraries(dumpcap ${dumpcap_LIBS})
855         install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
856 endif()
857
858 ADD_CUSTOM_COMMAND(
859         OUTPUT  ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
860         COMMAND ${PERL}
861                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
862                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
863                 < ${CMAKE_SOURCE_DIR}/AUTHORS
864                 > ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
865         DEPENDS
866                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
867                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
868                 ${CMAKE_SOURCE_DIR}/AUTHORS
869 )
870
871 ADD_CUSTOM_COMMAND(
872         OUTPUT  ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
873                 ${CMAKE_BINARY_DIR}/wireshark.pod
874         COMMAND ${PERL}
875                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
876                 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
877                 < ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
878                 > ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
879         COMMAND cat
880                 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
881                 ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
882                 > ${CMAKE_BINARY_DIR}/wireshark.pod
883         DEPENDS
884                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
885                 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
886                 ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
887                 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
888 )
889
890 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/capinfos 1 )
891 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dftest 1 )
892 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dumpcap 1 )
893 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/editcap 1 )
894 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/idl2wrs 1 )
895 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/mergecap 1 )
896 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/randpkt 1 )
897 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/rawshark 1 )
898 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/text2pcap 1 )
899 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/tshark 1 )
900 pod2manhtml( wireshark 1 )
901 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/wireshark-filter 4 )
902
903 add_custom_target(
904         auxiliary ALL
905         DEPENDS
906                 AUTHORS-SHORT
907                 capinfos.html
908                 dftest.html
909                 dumpcap.html
910                 editcap.html
911                 idl2wrs.html
912                 mergecap.html
913                 randpkt.html
914                 rawshark.html
915                 text2pcap.html
916                 tshark.html
917                 wireshark.html
918                 wireshark-filter.html
919 )
920
921 set(MAN1_FILES
922         ${CMAKE_BINARY_DIR}/capinfos.1
923         ${CMAKE_BINARY_DIR}/dftest.1
924         ${CMAKE_BINARY_DIR}/dumpcap.1
925         ${CMAKE_BINARY_DIR}/editcap.1
926         ${CMAKE_BINARY_DIR}/idl2wrs.1
927         ${CMAKE_BINARY_DIR}/mergecap.1
928         ${CMAKE_BINARY_DIR}/randpkt.1
929         ${CMAKE_BINARY_DIR}/rawshark.1
930         ${CMAKE_BINARY_DIR}/text2pcap.1
931         ${CMAKE_BINARY_DIR}/tshark.1
932         ${CMAKE_BINARY_DIR}/wireshark.1
933 )
934
935 set(MAN4_FILES
936         ${CMAKE_BINARY_DIR}/wireshark-filter.4
937 )
938
939 set(CLEAN_FILES
940         ${wireshark_FILES}
941         ${tshark_FILES}
942         ${rawshark_FILES}
943         ${dftest_FILES}
944         ${randpkt_FILES}
945         ${text2pcap_CLEAN_FILES}
946         ${mergecap_FILES}
947         ${capinfos_FILES}
948         ${editcap_FILES}
949         ${dumpcap_FILES}
950 )
951
952 if (WERROR)
953         set_source_files_properties(
954                 ${CLEAN_FILES}
955                 PROPERTIES
956                 COMPILE_FLAGS -Werror
957         )
958 endif()
959
960 install(
961         FILES
962                 ${INSTALL_FILES}
963         DESTINATION
964                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
965 )
966
967 install(
968         FILES
969                 ${MAN1_FILES}
970         DESTINATION
971                 ${CMAKE_INSTALL_MANDIR}/man1
972 )
973
974 install(
975         FILES
976                 ${MAN4_FILES}
977         DESTINATION
978                 ${CMAKE_INSTALL_MANDIR}/man4
979 )
980
981 install(
982         DIRECTORY
983                 ${INSTALL_DIRS}
984         DIRECTORY_PERMISSIONS
985                 OWNER_EXECUTE OWNER_WRITE OWNER_READ
986                 GROUP_EXECUTE GROUP_READ
987                 WORLD_EXECUTE WORLD_READ
988         DESTINATION
989                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
990         PATTERN ".svn" EXCLUDE
991         PATTERN "Makefile.*" EXCLUDE
992         PATTERN "faq.py" EXCLUDE
993 )