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