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