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