- Move cmake options into their own file, making it easier to
[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 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
334 include(ConfigureChecks.cmake)
335
336 #Big or little endian ?
337 include(TestBigEndian)
338 test_big_endian(WORDS_BIGENDIAN)
339
340 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
341
342 if(ENABLE_PLUGINS)
343         set(HAVE_PLUGINS 1)
344         set(PLUGIN_DIR="${DATAFILE_DIR}/plugins/${CPACK_PACKAGE_VERSION}")
345         set(PLUGIN_SRC_DIRS
346                 plugins/asn1
347                 plugins/docsis
348                 plugins/ethercat
349                 plugins/giop
350                 plugins/gryphon
351                 plugins/interlink
352                 plugins/irda
353                 plugins/m2m
354                 plugins/mate
355                 plugins/opcua
356                 plugins/profinet
357                 plugins/sercosiii
358                 plugins/stats_tree
359                 plugins/unistim
360                 plugins/wimax
361                 plugins/wimaxasncp
362         )
363 # It seems this stuff doesn't build with autofoo either...
364 #       if(YAPP_FOUND)
365 #               set(PLUGIN_SRC_DIRS
366 #                       ${PLUGIN_SRC_DIRS}
367 #                       plugins/tpg
368 #               )
369 #       endif()
370 else()
371         set(PLUGIN_SRC_DIRS )
372 endif()
373
374 foreach(PLUGIN_DIR ${PLUGIN_SRC_DIRS})
375         add_subdirectory( ${PLUGIN_DIR} )
376 endforeach()
377
378 add_subdirectory( codecs )
379 add_subdirectory( epan )
380 add_subdirectory( gtk )
381 add_subdirectory( tools/lemon )
382 add_subdirectory( wiretap )
383 add_subdirectory( wsutil )
384
385 if(ENABLE_GUIDES)
386 #       FIXME: Disabling the build via option currently doesn't work
387 #       add_subdirectory( docbook )
388 endif()
389
390 find_package(POD)
391
392 #Platform specific
393 if(UNIX)
394         set(WS_VAR_IMPORT "extern")
395 endif()
396
397 if(APPLE)
398 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
399         set(HAVE_OS_X_FRAMEWORKS 1)
400         FIND_LIBRARY (APPLE_CORE_SERVICES_LIBRARY CoreServices)
401         FIND_LIBRARY (APPLE_COCOA_LIBRARY Cocoa)
402 endif()
403
404 if(WIN32)
405         add_definitions(-D_NEED_VAR_IMPORT_)
406         set(WS_VAR_IMPORT "__declspec(dllimport) extern")
407
408         # Disable deprecation
409         if(MSVC80 OR MSVC90)
410                 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
411         endif()
412 endif()
413
414 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
415
416 include(FeatureSummary)
417 #SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ]
418 PRINT_ENABLED_FEATURES()
419 PRINT_DISABLED_FEATURES()
420
421 link_directories(
422         gtk
423         codecs
424         epan
425         wiretap
426         wsutil
427 )
428
429 ADD_CUSTOM_TARGET(
430         svnversion ALL
431         COMMAND ${PERL}
432                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
433                 ${CMAKE_CURRENT_SOURCE_DIR}
434         DEPENDS
435                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
436 )
437
438 ADD_CUSTOM_COMMAND(
439         OUTPUT  svnversion.h
440         COMMAND ${PERL}
441                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
442                 ${CMAKE_CURRENT_SOURCE_DIR}
443         DEPENDS
444                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
445 )
446
447 register_tap_files(tshark-tap-register.c
448         ${TSHARK_TAP_SRC}
449 )
450
451 ADD_CUSTOM_COMMAND(
452         OUTPUT  ps.c
453         COMMAND ${PYTHON_EXECUTABLE}
454                 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
455                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
456                 ps.c
457         DEPENDS
458                 ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
459                 ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
460 )
461
462 if(UNIX)
463         set(PLATFORM_SRC
464                 capture-pcap-util-unix.c
465         )
466 endif()
467
468 if(WIN32)
469         set(PLATFORM_SRC
470                 capture-wpcap.c capture_wpcap_packet.c
471         )
472 endif()
473
474 set(WTAP_PLUGIN_SOURCES
475         epan/plugins.c
476         epan/report_err.c
477         epan/filesystem.c
478 )
479
480 set(SHARK_COMMON_CAPTURE_SRC
481         capture_errs.c
482         capture_ifinfo.c
483         capture_ui_utils.c
484 )
485
486 set(WIRESHARK_COMMON_SRC
487         ${PLATFORM_SRC}
488         capture-pcap-util.c
489         cfile.c
490         clopts_common.c
491         disabled_protos.c
492         packet-range.c
493         print.c
494         ps.c
495         svnversion.h
496         sync_pipe_write.c
497         timestats.c
498         util.c
499         tap-megaco-common.c
500         tap-rtp-common.c
501         version_info.c
502 )
503
504 set(TSHARK_TAP_SRC
505         tap-afpstat.c
506         tap-ansi_astat.c
507         tap-bootpstat.c
508         tap-camelcounter.c
509         tap-camelsrt.c
510         tap-comparestat.c
511         tap-dcerpcstat.c
512         tap-diameter-avp.c
513         tap-funnel.c
514         tap-gsm_astat.c
515         tap-h225counter.c
516         tap-h225rassrt.c
517         tap-httpstat.c
518         tap-iostat.c
519         tap-iousers.c
520         tap-mgcpstat.c
521         tap-megacostat.c
522         tap-protocolinfo.c
523         tap-protohierstat.c
524         tap-radiusstat.c
525         tap-rpcstat.c
526         tap-rpcprogs.c
527         tap-rtp.c
528         tap-sctpchunkstat.c
529         tap-sipstat.c
530         tap-smbsids.c
531         tap-smbstat.c
532         tap-stats_tree.c
533         tap-wspstat.c
534 )
535
536 set(INSTALL_DIRS
537         diameter
538         dtds
539         help
540         radius
541         tpncp
542         wimaxasncp
543 )
544
545 set(INSTALL_FILES
546         ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
547         COPYING
548         ${CMAKE_BINARY_DIR}/capinfos.html
549         cfilters
550         colorfilters
551         dfilters
552         ${CMAKE_BINARY_DIR}/dumpcap.html
553         ${CMAKE_BINARY_DIR}/editcap.html
554         ${CMAKE_BINARY_DIR}/idl2wrs.html
555         ipmap.html
556         manuf
557         ${CMAKE_BINARY_DIR}/mergecap.html
558         ${CMAKE_BINARY_DIR}/rawshark.html
559         services
560         smi_modules
561         ${CMAKE_BINARY_DIR}/text2pcap.html
562         ${CMAKE_BINARY_DIR}/tshark.html
563         ${CMAKE_BINARY_DIR}/wireshark-filter.html
564         ${CMAKE_BINARY_DIR}/wireshark.html
565         docbook/ws.css
566 )
567
568 set(LIBEPAN_LIBS
569 #               @GETOPT_O@      # wsgetopt.c
570 #               @INET_ATON_LO@  # epan/inet_aton.c
571 #               @INET_NTOP_LO@  # inet_ntop.c
572 #               @INET_PTON_LO@  # inet_pton.c
573 #               @NSL_LIBS@      # -lnsl
574 #               @SOCKET_LIBS@   # -lsocket
575 #               @SSL_LIBS@      # -lcrypto
576 #               @STRERROR_O@    # strerror.c
577 #               @STRNCASECMP_O@ # strncasecmp.c
578 #               @STRPTIME_O@    # strptime.c
579                 epan
580 #               $(plugin_ldadd) # in case of static
581                 ${PCRE_LIBRARIES}
582                 ${PCAP_LIBRARIES}
583                 ${CARES_LIBRARIES}
584                 ${ADNS_LIBRARIES}
585                 ${KERBEROS_LIBRARIES}
586                 ${LUA_LIBRARIES}
587                 ${PYTHON_LIBRARIES}
588                 ${GEOIP_LIBRARIES}
589                 ${GCRYPT_LIBRARIES}
590                 ${GNUTLS_LIBRARIES}
591                 ${SMI_LIBRARIES}
592                 ${Z_LIBRARIES}
593                 ${M_LIBRARIES}
594 )
595
596 if(BUILD_wireshark)
597         set(wireshark_LIBS
598                 ui
599                 ${GTK2_LIBRARIES}
600                 codecs
601                 ${PORTAUDIO_LIBRARIES}
602                 ${LIBEPAN_LIBS}
603                 ${APPLE_CORE_SERVICES_LIBRARY}
604                 ${APPLE_COCOA_LIBRARY}
605         )
606         set(wireshark_FILES
607                 airpcap_loader.c
608                 alert_box.c
609                 capture.c
610                 capture_info.c
611                 capture_opts.c
612                 capture_sync.c
613                 color_filters.c
614                 file.c
615                 fileset.c
616                 filters.c
617                 g711.c
618                 merge.c
619                 proto_hier_stats.c
620                 summary.c
621                 tempfile.c
622                 ${SHARK_COMMON_CAPTURE_SRC}
623                 ${WIRESHARK_COMMON_SRC}
624         )
625         add_executable(wireshark ${wireshark_FILES})
626         add_dependencies(wireshark svnversion)
627         set_target_properties(wireshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
628         target_link_libraries(wireshark ${wireshark_LIBS})
629         install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
630 endif()
631
632 if(BUILD_tshark)
633         set(tshark_LIBS
634                 ${LIBEPAN_LIBS}
635                 ${APPLE_COCOA_LIBRARY}
636         )
637         set(tshark_FILES
638                 capture_opts.c
639                 capture_sync.c
640                 tempfile.c
641                 tshark-tap-register.c
642                 tshark.c
643                 ${TSHARK_TAP_SRC}
644                 ${SHARK_COMMON_CAPTURE_SRC}
645                 ${WIRESHARK_COMMON_SRC}
646         )
647         add_executable(tshark ${tshark_FILES})
648         add_dependencies(tshark svnversion)
649         set_target_properties(tshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
650         target_link_libraries(tshark ${tshark_LIBS})
651         install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
652 endif()
653
654 if(BUILD_rawshark)
655         set(rawshark_LIBS
656                 ${LIBEPAN_LIBS}
657                 ${APPLE_COCOA_LIBRARY}
658         )
659         set(rawshark_FILES
660                 ${WIRESHARK_COMMON_SRC}
661                 rawshark.c
662         )
663         add_executable(rawshark ${rawshark_FILES})
664         add_dependencies(rawshark svnversion)
665         set_target_properties(rawshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
666         target_link_libraries(rawshark ${rawshark_LIBS})
667         install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
668 endif()
669
670 if(BUILD_dftest)
671         set(dftest_LIBS
672                 ${LIBEPAN_LIBS}
673         )
674         set(dftest_FILES
675                 dftest.c
676                 util.c
677         )
678         add_executable(dftest ${dftest_FILES})
679         set_target_properties(dftest PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
680         target_link_libraries(dftest ${dftest_LIBS})
681         install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
682 endif()
683
684 if(BUILD_randpkt)
685         set(randpkt_LIBS
686                 wiretap
687                 ${M_LIBRARIES}
688                 ${PCAP_LIBRARIES}
689 #               @SOCKET_LIBS@
690 #               @NSL_LIBS@
691                 ${CARES_LIBRARIES}
692                 ${ADNS_LIBRARIES}
693                 ${Z_LIBRARIES}
694         )
695         set(randpkt_FILES
696                 randpkt.c
697         )
698         add_executable(randpkt ${randpkt_FILES})
699         set_target_properties(randpkt PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
700         target_link_libraries(randpkt ${randpkt_LIBS})
701         install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
702 endif()
703
704 if(BUILD_text2pcap)
705         set(text2pcap_LIBS
706                 wiretap
707                 ${M_LIBRARIES}
708                 ${Z_LIBRARIES}
709         )
710         set(text2pcap_FILES
711                 text2pcap.c
712         )
713         add_lex_files(text2pcap_FILES
714                 text2pcap-scanner.l
715         )
716         add_executable(text2pcap ${text2pcap_FILES})
717         add_dependencies(text2pcap svnversion)
718         set_target_properties(text2pcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
719         target_link_libraries(text2pcap ${text2pcap_LIBS})
720         install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
721 endif()
722
723 if(BUILD_mergecap)
724         set(mergecap_LIBS
725                 wiretap
726                 ${Z_LIBRARIES}
727         )
728         set(mergecap_FILES
729                 mergecap.c
730                 merge.c
731                 svnversion.h
732         )
733         add_executable(mergecap ${mergecap_FILES})
734         add_dependencies(mergecap svnversion)
735         set_target_properties(mergecap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
736         target_link_libraries(mergecap ${mergecap_LIBS})
737         install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
738 endif()
739
740 if(BUILD_capinfos)
741         set(capinfos_LIBS
742                 wiretap
743                 ${Z_LIBRARIES}
744                 ${GCRYPT_LIBRARIES}
745                 ${APPLE_COCOA_LIBRARY}
746         )
747         set(capinfos_FILES
748                 capinfos.c
749                 ${WTAP_PLUGIN_SOURCES}
750         )
751         add_executable(capinfos ${capinfos_FILES})
752         set_target_properties(capinfos PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
753         target_link_libraries(capinfos ${capinfos_LIBS})
754         install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
755 endif()
756
757 if(BUILD_editcap)
758         set(editcap_LIBS
759                 wiretap
760                 ${Z_LIBRARIES}
761         )
762         set(editcap_FILES
763                 editcap.c
764                 epan/crypt/crypt-md5.c
765                 epan/nstime.c
766                 ${WTAP_PLUGIN_SOURCES}
767         )
768         add_executable(editcap ${editcap_FILES})
769         add_dependencies(editcap svnversion)
770         set_target_properties(editcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
771         target_link_libraries(editcap ${editcap_LIBS})
772         install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
773 endif()
774
775 if(BUILD_dumpcap)
776         set(dumpcap_LIBS
777                 wiretap
778 #               @INET_NTOP_LO@
779                 ${PCAP_LIBRARIES}
780                 ${CAP_LIBRARIES}
781 #               @SOCKET_LIBS@
782 #               @NSL_LIBS@
783                 ${GCRYPT_LIBRARIES}
784                 ${GNUTLS_LIBRARIES}
785                 ${Z_LIBRARIES}
786                 ${APPLE_COCOA_LIBRARY}
787         )
788         set(dumpcap_FILES
789                 svnversion.h
790                 capture_opts.c
791                 capture-pcap-util.c
792                 capture_stop_conditions.c
793                 clopts_common.c
794                 conditions.c
795                 dumpcap.c
796                 pcapio.c
797                 ringbuffer.c
798                 sync_pipe_write.c
799                 tempfile.c
800                 version_info.c
801                 ${PLATFORM_SRC}
802         )
803         add_executable(dumpcap ${dumpcap_FILES})
804         add_dependencies(dumpcap svnversion)
805         set_target_properties(dumpcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
806         target_link_libraries(dumpcap ${dumpcap_LIBS})
807         install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
808 endif()
809
810 ADD_CUSTOM_COMMAND(
811         OUTPUT  AUTHORS-SHORT
812         COMMAND ${PERL}
813                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
814                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
815                 < ${CMAKE_SOURCE_DIR}/AUTHORS
816                 > AUTHORS-SHORT
817         DEPENDS
818                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
819                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
820                 ${CMAKE_SOURCE_DIR}/AUTHORS
821 )
822
823 ADD_CUSTOM_COMMAND(
824         OUTPUT  AUTHORS-SHORT-FORMAT
825                 wireshark.pod
826         COMMAND ${PERL}
827                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
828                 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
829                 < AUTHORS-SHORT
830                 > AUTHORS-SHORT-FORMAT
831         COMMAND cat
832                 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
833                 AUTHORS-SHORT-FORMAT
834                 > wireshark.pod
835         DEPENDS
836                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
837                 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
838                 AUTHORS-SHORT
839                 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
840 )
841
842 ADD_CUSTOM_COMMAND(
843         OUTPUT  wireshark-filter.pod
844         COMMAND tshark
845                 -G fields |
846                 ${PERL}
847                 ${CMAKE_SOURCE_DIR}/doc/dfilter2pod.pl
848                 ${CMAKE_SOURCE_DIR}/doc/wireshark-filter.pod.template
849                 > wireshark-filter.pod
850         DEPENDS
851                 ${CMAKE_SOURCE_DIR}/doc/dfilter2pod.pl
852                 ${CMAKE_SOURCE_DIR}/doc/wireshark-filter.pod.template
853                 tshark
854 )
855
856 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/capinfos 1 )
857 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dumpcap 1 )
858 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/editcap 1 )
859 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/idl2wrs 1 )
860 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/mergecap 1 )
861 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/rawshark 1 )
862 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/text2pcap 1 )
863 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/tshark 1 )
864 pod2manhtml( wireshark 1 )
865 pod2manhtml( wireshark-filter 4 )
866
867 add_custom_target(
868         auxiliary ALL
869         DEPENDS
870                 AUTHORS-SHORT
871                 capinfos.html
872                 dumpcap.html
873                 editcap.html
874                 idl2wrs.html
875                 mergecap.html
876                 rawshark.html
877                 text2pcap.html
878                 tshark.html
879                 wireshark.html
880                 wireshark-filter.html
881 )
882
883 set(MAN1_FILES
884         ${CMAKE_BINARY_DIR}/capinfos.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}/rawshark.1
890         ${CMAKE_BINARY_DIR}/text2pcap.1
891         ${CMAKE_BINARY_DIR}/tshark.1
892         ${CMAKE_BINARY_DIR}/wireshark.1
893 )
894
895 set(MAN4_FILES
896         ${CMAKE_BINARY_DIR}/wireshark-filter.4
897 )
898
899 set(CLEAN_FILES
900         ${wireshark_FILES}
901         ${tshark_FILES}
902         ${rawshark_FILES}
903         ${dftest_FILES}
904         ${randpkt_FILES}
905         ${text2pcap_FILES}
906         ${mergecap_FILES}
907         ${capinfos_FILES}
908         ${editcap_FILES}
909         ${dumpcap_FILES}
910 )
911
912 if (WERROR)
913         set_source_files_properties(
914                 ${CLEAN_FILES}
915                 PROPERTIES
916                 COMPILE_FLAGS -Werror
917         )
918 endif()
919
920 install(
921         FILES
922                 ${INSTALL_FILES}
923         DESTINATION
924                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
925 )
926
927 install(
928         FILES
929                 ${MAN1_FILES}
930         DESTINATION
931                 ${CMAKE_INSTALL_MANDIR}/man1
932 )
933
934 install(
935         FILES
936                 ${MAN4_FILES}
937         DESTINATION
938                 ${CMAKE_INSTALL_MANDIR}/man4
939 )
940
941 install(
942         DIRECTORY
943                 ${INSTALL_DIRS}
944         DIRECTORY_PERMISSIONS
945                 OWNER_EXECUTE OWNER_WRITE OWNER_READ
946                 GROUP_EXECUTE GROUP_READ
947                 WORLD_EXECUTE WORLD_READ
948         DESTINATION
949                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
950         PATTERN ".svn" EXCLUDE
951         PATTERN "Makefile.*" EXCLUDE
952         PATTERN "faq.py" EXCLUDE
953 )