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