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