From Jim Young, bug 7745.
[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         -DHAVE_CONFIG_H
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         set(WS_VAR_IMPORT "extern")
513 endif()
514
515 if(APPLE)
516 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
517         set(HAVE_OS_X_FRAMEWORKS 1)
518         FIND_LIBRARY (APPLE_CORE_SERVICES_LIBRARY CoreServices)
519         FIND_LIBRARY (APPLE_COCOA_LIBRARY Cocoa)
520 endif()
521
522 if(WIN32)
523         add_definitions(-D_NEED_VAR_IMPORT_)
524         set(WS_VAR_IMPORT "__declspec(dllimport) extern")
525         set(WS_MSVC_NORETURN "__declspec(noreturn)")
526
527         # Disable deprecation
528         if(MSVC80 OR MSVC90)
529                 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
530         endif()
531 else()
532         set(WS_MSVC_NORETURN " ")
533 endif()
534
535 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
536
537 include(FeatureSummary)
538 #SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ]
539 #FEATURE_SUMMARY(WHAT ALL) Requires removal of our local copy of FeatureSummary
540 PRINT_ENABLED_FEATURES()
541 PRINT_DISABLED_FEATURES()
542
543 link_directories(
544         ${CMAKE_BINARY_DIR}/ui
545         ${CMAKE_BINARY_DIR}/ui/gtk
546         ${CMAKE_BINARY_DIR}/ui/qt
547         ${CMAKE_BINARY_DIR}/codecs
548         ${CMAKE_BINARY_DIR}/epan
549         ${CMAKE_BINARY_DIR}/wiretap
550         ${CMAKE_BINARY_DIR}/wsutil
551 )
552
553 ADD_CUSTOM_TARGET(
554         svnversion ALL
555         COMMAND ${PERL}
556                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
557                 ${CMAKE_CURRENT_SOURCE_DIR}
558         DEPENDS
559                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
560 )
561
562 ADD_CUSTOM_COMMAND(
563         OUTPUT  svnversion.h
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  ps.c
573         COMMAND ${PYTHON_EXECUTABLE}
574                 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
575                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
576                 ps.c
577         DEPENDS
578                 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
579                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
580 )
581
582 if(UNIX)
583         set(PLATFORM_SRC
584                 capture-pcap-util-unix.c
585         )
586 endif()
587
588 if(WIN32)
589         set(PLATFORM_SRC
590                 capture-wpcap.c capture_wpcap_packet.c
591         )
592 endif()
593
594 set(WTAP_PLUGIN_SOURCES
595         epan/plugins.c
596         epan/report_err.c
597         epan/filesystem.c
598 )
599
600 set(SHARK_COMMON_CAPTURE_SRC
601         capture_ifinfo.c
602         capture_ui_utils.c
603 )
604
605 set(WIRESHARK_COMMON_SRC
606         ${PLATFORM_SRC}
607         capture-pcap-util.c
608         cfile.c
609         clopts_common.c
610         disabled_protos.c
611         frame_data_sequence.c
612         packet-range.c
613         print.c
614         ps.c
615         svnversion.h
616         sync_pipe_write.c
617         timestats.c
618         tap-megaco-common.c
619         tap-rtp-common.c
620         version_info.c
621 )
622
623 set(TSHARK_TAP_SRC
624         ui/cli/tap-afpstat.c
625         ui/cli/tap-ansi_astat.c
626         ui/cli/tap-bootpstat.c
627         ui/cli/tap-camelcounter.c
628         ui/cli/tap-camelsrt.c
629         ui/cli/tap-comparestat.c
630         ui/cli/tap-dcerpcstat.c
631         ui/cli/tap-diameter-avp.c
632         ui/cli/tap-expert.c
633         ui/cli/tap-follow.c
634         ui/cli/tap-funnel.c
635         ui/cli/tap-gsm_astat.c
636         ui/cli/tap-h225counter.c
637         ui/cli/tap-h225rassrt.c
638         ui/cli/tap-hosts.c
639         ui/cli/tap-httpstat.c
640         ui/cli/tap-icmpstat.c
641         ui/cli/tap-icmpv6stat.c
642         ui/cli/tap-iostat.c
643         ui/cli/tap-iousers.c
644         ui/cli/tap-macltestat.c
645         ui/cli/tap-mgcpstat.c
646         ui/cli/tap-megacostat.c
647         ui/cli/tap-protocolinfo.c
648         ui/cli/tap-protohierstat.c
649         ui/cli/tap-radiusstat.c
650         ui/cli/tap-rlcltestat.c
651         ui/cli/tap-rpcstat.c
652         ui/cli/tap-rpcprogs.c
653         ui/cli/tap-rtp.c
654         ui/cli/tap-rtspstat.c
655         ui/cli/tap-scsistat.c
656         ui/cli/tap-sctpchunkstat.c
657         ui/cli/tap-sipstat.c
658         ui/cli/tap-smbsids.c
659         ui/cli/tap-smbstat.c
660         ui/cli/tap-stats_tree.c
661         ui/cli/tap-sv.c
662         ui/cli/tap-wspstat.c
663 )
664
665 set(INSTALL_DIRS
666         diameter
667         dtds
668         help
669         radius
670         tpncp
671         wimaxasncp
672 )
673
674 set(INSTALL_FILES
675         ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
676         COPYING
677         ${CMAKE_BINARY_DIR}/capinfos.html
678         cfilters
679         colorfilters
680         dfilters
681         ${CMAKE_BINARY_DIR}/dftest.html
682         ${CMAKE_BINARY_DIR}/dumpcap.html
683         ${CMAKE_BINARY_DIR}/editcap.html
684         ${CMAKE_BINARY_DIR}/idl2wrs.html
685         ipmap.html
686         manuf
687         ${CMAKE_BINARY_DIR}/mergecap.html
688         pdml2html.xsl
689         ${CMAKE_BINARY_DIR}/randpkt.html
690         ${CMAKE_BINARY_DIR}/rawshark.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/text2pcap 1 )
1039 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/tshark 1 )
1040 pod2manhtml( wireshark 1 )
1041 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/wireshark-filter 4 )
1042
1043 add_custom_target(
1044         auxiliary ALL
1045         DEPENDS
1046                 AUTHORS-SHORT
1047                 capinfos.html
1048                 dftest.html
1049                 dumpcap.html
1050                 editcap.html
1051                 idl2wrs.html
1052                 mergecap.html
1053                 randpkt.html
1054                 rawshark.html
1055                 text2pcap.html
1056                 tshark.html
1057                 wireshark.html
1058                 wireshark-filter.html
1059 )
1060
1061 set(MAN1_FILES
1062         ${CMAKE_BINARY_DIR}/capinfos.1
1063         ${CMAKE_BINARY_DIR}/dftest.1
1064         ${CMAKE_BINARY_DIR}/dumpcap.1
1065         ${CMAKE_BINARY_DIR}/editcap.1
1066         ${CMAKE_BINARY_DIR}/idl2wrs.1
1067         ${CMAKE_BINARY_DIR}/mergecap.1
1068         ${CMAKE_BINARY_DIR}/randpkt.1
1069         ${CMAKE_BINARY_DIR}/rawshark.1
1070         ${CMAKE_BINARY_DIR}/text2pcap.1
1071         ${CMAKE_BINARY_DIR}/tshark.1
1072         ${CMAKE_BINARY_DIR}/wireshark.1
1073 )
1074
1075 set(MAN4_FILES
1076         ${CMAKE_BINARY_DIR}/wireshark-filter.4
1077 )
1078
1079 set(CLEAN_FILES
1080         ${wireshark_FILES}
1081         ${tshark_FILES}
1082         ${rawshark_FILES}
1083         ${dftest_FILES}
1084         ${randpkt_FILES}
1085         ${text2pcap_CLEAN_FILES}
1086         ${mergecap_FILES}
1087         ${capinfos_FILES}
1088         ${editcap_FILES}
1089         ${dumpcap_FILES}
1090 )
1091
1092 if (WERROR)
1093         set_source_files_properties(
1094                 ${CLEAN_FILES}
1095                 PROPERTIES
1096                 COMPILE_FLAGS -Werror
1097         )
1098 endif()
1099
1100 install(
1101         FILES
1102                 ${INSTALL_FILES}
1103         DESTINATION
1104                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
1105 )
1106
1107 install(
1108         FILES
1109                 ${MAN1_FILES}
1110         DESTINATION
1111                 ${CMAKE_INSTALL_MANDIR}/man1
1112 )
1113
1114 install(
1115         FILES
1116                 ${MAN4_FILES}
1117         DESTINATION
1118                 ${CMAKE_INSTALL_MANDIR}/man4
1119 )
1120
1121 install(
1122         DIRECTORY
1123                 ${INSTALL_DIRS}
1124         DIRECTORY_PERMISSIONS
1125                 OWNER_EXECUTE OWNER_WRITE OWNER_READ
1126                 GROUP_EXECUTE GROUP_READ
1127                 WORLD_EXECUTE WORLD_READ
1128         DESTINATION
1129                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
1130         PATTERN ".svn" EXCLUDE
1131         PATTERN "Makefile.*" EXCLUDE
1132         PATTERN "faq.py" EXCLUDE
1133 )
1134
1135
1136 if(DOC_DIR)
1137         message(STATUS "Docdir install: ${DOC_DIR}")
1138         INSTALL(
1139                 DIRECTORY
1140                         ${CMAKE_BINARY_DIR}/docbook/
1141                 DIRECTORY_PERMISSIONS
1142                         OWNER_EXECUTE OWNER_WRITE OWNER_READ
1143                         GROUP_EXECUTE GROUP_READ
1144                         WORLD_EXECUTE WORLD_READ
1145                 DESTINATION
1146                         ${DOC_DIR}/guides
1147                 FILES_MATCHING
1148                 PATTERN "*.pdf"
1149         )
1150 endif()