Commit 32350 replaced the self written FindZ.cmake by cmakes
[obnox/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 minimum package list
213 set(PACKAGELIST GLIB2 PCAP M LEX YACC Perl SH PythonInterp HtmlViewer ${PACKAGELIST})
214
215 #Build the gui ?
216 if(BUILD_wireshark)
217         set(PACKAGELIST GTK2 ${PACKAGELIST})
218         set(GTK2_OPTIONS COMPONENTS gtk)
219         set(GTK2_DEBUG false)
220 endif()
221
222 # SMI SNMP
223 if(ENABLE_SMI)
224         set(PACKAGELIST SMI ${PACKAGELIST})
225 endif()
226
227 # GNU crypto
228 if(ENABLE_GCRYPT)
229         set(PACKAGELIST GCRYPT ${PACKAGELIST})
230 endif()
231
232 # GNU SSL/TLS support
233 if(ENABLE_GNUTLS)
234         set(PACKAGELIST GNUTLS ${PACKAGELIST})
235 endif()
236
237 # Regular expressions lib
238 if(ENABLE_PCRE)
239         set(PACKAGELIST PCRE ${PACKAGELIST})
240 endif()
241
242 # Kerberos
243 if(ENABLE_KERBEROS)
244         set(PACKAGELIST KERBEROS ${PACKAGELIST})
245 endif()
246
247 # Portable audio
248 if(ENABLE_PORTAUDIO)
249         set(PACKAGELIST PORTAUDIO ${PACKAGELIST})
250 endif()
251
252
253 # Prefer c-ares over adns
254 if(ENABLE_CARES)        # C Asynchronouse resolver
255         set(PACKAGELIST CARES ${PACKAGELIST})
256 elseif(ENABLE_ADNS)     # Gnu asynchronous DNS
257         set(PACKAGELIST ADNS ${PACKAGELIST})
258 endif()
259
260 # Zlib compression
261 if(ENABLE_ZLIB)
262         set(PACKAGELIST ZLIB ${PACKAGELIST})
263 endif()
264
265 # Lua 5.1 dissectors
266 if(ENABLE_LUA)
267         set(PACKAGELIST LUA ${PACKAGELIST})
268 endif()
269
270 # GeoIP address resolving
271 if(ENABLE_GEOIP)
272         set(PACKAGELIST GEOIP ${PACKAGELIST})
273 endif()
274
275 # Capabilities
276 if(ENABLE_CAP)
277         set(PACKAGELIST CAP ${PACKAGELIST})
278 endif()
279
280 if(ENABLE_PYTHON)
281         set(PACKAGELIST PYTHON ${PACKAGELIST})
282 endif()
283
284 set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
285
286 #Let's loop the package list
287 foreach(PACKAGE ${PACKAGELIST})
288         if(${PACKAGE}_OPTIONS)
289                 find_package(${PACKAGE} ${${PACKAGE}_OPTIONS})
290         else()
291                 find_package(${PACKAGE} REQUIRED)
292         endif()
293         message(${PACKAGE}_FOUND)
294         if (${PACKAGE}_FOUND)
295                 set(HAVE_LIB${PACKAGE} 1)
296                 include_directories(${${PACKAGE}_INCLUDE_DIRS})
297                 message(STATUS "${PACKAGE} includes: ${${PACKAGE}_INCLUDE_DIRS}")
298                 message(STATUS "${PACKAGE} libs: ${${PACKAGE}_LIBRARIES}")
299         endif()
300 endforeach()
301
302 find_package(YAPP)
303
304 #packaging
305 include(CPackConfig.txt)
306
307 if(HAVE_LIBPYTHON)
308         set(HAVE_PYTHON 1)
309         set(PYTHON_DIR "${CMAKE_INSTALL_PREFIX}/lib/wireshark/python/${CPACK_PACKAGE_VERSION}")
310 endif()
311 if(HAVE_LIBLUA)
312         set(HAVE_LUA_H 1)
313         set(HAVE_LUA_5_1 1)
314 endif()
315 if(HAVE_LIBKERBEROS)
316         set(HAVE_KERBEROS 1)
317         # HAVE_HEIMDAL_KERBEROS
318         set(HAVE_MIT_KERBEROS 1)
319         set(HAVE_KEYTYPE_ARCFOUR_56 1)
320 endif()
321 if(HAVE_LIBGEOIP)
322         set(HAVE_GEOIP 1)
323 endif()
324 if(HAVE_LIBCARES)
325         set(HAVE_C_ARES 1)
326 endif()
327 if(HAVE_LIBADNS)
328         set(HAVE_GNU_ADNS 1)
329 endif()
330 if(ENABLE_AIRPCAP)
331         set(HAVE_AIRPCAP 1)
332 endif()
333 # That's the name autofoo uses
334 if(HAVE_LIBZLIB)
335         set(HAVE_LIBZ 1)
336 endif()
337
338 include(ConfigureChecks.cmake)
339
340 #Big or little endian ?
341 include(TestBigEndian)
342 test_big_endian(WORDS_BIGENDIAN)
343
344 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
345
346 if(ENABLE_PLUGINS)
347         set(HAVE_PLUGINS 1)
348         set(PLUGIN_DIR="${DATAFILE_DIR}/plugins/${CPACK_PACKAGE_VERSION}")
349         set(PLUGIN_SRC_DIRS
350                 plugins/asn1
351                 plugins/docsis
352                 plugins/ethercat
353                 plugins/giop
354                 plugins/gryphon
355                 plugins/interlink
356                 plugins/irda
357                 plugins/m2m
358                 plugins/mate
359                 plugins/opcua
360                 plugins/profinet
361                 plugins/sercosiii
362                 plugins/stats_tree
363                 plugins/unistim
364                 plugins/wimax
365                 plugins/wimaxasncp
366         )
367 # It seems this stuff doesn't build with autofoo either...
368 #       if(YAPP_FOUND)
369 #               set(PLUGIN_SRC_DIRS
370 #                       ${PLUGIN_SRC_DIRS}
371 #                       plugins/tpg
372 #               )
373 #       endif()
374 else()
375         set(PLUGIN_SRC_DIRS )
376 endif()
377
378 foreach(PLUGIN_DIR ${PLUGIN_SRC_DIRS})
379         add_subdirectory( ${PLUGIN_DIR} )
380 endforeach()
381
382 add_subdirectory( codecs )
383 add_subdirectory( epan )
384 add_subdirectory( gtk )
385 add_subdirectory( tools/lemon )
386 add_subdirectory( wiretap )
387 add_subdirectory( wsutil )
388
389 if(ENABLE_GUIDES)
390         add_subdirectory( docbook )
391 endif()
392
393 find_package(POD)
394
395 #Platform specific
396 if(UNIX)
397         set(WS_VAR_IMPORT "extern")
398 endif()
399
400 if(APPLE)
401 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
402         set(HAVE_OS_X_FRAMEWORKS 1)
403         FIND_LIBRARY (APPLE_CORE_SERVICES_LIBRARY CoreServices)
404         FIND_LIBRARY (APPLE_COCOA_LIBRARY Cocoa)
405 endif()
406
407 if(WIN32)
408         add_definitions(-D_NEED_VAR_IMPORT_)
409         set(WS_VAR_IMPORT "__declspec(dllimport) extern")
410
411         # Disable deprecation
412         if(MSVC80 OR MSVC90)
413                 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
414         endif()
415 endif()
416
417 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
418
419 include(FeatureSummary)
420 #SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ]
421 PRINT_ENABLED_FEATURES()
422 PRINT_DISABLED_FEATURES()
423
424 link_directories(
425         gtk
426         codecs
427         epan
428         wiretap
429         wsutil
430 )
431
432 ADD_CUSTOM_TARGET(
433         svnversion ALL
434         COMMAND ${PERL}
435                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
436                 ${CMAKE_CURRENT_SOURCE_DIR}
437         DEPENDS
438                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
439 )
440
441 ADD_CUSTOM_COMMAND(
442         OUTPUT  svnversion.h
443         COMMAND ${PERL}
444                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
445                 ${CMAKE_CURRENT_SOURCE_DIR}
446         DEPENDS
447                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
448 )
449
450 register_tap_files(tshark-tap-register.c
451         ${TSHARK_TAP_SRC}
452 )
453
454 ADD_CUSTOM_COMMAND(
455         OUTPUT  ps.c
456         COMMAND ${PYTHON_EXECUTABLE}
457                 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
458                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
459                 ps.c
460         DEPENDS
461                 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
462                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
463 )
464
465 if(UNIX)
466         set(PLATFORM_SRC
467                 capture-pcap-util-unix.c
468         )
469 endif()
470
471 if(WIN32)
472         set(PLATFORM_SRC
473                 capture-wpcap.c capture_wpcap_packet.c
474         )
475 endif()
476
477 set(WTAP_PLUGIN_SOURCES
478         epan/plugins.c
479         epan/report_err.c
480         epan/filesystem.c
481 )
482
483 set(SHARK_COMMON_CAPTURE_SRC
484         capture_errs.c
485         capture_ifinfo.c
486         capture_ui_utils.c
487 )
488
489 set(WIRESHARK_COMMON_SRC
490         ${PLATFORM_SRC}
491         capture-pcap-util.c
492         cfile.c
493         clopts_common.c
494         disabled_protos.c
495         packet-range.c
496         print.c
497         ps.c
498         svnversion.h
499         sync_pipe_write.c
500         timestats.c
501         util.c
502         tap-megaco-common.c
503         tap-rtp-common.c
504         version_info.c
505 )
506
507 set(TSHARK_TAP_SRC
508         tap-afpstat.c
509         tap-ansi_astat.c
510         tap-bootpstat.c
511         tap-camelcounter.c
512         tap-camelsrt.c
513         tap-comparestat.c
514         tap-dcerpcstat.c
515         tap-diameter-avp.c
516         tap-funnel.c
517         tap-gsm_astat.c
518         tap-h225counter.c
519         tap-h225rassrt.c
520         tap-httpstat.c
521         tap-iostat.c
522         tap-iousers.c
523         tap-mgcpstat.c
524         tap-megacostat.c
525         tap-protocolinfo.c
526         tap-protohierstat.c
527         tap-radiusstat.c
528         tap-rpcstat.c
529         tap-rpcprogs.c
530         tap-rtp.c
531         tap-sctpchunkstat.c
532         tap-sipstat.c
533         tap-smbsids.c
534         tap-smbstat.c
535         tap-stats_tree.c
536         tap-wspstat.c
537 )
538
539 set(INSTALL_DIRS
540         diameter
541         dtds
542         help
543         radius
544         tpncp
545         wimaxasncp
546 )
547
548 set(INSTALL_FILES
549         ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
550         COPYING
551         ${CMAKE_BINARY_DIR}/capinfos.html
552         cfilters
553         colorfilters
554         dfilters
555         ${CMAKE_BINARY_DIR}/dumpcap.html
556         ${CMAKE_BINARY_DIR}/editcap.html
557         ${CMAKE_BINARY_DIR}/idl2wrs.html
558         ipmap.html
559         manuf
560         ${CMAKE_BINARY_DIR}/mergecap.html
561         ${CMAKE_BINARY_DIR}/rawshark.html
562         services
563         smi_modules
564         ${CMAKE_BINARY_DIR}/text2pcap.html
565         ${CMAKE_BINARY_DIR}/tshark.html
566         ${CMAKE_BINARY_DIR}/wireshark-filter.html
567         ${CMAKE_BINARY_DIR}/wireshark.html
568         docbook/ws.css
569 )
570
571 set(LIBEPAN_LIBS
572 #               @GETOPT_O@      # wsgetopt.c
573 #               @INET_ATON_LO@  # epan/inet_aton.c
574 #               @INET_NTOP_LO@  # inet_ntop.c
575 #               @INET_PTON_LO@  # inet_pton.c
576 #               @NSL_LIBS@      # -lnsl
577 #               @SOCKET_LIBS@   # -lsocket
578 #               @SSL_LIBS@      # -lcrypto
579 #               @STRERROR_O@    # strerror.c
580 #               @STRNCASECMP_O@ # strncasecmp.c
581 #               @STRPTIME_O@    # strptime.c
582                 epan
583 #               $(plugin_ldadd) # in case of static
584                 ${PCRE_LIBRARIES}
585                 ${PCAP_LIBRARIES}
586                 ${CARES_LIBRARIES}
587                 ${ADNS_LIBRARIES}
588                 ${KERBEROS_LIBRARIES}
589                 ${LUA_LIBRARIES}
590                 ${PYTHON_LIBRARIES}
591                 ${GEOIP_LIBRARIES}
592                 ${GCRYPT_LIBRARIES}
593                 ${GNUTLS_LIBRARIES}
594                 ${SMI_LIBRARIES}
595                 ${ZLIB_LIBRARIES}
596                 ${M_LIBRARIES}
597 )
598
599 if(BUILD_wireshark)
600         set(wireshark_LIBS
601                 ui
602                 ${GTK2_LIBRARIES}
603                 codecs
604                 ${PORTAUDIO_LIBRARIES}
605                 ${LIBEPAN_LIBS}
606                 ${APPLE_CORE_SERVICES_LIBRARY}
607                 ${APPLE_COCOA_LIBRARY}
608         )
609         set(wireshark_FILES
610                 airpcap_loader.c
611                 alert_box.c
612                 capture.c
613                 capture_info.c
614                 capture_opts.c
615                 capture_sync.c
616                 color_filters.c
617                 file.c
618                 fileset.c
619                 filters.c
620                 g711.c
621                 merge.c
622                 proto_hier_stats.c
623                 summary.c
624                 tempfile.c
625                 ${SHARK_COMMON_CAPTURE_SRC}
626                 ${WIRESHARK_COMMON_SRC}
627         )
628         add_executable(wireshark ${wireshark_FILES})
629         add_dependencies(wireshark svnversion)
630         set_target_properties(wireshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
631         target_link_libraries(wireshark ${wireshark_LIBS})
632         install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
633 endif()
634
635 if(BUILD_tshark)
636         set(tshark_LIBS
637                 ${LIBEPAN_LIBS}
638                 ${APPLE_COCOA_LIBRARY}
639         )
640         set(tshark_FILES
641                 capture_opts.c
642                 capture_sync.c
643                 tempfile.c
644                 tshark-tap-register.c
645                 tshark.c
646                 ${TSHARK_TAP_SRC}
647                 ${SHARK_COMMON_CAPTURE_SRC}
648                 ${WIRESHARK_COMMON_SRC}
649         )
650         add_executable(tshark ${tshark_FILES})
651         add_dependencies(tshark svnversion)
652         set_target_properties(tshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
653         target_link_libraries(tshark ${tshark_LIBS})
654         install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
655 endif()
656
657 if(BUILD_rawshark)
658         set(rawshark_LIBS
659                 ${LIBEPAN_LIBS}
660                 ${APPLE_COCOA_LIBRARY}
661         )
662         set(rawshark_FILES
663                 ${WIRESHARK_COMMON_SRC}
664                 rawshark.c
665         )
666         add_executable(rawshark ${rawshark_FILES})
667         add_dependencies(rawshark svnversion)
668         set_target_properties(rawshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
669         target_link_libraries(rawshark ${rawshark_LIBS})
670         install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
671 endif()
672
673 if(BUILD_dftest)
674         set(dftest_LIBS
675                 ${LIBEPAN_LIBS}
676         )
677         set(dftest_FILES
678                 dftest.c
679                 util.c
680         )
681         add_executable(dftest ${dftest_FILES})
682         set_target_properties(dftest PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
683         target_link_libraries(dftest ${dftest_LIBS})
684         install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
685 endif()
686
687 if(BUILD_randpkt)
688         set(randpkt_LIBS
689                 wiretap
690                 ${M_LIBRARIES}
691                 ${PCAP_LIBRARIES}
692 #               @SOCKET_LIBS@
693 #               @NSL_LIBS@
694                 ${CARES_LIBRARIES}
695                 ${ADNS_LIBRARIES}
696                 ${ZLIB_LIBRARIES}
697         )
698         set(randpkt_FILES
699                 randpkt.c
700         )
701         add_executable(randpkt ${randpkt_FILES})
702         set_target_properties(randpkt PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
703         target_link_libraries(randpkt ${randpkt_LIBS})
704         install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
705 endif()
706
707 if(BUILD_text2pcap)
708         set(text2pcap_LIBS
709                 wiretap
710                 ${M_LIBRARIES}
711                 ${ZLIB_LIBRARIES}
712         )
713         set(text2pcap_CLEAN_FILES
714                 text2pcap.c
715         )
716         set(text2pcap_FILES
717                 ${text2pcap_CLEAN_FILES}
718         )
719         add_lex_files(text2pcap_FILES
720                 text2pcap-scanner.l
721         )
722         add_executable(text2pcap ${text2pcap_FILES})
723         add_dependencies(text2pcap svnversion)
724         set_target_properties(text2pcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
725         target_link_libraries(text2pcap ${text2pcap_LIBS})
726         install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
727 endif()
728
729 if(BUILD_mergecap)
730         set(mergecap_LIBS
731                 wiretap
732                 ${ZLIB_LIBRARIES}
733         )
734         set(mergecap_FILES
735                 mergecap.c
736                 merge.c
737                 svnversion.h
738         )
739         add_executable(mergecap ${mergecap_FILES})
740         add_dependencies(mergecap svnversion)
741         set_target_properties(mergecap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
742         target_link_libraries(mergecap ${mergecap_LIBS})
743         install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
744 endif()
745
746 if(BUILD_capinfos)
747         set(capinfos_LIBS
748                 wiretap
749                 ${ZLIB_LIBRARIES}
750                 ${GCRYPT_LIBRARIES}
751                 ${APPLE_COCOA_LIBRARY}
752         )
753         set(capinfos_FILES
754                 capinfos.c
755                 ${WTAP_PLUGIN_SOURCES}
756         )
757         add_executable(capinfos ${capinfos_FILES})
758         set_target_properties(capinfos PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
759         target_link_libraries(capinfos ${capinfos_LIBS})
760         install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
761 endif()
762
763 if(BUILD_editcap)
764         set(editcap_LIBS
765                 wiretap
766                 ${ZLIB_LIBRARIES}
767         )
768         set(editcap_FILES
769                 editcap.c
770                 epan/crypt/crypt-md5.c
771                 epan/nstime.c
772                 ${WTAP_PLUGIN_SOURCES}
773         )
774         add_executable(editcap ${editcap_FILES})
775         add_dependencies(editcap svnversion)
776         set_target_properties(editcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
777         target_link_libraries(editcap ${editcap_LIBS})
778         install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
779 endif()
780
781 if(BUILD_dumpcap)
782         set(dumpcap_LIBS
783                 wiretap
784 #               @INET_NTOP_LO@
785                 ${PCAP_LIBRARIES}
786                 ${CAP_LIBRARIES}
787 #               @SOCKET_LIBS@
788 #               @NSL_LIBS@
789                 ${GCRYPT_LIBRARIES}
790                 ${GNUTLS_LIBRARIES}
791                 ${ZLIB_LIBRARIES}
792                 ${APPLE_COCOA_LIBRARY}
793         )
794         set(dumpcap_FILES
795                 svnversion.h
796                 capture_opts.c
797                 capture-pcap-util.c
798                 capture_stop_conditions.c
799                 clopts_common.c
800                 conditions.c
801                 dumpcap.c
802                 pcapio.c
803                 ringbuffer.c
804                 sync_pipe_write.c
805                 tempfile.c
806                 version_info.c
807                 ${PLATFORM_SRC}
808         )
809         add_executable(dumpcap ${dumpcap_FILES})
810         add_dependencies(dumpcap svnversion)
811         set_target_properties(dumpcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
812         target_link_libraries(dumpcap ${dumpcap_LIBS})
813         install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
814 endif()
815
816 ADD_CUSTOM_COMMAND(
817         OUTPUT  AUTHORS-SHORT
818         COMMAND ${PERL}
819                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
820                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
821                 < ${CMAKE_SOURCE_DIR}/AUTHORS
822                 > AUTHORS-SHORT
823         DEPENDS
824                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
825                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
826                 ${CMAKE_SOURCE_DIR}/AUTHORS
827 )
828
829 ADD_CUSTOM_COMMAND(
830         OUTPUT  AUTHORS-SHORT-FORMAT
831                 wireshark.pod
832         COMMAND ${PERL}
833                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
834                 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
835                 < AUTHORS-SHORT
836                 > AUTHORS-SHORT-FORMAT
837         COMMAND cat
838                 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
839                 AUTHORS-SHORT-FORMAT
840                 > wireshark.pod
841         DEPENDS
842                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
843                 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
844                 AUTHORS-SHORT
845                 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
846 )
847
848 ADD_CUSTOM_COMMAND(
849         OUTPUT  wireshark-filter.pod
850         COMMAND tshark
851                 -G fields |
852                 ${PERL}
853                 ${CMAKE_SOURCE_DIR}/doc/dfilter2pod.pl
854                 ${CMAKE_SOURCE_DIR}/doc/wireshark-filter.pod.template
855                 > wireshark-filter.pod
856         DEPENDS
857                 ${CMAKE_SOURCE_DIR}/doc/dfilter2pod.pl
858                 ${CMAKE_SOURCE_DIR}/doc/wireshark-filter.pod.template
859                 tshark
860 )
861
862 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/capinfos 1 )
863 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dumpcap 1 )
864 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/editcap 1 )
865 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/idl2wrs 1 )
866 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/mergecap 1 )
867 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/rawshark 1 )
868 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/text2pcap 1 )
869 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/tshark 1 )
870 pod2manhtml( wireshark 1 )
871 pod2manhtml( wireshark-filter 4 )
872
873 add_custom_target(
874         auxiliary ALL
875         DEPENDS
876                 AUTHORS-SHORT
877                 capinfos.html
878                 dumpcap.html
879                 editcap.html
880                 idl2wrs.html
881                 mergecap.html
882                 rawshark.html
883                 text2pcap.html
884                 tshark.html
885                 wireshark.html
886                 wireshark-filter.html
887 )
888
889 set(MAN1_FILES
890         ${CMAKE_BINARY_DIR}/capinfos.1
891         ${CMAKE_BINARY_DIR}/dumpcap.1
892         ${CMAKE_BINARY_DIR}/editcap.1
893         ${CMAKE_BINARY_DIR}/idl2wrs.1
894         ${CMAKE_BINARY_DIR}/mergecap.1
895         ${CMAKE_BINARY_DIR}/rawshark.1
896         ${CMAKE_BINARY_DIR}/text2pcap.1
897         ${CMAKE_BINARY_DIR}/tshark.1
898         ${CMAKE_BINARY_DIR}/wireshark.1
899 )
900
901 set(MAN4_FILES
902         ${CMAKE_BINARY_DIR}/wireshark-filter.4
903 )
904
905 set(CLEAN_FILES
906         ${wireshark_FILES}
907         ${tshark_FILES}
908         ${rawshark_FILES}
909         ${dftest_FILES}
910         ${randpkt_FILES}
911         ${text2pcap_CLEAN_FILES}
912         ${mergecap_FILES}
913         ${capinfos_FILES}
914         ${editcap_FILES}
915         ${dumpcap_FILES}
916 )
917
918 if (WERROR)
919         set_source_files_properties(
920                 ${CLEAN_FILES}
921                 PROPERTIES
922                 COMPILE_FLAGS -Werror
923         )
924 endif()
925
926 install(
927         FILES
928                 ${INSTALL_FILES}
929         DESTINATION
930                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
931 )
932
933 install(
934         FILES
935                 ${MAN1_FILES}
936         DESTINATION
937                 ${CMAKE_INSTALL_MANDIR}/man1
938 )
939
940 install(
941         FILES
942                 ${MAN4_FILES}
943         DESTINATION
944                 ${CMAKE_INSTALL_MANDIR}/man4
945 )
946
947 install(
948         DIRECTORY
949                 ${INSTALL_DIRS}
950         DIRECTORY_PERMISSIONS
951                 OWNER_EXECUTE OWNER_WRITE OWNER_READ
952                 GROUP_EXECUTE GROUP_READ
953                 WORLD_EXECUTE WORLD_READ
954         DESTINATION
955                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
956         PATTERN ".svn" EXCLUDE
957         PATTERN "Makefile.*" EXCLUDE
958         PATTERN "faq.py" EXCLUDE
959 )