Compile and link idl2wrs
[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
28 #Where to find local cmake scripts
29 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
30 INCLUDE(UseLemon)
31 INCLUDE(UseMakeDissectorReg)
32 INCLUDE(UseMakeTapReg)
33
34 # Under linux the release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG
35
36 # Disable this later. Alternative: "make VERBOSE=1"
37 set(CMAKE_VERBOSE_MAKEFILE ON)
38
39 set(BUILD_SHARED_LIBS ON)
40
41 #Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ...
42 include(CMakeInstallDirs)
43
44 include_directories(
45         ${CMAKE_BINARY_DIR}
46         ${CMAKE_SOURCE_DIR}
47         ${CMAKE_SOURCE_DIR}/epan
48         ${CMAKE_SOURCE_DIR}/tools/lemon
49         ${CMAKE_SOURCE_DIR}/wiretap
50 )
51
52 #Where to put libraries
53 if(NOT LIBRARY_OUTPUT_PATH)
54         set(LIBRARY_OUTPUT_PATH ${Wireshark_BINARY_DIR}/lib CACHE INTERNAL
55                    "Single output directory for building all libraries.")
56 endif()
57
58 option(BUILD_wireshark   "Build the GUI version of Wireshark" ON)
59 option(BUILD_tshark      "Build tshark" ON)
60 option(BUILD_rawshark    "Build rawshark" ON)
61 option(BUILD_dumpcap     "Build dumpcap" ON)
62 option(BUILD_text2pcap   "Build text2pcap" ON)
63 option(BUILD_mergecap    "Build mergecap" ON)
64 option(BUILD_editcap     "Build editcap" ON)
65 option(BUILD_capinfos    "Build capinfos" ON)
66 option(BUILD_randpkt     "Build randpkt" ON)
67 option(BUILD_dftest      "Build dftest" ON)
68 option(AUTOGEN_dcerpc    "Autogenerate dcerpc dissectors" OFF)
69 option(AUTOGEN_pidl      "Autogenerate pidl dissectors" OFF)
70
71 option(DISABLE_WERROR    "Do not treat Warnings as errors" OFF)
72 option(ENABLE_EXTRA_GCC_CHECKS "Do additional -W checks in GCC (disables -Werror)" ON)
73 option(ENABLE_AIRPCAP    "Enable Airpcap support" ON)
74 # todo
75 option(ENABLE_STATIC     "Build a static version of Wireshark" OFF)
76 option(ENABLE_PLUGINS    "Build with plugins" ON)
77
78 option(ENABLE_ADNS       "Build with adns support" ON)
79 option(ENABLE_PCRE       "Build with pcre support" ON)
80 option(ENABLE_PORTAUDIO  "Build with portaudio support" ON)
81 option(ENABLE_Z          "Build with zlib compression support" ON)
82 # todo wslua currently seems to be broken
83 option(ENABLE_LUA        "Build with lua dissector support" ON)
84 option(ENABLE_PYTHON     "Build with python dissector support" ON)
85 option(ENABLE_SMI        "Build with smi snmp support" ON)
86 option(ENABLE_GNUTLS     "Build with GNU TLS support" ON)
87 option(ENABLE_GCRYPT     "Build with GNU crypto support" ON)
88 option(ENABLE_GEOIP      "Build with GeoIP support" ON)
89 option(ENABLE_CAP        "Build with posix capabilities support" ON)
90 option(ENABLE_CARES      "Build with c_ares support" ON)
91 # todo Mostly hardcoded
92 option(ENABLE_KERBEROS   "Build with Kerberos support" ON)
93
94
95 set(WIRESHARK_C_FLAGS
96         -O2
97         -Werror
98         -Wall
99         -W
100         -Wextra
101         -Wdeclaration-after-statement
102         -Wendif-labels
103         -Wpointer-arith
104         -Wno-pointer-sign
105         -Warray-bounds
106         -Wcast-align
107         -Wformat-security
108 )
109
110 set(WIRESHARK_EXTRA_C_FLAGS
111         -pedantic
112         -Woverflow
113         -Wlogical-op
114         -Wno-overlength-strings
115         -fstrict-overflow -Wstrict-overflow=4
116         -Wunreachable-code
117         -Wunsafe-loop-optimizations
118         -Wno-long-long
119         -Wbad-function-cast
120         -Wcast-qual
121         -Waddress
122         -Warray-bounds
123         -Wattributes
124         -Wdiv-by-zero
125         -Wformat-security
126         -Wignored-qualifiers
127         -Wpragmas
128         -Wredundant-decls
129         -Wvla
130         # packet-ncp2222.inc prevents this from going into all warnings
131         -Wwrite-strings
132         -Wstrict-prototypes
133         -Wmissing-declarations
134         # Problem with packet-afs.c
135         -Wshadow
136         # More cleanup needed for this on LP64
137         -Wshorten-64-to-32
138 )
139
140 if(ENABLE_EXTRA_GCC_CHECKS)
141         set(WIRESHARK_C_FLAGS ${WIRESHARK_C_FLAGS} ${WIRESHARK_EXTRA_C_FLAGS})
142 endif()
143
144 add_definitions(
145         -DHAVE_CONFIG_H
146         -DPACKAGE=\"wireshark\"
147         -DNEW_PACKET_LIST
148 )
149
150 # Counterhack to work around some cache magic in CHECK_C_SOURCE_COMPILES
151 include(CheckCCompilerFlag)
152 set(C 0)
153 # Sigh: Have to use THIS_FLAG instead of ${F} for some reason
154 foreach(THIS_FLAG ${WIRESHARK_C_FLAGS})
155         set(F WS_C_FLAG_${C})
156         set(${F} ${THIS_FLAG})
157         set(V WS_C_FLAG_VALID${C})
158         check_c_compiler_flag(${${F}} ${V})
159         if (${${V}})
160                 add_definitions(${${F}})
161         endif()
162         math(EXPR C "${C} + 1")
163 endforeach()
164
165 if(DISABLE_WERROR OR ENABLE_EXTRA_GCC_CHECKS)
166         remove_definitions( -Werror )
167 endif()
168
169 if(CMAKE_COMPILER_IS_GNUCC)
170         add_definitions( -D_U_=__attribute__\(\(unused\)\) )
171 else()
172         add_definitions( -D_U_=\"\" )
173 endif()
174
175 # todo 
176 # Same for linker flags, but it looks like it's do-it-yourself here
177 # AC_WIRESHARK_GCC_LDFLAGS_CHECK([-Wl,--as-needed])
178
179 #The minimum package list
180 set(PACKAGELIST GLIB2 PCAP M LEX YACC Perl SH PythonInterp HtmlViewer ${PACKAGELIST})
181
182 #Build the gui ?
183 if(BUILD_wireshark)
184         set(PACKAGELIST GTK2 ${PACKAGELIST})
185 endif()
186
187 # SMI SNMP
188 if(ENABLE_SMI)
189         set(PACKAGELIST SMI ${PACKAGELIST})
190 endif()
191
192 # GNU crypto
193 if(ENABLE_GCRYPT)
194         set(PACKAGELIST GCRYPT ${PACKAGELIST})
195 endif()
196
197 # GNU SSL/TLS support
198 if(ENABLE_GNUTLS)
199         set(PACKAGELIST GNUTLS ${PACKAGELIST})
200 endif()
201
202 # Regular expressions lib
203 if(ENABLE_PCRE)
204         set(PACKAGELIST PCRE ${PACKAGELIST})
205 endif()
206
207 # Kerberos
208 if(ENABLE_KERBEROS)
209         set(PACKAGELIST KERBEROS ${PACKAGELIST})
210 endif()
211
212 # Portable audio
213 if(ENABLE_PORTAUDIO)
214         set(PACKAGELIST PORTAUDIO ${PACKAGELIST})
215 endif()
216
217
218 # Prefer c-ares over adns
219 if(ENABLE_CARES)        # C Asynchronouse resolver
220         set(PACKAGELIST CARES ${PACKAGELIST})
221 elseif(ENABLE_ADNS)     # Gnu asynchronous DNS
222         set(PACKAGELIST ADNS ${PACKAGELIST})
223 endif()
224
225 # Zlib compression
226 if(ENABLE_Z)
227         set(PACKAGELIST Z ${PACKAGELIST})
228 endif()
229
230 # Lua 5.1 dissectors
231 if(ENABLE_LUA)
232         set(PACKAGELIST LUA ${PACKAGELIST})
233 endif()
234
235 # GeoIP address resolving
236 if(ENABLE_GEOIP)
237         set(PACKAGELIST GEOIP ${PACKAGELIST})
238 endif()
239
240 # Capabilities
241 if(ENABLE_CAP)
242         set(PACKAGELIST CAP ${PACKAGELIST})
243 endif()
244
245 if(ENABLE_PYTHON)
246         set(PACKAGELIST PYTHON ${PACKAGELIST})
247 endif()
248
249 set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
250
251 #Let's loop the package list
252 foreach(PACKAGE ${PACKAGELIST})
253         find_package(${PACKAGE} REQUIRED)
254         message(${PACKAGE}_FOUND)
255         if (${PACKAGE}_FOUND)
256                 set(HAVE_LIB${PACKAGE} 1)
257                 include_directories(${${PACKAGE}_INCLUDE_DIRS})
258                 message(STATUS "${PACKAGE} includes: ${${PACKAGE}_INCLUDE_DIRS}")
259                 message(STATUS "${PACKAGE} libs: ${${PACKAGE}_LIBRARIES}")
260         endif()
261 endforeach()
262
263 find_package(YAPP)
264
265 if(HAVE_LIBPYTHON)
266         set(HAVE_PYTHON 1)
267         set(PYTHON_DIR "${CMAKE_INSTALL_PREFIX}/lib/wireshark/python/${VERSION}")
268 endif()
269 if(HAVE_LIBLUA)
270         set(HAVE_LUA_H 1)
271         set(HAVE_LUA_5_1 1)
272 endif()
273 if(HAVE_LIBKERBEROS)
274         set(HAVE_KERBEROS 1)
275         # HAVE_HEIMDAL_KERBEROS
276         set(HAVE_MIT_KERBEROS 1)
277         set(HAVE_KEYTYPE_ARCFOUR_56 1)
278 endif()
279 if(HAVE_LIBGEOIP)
280         set(HAVE_GEOIP 1)
281 endif()
282 if(HAVE_LIBCARES)
283         set(HAVE_C_ARES 1)
284 endif()
285 if(HAVE_LIBADNS)
286         set(HAVE_GNU_ADNS 1)
287 endif()
288 if(ENABLE_AIRPCAP)
289         set(HAVE_AIRPCAP 1)
290 endif()
291
292 include(ConfigureChecks.cmake)
293
294 #Big or little endian ?
295 include(TestBigEndian)
296 test_big_endian(WORDS_BIGENDIAN)
297
298 #packaging
299 set(CPACK_PACKAGE_NAME wireshark)
300 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "capture packet")
301 set(CPACK_PACKAGE_VENDOR "wireshark")
302 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
303 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
304 set(CPACK_PACKAGE_VERSION_MAJOR "1")
305 set(CPACK_PACKAGE_VERSION_MINOR "3")
306 set(CPACK_PACKAGE_VERSION_PATCH "1")
307 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
308
309 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
310 set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr")
311 set(CPACK_GENERATOR "TGZ")
312 set(CPACK_SOURCE_GENERATOR "TGZ")
313
314 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
315
316 if(ENABLE_PLUGINS)
317         set(HAVE_PLUGINS 1)
318         set(PLUGIN_DIR="${DATAFILE_DIR}/plugins/${CPACK_PACKAGE_VERSION}")
319         set(PLUGIN_SRC_DIRS
320                 plugins/asn1
321                 plugins/docsis
322                 plugins/ethercat
323                 plugins/giop
324                 plugins/gryphon
325                 plugins/irda
326                 plugins/m2m
327                 plugins/mate
328                 plugins/opcua
329                 plugins/profinet
330                 plugins/sercosiii
331                 plugins/stats_tree
332                 plugins/unistim
333                 plugins/wimax
334                 plugins/wimaxasncp
335         )
336 # It seems this stuff doesn't build with autofoo either...
337 #       if(YAPP_FOUND)
338 #               set(PLUGIN_SRC_DIRS
339 #                       ${PLUGIN_SRC_DIRS}
340 #                       plugins/tpg
341 #               )
342 #       endif()
343 else()
344         set(PLUGIN_SRC_DIRS )
345 endif()
346
347 foreach(PLUGIN_DIR ${PLUGIN_SRC_DIRS})
348         add_subdirectory( ${PLUGIN_DIR} )
349 endforeach()
350
351 #Platform specific
352 if(UNIX)
353         set(WS_VAR_IMPORT "extern")
354 endif()
355
356 if(APPLE)
357 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
358         set(HAVE_OS_X_FRAMEWORKS 1)
359         FIND_LIBRARY (APPLE_CORE_SERVICES_LIBRARY CoreServices)
360         FIND_LIBRARY (APPLE_COCOA_LIBRARY Cocoa)
361 endif()
362
363 if(WIN32)
364         add_definitions(-D_NEED_VAR_IMPORT_)
365         set(WS_VAR_IMPORT "__declspec(dllimport) extern")
366
367         # Disable deprecation
368         if(MSVC80 OR MSVC90)
369                 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
370         endif()
371 endif()
372
373
374 add_subdirectory( codecs )
375 add_subdirectory( epan )
376 add_subdirectory( gtk )
377 add_subdirectory( wiretap )
378 add_subdirectory( wsutil )
379
380 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
381
382 include(FeatureSummary)
383 #SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ] 
384 PRINT_ENABLED_FEATURES()
385 PRINT_DISABLED_FEATURES()
386
387 link_directories(
388         gtk
389         codecs
390         epan
391         wiretap
392         wsutil
393 )
394
395 ADD_CUSTOM_COMMAND(
396         OUTPUT svnversion.h
397         COMMAND ${PERL}
398                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
399                 ${CMAKE_CURRENT_SOURCE_DIR}
400         DEPENDS
401                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
402 )
403
404 # Create the necessary tools
405 set(lemon_FILES
406         tools/lemon/lemon.c
407 )
408 set(lemon_LIBS
409         # Do we need something here on any platform?
410 )
411 add_executable(lemon ${lemon_FILES})
412 target_link_libraries(lemon ${lemon_LIBS})
413 # but don't install
414
415 register_tap_files(tshark-tap-register.c
416         ${TSHARK_TAP_SRC}
417 )
418
419 ADD_CUSTOM_COMMAND(
420         OUTPUT ps.c
421         COMMAND ${PYTHON_EXECUTABLE}
422           ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
423           ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
424           ps.c
425         DEPENDS
426           ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
427           ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
428 )
429
430 if(UNIX)
431         set(PLATFORM_SRC
432                 capture-pcap-util-unix.c
433         )
434 endif()
435
436 if(WIN32)
437         set(PLATFORM_SRC
438                 capture-wpcap.c capture_wpcap_packet.c
439         )
440 endif()
441
442 set(WTAP_PLUGIN_SOURCES
443         epan/plugins.c
444         epan/report_err.c
445         epan/filesystem.c
446 )
447
448 set(WIRESHARK_COMMON_SRC
449         ${PLATFORM_SRC}
450         capture_errs.c
451         capture-pcap-util.c
452         capture_ui_utils.c
453         cfile.c
454         clopts_common.c
455         disabled_protos.c
456         packet-range.c
457         print.c
458         ps.c
459         sync_pipe_write.c
460         timestats.c
461         util.c
462         tap-megaco-common.c
463         tap-rtp-common.c
464         version_info.c
465 )
466
467 set(TSHARK_TAP_SRC
468         tap-afpstat.c
469         tap-ansi_astat.c
470         tap-bootpstat.c
471         tap-camelcounter.c
472         tap-camelsrt.c
473         tap-comparestat.c
474         tap-dcerpcstat.c
475         tap-funnel.c
476         tap-gsm_astat.c
477         tap-h225counter.c
478         tap-h225rassrt.c
479         tap-httpstat.c
480         tap-iostat.c
481         tap-iousers.c
482         tap-mgcpstat.c
483         tap-megacostat.c
484         tap-protocolinfo.c
485         tap-protohierstat.c
486         tap-radiusstat.c
487         tap-rpcstat.c
488         tap-rpcprogs.c
489         tap-rtp.c
490         tap-sctpchunkstat.c
491         tap-sipstat.c
492         tap-smbsids.c
493         tap-smbstat.c
494         tap-stats_tree.c
495         tap-wspstat.c
496 )
497
498 set(INSTALL_DIRS
499         diameter
500         dtds
501         help
502         radius
503         tpncp
504         wimaxasncp
505 )
506
507 set(INSTALL_FILES
508         ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
509         COPYING
510 #       capinfos.html
511         cfilters
512         colorfilters
513 #       console.lua
514         dfilters
515 #       dtd_gen.lua
516 #       dumpcap.html
517 #       editcap.html
518 #       idl2wrs.html
519 #       init.lua
520 #       ipmap.html
521         manuf
522 #       mergecap.html
523 #       rawshark.html
524         services
525         smi_modules
526 #       text2pcap.html
527 #       tshark.html
528 #       wireshark-filter.html
529 #       wireshark.html
530 #       ws.css
531 )
532
533 set(LIBEPAN_LIBS
534 #               $(wireshark_optional_objects)
535                 epan
536 #               @INET_PTON_LO@
537 #               @INET_NTOP_LO@
538 #               @SSL_LIBS@
539 #               $(plugin_ldadd)
540                 ${PCRE_LIBRARIES}
541                 ${PCAP_LIBRARIES}
542 #               @SOCKET_LIBS@
543 #               @NSL_LIBS@
544                 ${CARES_LIBRARIES}
545                 ${ADNS_LIBRARIES}
546                 ${KERBEROS_LIBRARIES}
547 #               @FRAMEWORKS@
548                 ${LUA_LIBRARIES}
549                 ${PYTHON_LIBRARIES}
550                 ${GEOIP_LIBRARIES}
551                 ${GCRYPT_LIBRARIES}
552                 ${GNUTLS_LIBRARIES}
553                 ${SMI_LIBRARIES}
554                 ${Z_LIBRARIES}
555                 ${M_LIBRARIES}
556 )
557
558 if(BUILD_wireshark)
559         set(wireshark_LIBS
560                 ui
561                 ${GTK2_LIBRARIES}
562                 codecs
563                 ${PORTAUDIO_LIBRARIES}
564                 ${LIBEPAN_LIBS}
565                 ${APPLE_CORE_SERVICES_LIBRARY}
566                 ${APPLE_COCOA_LIBRARY}
567         )
568         set(wireshark_FILES
569                 airpcap_loader.c
570                 alert_box.c
571                 capture.c
572                 capture_info.c
573                 capture_opts.c
574                 capture_sync.c
575                 color_filters.c
576                 file.c
577                 fileset.c
578                 filters.c
579                 g711.c
580                 merge.c
581                 proto_hier_stats.c
582                 summary.c
583                 tempfile.c
584                 ${WIRESHARK_COMMON_SRC}
585         )
586         add_executable(wireshark ${wireshark_FILES})
587         target_link_libraries(wireshark ${wireshark_LIBS})
588         install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
589 endif()
590
591 if(BUILD_tshark)
592         set(tshark_LIBS
593                 ${LIBEPAN_LIBS}
594                 ${APPLE_COCOA_LIBRARY}
595         )
596         set(tshark_FILES
597                 capture_opts.c
598                 capture_sync.c
599                 tempfile.c
600                 tshark-tap-register.c
601                 tshark.c
602                 ${TSHARK_TAP_SRC}
603                 ${WIRESHARK_COMMON_SRC}
604         )
605         add_executable(tshark ${tshark_FILES})
606         target_link_libraries(tshark ${tshark_LIBS})
607         install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
608 endif()
609
610 if(BUILD_rawshark)
611         set(rawshark_LIBS
612                 ${LIBEPAN_LIBS}
613                 ${APPLE_COCOA_LIBRARY}
614         )
615         set(rawshark_FILES
616                 ${WIRESHARK_COMMON_SRC}
617                 rawshark.c
618         )
619         add_executable(rawshark ${rawshark_FILES})
620         target_link_libraries(rawshark ${rawshark_LIBS})
621         install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
622 endif()
623
624 if(BUILD_dftest)
625         set(dftest_LIBS
626                 ${LIBEPAN_LIBS}
627         )
628         set(dftest_FILES
629                 dftest.c
630                 util.c
631         )
632         add_executable(dftest ${dftest_FILES})
633         target_link_libraries(dftest ${dftest_LIBS})
634         install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
635 endif()
636
637 if(BUILD_randpkt)
638         set(randpkt_LIBS
639                 wiretap
640                 ${M_LIBRARIES}
641                 ${PCAP_LIBRARIES}
642 #               @SOCKET_LIBS@
643 #               @NSL_LIBS@
644                 ${CARES_LIBRARIES}
645                 ${ADNS_LIBRARIES}
646                 ${Z_LIBRARIES}
647         )
648         set(randpkt_FILES
649                 randpkt.c
650         )
651         add_executable(randpkt ${randpkt_FILES})
652         target_link_libraries(randpkt ${randpkt_LIBS})
653         install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
654 endif()
655
656 if(BUILD_text2pcap)
657         set(text2pcap_LIBS
658                 wiretap
659                 ${M_LIBRARIES}
660                 ${Z_LIBRARIES}
661         )
662         set(text2pcap_FILES
663                 text2pcap.c
664         )
665         add_lex_files(text2pcap_FILES
666                 text2pcap-scanner.l
667         )
668         add_executable(text2pcap ${text2pcap_FILES})
669         target_link_libraries(text2pcap ${text2pcap_LIBS})
670         install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
671 endif()
672
673 if(BUILD_mergecap)
674         set(mergecap_LIBS
675                 wiretap
676                 ${Z_LIBRARIES}
677         )
678         set(mergecap_FILES
679                 mergecap.c
680                 merge.c
681                 svnversion.h
682         )
683         add_executable(mergecap ${mergecap_FILES})
684         target_link_libraries(mergecap ${mergecap_LIBS})
685         install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
686 endif()
687
688 if(BUILD_capinfos)
689         set(capinfos_LIBS
690                 wiretap
691                 ${Z_LIBRARIES}
692                 ${APPLE_COCOA_LIBRARY}
693         )
694         set(capinfos_FILES
695                 capinfos.c
696                 ${WTAP_PLUGIN_SOURCES}
697         )
698         add_executable(capinfos ${capinfos_FILES})
699         target_link_libraries(capinfos ${capinfos_LIBS})
700         install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
701 endif()
702
703 if(BUILD_editcap)
704         set(editcap_LIBS
705                 wiretap
706                 ${Z_LIBRARIES}
707         )
708         set(editcap_FILES
709                 editcap.c
710                 epan/crypt/crypt-md5.c
711                 epan/nstime.c
712                 ${WTAP_PLUGIN_SOURCES}
713         )
714         add_executable(editcap ${editcap_FILES})
715         target_link_libraries(editcap ${editcap_LIBS})
716         install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
717 endif()
718
719 if(BUILD_dumpcap)
720         set(dumpcap_LIBS
721                 wiretap
722 #               @INET_NTOP_LO@
723                 ${PCAP_LIBRARIES}
724                 ${CAP_LIBRARIES}
725 #               @SOCKET_LIBS@
726 #               @NSL_LIBS@
727 #               @FRAMEWORKS@
728                 ${GCRYPT_LIBRARIES}
729                 ${GNUTLS_LIBRARIES}
730                 ${Z_LIBRARIES}
731                 ${APPLE_COCOA_LIBRARY}
732         )
733         set(dumpcap_FILES
734                 svnversion.h
735                 capture_opts.c
736                 capture-pcap-util.c
737                 capture_stop_conditions.c
738                 clopts_common.c
739                 conditions.c
740                 dumpcap.c
741                 pcapio.c
742                 ringbuffer.c
743                 sync_pipe_write.c
744                 tempfile.c
745                 version_info.c
746                 ${PLATFORM_SRC}
747         )
748         add_executable(dumpcap ${dumpcap_FILES})
749         target_link_libraries(dumpcap ${dumpcap_LIBS})
750         install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
751 endif()
752
753 ADD_CUSTOM_COMMAND(
754         OUTPUT  AUTHORS-SHORT
755         COMMAND ${PERL}
756                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
757                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
758                 < ${CMAKE_SOURCE_DIR}/AUTHORS
759                 > AUTHORS-SHORT
760         DEPENDS
761                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
762                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
763                 ${CMAKE_SOURCE_DIR}/AUTHORS
764 )
765
766 add_custom_target(
767         auxiliary ALL
768         DEPENDS
769                 AUTHORS-SHORT
770                 # todo: Add manpages and onlinedocs and generate them
771 )
772
773 install(
774         FILES
775                 ${INSTALL_FILES}
776         DESTINATION
777                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
778 )
779
780 install(
781         DIRECTORY
782                 ${INSTALL_DIRS}
783         DIRECTORY_PERMISSIONS
784                 OWNER_EXECUTE OWNER_WRITE OWNER_READ
785                 GROUP_EXECUTE GROUP_READ
786                 WORLD_EXECUTE WORLD_READ
787         DESTINATION
788                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
789         PATTERN ".svn" EXCLUDE
790         PATTERN "Makefile.*" EXCLUDE
791         PATTERN "faq.py" EXCLUDE
792 )