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