From Cal Turney via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5223 :
[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         ${CMAKE_BINARY_DIR}/gtk
433         ${CMAKE_BINARY_DIR}/codecs
434         ${CMAKE_BINARY_DIR}/epan
435         ${CMAKE_BINARY_DIR}/wiretap
436         ${CMAKE_BINARY_DIR}/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-scsistat.c
539         tap-sctpchunkstat.c
540         tap-sipstat.c
541         tap-smbsids.c
542         tap-smbstat.c
543         tap-stats_tree.c
544         tap-sv.c
545         tap-wspstat.c
546 )
547
548 set(INSTALL_DIRS
549         diameter
550         dtds
551         help
552         radius
553         tpncp
554         wimaxasncp
555 )
556
557 set(INSTALL_FILES
558         ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
559         COPYING
560         ${CMAKE_BINARY_DIR}/capinfos.html
561         cfilters
562         colorfilters
563         dfilters
564         ${CMAKE_BINARY_DIR}/dftest.html
565         ${CMAKE_BINARY_DIR}/dumpcap.html
566         ${CMAKE_BINARY_DIR}/editcap.html
567         ${CMAKE_BINARY_DIR}/idl2wrs.html
568         ipmap.html
569         manuf
570         ${CMAKE_BINARY_DIR}/mergecap.html
571         ${CMAKE_BINARY_DIR}/randpkt.html
572         ${CMAKE_BINARY_DIR}/rawshark.html
573         services
574         smi_modules
575         ${CMAKE_BINARY_DIR}/text2pcap.html
576         ${CMAKE_BINARY_DIR}/tshark.html
577         ${CMAKE_BINARY_DIR}/wireshark-filter.html
578         ${CMAKE_BINARY_DIR}/wireshark.html
579         docbook/ws.css
580 )
581
582 set(LIBEPAN_LIBS
583 #               @NSL_LIBS@      # -lnsl
584 #               @SOCKET_LIBS@   # -lsocket
585 #               @SSL_LIBS@      # -lcrypto
586                 epan
587 #               $(plugin_ldadd) # in case of static
588                 ${PCRE_LIBRARIES}
589                 ${PCAP_LIBRARIES}
590                 ${CARES_LIBRARIES}
591                 ${ADNS_LIBRARIES}
592                 ${KERBEROS_LIBRARIES}
593                 ${LUA_LIBRARIES}
594                 ${PYTHON_LIBRARIES}
595                 ${GEOIP_LIBRARIES}
596                 ${GCRYPT_LIBRARIES}
597                 ${GNUTLS_LIBRARIES}
598                 ${SMI_LIBRARIES}
599                 ${ZLIB_LIBRARIES}
600                 ${M_LIBRARIES}
601 )
602
603 if(BUILD_wireshark)
604         set(wireshark_LIBS
605                 ui
606                 ${GTK2_LIBRARIES}
607                 codecs
608                 ${PORTAUDIO_LIBRARIES}
609                 ${LIBEPAN_LIBS}
610                 ${APPLE_CORE_SERVICES_LIBRARY}
611                 ${APPLE_COCOA_LIBRARY}
612         )
613         set(wireshark_FILES
614                 airpcap_loader.c
615                 alert_box.c
616                 capture.c
617                 capture_info.c
618                 capture_opts.c
619                 capture_sync.c
620                 color_filters.c
621                 file.c
622                 fileset.c
623                 filters.c
624                 g711.c
625                 merge.c
626                 proto_hier_stats.c
627                 summary.c
628                 tempfile.c
629                 ${SHARK_COMMON_CAPTURE_SRC}
630                 ${WIRESHARK_COMMON_SRC}
631         )
632         add_executable(wireshark ${wireshark_FILES})
633         add_dependencies(wireshark svnversion)
634         set_target_properties(wireshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
635         target_link_libraries(wireshark ${wireshark_LIBS})
636         install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
637 endif()
638
639 if(BUILD_tshark)
640         set(tshark_LIBS
641                 ${LIBEPAN_LIBS}
642                 ${APPLE_COCOA_LIBRARY}
643         )
644         set(tshark_FILES
645                 capture_opts.c
646                 capture_sync.c
647                 tempfile.c
648                 tshark-tap-register.c
649                 tshark.c
650                 ${TSHARK_TAP_SRC}
651                 ${SHARK_COMMON_CAPTURE_SRC}
652                 ${WIRESHARK_COMMON_SRC}
653         )
654         add_executable(tshark ${tshark_FILES})
655         add_dependencies(tshark svnversion)
656         set_target_properties(tshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
657         target_link_libraries(tshark ${tshark_LIBS})
658         install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
659 endif()
660
661 if(BUILD_rawshark)
662         set(rawshark_LIBS
663                 ${LIBEPAN_LIBS}
664                 ${APPLE_COCOA_LIBRARY}
665         )
666         set(rawshark_FILES
667                 ${WIRESHARK_COMMON_SRC}
668                 rawshark.c
669         )
670         add_executable(rawshark ${rawshark_FILES})
671         add_dependencies(rawshark svnversion)
672         set_target_properties(rawshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
673         target_link_libraries(rawshark ${rawshark_LIBS})
674         install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
675 endif()
676
677 if(BUILD_dftest)
678         set(dftest_LIBS
679                 ${LIBEPAN_LIBS}
680         )
681         set(dftest_FILES
682                 dftest.c
683                 util.c
684         )
685         add_executable(dftest ${dftest_FILES})
686         set_target_properties(dftest PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
687         target_link_libraries(dftest ${dftest_LIBS})
688         install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
689 endif()
690
691 if(BUILD_randpkt)
692         set(randpkt_LIBS
693                 wiretap
694                 ${M_LIBRARIES}
695                 ${PCAP_LIBRARIES}
696 #               @SOCKET_LIBS@
697 #               @NSL_LIBS@
698                 ${CARES_LIBRARIES}
699                 ${ADNS_LIBRARIES}
700                 ${ZLIB_LIBRARIES}
701         )
702         set(randpkt_FILES
703                 randpkt.c
704         )
705         add_executable(randpkt ${randpkt_FILES})
706         set_target_properties(randpkt PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
707         target_link_libraries(randpkt ${randpkt_LIBS})
708         install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
709 endif()
710
711 if(BUILD_text2pcap)
712         set(text2pcap_LIBS
713                 wiretap
714                 ${M_LIBRARIES}
715                 ${ZLIB_LIBRARIES}
716         )
717         set(text2pcap_CLEAN_FILES
718                 text2pcap.c
719         )
720         set(text2pcap_FILES
721                 ${text2pcap_CLEAN_FILES}
722         )
723         add_lex_files(text2pcap_FILES
724                 text2pcap-scanner.l
725         )
726         add_executable(text2pcap ${text2pcap_FILES})
727         add_dependencies(text2pcap svnversion)
728         set_target_properties(text2pcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
729         target_link_libraries(text2pcap ${text2pcap_LIBS})
730         install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
731 endif()
732
733 if(BUILD_mergecap)
734         set(mergecap_LIBS
735                 wiretap
736                 ${ZLIB_LIBRARIES}
737         )
738         set(mergecap_FILES
739                 mergecap.c
740                 merge.c
741                 svnversion.h
742         )
743         add_executable(mergecap ${mergecap_FILES})
744         add_dependencies(mergecap svnversion)
745         set_target_properties(mergecap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
746         target_link_libraries(mergecap ${mergecap_LIBS})
747         install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
748 endif()
749
750 if(BUILD_capinfos)
751         set(capinfos_LIBS
752                 wiretap
753                 ${ZLIB_LIBRARIES}
754                 ${GCRYPT_LIBRARIES}
755                 ${APPLE_COCOA_LIBRARY}
756         )
757         set(capinfos_FILES
758                 capinfos.c
759                 ${WTAP_PLUGIN_SOURCES}
760         )
761         add_executable(capinfos ${capinfos_FILES})
762         add_dependencies(capinfos svnversion)
763         set_target_properties(capinfos PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
764         target_link_libraries(capinfos ${capinfos_LIBS})
765         install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
766 endif()
767
768 if(BUILD_editcap)
769         set(editcap_LIBS
770                 wiretap
771                 ${ZLIB_LIBRARIES}
772         )
773         set(editcap_FILES
774                 editcap.c
775                 epan/crypt/crypt-md5.c
776                 epan/nstime.c
777                 ${WTAP_PLUGIN_SOURCES}
778         )
779         add_executable(editcap ${editcap_FILES})
780         add_dependencies(editcap svnversion)
781         set_target_properties(editcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
782         target_link_libraries(editcap ${editcap_LIBS})
783         install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
784 endif()
785
786 if(BUILD_dumpcap)
787         set(dumpcap_LIBS
788                 wiretap
789 #               @INET_NTOP_LO@
790                 ${PCAP_LIBRARIES}
791                 ${CAP_LIBRARIES}
792 #               @SOCKET_LIBS@
793 #               @NSL_LIBS@
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( ${CMAKE_SOURCE_DIR}/doc/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 )