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