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