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