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