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