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