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