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