Add a few more optional compiler warnings and some (commented out)
[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
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)" OFF)
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 option(ENABLE_LUA        "Build with lua dissector support" ON)
83 option(ENABLE_PYTHON     "Build with python dissector support" ON)
84 option(ENABLE_SMI        "Build with smi snmp support" ON)
85 option(ENABLE_GNUTLS     "Build with GNU TLS support" ON)
86 option(ENABLE_GCRYPT     "Build with GNU crypto support" ON)
87 option(ENABLE_GEOIP      "Build with GeoIP support" ON)
88 option(ENABLE_CAP        "Build with posix capabilities support" ON)
89 option(ENABLE_CARES      "Build with c_ares support" ON)
90 # todo Mostly hardcoded
91 option(ENABLE_KERBEROS   "Build with Kerberos support" ON)
92
93
94 set(WIRESHARK_C_FLAGS
95         -O2
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         -Wc++-compat
129         -Wjump-misses-init
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(NOT DISABLE_WERROR AND NOT ENABLE_EXTRA_GCC_CHECKS)
166         check_c_compiler_flag(-Werror 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 # AC_WIRESHARK_GCC_LDFLAGS_CHECK([-flto])
179 # AC_WIRESHARK_GCC_LDFLAGS_CHECK([-fwhopr])
180 # AC_WIRESHARK_GCC_LDFLAGS_CHECK([-fwhole-program])
181
182
183 #The minimum package list
184 set(PACKAGELIST GLIB2 PCAP M LEX YACC Perl SH PythonInterp HtmlViewer ${PACKAGELIST})
185
186 #Build the gui ?
187 if(BUILD_wireshark)
188         set(PACKAGELIST GTK2 ${PACKAGELIST})
189 endif()
190
191 # SMI SNMP
192 if(ENABLE_SMI)
193         set(PACKAGELIST SMI ${PACKAGELIST})
194 endif()
195
196 # GNU crypto
197 if(ENABLE_GCRYPT)
198         set(PACKAGELIST GCRYPT ${PACKAGELIST})
199 endif()
200
201 # GNU SSL/TLS support
202 if(ENABLE_GNUTLS)
203         set(PACKAGELIST GNUTLS ${PACKAGELIST})
204 endif()
205
206 # Regular expressions lib
207 if(ENABLE_PCRE)
208         set(PACKAGELIST PCRE ${PACKAGELIST})
209 endif()
210
211 # Kerberos
212 if(ENABLE_KERBEROS)
213         set(PACKAGELIST KERBEROS ${PACKAGELIST})
214 endif()
215
216 # Portable audio
217 if(ENABLE_PORTAUDIO)
218         set(PACKAGELIST PORTAUDIO ${PACKAGELIST})
219 endif()
220
221
222 # Prefer c-ares over adns
223 if(ENABLE_CARES)        # C Asynchronouse resolver
224         set(PACKAGELIST CARES ${PACKAGELIST})
225 elseif(ENABLE_ADNS)     # Gnu asynchronous DNS
226         set(PACKAGELIST ADNS ${PACKAGELIST})
227 endif()
228
229 # Zlib compression
230 if(ENABLE_Z)
231         set(PACKAGELIST Z ${PACKAGELIST})
232 endif()
233
234 # Lua 5.1 dissectors
235 if(ENABLE_LUA)
236         set(PACKAGELIST LUA ${PACKAGELIST})
237 endif()
238
239 # GeoIP address resolving
240 if(ENABLE_GEOIP)
241         set(PACKAGELIST GEOIP ${PACKAGELIST})
242 endif()
243
244 # Capabilities
245 if(ENABLE_CAP)
246         set(PACKAGELIST CAP ${PACKAGELIST})
247 endif()
248
249 if(ENABLE_PYTHON)
250         set(PACKAGELIST PYTHON ${PACKAGELIST})
251 endif()
252
253 set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
254
255 #Let's loop the package list
256 foreach(PACKAGE ${PACKAGELIST})
257         find_package(${PACKAGE} REQUIRED)
258         message(${PACKAGE}_FOUND)
259         if (${PACKAGE}_FOUND)
260                 set(HAVE_LIB${PACKAGE} 1)
261                 include_directories(${${PACKAGE}_INCLUDE_DIRS})
262                 message(STATUS "${PACKAGE} includes: ${${PACKAGE}_INCLUDE_DIRS}")
263                 message(STATUS "${PACKAGE} libs: ${${PACKAGE}_LIBRARIES}")
264         endif()
265 endforeach()
266
267 find_package(YAPP)
268
269 if(HAVE_LIBPYTHON)
270         set(HAVE_PYTHON 1)
271         set(PYTHON_DIR "${CMAKE_INSTALL_PREFIX}/lib/wireshark/python/${VERSION}")
272 endif()
273 if(HAVE_LIBLUA)
274         set(HAVE_LUA_H 1)
275         set(HAVE_LUA_5_1 1)
276 endif()
277 if(HAVE_LIBKERBEROS)
278         set(HAVE_KERBEROS 1)
279         # HAVE_HEIMDAL_KERBEROS
280         set(HAVE_MIT_KERBEROS 1)
281         set(HAVE_KEYTYPE_ARCFOUR_56 1)
282 endif()
283 if(HAVE_LIBGEOIP)
284         set(HAVE_GEOIP 1)
285 endif()
286 if(HAVE_LIBCARES)
287         set(HAVE_C_ARES 1)
288 endif()
289 if(HAVE_LIBADNS)
290         set(HAVE_GNU_ADNS 1)
291 endif()
292 if(ENABLE_AIRPCAP)
293         set(HAVE_AIRPCAP 1)
294 endif()
295
296 include(ConfigureChecks.cmake)
297
298 #Big or little endian ?
299 include(TestBigEndian)
300 test_big_endian(WORDS_BIGENDIAN)
301
302 #packaging
303 set(CPACK_PACKAGE_NAME wireshark)
304 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "capture packet")
305 set(CPACK_PACKAGE_VENDOR "wireshark")
306 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
307 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
308 set(CPACK_PACKAGE_VERSION_MAJOR "1")
309 set(CPACK_PACKAGE_VERSION_MINOR "3")
310 set(CPACK_PACKAGE_VERSION_PATCH "2")
311 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
312
313 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
314 set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr")
315 set(CPACK_GENERATOR "TGZ")
316 set(CPACK_SOURCE_GENERATOR "TGZ")
317
318 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
319
320 if(ENABLE_PLUGINS)
321         set(HAVE_PLUGINS 1)
322         set(PLUGIN_DIR="${DATAFILE_DIR}/plugins/${CPACK_PACKAGE_VERSION}")
323         set(PLUGIN_SRC_DIRS
324                 plugins/asn1
325                 plugins/docsis
326                 plugins/ethercat
327                 plugins/giop
328                 plugins/gryphon
329                 plugins/irda
330                 plugins/m2m
331                 plugins/mate
332                 plugins/opcua
333                 plugins/profinet
334                 plugins/sercosiii
335                 plugins/stats_tree
336                 plugins/unistim
337                 plugins/wimax
338                 plugins/wimaxasncp
339         )
340 # It seems this stuff doesn't build with autofoo either...
341 #       if(YAPP_FOUND)
342 #               set(PLUGIN_SRC_DIRS
343 #                       ${PLUGIN_SRC_DIRS}
344 #                       plugins/tpg
345 #               )
346 #       endif()
347 else()
348         set(PLUGIN_SRC_DIRS )
349 endif()
350
351 foreach(PLUGIN_DIR ${PLUGIN_SRC_DIRS})
352         add_subdirectory( ${PLUGIN_DIR} )
353 endforeach()
354
355 add_subdirectory( codecs )
356 add_subdirectory( epan )
357 add_subdirectory( gtk )
358 add_subdirectory( tools/lemon )
359 add_subdirectory( wiretap )
360 add_subdirectory( wsutil )
361
362 #Platform specific
363 if(UNIX)
364         set(WS_VAR_IMPORT "extern")
365 endif()
366
367 if(APPLE)
368 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
369         set(HAVE_OS_X_FRAMEWORKS 1)
370         FIND_LIBRARY (APPLE_CORE_SERVICES_LIBRARY CoreServices)
371         FIND_LIBRARY (APPLE_COCOA_LIBRARY Cocoa)
372 endif()
373
374 if(WIN32)
375         add_definitions(-D_NEED_VAR_IMPORT_)
376         set(WS_VAR_IMPORT "__declspec(dllimport) extern")
377
378         # Disable deprecation
379         if(MSVC80 OR MSVC90)
380                 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
381         endif()
382 endif()
383
384 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
385
386 include(FeatureSummary)
387 #SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ]
388 PRINT_ENABLED_FEATURES()
389 PRINT_DISABLED_FEATURES()
390
391 link_directories(
392         gtk
393         codecs
394         epan
395         wiretap
396         wsutil
397 )
398
399 ADD_CUSTOM_COMMAND(
400         OUTPUT svnversion.h
401         COMMAND ${PERL}
402                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
403                 ${CMAKE_CURRENT_SOURCE_DIR}
404         DEPENDS
405                 ${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
406 )
407
408 register_tap_files(tshark-tap-register.c
409         ${TSHARK_TAP_SRC}
410 )
411
412 ADD_CUSTOM_COMMAND(
413         OUTPUT ps.c
414         COMMAND ${PYTHON_EXECUTABLE}
415           ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
416           ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
417           ps.c
418         DEPENDS
419           ${CMAKE_CURRENT_SOURCE_DIR}/tools/rdps.py
420           ${CMAKE_CURRENT_SOURCE_DIR}/print.ps
421 )
422
423 if(UNIX)
424         set(PLATFORM_SRC
425                 capture-pcap-util-unix.c
426         )
427 endif()
428
429 if(WIN32)
430         set(PLATFORM_SRC
431                 capture-wpcap.c capture_wpcap_packet.c
432         )
433 endif()
434
435 set(WTAP_PLUGIN_SOURCES
436         epan/plugins.c
437         epan/report_err.c
438         epan/filesystem.c
439 )
440
441 set(WIRESHARK_COMMON_SRC
442         ${PLATFORM_SRC}
443         capture_errs.c
444         capture-pcap-util.c
445         capture_ui_utils.c
446         cfile.c
447         clopts_common.c
448         disabled_protos.c
449         packet-range.c
450         print.c
451         ps.c
452         sync_pipe_write.c
453         timestats.c
454         util.c
455         tap-megaco-common.c
456         tap-rtp-common.c
457         version_info.c
458 )
459
460 set(TSHARK_TAP_SRC
461         tap-afpstat.c
462         tap-ansi_astat.c
463         tap-bootpstat.c
464         tap-camelcounter.c
465         tap-camelsrt.c
466         tap-comparestat.c
467         tap-dcerpcstat.c
468         tap-funnel.c
469         tap-gsm_astat.c
470         tap-h225counter.c
471         tap-h225rassrt.c
472         tap-httpstat.c
473         tap-iostat.c
474         tap-iousers.c
475         tap-mgcpstat.c
476         tap-megacostat.c
477         tap-protocolinfo.c
478         tap-protohierstat.c
479         tap-radiusstat.c
480         tap-rpcstat.c
481         tap-rpcprogs.c
482         tap-rtp.c
483         tap-sctpchunkstat.c
484         tap-sipstat.c
485         tap-smbsids.c
486         tap-smbstat.c
487         tap-stats_tree.c
488         tap-wspstat.c
489 )
490
491 set(INSTALL_DIRS
492         diameter
493         dtds
494         help
495         radius
496         tpncp
497         wimaxasncp
498 )
499
500 set(INSTALL_FILES
501         ${CMAKE_BINARY_DIR}/AUTHORS-SHORT
502         COPYING
503 #       capinfos.html
504         cfilters
505         colorfilters
506 #       console.lua
507         dfilters
508 #       dtd_gen.lua
509 #       dumpcap.html
510 #       editcap.html
511 #       idl2wrs.html
512 #       init.lua
513 #       ipmap.html
514         manuf
515 #       mergecap.html
516 #       rawshark.html
517         services
518         smi_modules
519 #       text2pcap.html
520 #       tshark.html
521 #       wireshark-filter.html
522 #       wireshark.html
523 #       ws.css
524 )
525
526 set(LIBEPAN_LIBS
527 #               $(wireshark_optional_objects)
528                 epan
529 #               @INET_PTON_LO@
530 #               @INET_NTOP_LO@
531 #               @SSL_LIBS@
532 #               $(plugin_ldadd)
533                 ${PCRE_LIBRARIES}
534                 ${PCAP_LIBRARIES}
535 #               @SOCKET_LIBS@
536 #               @NSL_LIBS@
537                 ${CARES_LIBRARIES}
538                 ${ADNS_LIBRARIES}
539                 ${KERBEROS_LIBRARIES}
540 #               @FRAMEWORKS@
541                 ${LUA_LIBRARIES}
542                 ${PYTHON_LIBRARIES}
543                 ${GEOIP_LIBRARIES}
544                 ${GCRYPT_LIBRARIES}
545                 ${GNUTLS_LIBRARIES}
546                 ${SMI_LIBRARIES}
547                 ${Z_LIBRARIES}
548                 ${M_LIBRARIES}
549 )
550
551 if(BUILD_wireshark)
552         set(wireshark_LIBS
553                 ui
554                 ${GTK2_LIBRARIES}
555                 codecs
556                 ${PORTAUDIO_LIBRARIES}
557                 ${LIBEPAN_LIBS}
558                 ${APPLE_CORE_SERVICES_LIBRARY}
559                 ${APPLE_COCOA_LIBRARY}
560         )
561         set(wireshark_FILES
562                 airpcap_loader.c
563                 alert_box.c
564                 capture.c
565                 capture_info.c
566                 capture_opts.c
567                 capture_sync.c
568                 color_filters.c
569                 file.c
570                 fileset.c
571                 filters.c
572                 g711.c
573                 merge.c
574                 proto_hier_stats.c
575                 summary.c
576                 tempfile.c
577                 ${WIRESHARK_COMMON_SRC}
578         )
579         add_executable(wireshark ${wireshark_FILES})
580         target_link_libraries(wireshark ${wireshark_LIBS})
581         install(TARGETS wireshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
582 endif()
583
584 if(BUILD_tshark)
585         set(tshark_LIBS
586                 ${LIBEPAN_LIBS}
587                 ${APPLE_COCOA_LIBRARY}
588         )
589         set(tshark_FILES
590                 capture_opts.c
591                 capture_sync.c
592                 tempfile.c
593                 tshark-tap-register.c
594                 tshark.c
595                 ${TSHARK_TAP_SRC}
596                 ${WIRESHARK_COMMON_SRC}
597         )
598         add_executable(tshark ${tshark_FILES})
599         target_link_libraries(tshark ${tshark_LIBS})
600         install(TARGETS tshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
601 endif()
602
603 if(BUILD_rawshark)
604         set(rawshark_LIBS
605                 ${LIBEPAN_LIBS}
606                 ${APPLE_COCOA_LIBRARY}
607         )
608         set(rawshark_FILES
609                 ${WIRESHARK_COMMON_SRC}
610                 rawshark.c
611         )
612         add_executable(rawshark ${rawshark_FILES})
613         target_link_libraries(rawshark ${rawshark_LIBS})
614         install(TARGETS rawshark RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
615 endif()
616
617 if(BUILD_dftest)
618         set(dftest_LIBS
619                 ${LIBEPAN_LIBS}
620         )
621         set(dftest_FILES
622                 dftest.c
623                 util.c
624         )
625         add_executable(dftest ${dftest_FILES})
626         target_link_libraries(dftest ${dftest_LIBS})
627         install(TARGETS dftest RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
628 endif()
629
630 if(BUILD_randpkt)
631         set(randpkt_LIBS
632                 wiretap
633                 ${M_LIBRARIES}
634                 ${PCAP_LIBRARIES}
635 #               @SOCKET_LIBS@
636 #               @NSL_LIBS@
637                 ${CARES_LIBRARIES}
638                 ${ADNS_LIBRARIES}
639                 ${Z_LIBRARIES}
640         )
641         set(randpkt_FILES
642                 randpkt.c
643         )
644         add_executable(randpkt ${randpkt_FILES})
645         target_link_libraries(randpkt ${randpkt_LIBS})
646         install(TARGETS randpkt RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
647 endif()
648
649 if(BUILD_text2pcap)
650         set(text2pcap_LIBS
651                 wiretap
652                 ${M_LIBRARIES}
653                 ${Z_LIBRARIES}
654         )
655         set(text2pcap_FILES
656                 text2pcap.c
657         )
658         set(text2pcap_CLEAN_FILES
659                 ${text2pcap_FILES}
660         )
661         add_lex_files(text2pcap_FILES
662                 text2pcap-scanner.l
663         )
664         add_executable(text2pcap ${text2pcap_FILES})
665         target_link_libraries(text2pcap ${text2pcap_LIBS})
666         install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
667 endif()
668
669 if(BUILD_mergecap)
670         set(mergecap_LIBS
671                 wiretap
672                 ${Z_LIBRARIES}
673         )
674         set(mergecap_FILES
675                 mergecap.c
676                 merge.c
677                 svnversion.h
678         )
679         add_executable(mergecap ${mergecap_FILES})
680         target_link_libraries(mergecap ${mergecap_LIBS})
681         install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
682 endif()
683
684 if(BUILD_capinfos)
685         set(capinfos_LIBS
686                 wiretap
687                 ${Z_LIBRARIES}
688                 ${APPLE_COCOA_LIBRARY}
689         )
690         set(capinfos_FILES
691                 capinfos.c
692                 ${WTAP_PLUGIN_SOURCES}
693         )
694         add_executable(capinfos ${capinfos_FILES})
695         target_link_libraries(capinfos ${capinfos_LIBS})
696         install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
697 endif()
698
699 if(BUILD_editcap)
700         set(editcap_LIBS
701                 wiretap
702                 ${Z_LIBRARIES}
703         )
704         set(editcap_FILES
705                 editcap.c
706                 epan/crypt/crypt-md5.c
707                 epan/nstime.c
708                 ${WTAP_PLUGIN_SOURCES}
709         )
710         add_executable(editcap ${editcap_FILES})
711         target_link_libraries(editcap ${editcap_LIBS})
712         install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
713 endif()
714
715 if(BUILD_dumpcap)
716         set(dumpcap_LIBS
717                 wiretap
718 #               @INET_NTOP_LO@
719                 ${PCAP_LIBRARIES}
720                 ${CAP_LIBRARIES}
721 #               @SOCKET_LIBS@
722 #               @NSL_LIBS@
723 #               @FRAMEWORKS@
724                 ${GCRYPT_LIBRARIES}
725                 ${GNUTLS_LIBRARIES}
726                 ${Z_LIBRARIES}
727                 ${APPLE_COCOA_LIBRARY}
728         )
729         set(dumpcap_FILES
730                 svnversion.h
731                 capture_opts.c
732                 capture-pcap-util.c
733                 capture_stop_conditions.c
734                 clopts_common.c
735                 conditions.c
736                 dumpcap.c
737                 pcapio.c
738                 ringbuffer.c
739                 sync_pipe_write.c
740                 tempfile.c
741                 version_info.c
742                 ${PLATFORM_SRC}
743         )
744         add_executable(dumpcap ${dumpcap_FILES})
745         target_link_libraries(dumpcap ${dumpcap_LIBS})
746         install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
747 endif()
748
749 ADD_CUSTOM_COMMAND(
750         OUTPUT  AUTHORS-SHORT
751         COMMAND ${PERL}
752                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
753                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
754                 < ${CMAKE_SOURCE_DIR}/AUTHORS
755                 > AUTHORS-SHORT
756         DEPENDS
757                 ${CMAKE_SOURCE_DIR}/doc/perlnoutf.pl
758                 ${CMAKE_SOURCE_DIR}/doc/make-authors-short.pl
759                 ${CMAKE_SOURCE_DIR}/AUTHORS
760 )
761
762 add_custom_target(
763         auxiliary ALL
764         DEPENDS
765                 AUTHORS-SHORT
766                 # todo: Add manpages and onlinedocs and generate them
767 )
768
769 set(CLEAN_FILES
770         ${wireshark_FILES}
771         ${tshark_FILES}
772         ${rawshark_FILES}
773         ${dftest_FILES}
774         ${randpkt_FILES}
775         ${text2pcap_CLEAN_FILES}
776         ${mergecap_FILES}
777         ${capinfos_FILES}
778         ${editcap_FILES}
779         ${dumpcap_FILES}
780 )
781
782 if (WERROR)
783         set_source_files_properties(
784                 ${CLEAN_FILES}
785                 PROPERTIES
786                 COMPILE_FLAGS -Werror
787         )
788 endif()
789
790 install(
791         FILES
792                 ${INSTALL_FILES}
793         DESTINATION
794                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
795 )
796
797 install(
798         DIRECTORY
799                 ${INSTALL_DIRS}
800         DIRECTORY_PERMISSIONS
801                 OWNER_EXECUTE OWNER_WRITE OWNER_READ
802                 GROUP_EXECUTE GROUP_READ
803                 WORLD_EXECUTE WORLD_READ
804         DESTINATION
805                 ${CMAKE_INSTALL_DATADIR}/${CPACK_PACKAGE_NAME}
806         PATTERN ".svn" EXCLUDE
807         PATTERN "Makefile.*" EXCLUDE
808         PATTERN "faq.py" EXCLUDE
809 )