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