Add frame_data_sequence.c.
[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 #       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         set(WS_MSVC_NORETURN "__declspec(noreturn)")
438
439         # Disable deprecation
440         if(MSVC80 OR MSVC90)
441                 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
442         endif()
443 else()
444         set(WS_MSVC_NORETURN " ")
445 endif()
446
447 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
448
449 include(FeatureSummary)
450 #SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ]
451 PRINT_ENABLED_FEATURES()
452 PRINT_DISABLED_FEATURES()
453
454 link_directories(
455         ${CMAKE_BINARY_DIR}/gtk
456         ${CMAKE_BINARY_DIR}/codecs
457         ${CMAKE_BINARY_DIR}/epan
458         ${CMAKE_BINARY_DIR}/wiretap
459         ${CMAKE_BINARY_DIR}/wsutil
460 )
461
462 ADD_CUSTOM_TARGET(
463         svnversion ALL
464         COMMAND ${PERL}
465                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
466                 ${CMAKE_CURRENT_SOURCE_DIR}
467         DEPENDS
468                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
469 )
470
471 ADD_CUSTOM_COMMAND(
472         OUTPUT  svnversion.h
473         COMMAND ${PERL}
474                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
475                 ${CMAKE_CURRENT_SOURCE_DIR}
476         DEPENDS
477                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
478 )
479
480 register_tap_files(tshark-tap-register.c
481         ${TSHARK_TAP_SRC}
482 )
483
484 ADD_CUSTOM_COMMAND(
485         OUTPUT  ps.c
486         COMMAND ${PYTHON_EXECUTABLE}
487                 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
488                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
489                 ps.c
490         DEPENDS
491                 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
492                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
493 )
494
495 if(UNIX)
496         set(PLATFORM_SRC
497                 capture-pcap-util-unix.c
498         )
499 endif()
500
501 if(WIN32)
502         set(PLATFORM_SRC
503                 capture-wpcap.c capture_wpcap_packet.c
504         )
505 endif()
506
507 set(WTAP_PLUGIN_SOURCES
508         epan/plugins.c
509         epan/report_err.c
510         epan/filesystem.c
511 )
512
513 set(SHARK_COMMON_CAPTURE_SRC
514         capture_errs.c
515         capture_ifinfo.c
516         capture_ui_utils.c
517 )
518
519 set(WIRESHARK_COMMON_SRC
520         ${PLATFORM_SRC}
521         capture-pcap-util.c
522         cfile.c
523         clopts_common.c
524         disabled_protos.c
525         frame_data_sequence.c
526         packet-range.c
527         print.c
528         ps.c
529         svnversion.h
530         sync_pipe_write.c
531         timestats.c
532         util.c
533         tap-megaco-common.c
534         tap-rtp-common.c
535         version_info.c
536 )
537
538 set(TSHARK_TAP_SRC
539         tap-afpstat.c
540         tap-ansi_astat.c
541         tap-bootpstat.c
542         tap-camelcounter.c
543         tap-camelsrt.c
544         tap-comparestat.c
545         tap-dcerpcstat.c
546         tap-diameter-avp.c
547         tap-funnel.c
548         tap-gsm_astat.c
549         tap-h225counter.c
550         tap-h225rassrt.c
551         tap-httpstat.c
552         tap-icmpstat.c
553         tap-icmpv6stat.c
554         tap-iostat.c
555         tap-iousers.c
556         tap-mgcpstat.c
557         tap-megacostat.c
558         tap-protocolinfo.c
559         tap-protohierstat.c
560         tap-radiusstat.c
561         tap-rpcstat.c
562         tap-rpcprogs.c
563         tap-rtp.c
564         tap-scsistat.c
565         tap-sctpchunkstat.c
566         tap-sipstat.c
567         tap-smbsids.c
568         tap-smbstat.c
569         tap-stats_tree.c
570         tap-sv.c
571         tap-wspstat.c
572 )
573
574 set(INSTALL_DIRS
575         diameter
576         docbook
577         dtds
578         help
579         radius
580         tpncp
581         wimaxasncp
582 )
583
584 set(INSTALL_FILES
585         ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
586         COPYING
587         ${CMAKE_BINARY_DIR}/capinfos.html
588         cfilters
589         colorfilters
590         dfilters
591         ${CMAKE_BINARY_DIR}/dftest.html
592         ${CMAKE_BINARY_DIR}/dumpcap.html
593         ${CMAKE_BINARY_DIR}/editcap.html
594         ${CMAKE_BINARY_DIR}/idl2wrs.html
595         ipmap.html
596         manuf
597         ${CMAKE_BINARY_DIR}/mergecap.html
598         ${CMAKE_BINARY_DIR}/randpkt.html
599         ${CMAKE_BINARY_DIR}/rawshark.html
600         services
601         smi_modules
602         ${CMAKE_BINARY_DIR}/text2pcap.html
603         ${CMAKE_BINARY_DIR}/tshark.html
604         ${CMAKE_BINARY_DIR}/wireshark-filter.html
605         ${CMAKE_BINARY_DIR}/wireshark.html
606         docbook/ws.css
607 )
608
609 set(LIBEPAN_LIBS
610 #               @NSL_LIBS@      # -lnsl
611 #               @SOCKET_LIBS@   # -lsocket
612 #               @SSL_LIBS@      # -lcrypto
613                 epan
614 #               $(plugin_ldadd) # in case of static
615                 ${PCRE_LIBRARIES}
616                 ${PCAP_LIBRARIES}
617                 ${CARES_LIBRARIES}
618                 ${ADNS_LIBRARIES}
619                 ${KERBEROS_LIBRARIES}
620                 ${LUA_LIBRARIES}
621                 ${PYTHON_LIBRARIES}
622                 ${GEOIP_LIBRARIES}
623                 ${GCRYPT_LIBRARIES}
624                 ${GNUTLS_LIBRARIES}
625                 ${SMI_LIBRARIES}
626                 ${ZLIB_LIBRARIES}
627                 ${M_LIBRARIES}
628 )
629
630 if(BUILD_wireshark AND GTK2_FOUND)
631         set(wireshark_LIBS
632                 ui
633                 ${GTK2_LIBRARIES}
634                 codecs
635                 ${PORTAUDIO_LIBRARIES}
636                 ${LIBEPAN_LIBS}
637                 ${APPLE_CORE_SERVICES_LIBRARY}
638                 ${APPLE_COCOA_LIBRARY}
639         )
640         set(wireshark_FILES
641                 airpcap_loader.c
642                 alert_box.c
643                 capture.c
644                 capture_info.c
645                 capture_opts.c
646                 capture_sync.c
647                 color_filters.c
648                 file.c
649                 fileset.c
650                 filters.c
651                 g711.c
652                 merge.c
653                 proto_hier_stats.c
654                 summary.c
655                 tempfile.c
656                 u3.c
657                 ${SHARK_COMMON_CAPTURE_SRC}
658                 ${WIRESHARK_COMMON_SRC}
659         )
660         add_executable(wireshark ${wireshark_FILES})
661         add_dependencies(wireshark svnversion)
662         set_target_properties(wireshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
663         target_link_libraries(wireshark ${wireshark_LIBS})
664         install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
665 endif()
666
667 if(BUILD_tshark)
668         set(tshark_LIBS
669                 ${LIBEPAN_LIBS}
670                 ${APPLE_COCOA_LIBRARY}
671         )
672         set(tshark_FILES
673                 capture_opts.c
674                 capture_sync.c
675                 tempfile.c
676                 tshark-tap-register.c
677                 tshark.c
678                 ${TSHARK_TAP_SRC}
679                 ${SHARK_COMMON_CAPTURE_SRC}
680                 ${WIRESHARK_COMMON_SRC}
681         )
682         add_executable(tshark ${tshark_FILES})
683         add_dependencies(tshark svnversion)
684         set_target_properties(tshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
685         target_link_libraries(tshark ${tshark_LIBS})
686         install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
687 endif()
688
689 if(BUILD_rawshark)
690         set(rawshark_LIBS
691                 ${LIBEPAN_LIBS}
692                 ${APPLE_COCOA_LIBRARY}
693         )
694         set(rawshark_FILES
695                 ${WIRESHARK_COMMON_SRC}
696                 rawshark.c
697         )
698         add_executable(rawshark ${rawshark_FILES})
699         add_dependencies(rawshark svnversion)
700         set_target_properties(rawshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
701         target_link_libraries(rawshark ${rawshark_LIBS})
702         install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
703 endif()
704
705 if(BUILD_dftest)
706         set(dftest_LIBS
707                 ${LIBEPAN_LIBS}
708         )
709         set(dftest_FILES
710                 dftest.c
711                 util.c
712         )
713         add_executable(dftest ${dftest_FILES})
714         set_target_properties(dftest PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
715         target_link_libraries(dftest ${dftest_LIBS})
716         install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
717 endif()
718
719 if(BUILD_randpkt)
720         set(randpkt_LIBS
721                 wiretap
722                 ${M_LIBRARIES}
723                 ${PCAP_LIBRARIES}
724 #               @SOCKET_LIBS@
725 #               @NSL_LIBS@
726                 ${CARES_LIBRARIES}
727                 ${ADNS_LIBRARIES}
728                 ${ZLIB_LIBRARIES}
729         )
730         set(randpkt_FILES
731                 randpkt.c
732         )
733         add_executable(randpkt ${randpkt_FILES})
734         set_target_properties(randpkt PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
735         target_link_libraries(randpkt ${randpkt_LIBS})
736         install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
737 endif()
738
739 if(BUILD_text2pcap)
740         set(text2pcap_LIBS
741                 wiretap
742                 ${M_LIBRARIES}
743                 ${ZLIB_LIBRARIES}
744         )
745         set(text2pcap_CLEAN_FILES
746                 text2pcap.c
747         )
748         set(text2pcap_FILES
749                 ${text2pcap_CLEAN_FILES}
750         )
751         add_lex_files(text2pcap_FILES
752                 text2pcap-scanner.l
753         )
754         add_executable(text2pcap ${text2pcap_FILES})
755         add_dependencies(text2pcap svnversion)
756         set_target_properties(text2pcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
757         target_link_libraries(text2pcap ${text2pcap_LIBS})
758         install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
759 endif()
760
761 if(BUILD_mergecap)
762         set(mergecap_LIBS
763                 wiretap
764                 ${ZLIB_LIBRARIES}
765         )
766         set(mergecap_FILES
767                 mergecap.c
768                 merge.c
769                 svnversion.h
770         )
771         add_executable(mergecap ${mergecap_FILES})
772         add_dependencies(mergecap svnversion)
773         set_target_properties(mergecap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
774         target_link_libraries(mergecap ${mergecap_LIBS})
775         install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
776 endif()
777
778 if(BUILD_capinfos)
779         set(capinfos_LIBS
780                 wiretap
781                 ${ZLIB_LIBRARIES}
782                 ${GCRYPT_LIBRARIES}
783                 ${APPLE_COCOA_LIBRARY}
784         )
785         set(capinfos_FILES
786                 capinfos.c
787                 ${WTAP_PLUGIN_SOURCES}
788         )
789         add_executable(capinfos ${capinfos_FILES})
790         add_dependencies(capinfos svnversion)
791         set_target_properties(capinfos PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
792         target_link_libraries(capinfos ${capinfos_LIBS})
793         install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
794 endif()
795
796 if(BUILD_editcap)
797         set(editcap_LIBS
798                 wiretap
799                 ${ZLIB_LIBRARIES}
800         )
801         set(editcap_FILES
802                 editcap.c
803                 epan/crypt/crypt-md5.c
804                 epan/nstime.c
805                 ${WTAP_PLUGIN_SOURCES}
806         )
807         add_executable(editcap ${editcap_FILES})
808         add_dependencies(editcap svnversion)
809         set_target_properties(editcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
810         target_link_libraries(editcap ${editcap_LIBS})
811         install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
812 endif()
813
814 if(BUILD_dumpcap)
815         set(dumpcap_LIBS
816 #               @INET_NTOP_LO@
817                 wsutil
818                 ${PCAP_LIBRARIES}
819                 ${CAP_LIBRARIES}
820 #               @SOCKET_LIBS@
821 #               @NSL_LIBS@
822                 ${GLIB2_LIBRARIES}
823                 ${ZLIB_LIBRARIES}
824                 ${APPLE_COCOA_LIBRARY}
825         )
826         set(dumpcap_FILES
827                 svnversion.h
828                 capture_opts.c
829                 capture-pcap-util.c
830                 capture_stop_conditions.c
831                 clopts_common.c
832                 conditions.c
833                 dumpcap.c
834                 pcapio.c
835                 ringbuffer.c
836                 sync_pipe_write.c
837                 tempfile.c
838                 version_info.c
839                 ${PLATFORM_SRC}
840         )
841         add_executable(dumpcap ${dumpcap_FILES})
842         add_dependencies(dumpcap svnversion)
843         set_target_properties(dumpcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
844         target_link_libraries(dumpcap ${dumpcap_LIBS})
845         install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
846 endif()
847
848 ADD_CUSTOM_COMMAND(
849         OUTPUT  ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
850         COMMAND ${PERL}
851                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
852                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
853                 < ${CMAKE_SOURCE_DIR}/AUTHORS
854                 > ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
855         DEPENDS
856                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
857                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
858                 ${CMAKE_SOURCE_DIR}/AUTHORS
859 )
860
861 ADD_CUSTOM_COMMAND(
862         OUTPUT  ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
863                 ${CMAKE_BINARY_DIR}/wireshark.pod
864         COMMAND ${PERL}
865                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
866                 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
867                 < ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
868                 > ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
869         COMMAND cat
870                 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
871                 ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
872                 > ${CMAKE_BINARY_DIR}/wireshark.pod
873         DEPENDS
874                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
875                 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
876                 ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
877                 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
878 )
879
880 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/capinfos 1 )
881 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dftest 1 )
882 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dumpcap 1 )
883 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/editcap 1 )
884 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/idl2wrs 1 )
885 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/mergecap 1 )
886 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/randpkt 1 )
887 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/rawshark 1 )
888 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/text2pcap 1 )
889 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/tshark 1 )
890 pod2manhtml( wireshark 1 )
891 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/wireshark-filter 4 )
892
893 add_custom_target(
894         auxiliary ALL
895         DEPENDS
896                 AUTHORS-SHORT
897                 capinfos.html
898                 dftest.html
899                 dumpcap.html
900                 editcap.html
901                 idl2wrs.html
902                 mergecap.html
903                 randpkt.html
904                 rawshark.html
905                 text2pcap.html
906                 tshark.html
907                 wireshark.html
908                 wireshark-filter.html
909 )
910
911 set(MAN1_FILES
912         ${CMAKE_BINARY_DIR}/capinfos.1
913         ${CMAKE_BINARY_DIR}/dftest.1
914         ${CMAKE_BINARY_DIR}/dumpcap.1
915         ${CMAKE_BINARY_DIR}/editcap.1
916         ${CMAKE_BINARY_DIR}/idl2wrs.1
917         ${CMAKE_BINARY_DIR}/mergecap.1
918         ${CMAKE_BINARY_DIR}/randpkt.1
919         ${CMAKE_BINARY_DIR}/rawshark.1
920         ${CMAKE_BINARY_DIR}/text2pcap.1
921         ${CMAKE_BINARY_DIR}/tshark.1
922         ${CMAKE_BINARY_DIR}/wireshark.1
923 )
924
925 set(MAN4_FILES
926         ${CMAKE_BINARY_DIR}/wireshark-filter.4
927 )
928
929 set(CLEAN_FILES
930         ${wireshark_FILES}
931         ${tshark_FILES}
932         ${rawshark_FILES}
933         ${dftest_FILES}
934         ${randpkt_FILES}
935         ${text2pcap_CLEAN_FILES}
936         ${mergecap_FILES}
937         ${capinfos_FILES}
938         ${editcap_FILES}
939         ${dumpcap_FILES}
940 )
941
942 if (WERROR)
943         set_source_files_properties(
944                 ${CLEAN_FILES}
945                 PROPERTIES
946                 COMPILE_FLAGS -Werror
947         )
948 endif()
949
950 install(
951         FILES
952                 ${INSTALL_FILES}
953         DESTINATION
954                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
955 )
956
957 install(
958         FILES
959                 ${MAN1_FILES}
960         DESTINATION
961                 ${CMAKE_INSTALL_MANDIR}/man1
962 )
963
964 install(
965         FILES
966                 ${MAN4_FILES}
967         DESTINATION
968                 ${CMAKE_INSTALL_MANDIR}/man4
969 )
970
971 install(
972         DIRECTORY
973                 ${INSTALL_DIRS}
974         DIRECTORY_PERMISSIONS
975                 OWNER_EXECUTE OWNER_WRITE OWNER_READ
976                 GROUP_EXECUTE GROUP_READ
977                 WORLD_EXECUTE WORLD_READ
978         DESTINATION
979                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
980         PATTERN ".svn" EXCLUDE
981         PATTERN "Makefile.*" EXCLUDE
982         PATTERN "faq.py" EXCLUDE
983 )