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