As reported by Michael Speck:
[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 GTHREAD2 M LEX YACC Perl SH PythonInterp)
231 set(GLIB2_FIND_REQUIRED)
232 set(GLIB2_MIN_VERSION 2.14.0)
233 set(GTHREAD2_REQUIRED)
234 set(PCAP_REQUIRED)
235 set(M_REQUIRED)
236
237 set(PACKAGELIST ${PACKAGELIST} HtmlViewer)
238
239 if(ENABLE_PCAP)
240         set(PACKAGELIST ${PACKAGELIST} PCAP)
241 endif()
242
243 #Build the gui ?
244 if(BUILD_wireshark)
245         if(ENABLE_GTK3)
246                 set(PACKAGELIST ${PACKAGELIST} GTK3)
247         else()
248                 set(PACKAGELIST ${PACKAGELIST} GTK2)
249                 set(GTK2_OPTIONS COMPONENTS gtk)
250                 set(GTK2_FIND_VERSION 2.12)
251                 set(GTK2_DEBUG false)
252         endif()
253 endif()
254
255 # SMI SNMP
256 if(ENABLE_SMI)
257         set(PACKAGELIST ${PACKAGELIST} SMI)
258 endif()
259
260 # GNU crypto
261 if(ENABLE_GCRYPT)
262         set(PACKAGELIST ${PACKAGELIST} GCRYPT)
263 endif()
264
265 # GNU SSL/TLS support
266 if(ENABLE_GNUTLS)
267         set(PACKAGELIST ${PACKAGELIST} GNUTLS)
268 endif()
269
270 # Kerberos
271 if(ENABLE_KERBEROS)
272         set(PACKAGELIST ${PACKAGELIST} KERBEROS)
273 endif()
274
275 # Portable audio
276 if(ENABLE_PORTAUDIO)
277         set(PACKAGELIST ${PACKAGELIST} PORTAUDIO)
278 endif()
279
280
281 # Prefer c-ares over adns
282 if(ENABLE_CARES)        # C Asynchronouse resolver
283         set(PACKAGELIST ${PACKAGELIST} CARES)
284 elseif(ENABLE_ADNS)     # Gnu asynchronous DNS
285         set(PACKAGELIST ${PACKAGELIST} ADNS)
286 endif()
287
288 # Zlib compression
289 if(ENABLE_ZLIB)
290         set(PACKAGELIST ${PACKAGELIST} ZLIB)
291 endif()
292
293 # Lua 5.1 dissectors
294 if(ENABLE_LUA)
295         set(PACKAGELIST ${PACKAGELIST} LUA)
296 endif()
297
298 # GeoIP address resolving
299 if(ENABLE_GEOIP)
300         set(PACKAGELIST ${PACKAGELIST} GEOIP)
301 endif()
302
303 # Capabilities
304 if(ENABLE_CAP)
305         set(PACKAGELIST ${PACKAGELIST} CAP)
306 endif()
307
308 if(ENABLE_PYTHON)
309         set(PACKAGELIST ${PACKAGELIST} PYTHON)
310 endif()
311
312 set(PACKAGELIST ${PACKAGELIST} YAPP)
313
314 set(PACKAGELIST ${PACKAGELIST} POD)
315
316
317 set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
318
319 #Let's loop the package list
320 foreach(PACKAGE ${PACKAGELIST})
321         if(${PACKAGE}_OPTIONS)
322                 find_package(${PACKAGE} ${${PACKAGE}_OPTIONS})
323         elseif(${PACKAGE}_REQUIRED)
324                 find_package(${PACKAGE} REQUIRED)
325         else()
326                 find_package(${PACKAGE})
327         endif()
328         message(${PACKAGE}_FOUND)
329         if (${PACKAGE}_FOUND)
330                 set(HAVE_LIB${PACKAGE} 1)
331                 include_directories(${${PACKAGE}_INCLUDE_DIRS})
332                 message(STATUS "${PACKAGE} includes: ${${PACKAGE}_INCLUDE_DIRS}")
333                 message(STATUS "${PACKAGE} libs: ${${PACKAGE}_LIBRARIES}")
334         endif()
335 endforeach()
336
337 #packaging
338 include(CPackConfig.txt)
339
340 if(HAVE_LIBPYTHON)
341         set(HAVE_PYTHON 1)
342         set(PYTHON_DIR "${CMAKE_INSTALL_PREFIX}/lib/wireshark/python/${CPACK_PACKAGE_VERSION}")
343 endif()
344 if(HAVE_LIBLUA)
345         set(HAVE_LUA_H 1)
346         set(HAVE_LUA_5_1 1)
347 endif()
348 if(HAVE_LIBKERBEROS)
349         set(HAVE_KERBEROS 1)
350         # HAVE_HEIMDAL_KERBEROS
351         set(HAVE_MIT_KERBEROS 1)
352         set(HAVE_KEYTYPE_ARCFOUR_56 1)
353 endif()
354 if(HAVE_LIBGEOIP)
355         set(HAVE_GEOIP 1)
356 endif()
357 if(HAVE_LIBCARES)
358         set(HAVE_C_ARES 1)
359 endif()
360 if(HAVE_LIBADNS)
361         set(HAVE_GNU_ADNS 1)
362 endif()
363 if(ENABLE_AIRPCAP)
364         set(HAVE_AIRPCAP 1)
365 endif()
366 # No matter which version of GTK is present
367 if(GTK2_FOUND OR GTK3_FOUND)
368         set(GTK_FOUND ON)
369 endif()
370 # That's the name autofoo uses
371 if(HAVE_LIBZLIB)
372         set(HAVE_LIBZ 1)
373 endif()
374
375 include(ConfigureChecks.cmake)
376
377 #Big or little endian ?
378 include(TestBigEndian)
379 test_big_endian(WORDS_BIGENDIAN)
380
381 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
382
383 if(ENABLE_PLUGINS)
384         set(HAVE_PLUGINS 1)
385         set(PLUGIN_DIR="${DATAFILE_DIR}/plugins/${CPACK_PACKAGE_VERSION}")
386         set(PLUGIN_SRC_DIRS
387                 plugins/asn1
388                 plugins/docsis
389                 plugins/ethercat
390                 plugins/giop
391                 plugins/gryphon
392                 plugins/irda
393                 plugins/m2m
394                 plugins/mate
395                 plugins/opcua
396                 plugins/profinet
397                 plugins/stats_tree
398                 plugins/unistim
399                 plugins/wimax
400                 plugins/wimaxasncp
401         )
402 # It seems this stuff doesn't build with autofoo either...
403 #       if(YAPP_FOUND)
404 #               set(PLUGIN_SRC_DIRS
405 #                       ${PLUGIN_SRC_DIRS}
406 #                       plugins/tpg
407 #               )
408 #       endif()
409 else()
410         set(PLUGIN_SRC_DIRS )
411 endif()
412
413 foreach(PLUGIN_DIR ${PLUGIN_SRC_DIRS})
414         add_subdirectory( ${PLUGIN_DIR} )
415 endforeach()
416
417 add_subdirectory( codecs )
418 add_subdirectory( epan )
419 add_subdirectory( tools/lemon )
420 add_subdirectory( wiretap )
421 add_subdirectory( wsutil )
422
423 if(BUILD_wireshark AND GTK_FOUND)
424         add_subdirectory( gtk )
425 endif()
426
427 # Basedir where to install guides
428 set(DOC_DIR "$ENV{docdir}")
429 message(STATUS "docdir: ${DOC_DIR}")
430
431 if(ENABLE_GUIDES)
432         add_subdirectory( docbook )
433 endif()
434
435 if(ENABLE_PCAP_NG_DEFAULT)
436         set(PCAP_NG_DEFAULT 1)
437 endif()
438
439 #Platform specific
440 if(UNIX)
441         set(WS_VAR_IMPORT "extern")
442 endif()
443
444 if(APPLE)
445 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
446         set(HAVE_OS_X_FRAMEWORKS 1)
447         FIND_LIBRARY (APPLE_CORE_SERVICES_LIBRARY CoreServices)
448         FIND_LIBRARY (APPLE_COCOA_LIBRARY Cocoa)
449 endif()
450
451 if(WIN32)
452         add_definitions(-D_NEED_VAR_IMPORT_)
453         set(WS_VAR_IMPORT "__declspec(dllimport) extern")
454         set(WS_MSVC_NORETURN "__declspec(noreturn)")
455
456         # Disable deprecation
457         if(MSVC80 OR MSVC90)
458                 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
459         endif()
460 else()
461         set(WS_MSVC_NORETURN " ")
462 endif()
463
464 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
465
466 include(FeatureSummary)
467 #SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ]
468 PRINT_ENABLED_FEATURES()
469 PRINT_DISABLED_FEATURES()
470
471 link_directories(
472         ${CMAKE_BINARY_DIR}/gtk
473         ${CMAKE_BINARY_DIR}/codecs
474         ${CMAKE_BINARY_DIR}/epan
475         ${CMAKE_BINARY_DIR}/wiretap
476         ${CMAKE_BINARY_DIR}/wsutil
477 )
478
479 ADD_CUSTOM_TARGET(
480         svnversion ALL
481         COMMAND ${PERL}
482                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
483                 ${CMAKE_CURRENT_SOURCE_DIR}
484         DEPENDS
485                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
486 )
487
488 ADD_CUSTOM_COMMAND(
489         OUTPUT  svnversion.h
490         COMMAND ${PERL}
491                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
492                 ${CMAKE_CURRENT_SOURCE_DIR}
493         DEPENDS
494                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
495 )
496
497 register_tap_files(tshark-tap-register.c
498         ${TSHARK_TAP_SRC}
499 )
500
501 ADD_CUSTOM_COMMAND(
502         OUTPUT  ps.c
503         COMMAND ${PYTHON_EXECUTABLE}
504                 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
505                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
506                 ps.c
507         DEPENDS
508                 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
509                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
510 )
511
512 if(UNIX)
513         set(PLATFORM_SRC
514                 capture-pcap-util-unix.c
515         )
516 endif()
517
518 if(WIN32)
519         set(PLATFORM_SRC
520                 capture-wpcap.c capture_wpcap_packet.c
521         )
522 endif()
523
524 set(WTAP_PLUGIN_SOURCES
525         epan/plugins.c
526         epan/report_err.c
527         epan/filesystem.c
528 )
529
530 set(SHARK_COMMON_CAPTURE_SRC
531         capture_errs.c
532         capture_ifinfo.c
533         capture_ui_utils.c
534 )
535
536 set(WIRESHARK_COMMON_SRC
537         ${PLATFORM_SRC}
538         capture-pcap-util.c
539         cfile.c
540         clopts_common.c
541         disabled_protos.c
542         frame_data_sequence.c
543         packet-range.c
544         print.c
545         ps.c
546         svnversion.h
547         sync_pipe_write.c
548         timestats.c
549         util.c
550         tap-megaco-common.c
551         tap-rtp-common.c
552         version_info.c
553 )
554
555 set(TSHARK_TAP_SRC
556         tap-afpstat.c
557         tap-ansi_astat.c
558         tap-bootpstat.c
559         tap-camelcounter.c
560         tap-camelsrt.c
561         tap-comparestat.c
562         tap-dcerpcstat.c
563         tap-diameter-avp.c
564         tap-expert.c
565         tap-funnel.c
566         tap-gsm_astat.c
567         tap-h225counter.c
568         tap-h225rassrt.c
569         tap-hosts.c
570         tap-httpstat.c
571         tap-icmpstat.c
572         tap-icmpv6stat.c
573         tap-iostat.c
574         tap-iousers.c
575         tap-macltestat.c
576         tap-mgcpstat.c
577         tap-megacostat.c
578         tap-protocolinfo.c
579         tap-protohierstat.c
580         tap-radiusstat.c
581         tap-rlcltestat.c
582         tap-rpcstat.c
583         tap-rpcprogs.c
584         tap-rtp.c
585         tap-rtspstat.c
586         tap-scsistat.c
587         tap-sctpchunkstat.c
588         tap-sipstat.c
589         tap-smbsids.c
590         tap-smbstat.c
591         tap-stats_tree.c
592         tap-sv.c
593         tap-wspstat.c
594 )
595
596 set(INSTALL_DIRS
597         diameter
598         docbook
599         dtds
600         help
601         radius
602         tpncp
603         wimaxasncp
604 )
605
606 set(INSTALL_FILES
607         ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
608         COPYING
609         ${CMAKE_BINARY_DIR}/capinfos.html
610         cfilters
611         colorfilters
612         dfilters
613         ${CMAKE_BINARY_DIR}/dftest.html
614         ${CMAKE_BINARY_DIR}/dumpcap.html
615         ${CMAKE_BINARY_DIR}/editcap.html
616         ${CMAKE_BINARY_DIR}/idl2wrs.html
617         ipmap.html
618         manuf
619         ${CMAKE_BINARY_DIR}/mergecap.html
620         pdml2html.xsl
621         ${CMAKE_BINARY_DIR}/randpkt.html
622         ${CMAKE_BINARY_DIR}/rawshark.html
623         services
624         smi_modules
625         ${CMAKE_BINARY_DIR}/text2pcap.html
626         ${CMAKE_BINARY_DIR}/tshark.html
627         ${CMAKE_BINARY_DIR}/wireshark-filter.html
628         ${CMAKE_BINARY_DIR}/wireshark.html
629         docbook/ws.css
630 )
631
632 set(LIBEPAN_LIBS
633 #               @NSL_LIBS@      # -lnsl
634 #               @SOCKET_LIBS@   # -lsocket
635 #               @SSL_LIBS@      # -lcrypto
636                 epan
637 #               $(plugin_ldadd) # in case of static
638                 ${PCAP_LIBRARIES}
639                 ${CARES_LIBRARIES}
640                 ${ADNS_LIBRARIES}
641                 ${KERBEROS_LIBRARIES}
642                 ${LUA_LIBRARIES}
643                 ${PYTHON_LIBRARIES}
644                 ${GEOIP_LIBRARIES}
645                 ${GCRYPT_LIBRARIES}
646                 ${GNUTLS_LIBRARIES}
647                 ${SMI_LIBRARIES}
648                 ${ZLIB_LIBRARIES}
649                 ${M_LIBRARIES}
650 )
651
652 if(BUILD_wireshark AND GTK_FOUND)
653         set(wireshark_LIBS
654                 ui
655                 ${GTK2_LIBRARIES}
656                 ${GTK3_LIBRARIES}
657                 ${GTHREAD2_LIBRARIES}
658                 codecs
659                 ${PORTAUDIO_LIBRARIES}
660                 ${LIBEPAN_LIBS}
661                 ${APPLE_CORE_SERVICES_LIBRARY}
662                 ${APPLE_COCOA_LIBRARY}
663         )
664         set(wireshark_FILES
665                 airpcap_loader.c
666                 alert_box.c
667                 capture.c
668                 capture_info.c
669                 capture_opts.c
670                 capture_sync.c
671                 color_filters.c
672                 file.c
673                 fileset.c
674                 filters.c
675                 g711.c
676                 merge.c
677                 proto_hier_stats.c
678                 summary.c
679                 tempfile.c
680                 u3.c
681                 ${SHARK_COMMON_CAPTURE_SRC}
682                 ${WIRESHARK_COMMON_SRC}
683         )
684         add_executable(wireshark ${wireshark_FILES})
685         add_dependencies(wireshark svnversion)
686         set_target_properties(wireshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
687         target_link_libraries(wireshark ${wireshark_LIBS})
688         install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
689 endif()
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/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 )