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