Use absolute paths in link_directories.
[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-sctpchunkstat.c
539         tap-sipstat.c
540         tap-smbsids.c
541         tap-smbstat.c
542         tap-stats_tree.c
543         tap-sv.c
544         tap-wspstat.c
545 )
546
547 set(INSTALL_DIRS
548         diameter
549         dtds
550         help
551         radius
552         tpncp
553         wimaxasncp
554 )
555
556 set(INSTALL_FILES
557         ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
558         COPYING
559         ${CMAKE_BINARY_DIR}/capinfos.html
560         cfilters
561         colorfilters
562         dfilters
563         ${CMAKE_BINARY_DIR}/dftest.html
564         ${CMAKE_BINARY_DIR}/dumpcap.html
565         ${CMAKE_BINARY_DIR}/editcap.html
566         ${CMAKE_BINARY_DIR}/idl2wrs.html
567         ipmap.html
568         manuf
569         ${CMAKE_BINARY_DIR}/mergecap.html
570         ${CMAKE_BINARY_DIR}/randpkt.html
571         ${CMAKE_BINARY_DIR}/rawshark.html
572         services
573         smi_modules
574         ${CMAKE_BINARY_DIR}/text2pcap.html
575         ${CMAKE_BINARY_DIR}/tshark.html
576         ${CMAKE_BINARY_DIR}/wireshark-filter.html
577         ${CMAKE_BINARY_DIR}/wireshark.html
578         docbook/ws.css
579 )
580
581 set(LIBEPAN_LIBS
582 #               @NSL_LIBS@      # -lnsl
583 #               @SOCKET_LIBS@   # -lsocket
584 #               @SSL_LIBS@      # -lcrypto
585                 epan
586 #               $(plugin_ldadd) # in case of static
587                 ${PCRE_LIBRARIES}
588                 ${PCAP_LIBRARIES}
589                 ${CARES_LIBRARIES}
590                 ${ADNS_LIBRARIES}
591                 ${KERBEROS_LIBRARIES}
592                 ${LUA_LIBRARIES}
593                 ${PYTHON_LIBRARIES}
594                 ${GEOIP_LIBRARIES}
595                 ${GCRYPT_LIBRARIES}
596                 ${GNUTLS_LIBRARIES}
597                 ${SMI_LIBRARIES}
598                 ${ZLIB_LIBRARIES}
599                 ${M_LIBRARIES}
600 )
601
602 if(BUILD_wireshark)
603         set(wireshark_LIBS
604                 ui
605                 ${GTK2_LIBRARIES}
606                 codecs
607                 ${PORTAUDIO_LIBRARIES}
608                 ${LIBEPAN_LIBS}
609                 ${APPLE_CORE_SERVICES_LIBRARY}
610                 ${APPLE_COCOA_LIBRARY}
611         )
612         set(wireshark_FILES
613                 airpcap_loader.c
614                 alert_box.c
615                 capture.c
616                 capture_info.c
617                 capture_opts.c
618                 capture_sync.c
619                 color_filters.c
620                 file.c
621                 fileset.c
622                 filters.c
623                 g711.c
624                 merge.c
625                 proto_hier_stats.c
626                 summary.c
627                 tempfile.c
628                 ${SHARK_COMMON_CAPTURE_SRC}
629                 ${WIRESHARK_COMMON_SRC}
630         )
631         add_executable(wireshark ${wireshark_FILES})
632         add_dependencies(wireshark svnversion)
633         set_target_properties(wireshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
634         target_link_libraries(wireshark ${wireshark_LIBS})
635         install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
636 endif()
637
638 if(BUILD_tshark)
639         set(tshark_LIBS
640                 ${LIBEPAN_LIBS}
641                 ${APPLE_COCOA_LIBRARY}
642         )
643         set(tshark_FILES
644                 capture_opts.c
645                 capture_sync.c
646                 tempfile.c
647                 tshark-tap-register.c
648                 tshark.c
649                 ${TSHARK_TAP_SRC}
650                 ${SHARK_COMMON_CAPTURE_SRC}
651                 ${WIRESHARK_COMMON_SRC}
652         )
653         add_executable(tshark ${tshark_FILES})
654         add_dependencies(tshark svnversion)
655         set_target_properties(tshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
656         target_link_libraries(tshark ${tshark_LIBS})
657         install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
658 endif()
659
660 if(BUILD_rawshark)
661         set(rawshark_LIBS
662                 ${LIBEPAN_LIBS}
663                 ${APPLE_COCOA_LIBRARY}
664         )
665         set(rawshark_FILES
666                 ${WIRESHARK_COMMON_SRC}
667                 rawshark.c
668         )
669         add_executable(rawshark ${rawshark_FILES})
670         add_dependencies(rawshark svnversion)
671         set_target_properties(rawshark PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
672         target_link_libraries(rawshark ${rawshark_LIBS})
673         install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
674 endif()
675
676 if(BUILD_dftest)
677         set(dftest_LIBS
678                 ${LIBEPAN_LIBS}
679         )
680         set(dftest_FILES
681                 dftest.c
682                 util.c
683         )
684         add_executable(dftest ${dftest_FILES})
685         set_target_properties(dftest PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
686         target_link_libraries(dftest ${dftest_LIBS})
687         install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
688 endif()
689
690 if(BUILD_randpkt)
691         set(randpkt_LIBS
692                 wiretap
693                 ${M_LIBRARIES}
694                 ${PCAP_LIBRARIES}
695 #               @SOCKET_LIBS@
696 #               @NSL_LIBS@
697                 ${CARES_LIBRARIES}
698                 ${ADNS_LIBRARIES}
699                 ${ZLIB_LIBRARIES}
700         )
701         set(randpkt_FILES
702                 randpkt.c
703         )
704         add_executable(randpkt ${randpkt_FILES})
705         set_target_properties(randpkt PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
706         target_link_libraries(randpkt ${randpkt_LIBS})
707         install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
708 endif()
709
710 if(BUILD_text2pcap)
711         set(text2pcap_LIBS
712                 wiretap
713                 ${M_LIBRARIES}
714                 ${ZLIB_LIBRARIES}
715         )
716         set(text2pcap_CLEAN_FILES
717                 text2pcap.c
718         )
719         set(text2pcap_FILES
720                 ${text2pcap_CLEAN_FILES}
721         )
722         add_lex_files(text2pcap_FILES
723                 text2pcap-scanner.l
724         )
725         add_executable(text2pcap ${text2pcap_FILES})
726         add_dependencies(text2pcap svnversion)
727         set_target_properties(text2pcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
728         target_link_libraries(text2pcap ${text2pcap_LIBS})
729         install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
730 endif()
731
732 if(BUILD_mergecap)
733         set(mergecap_LIBS
734                 wiretap
735                 ${ZLIB_LIBRARIES}
736         )
737         set(mergecap_FILES
738                 mergecap.c
739                 merge.c
740                 svnversion.h
741         )
742         add_executable(mergecap ${mergecap_FILES})
743         add_dependencies(mergecap svnversion)
744         set_target_properties(mergecap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
745         target_link_libraries(mergecap ${mergecap_LIBS})
746         install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
747 endif()
748
749 if(BUILD_capinfos)
750         set(capinfos_LIBS
751                 wiretap
752                 ${ZLIB_LIBRARIES}
753                 ${GCRYPT_LIBRARIES}
754                 ${APPLE_COCOA_LIBRARY}
755         )
756         set(capinfos_FILES
757                 capinfos.c
758                 ${WTAP_PLUGIN_SOURCES}
759         )
760         add_executable(capinfos ${capinfos_FILES})
761         add_dependencies(capinfos svnversion)
762         set_target_properties(capinfos PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
763         target_link_libraries(capinfos ${capinfos_LIBS})
764         install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
765 endif()
766
767 if(BUILD_editcap)
768         set(editcap_LIBS
769                 wiretap
770                 ${ZLIB_LIBRARIES}
771         )
772         set(editcap_FILES
773                 editcap.c
774                 epan/crypt/crypt-md5.c
775                 epan/nstime.c
776                 ${WTAP_PLUGIN_SOURCES}
777         )
778         add_executable(editcap ${editcap_FILES})
779         add_dependencies(editcap svnversion)
780         set_target_properties(editcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
781         target_link_libraries(editcap ${editcap_LIBS})
782         install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
783 endif()
784
785 if(BUILD_dumpcap)
786         set(dumpcap_LIBS
787                 wiretap
788 #               @INET_NTOP_LO@
789                 ${PCAP_LIBRARIES}
790                 ${CAP_LIBRARIES}
791 #               @SOCKET_LIBS@
792 #               @NSL_LIBS@
793                 ${ZLIB_LIBRARIES}
794                 ${APPLE_COCOA_LIBRARY}
795         )
796         set(dumpcap_FILES
797                 svnversion.h
798                 capture_opts.c
799                 capture-pcap-util.c
800                 capture_stop_conditions.c
801                 clopts_common.c
802                 conditions.c
803                 dumpcap.c
804                 pcapio.c
805                 ringbuffer.c
806                 sync_pipe_write.c
807                 tempfile.c
808                 version_info.c
809                 ${PLATFORM_SRC}
810         )
811         add_executable(dumpcap ${dumpcap_FILES})
812         add_dependencies(dumpcap svnversion)
813         set_target_properties(dumpcap PROPERTIES LINK_FLAGS ${WS_LINK_FLAGS})
814         target_link_libraries(dumpcap ${dumpcap_LIBS})
815         install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
816 endif()
817
818 ADD_CUSTOM_COMMAND(
819         OUTPUT  AUTHORS-SHORT
820         COMMAND ${PERL}
821                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
822                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
823                 < ${CMAKE_SOURCE_DIR}/AUTHORS
824                 > AUTHORS-SHORT
825         DEPENDS
826                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
827                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
828                 ${CMAKE_SOURCE_DIR}/AUTHORS
829 )
830
831 ADD_CUSTOM_COMMAND(
832         OUTPUT  AUTHORS-SHORT-FORMAT
833                 wireshark.pod
834         COMMAND ${PERL}
835                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
836                 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
837                 < AUTHORS-SHORT
838                 > AUTHORS-SHORT-FORMAT
839         COMMAND cat
840                 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
841                 AUTHORS-SHORT-FORMAT
842                 > wireshark.pod
843         DEPENDS
844                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
845                 ${CMAKE_SOURCE_DIR}/doc/make-authors-format.pl
846                 AUTHORS-SHORT
847                 ${CMAKE_SOURCE_DIR}/doc/wireshark.pod.template
848 )
849
850 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/capinfos 1 )
851 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dftest 1 )
852 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/dumpcap 1 )
853 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/editcap 1 )
854 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/idl2wrs 1 )
855 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/mergecap 1 )
856 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/randpkt 1 )
857 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/rawshark 1 )
858 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/text2pcap 1 )
859 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/tshark 1 )
860 pod2manhtml( wireshark 1 )
861 pod2manhtml( ${CMAKE_SOURCE_DIR}/doc/wireshark-filter 4 )
862
863 add_custom_target(
864         auxiliary ALL
865         DEPENDS
866                 AUTHORS-SHORT
867                 capinfos.html
868                 dftest.html
869                 dumpcap.html
870                 editcap.html
871                 idl2wrs.html
872                 mergecap.html
873                 randpkt.html
874                 rawshark.html
875                 text2pcap.html
876                 tshark.html
877                 wireshark.html
878                 wireshark-filter.html
879 )
880
881 set(MAN1_FILES
882         ${CMAKE_BINARY_DIR}/capinfos.1
883         ${CMAKE_BINARY_DIR}/dftest.1
884         ${CMAKE_BINARY_DIR}/dumpcap.1
885         ${CMAKE_BINARY_DIR}/editcap.1
886         ${CMAKE_BINARY_DIR}/idl2wrs.1
887         ${CMAKE_BINARY_DIR}/mergecap.1
888         ${CMAKE_BINARY_DIR}/randpkt.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_CLEAN_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 )