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