Add dumpabi targets to CMake builds
[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 OR CMAKE_CXX_COMPILER MATCHES ".*clang")
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 add_custom_target(dumpabi DEPENDS dumpabi-libwireshark dumpabi-libwiretap dumpabi-libwsutil color.h)
486
487 if((BUILD_wireshark AND GTK_FOUND) OR (BUILD_qtshark AND QT_FOUND))
488         add_subdirectory( ui )
489 endif()
490
491 if(BUILD_wireshark AND GTK_FOUND)
492         add_subdirectory( ui/gtk )
493 endif()
494
495 if(BUILD_qtshark AND QT_FOUND)
496         add_subdirectory( ui/qt )
497 endif()
498
499
500 # Basedir where to install guides
501 set(DOC_DIR "$ENV{docdir}" CACHE FILEPATH "Installation directory for ug and dg pdfs.")
502 message(STATUS "docdir: ${DOC_DIR}")
503
504 if(ENABLE_GUIDES)
505         add_subdirectory( docbook )
506 endif()
507
508 if(ENABLE_PCAP_NG_DEFAULT)
509         set(PCAP_NG_DEFAULT 1)
510 endif()
511
512 #Platform specific
513 if(UNIX)
514         if(CMAKE_COMPILER_IS_GNUCC)
515                 # set(WS_VAR_IMPORT "__attribute__((visibility(\"default\")))" )
516                 set(WS_VAR_IMPORT "extern")
517         else()
518                 set(WS_VAR_IMPORT "extern")
519         endif()
520 endif()
521
522 if(APPLE)
523         #
524         # We assume that APPLE means OS X so that we have the OS X
525         # frameworks.
526         #
527         set(HAVE_OS_X_FRAMEWORKS 1)
528         FIND_LIBRARY (APPLE_APPLICATION_SERVICES_LIBRARY ApplicationServices)
529         FIND_LIBRARY (APPLE_CORE_FOUNDATION_LIBRARY CoreFoundation)
530         FIND_LIBRARY (APPLE_SYSTEM_CONFIGURATION_LIBRARY SystemConfiguration)
531 endif()
532
533 if(WIN32)
534         add_definitions(-D_NEED_VAR_IMPORT_)
535         set(WS_VAR_IMPORT "__declspec(dllimport) extern")
536         set(WS_MSVC_NORETURN "__declspec(noreturn)")
537
538         # Disable deprecation
539         if(MSVC80 OR MSVC90)
540                 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
541         endif()
542 else()
543         set(WS_MSVC_NORETURN " ")
544 endif()
545
546 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
547
548 set( configure_input "Built with CMake ${CMAKE_VERSION}" )
549 set( VERSION ${PROJECT_VERSION} )
550
551 configure_file(
552         ${CMAKE_SOURCE_DIR}/packaging/macosx/Info.plist.in
553         ${CMAKE_SOURCE_DIR}/packaging/macosx/Info.plist
554         @ONLY)
555
556 include(FeatureSummary)
557 #SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ]
558 #FEATURE_SUMMARY(WHAT ALL) Requires removal of our local copy of FeatureSummary
559 PRINT_ENABLED_FEATURES()
560 PRINT_DISABLED_FEATURES()
561
562 link_directories(
563         ${CMAKE_BINARY_DIR}/ui
564         ${CMAKE_BINARY_DIR}/ui/gtk
565         ${CMAKE_BINARY_DIR}/ui/qt
566         ${CMAKE_BINARY_DIR}/codecs
567         ${CMAKE_BINARY_DIR}/epan
568         ${CMAKE_BINARY_DIR}/wiretap
569         ${CMAKE_BINARY_DIR}/wsutil
570 )
571
572 ADD_CUSTOM_TARGET(
573         svnversion ALL
574         COMMAND ${PERL}
575                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
576                 ${CMAKE_CURRENT_SOURCE_DIR}
577         DEPENDS
578                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
579 )
580
581 ADD_CUSTOM_COMMAND(
582         OUTPUT  svnversion.h
583         COMMAND ${PERL}
584                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
585                 ${CMAKE_CURRENT_SOURCE_DIR}
586         DEPENDS
587                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
588 )
589
590 ADD_CUSTOM_COMMAND(
591         OUTPUT  ps.c
592         COMMAND ${PYTHON_EXECUTABLE}
593                 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
594                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
595                 ps.c
596         DEPENDS
597                 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
598                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
599 )
600
601 if(UNIX)
602         set(PLATFORM_SRC
603                 capture-pcap-util-unix.c capture_unix_ifnames.c
604         )
605 endif()
606
607 if(WIN32)
608         set(PLATFORM_SRC
609                 capture-wpcap.c capture_wpcap_packet.c capture_win_ifnames.c
610         )
611 endif()
612
613 set(WTAP_PLUGIN_SOURCES
614         epan/plugins.c
615         epan/report_err.c
616         epan/filesystem.c
617 )
618
619 set(SHARK_COMMON_CAPTURE_SRC
620         capture_ifinfo.c
621         capture_ui_utils.c
622 )
623
624 set(WIRESHARK_COMMON_SRC
625         ${PLATFORM_SRC}
626         capture-pcap-util.c
627         cfile.c
628         cfutils.c
629         clopts_common.c
630         disabled_protos.c
631         frame_data_sequence.c
632         packet-range.c
633         print.c
634         ps.c
635         svnversion.h
636         sync_pipe_write.c
637         timestats.c
638         tap-megaco-common.c
639         tap-rtp-common.c
640         version_info.c
641 )
642
643 set(TSHARK_TAP_SRC
644         ui/cli/tap-afpstat.c
645         ui/cli/tap-ansi_astat.c
646         ui/cli/tap-bootpstat.c
647         ui/cli/tap-camelcounter.c
648         ui/cli/tap-camelsrt.c
649         ui/cli/tap-comparestat.c
650         ui/cli/tap-dcerpcstat.c
651         ui/cli/tap-diameter-avp.c
652         ui/cli/tap-expert.c
653         ui/cli/tap-follow.c
654         ui/cli/tap-funnel.c
655         ui/cli/tap-gsm_astat.c
656         ui/cli/tap-h225counter.c
657         ui/cli/tap-h225rassrt.c
658         ui/cli/tap-hosts.c
659         ui/cli/tap-httpstat.c
660         ui/cli/tap-icmpstat.c
661         ui/cli/tap-icmpv6stat.c
662         ui/cli/tap-iostat.c
663         ui/cli/tap-iousers.c
664         ui/cli/tap-macltestat.c
665         ui/cli/tap-mgcpstat.c
666         ui/cli/tap-megacostat.c
667         ui/cli/tap-protocolinfo.c
668         ui/cli/tap-protohierstat.c
669         ui/cli/tap-radiusstat.c
670         ui/cli/tap-rlcltestat.c
671         ui/cli/tap-rpcstat.c
672         ui/cli/tap-rpcprogs.c
673         ui/cli/tap-rtp.c
674         ui/cli/tap-rtspstat.c
675         ui/cli/tap-scsistat.c
676         ui/cli/tap-sctpchunkstat.c
677         ui/cli/tap-sipstat.c
678         ui/cli/tap-smbsids.c
679         ui/cli/tap-smbstat.c
680         ui/cli/tap-stats_tree.c
681         ui/cli/tap-sv.c
682         ui/cli/tap-wspstat.c
683 )
684
685 set(INSTALL_DIRS
686         diameter
687         dtds
688         help
689         radius
690         tpncp
691         wimaxasncp
692 )
693
694 set(INSTALL_FILES
695         ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
696         COPYING
697         ${CMAKE_BINARY_DIR}/capinfos.html
698         cfilters
699         colorfilters
700         dfilters
701         ${CMAKE_BINARY_DIR}/dftest.html
702         ${CMAKE_BINARY_DIR}/dumpcap.html
703         ${CMAKE_BINARY_DIR}/editcap.html
704         ${CMAKE_BINARY_DIR}/idl2wrs.html
705         ipmap.html
706         manuf
707         ${CMAKE_BINARY_DIR}/mergecap.html
708         pdml2html.xsl
709         ${CMAKE_BINARY_DIR}/randpkt.html
710         ${CMAKE_BINARY_DIR}/rawshark.html
711         ${CMAKE_BINARY_DIR}/reordercap.html
712         services
713         smi_modules
714         ${CMAKE_BINARY_DIR}/text2pcap.html
715         ${CMAKE_BINARY_DIR}/tshark.html
716         ${CMAKE_BINARY_DIR}/wireshark-filter.html
717         ${CMAKE_BINARY_DIR}/wireshark.html
718         docbook/ws.css
719 )
720
721 set(LIBEPAN_LIBS
722 #               @NSL_LIBS@      # -lnsl
723 #               @SOCKET_LIBS@   # -lsocket
724 #               @SSL_LIBS@      # -lcrypto
725                 epan
726 #               $(plugin_ldadd) # in case of static
727                 ${PCAP_LIBRARIES}
728                 ${CARES_LIBRARIES}
729                 ${ADNS_LIBRARIES}
730                 ${KERBEROS_LIBRARIES}
731                 ${LUA_LIBRARIES}
732                 ${PYTHON_LIBRARIES}
733                 ${GEOIP_LIBRARIES}
734                 ${GCRYPT_LIBRARIES}
735                 ${GNUTLS_LIBRARIES}
736                 ${SMI_LIBRARIES}
737                 ${ZLIB_LIBRARIES}
738                 ${M_LIBRARIES}
739 )
740
741 if( (BUILD_wireshark AND GTK_FOUND) OR (BUILD_qtshark AND QT_FOUND) )
742         set(wireshark_FILES
743                 airpcap_loader.c
744                 capture.c
745                 capture_info.c
746                 capture_opts.c
747                 capture_sync.c
748                 color_filters.c
749                 file.c
750                 fileset.c
751                 filters.c
752                 g711.c
753                 iface_monitor.c
754                 merge.c
755                 proto_hier_stats.c
756                 summary.c
757                 tempfile.c
758                 u3.c
759                 ws80211_utils.c
760                 ${SHARK_COMMON_CAPTURE_SRC}
761                 ${WIRESHARK_COMMON_SRC}
762         )
763 endif()
764
765 if(BUILD_wireshark AND GTK_FOUND)
766         set(wireshark_LIBS
767                 gtkui
768                 ui
769                 ui_dirty
770                 ${GTK2_LIBRARIES}
771                 ${GTK3_LIBRARIES}
772                 ${GTHREAD2_LIBRARIES}
773                 codecs
774                 ${PORTAUDIO_LIBRARIES}
775                 ${LIBEPAN_LIBS}
776                 ${APPLE_APPLICATION_SERVICES_LIBRARY}
777                 ${APPLE_CORE_SERVICES_LIBRARY}
778                 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
779                 ${NL_LIBRARIES}
780         )
781         # qtshark and wireshark share wireshark_FILES
782
783         add_executable(wireshark ${wireshark_FILES})
784         add_dependencies(wireshark svnversion)
785         set_target_properties(wireshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
786         target_link_libraries(wireshark ${wireshark_LIBS})
787         install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
788 endif()
789
790 if(BUILD_qtshark AND QT_FOUND)
791         set(qtshark_LIBS
792                 qtui
793                 ui
794                 ui_dirty
795                 ${QT_LIBRARIES}
796                 ${GTHREAD2_LIBRARIES}
797                 codecs
798                 ${PORTAUDIO_LIBRARIES}
799                 ${LIBEPAN_LIBS}
800                 ${APPLE_APPLICATION_SERVICES_LIBRARY}
801                 ${APPLE_CORE_FOUNDATION_LIBRARY}
802                 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
803                 ${NL_LIBRARIES}
804         )
805         # qtshark and wireshark share wireshark_FILES
806
807         add_executable(qtshark ${wireshark_FILES})
808         add_dependencies(qtshark svnversion)
809         set_target_properties(qtshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
810         target_link_libraries(qtshark ${qtshark_LIBS})
811         install(TARGETS qtshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
812 endif()
813
814 register_tap_files(tshark-tap-register.c
815         ${TSHARK_TAP_SRC}
816 )
817
818 if(BUILD_tshark)
819         set(tshark_LIBS
820                 ${LIBEPAN_LIBS}
821                 ${APPLE_CORE_FOUNDATION_LIBRARY}
822                 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
823         )
824         set(tshark_FILES
825                 capture_opts.c
826                 capture_sync.c
827                 tempfile.c
828                 tshark-tap-register.c
829                 tshark.c
830                 ui/util.c
831                 ${TSHARK_TAP_SRC}
832                 ${SHARK_COMMON_CAPTURE_SRC}
833                 ${WIRESHARK_COMMON_SRC}
834         )
835         add_executable(tshark ${tshark_FILES})
836         add_dependencies(tshark svnversion)
837         set_target_properties(tshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
838         target_link_libraries(tshark ${tshark_LIBS})
839         install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
840 endif()
841
842 if(BUILD_rawshark AND PCAP_FOUND)
843         set(rawshark_LIBS
844                 ${LIBEPAN_LIBS}
845                 ${APPLE_CORE_FOUNDATION_LIBRARY}
846                 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
847         )
848         set(rawshark_FILES
849                 ${WIRESHARK_COMMON_SRC}
850                 rawshark.c
851                 ui/util.c
852         )
853         add_executable(rawshark ${rawshark_FILES})
854         add_dependencies(rawshark svnversion)
855         set_target_properties(rawshark PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
856         target_link_libraries(rawshark ${rawshark_LIBS})
857         install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
858 endif()
859
860 if(BUILD_dftest)
861         set(dftest_LIBS
862                 ${LIBEPAN_LIBS}
863         )
864         set(dftest_FILES
865                 dftest.c
866                 ui/util.c
867         )
868         add_executable(dftest ${dftest_FILES})
869         set_target_properties(dftest PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
870         target_link_libraries(dftest ${dftest_LIBS})
871         install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
872 endif()
873
874 if(BUILD_randpkt)
875         set(randpkt_LIBS
876                 wiretap
877                 ${M_LIBRARIES}
878                 ${PCAP_LIBRARIES}
879 #               @SOCKET_LIBS@
880 #               @NSL_LIBS@
881                 ${CARES_LIBRARIES}
882                 ${ADNS_LIBRARIES}
883                 ${ZLIB_LIBRARIES}
884         )
885         set(randpkt_FILES
886                 randpkt.c
887         )
888         add_executable(randpkt ${randpkt_FILES})
889         set_target_properties(randpkt PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
890         target_link_libraries(randpkt ${randpkt_LIBS})
891         install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
892 endif()
893
894 if(BUILD_text2pcap)
895         set(text2pcap_LIBS
896                 wsutil
897                 ${M_LIBRARIES}
898                 ${ZLIB_LIBRARIES}
899         )
900         set(text2pcap_CLEAN_FILES
901                 text2pcap.c
902                 pcapio.c
903         )
904         set(text2pcap_FILES
905                 ${text2pcap_CLEAN_FILES}
906         )
907         add_lex_files(text2pcap_FILES
908                 text2pcap-scanner.l
909         )
910         add_executable(text2pcap ${text2pcap_FILES})
911         add_dependencies(text2pcap svnversion)
912         set_target_properties(text2pcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
913         target_link_libraries(text2pcap ${text2pcap_LIBS})
914         install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
915 endif()
916
917 if(BUILD_mergecap)
918         set(mergecap_LIBS
919                 wiretap
920                 ${ZLIB_LIBRARIES}
921         )
922         set(mergecap_FILES
923                 mergecap.c
924                 merge.c
925                 svnversion.h
926                 ${WTAP_PLUGIN_SOURCES}
927         )
928         add_executable(mergecap ${mergecap_FILES})
929         add_dependencies(mergecap svnversion)
930         set_target_properties(mergecap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
931         target_link_libraries(mergecap ${mergecap_LIBS})
932         install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
933 endif()
934
935 if(BUILD_reordercap)
936         set(reordercap_LIBS
937                 wiretap
938                 ${ZLIB_LIBRARIES}
939         )
940         set(reordercap_FILES
941                 reordercap.c
942                 svnversion.h
943                 ${WTAP_PLUGIN_SOURCES}
944         )
945         add_executable(reordercap ${reordercap_FILES})
946         add_dependencies(reordercap svnversion)
947         set_target_properties(reordercap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
948         target_link_libraries(reordercap ${reordercap_LIBS})
949         install(TARGETS reordercap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
950 endif()
951
952 if(BUILD_capinfos)
953         set(capinfos_LIBS
954                 wiretap
955                 wsutil
956                 ${ZLIB_LIBRARIES}
957                 ${GCRYPT_LIBRARIES}
958         )
959         set(capinfos_FILES
960                 capinfos.c
961                 ${WTAP_PLUGIN_SOURCES}
962         )
963         add_executable(capinfos ${capinfos_FILES})
964         add_dependencies(capinfos svnversion)
965         set_target_properties(capinfos PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
966         target_link_libraries(capinfos ${capinfos_LIBS})
967         install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
968 endif()
969
970 if(BUILD_editcap)
971         set(editcap_LIBS
972                 wiretap
973                 ${ZLIB_LIBRARIES}
974         )
975         set(editcap_FILES
976                 editcap.c
977                 epan/crypt/md5.c
978                 epan/nstime.c
979                 ${WTAP_PLUGIN_SOURCES}
980         )
981         add_executable(editcap ${editcap_FILES})
982         add_dependencies(editcap svnversion)
983         set_target_properties(editcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
984         target_link_libraries(editcap ${editcap_LIBS})
985         install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
986 endif()
987
988 if(BUILD_dumpcap AND PCAP_FOUND)
989         set(dumpcap_LIBS
990 #               @INET_NTOP_LO@
991                 wsutil
992                 ${PCAP_LIBRARIES}
993                 ${CAP_LIBRARIES}
994 #               @SOCKET_LIBS@
995 #               @NSL_LIBS@
996                 ${GLIB2_LIBRARIES}
997                 ${GTHREAD2_LIBRARIES}
998                 ${ZLIB_LIBRARIES}
999                 ${APPLE_CORE_FOUNDATION_LIBRARY}
1000                 ${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
1001                 ${NL_LIBRARIES}
1002         )
1003         set(dumpcap_FILES
1004                 svnversion.h
1005                 capture_opts.c
1006                 capture-pcap-util.c
1007                 capture_stop_conditions.c
1008                 cfutils.c
1009                 clopts_common.c
1010                 conditions.c
1011                 dumpcap.c
1012                 pcapio.c
1013                 ringbuffer.c
1014                 sync_pipe_write.c
1015                 tempfile.c
1016                 version_info.c
1017                 ws80211_utils.c
1018                 ${PLATFORM_SRC}
1019         )
1020         add_executable(dumpcap ${dumpcap_FILES})
1021         add_dependencies(dumpcap svnversion)
1022         set_target_properties(dumpcap PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
1023         target_link_libraries(dumpcap ${dumpcap_LIBS})
1024         install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
1025 endif()
1026
1027 ADD_CUSTOM_COMMAND(
1028         OUTPUT  ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
1029         COMMAND ${PERL}
1030                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
1031                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
1032                 < ${CMAKE_SOURCE_DIR}/AUTHORS
1033                 > ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
1034         DEPENDS
1035                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
1036                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
1037                 ${CMAKE_SOURCE_DIR}/AUTHORS
1038 )
1039
1040 ADD_CUSTOM_COMMAND(
1041         OUTPUT  ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
1042                 ${CMAKE_BINARY_DIR}/wireshark.pod
1043         COMMAND ${PERL}
1044                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
1045                 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
1046                 < ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
1047                 > ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
1048         COMMAND cat
1049                 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
1050                 ${CMAKE_BINARY_DIR}/AUTHORS-SHORT-FORMAT
1051                 > ${CMAKE_BINARY_DIR}/wireshark.pod
1052         DEPENDS
1053                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
1054                 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
1055                 ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
1056                 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
1057 )
1058
1059 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/capinfos 1 )
1060 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dftest 1 )
1061 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dumpcap 1 )
1062 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/editcap 1 )
1063 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/idl2wrs 1 )
1064 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/mergecap 1 )
1065 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/randpkt 1 )
1066 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/rawshark 1 )
1067 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/reordercap 1 )
1068 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/text2pcap 1 )
1069 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/tshark 1 )
1070 pod2manhtml( wireshark 1 )
1071 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/wireshark-filter 4 )
1072
1073 add_custom_target(
1074         auxiliary ALL
1075         DEPENDS
1076                 AUTHORS-SHORT
1077                 capinfos.html
1078                 dftest.html
1079                 dumpcap.html
1080                 editcap.html
1081                 idl2wrs.html
1082                 mergecap.html
1083                 randpkt.html
1084                 rawshark.html
1085                 reordercap.html
1086                 text2pcap.html
1087                 tshark.html
1088                 wireshark.html
1089                 wireshark-filter.html
1090 )
1091
1092 set(MAN1_FILES
1093         ${CMAKE_BINARY_DIR}/capinfos.1
1094         ${CMAKE_BINARY_DIR}/dftest.1
1095         ${CMAKE_BINARY_DIR}/dumpcap.1
1096         ${CMAKE_BINARY_DIR}/editcap.1
1097         ${CMAKE_BINARY_DIR}/idl2wrs.1
1098         ${CMAKE_BINARY_DIR}/mergecap.1
1099         ${CMAKE_BINARY_DIR}/randpkt.1
1100         ${CMAKE_BINARY_DIR}/rawshark.1
1101         ${CMAKE_BINARY_DIR}/reordercap.1
1102         ${CMAKE_BINARY_DIR}/text2pcap.1
1103         ${CMAKE_BINARY_DIR}/tshark.1
1104         ${CMAKE_BINARY_DIR}/wireshark.1
1105 )
1106
1107 set(MAN4_FILES
1108         ${CMAKE_BINARY_DIR}/wireshark-filter.4
1109 )
1110
1111 set(CLEAN_FILES
1112         ${wireshark_FILES}
1113         ${tshark_FILES}
1114         ${rawshark_FILES}
1115         ${dftest_FILES}
1116         ${randpkt_FILES}
1117         ${text2pcap_CLEAN_FILES}
1118         ${mergecap_FILES}
1119         ${capinfos_FILES}
1120         ${editcap_FILES}
1121         ${dumpcap_FILES}
1122 )
1123
1124 if (WERROR)
1125         set_source_files_properties(
1126                 ${CLEAN_FILES}
1127                 PROPERTIES
1128                 COMPILE_FLAGS -Werror
1129         )
1130 endif()
1131
1132 install(
1133         FILES
1134                 ${INSTALL_FILES}
1135         DESTINATION
1136                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
1137 )
1138
1139 install(
1140         FILES
1141                 ${MAN1_FILES}
1142         DESTINATION
1143                 ${CMAKE_INSTALL_MANDIR}/man1
1144 )
1145
1146 install(
1147         FILES
1148                 ${MAN4_FILES}
1149         DESTINATION
1150                 ${CMAKE_INSTALL_MANDIR}/man4
1151 )
1152
1153 install(
1154         DIRECTORY
1155                 ${INSTALL_DIRS}
1156         DIRECTORY_PERMISSIONS
1157                 OWNER_EXECUTE OWNER_WRITE OWNER_READ
1158                 GROUP_EXECUTE GROUP_READ
1159                 WORLD_EXECUTE WORLD_READ
1160         DESTINATION
1161                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
1162         PATTERN ".svn" EXCLUDE
1163         PATTERN "Makefile.*" EXCLUDE
1164         PATTERN "faq.py" EXCLUDE
1165 )
1166
1167
1168 if(DOC_DIR)
1169         message(STATUS "Docdir install: ${DOC_DIR}")
1170         INSTALL(
1171                 DIRECTORY
1172                         ${CMAKE_BINARY_DIR}/docbook/
1173                 DIRECTORY_PERMISSIONS
1174                         OWNER_EXECUTE OWNER_WRITE OWNER_READ
1175                         GROUP_EXECUTE GROUP_READ
1176                         WORLD_EXECUTE WORLD_READ
1177                 DESTINATION
1178                         ${DOC_DIR}/guides
1179                 FILES_MATCHING
1180                 PATTERN "*.pdf"
1181         )
1182 endif()