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