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