Bug 6448 says the embedded Python stuff does not really work.
[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 # 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)
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(PYTHON_FOUND)
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                 recent.c
675                 summary.c
676                 tempfile.c
677                 u3.c
678                 ${SHARK_COMMON_CAPTURE_SRC}
679                 ${WIRESHARK_COMMON_SRC}
680         )
681         add_executable(wireshark ${wireshark_FILES})
682         add_dependencies(wireshark svnversion)
683         set_target_properties(wireshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
684         target_link_libraries(wireshark ${wireshark_LIBS})
685         install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
686 endif()
687
688 register_tap_files(tshark-tap-register.c
689         ${TSHARK_TAP_SRC}
690 )
691
692 if(BUILD_tshark)
693         set(tshark_LIBS
694                 ${LIBEPAN_LIBS}
695                 ${APPLE_COCOA_LIBRARY}
696         )
697         set(tshark_FILES
698                 capture_opts.c
699                 capture_sync.c
700                 tempfile.c
701                 tshark-tap-register.c
702                 tshark.c
703                 ${TSHARK_TAP_SRC}
704                 ${SHARK_COMMON_CAPTURE_SRC}
705                 ${WIRESHARK_COMMON_SRC}
706         )
707         add_executable(tshark ${tshark_FILES})
708         add_dependencies(tshark svnversion)
709         set_target_properties(tshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
710         target_link_libraries(tshark ${tshark_LIBS})
711         install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
712 endif()
713
714 if(BUILD_rawshark AND PCAP_FOUND)
715         set(rawshark_LIBS
716                 ${LIBEPAN_LIBS}
717                 ${APPLE_COCOA_LIBRARY}
718         )
719         set(rawshark_FILES
720                 ${WIRESHARK_COMMON_SRC}
721                 rawshark.c
722         )
723         add_executable(rawshark ${rawshark_FILES})
724         add_dependencies(rawshark svnversion)
725         set_target_properties(rawshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
726         target_link_libraries(rawshark ${rawshark_LIBS})
727         install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
728 endif()
729
730 if(BUILD_dftest)
731         set(dftest_LIBS
732                 ${LIBEPAN_LIBS}
733         )
734         set(dftest_FILES
735                 dftest.c
736                 util.c
737         )
738         add_executable(dftest ${dftest_FILES})
739         set_target_properties(dftest PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
740         target_link_libraries(dftest ${dftest_LIBS})
741         install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
742 endif()
743
744 if(BUILD_randpkt)
745         set(randpkt_LIBS
746                 wiretap
747                 ${M_LIBRARIES}
748                 ${PCAP_LIBRARIES}
749 #               @SOCKET_LIBS@
750 #               @NSL_LIBS@
751                 ${CARES_LIBRARIES}
752                 ${ADNS_LIBRARIES}
753                 ${ZLIB_LIBRARIES}
754         )
755         set(randpkt_FILES
756                 randpkt.c
757         )
758         add_executable(randpkt ${randpkt_FILES})
759         set_target_properties(randpkt PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
760         target_link_libraries(randpkt ${randpkt_LIBS})
761         install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
762 endif()
763
764 if(BUILD_text2pcap)
765         set(text2pcap_LIBS
766                 wiretap
767                 ${M_LIBRARIES}
768                 ${ZLIB_LIBRARIES}
769         )
770         set(text2pcap_CLEAN_FILES
771                 text2pcap.c
772         )
773         set(text2pcap_FILES
774                 ${text2pcap_CLEAN_FILES}
775         )
776         add_lex_files(text2pcap_FILES
777                 text2pcap-scanner.l
778         )
779         add_executable(text2pcap ${text2pcap_FILES})
780         add_dependencies(text2pcap svnversion)
781         set_target_properties(text2pcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
782         target_link_libraries(text2pcap ${text2pcap_LIBS})
783         install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
784 endif()
785
786 if(BUILD_mergecap)
787         set(mergecap_LIBS
788                 wiretap
789                 ${ZLIB_LIBRARIES}
790         )
791         set(mergecap_FILES
792                 mergecap.c
793                 merge.c
794                 svnversion.h
795         )
796         add_executable(mergecap ${mergecap_FILES})
797         add_dependencies(mergecap svnversion)
798         set_target_properties(mergecap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
799         target_link_libraries(mergecap ${mergecap_LIBS})
800         install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
801 endif()
802
803 if(BUILD_capinfos)
804         set(capinfos_LIBS
805                 wiretap
806                 ${ZLIB_LIBRARIES}
807                 ${GCRYPT_LIBRARIES}
808                 ${APPLE_COCOA_LIBRARY}
809         )
810         set(capinfos_FILES
811                 capinfos.c
812                 ${WTAP_PLUGIN_SOURCES}
813         )
814         add_executable(capinfos ${capinfos_FILES})
815         add_dependencies(capinfos svnversion)
816         set_target_properties(capinfos PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
817         target_link_libraries(capinfos ${capinfos_LIBS})
818         install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
819 endif()
820
821 if(BUILD_editcap)
822         set(editcap_LIBS
823                 wiretap
824                 ${ZLIB_LIBRARIES}
825         )
826         set(editcap_FILES
827                 editcap.c
828                 epan/crypt/md5.c
829                 epan/nstime.c
830                 ${WTAP_PLUGIN_SOURCES}
831         )
832         add_executable(editcap ${editcap_FILES})
833         add_dependencies(editcap svnversion)
834         set_target_properties(editcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
835         target_link_libraries(editcap ${editcap_LIBS})
836         install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
837 endif()
838
839 if(BUILD_dumpcap AND PCAP_FOUND)
840         set(dumpcap_LIBS
841 #               @INET_NTOP_LO@
842                 wsutil
843                 ${PCAP_LIBRARIES}
844                 ${CAP_LIBRARIES}
845 #               @SOCKET_LIBS@
846 #               @NSL_LIBS@
847                 ${GLIB2_LIBRARIES}
848                 ${GTHREAD2_LIBRARIES}
849                 ${ZLIB_LIBRARIES}
850                 ${APPLE_COCOA_LIBRARY}
851         )
852         set(dumpcap_FILES
853                 svnversion.h
854                 capture_opts.c
855                 capture-pcap-util.c
856                 capture_stop_conditions.c
857                 clopts_common.c
858                 conditions.c
859                 dumpcap.c
860                 pcapio.c
861                 ringbuffer.c
862                 sync_pipe_write.c
863                 tempfile.c
864                 version_info.c
865                 ${PLATFORM_SRC}
866         )
867         add_executable(dumpcap ${dumpcap_FILES})
868         add_dependencies(dumpcap svnversion)
869         set_target_properties(dumpcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
870         target_link_libraries(dumpcap ${dumpcap_LIBS})
871         install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
872 endif()
873
874 ADD_CUSTOM_COMMAND(
875         OUTPUT  ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
876         COMMAND ${PERL}
877                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
878                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
879                 < ${CMAKE_SOURCE_DIR}/AUTHORS
880                 > ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
881         DEPENDS
882                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
883                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
884                 ${CMAKE_SOURCE_DIR}/AUTHORS
885 )
886
887 ADD_CUSTOM_COMMAND(
888         OUTPUT  ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
889                 ${CMAKE_BINARY_DIR}/wireshark.pod
890         COMMAND ${PERL}
891                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
892                 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
893                 < ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
894                 > ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
895         COMMAND cat
896                 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
897                 ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
898                 > ${CMAKE_BINARY_DIR}/wireshark.pod
899         DEPENDS
900                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
901                 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
902                 ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
903                 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
904 )
905
906 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/capinfos 1 )
907 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dftest 1 )
908 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dumpcap 1 )
909 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/editcap 1 )
910 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/idl2wrs 1 )
911 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/mergecap 1 )
912 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/randpkt 1 )
913 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/rawshark 1 )
914 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/text2pcap 1 )
915 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/tshark 1 )
916 pod2manhtml( wireshark 1 )
917 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/wireshark-filter 4 )
918
919 add_custom_target(
920         auxiliary ALL
921         DEPENDS
922                 AUTHORS-SHORT
923                 capinfos.html
924                 dftest.html
925                 dumpcap.html
926                 editcap.html
927                 idl2wrs.html
928                 mergecap.html
929                 randpkt.html
930                 rawshark.html
931                 text2pcap.html
932                 tshark.html
933                 wireshark.html
934                 wireshark-filter.html
935 )
936
937 set(MAN1_FILES
938         ${CMAKE_BINARY_DIR}/capinfos.1
939         ${CMAKE_BINARY_DIR}/dftest.1
940         ${CMAKE_BINARY_DIR}/dumpcap.1
941         ${CMAKE_BINARY_DIR}/editcap.1
942         ${CMAKE_BINARY_DIR}/idl2wrs.1
943         ${CMAKE_BINARY_DIR}/mergecap.1
944         ${CMAKE_BINARY_DIR}/randpkt.1
945         ${CMAKE_BINARY_DIR}/rawshark.1
946         ${CMAKE_BINARY_DIR}/text2pcap.1
947         ${CMAKE_BINARY_DIR}/tshark.1
948         ${CMAKE_BINARY_DIR}/wireshark.1
949 )
950
951 set(MAN4_FILES
952         ${CMAKE_BINARY_DIR}/wireshark-filter.4
953 )
954
955 set(CLEAN_FILES
956         ${wireshark_FILES}
957         ${tshark_FILES}
958         ${rawshark_FILES}
959         ${dftest_FILES}
960         ${randpkt_FILES}
961         ${text2pcap_CLEAN_FILES}
962         ${mergecap_FILES}
963         ${capinfos_FILES}
964         ${editcap_FILES}
965         ${dumpcap_FILES}
966 )
967
968 if (WERROR)
969         set_source_files_properties(
970                 ${CLEAN_FILES}
971                 PROPERTIES
972                 COMPILE_FLAGS -Werror
973         )
974 endif()
975
976 install(
977         FILES
978                 ${INSTALL_FILES}
979         DESTINATION
980                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
981 )
982
983 install(
984         FILES
985                 ${MAN1_FILES}
986         DESTINATION
987                 ${CMAKE_INSTALL_MANDIR}/man1
988 )
989
990 install(
991         FILES
992                 ${MAN4_FILES}
993         DESTINATION
994                 ${CMAKE_INSTALL_MANDIR}/man4
995 )
996
997 install(
998         DIRECTORY
999                 ${INSTALL_DIRS}
1000         DIRECTORY_PERMISSIONS
1001                 OWNER_EXECUTE OWNER_WRITE OWNER_READ
1002                 GROUP_EXECUTE GROUP_READ
1003                 WORLD_EXECUTE WORLD_READ
1004         DESTINATION
1005                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
1006         PATTERN ".svn" EXCLUDE
1007         PATTERN "Makefile.*" EXCLUDE
1008         PATTERN "faq.py" EXCLUDE
1009 )