CMake: Remove PRId64, PRIu64, PRIx64, PRIX64, and PRIo64 which are unused
[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 subdirs(
29   wiretap
30   wsutil
31 )
32
33 #Where to find local cmake scripts
34 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
35
36 # Under linux the release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG
37
38 # Disable this later. Alternative: "make VERBOSE=1"
39 set(CMAKE_VERBOSE_MAKEFILE ON)
40
41 set(BUILD_SHARED_LIBS ON)
42
43 #Defines CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_DATADIR, etc ...
44 include(CMakeInstallDirs)
45
46 include_directories(
47   ${CMAKE_BINARY_DIR}
48   ${CMAKE_SOURCE_DIR}
49   ${CMAKE_SOURCE_DIR}/include
50   ${CMAKE_SOURCE_DIR}/wiretap
51   ${CMAKE_SOURCE_DIR}/wsutil
52 )
53
54 #Where to put libraries
55 if(NOT LIBRARY_OUTPUT_PATH)
56   set(LIBRARY_OUTPUT_PATH ${wireshark_BINARY_DIR}/lib CACHE INTERNAL
57        "Single output directory for building all libraries.")
58 endif()
59
60 option(BUILD_wireshark   "Build the GUI version of Wireshark" ON)
61 option(BUILD_tshark      "Build tshark" ON)
62 option(BUILD_rawshark    "Build rawshark" ON)
63 option(BUILD_dumpcap     "Build dumpcap" ON)
64 option(BUILD_text2pcap   "Build text2pcap" ON)
65 option(BUILD_mergecap    "Build mergecap" ON)
66 option(BUILD_editcap     "Build editcap" ON)
67 option(BUILD_capinfos    "Build capinfos" ON)
68 option(BUILD_randpkt     "Build randpkt" ON)
69 option(BUILD_dftest      "Build dftest" ON)
70 option(ENABLE_STATIC     "Build a static version of Wireshark" OFF)
71 option(ENABLE_ADNS       "Build with adns support" ON)
72 option(ENABLE_EXTRA_GCC_CHECKS "Do additional -W checks in GCC" OFF)
73
74 if(ENABLE_EXTRA_GCC_CHECKS)
75   set(WIRESHARK_EXTRA_GCC_FLAGS -Wcast-qual -Wcast-align -Wbad-function-cast
76       -pedantic -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings)
77 endif()
78
79 if(CMAKE_COMPILER_IS_GNUCC)
80   add_definitions(
81     -DHAVE_CONFIG_H
82     -D_U_=__attribute__\(\(unused\)\)
83     -Wall -Wpointer-arith -W
84     ${WIRESHARK_EXTRA_GCC_FLAGS}
85   )
86 else()
87   add_definitions(-DHAVE_CONFIG_H -D_U_=\"\")
88 endif()
89
90 #The minimum package list
91 if(WIN32)
92   set(PACKAGELIST WSWIN32 LEX YACC Perl ${PACKAGELIST})
93 else()
94   set(PACKAGELIST GLIB2 PCAP LEX YACC Perl ${PACKAGELIST})
95 endif()
96
97 #build the gui ?
98 if(BUILD_wireshark)
99   set(PACKAGELIST GTK2 ${PACKAGELIST})
100 endif()
101
102 #Gnu asynchronous dns
103 if(ENABLE_ADNS)
104   set(PACKAGELIST ADNS ${PACKAGELIST})
105   set(HAVE_GNU_ADNS 1)
106 endif()
107
108 set(PROGLIST text2pcap mergecap capinfos editcap dumpcap)
109
110 #Let's loop the package list
111 foreach(PACKAGE ${PACKAGELIST})
112   find_package(${PACKAGE} REQUIRED)
113   message(${PACKAGE}_FOUND)
114   if (${PACKAGE}_FOUND)
115     set(HAVE_LIB${PACKAGE} "1")
116     include_directories(${${PACKAGE}_INCLUDE_DIRS})
117     message(STATUS "${PACKAGE} include ${${PACKAGE}_INCLUDE_DIRS}")
118     foreach(PROG ${PROGLIST})
119 #      set(${PROG}_LIBS ${${PROG}_LIBS} ${${PACKAGE}_LIBRARIES})
120     endforeach()
121     message(STATUS "${PACKAGE} lib ${${PACKAGE}_LIBRARIES}")
122   endif()
123 endforeach()
124
125 #packaging
126 set(CPACK_PACKAGE_NAME wireshark)
127 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "capture packet")
128 set(CPACK_PACKAGE_VENDOR "wireshark")
129 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
130 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
131 set(CPACK_PACKAGE_VERSION_MAJOR "1")
132 set(CPACK_PACKAGE_VERSION_MINOR "3")
133 set(CPACK_PACKAGE_VERSION_PATCH "0")
134 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
135
136 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
137 set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr")
138 set(CPACK_GENERATOR "TGZ")
139 set(CPACK_SOURCE_GENERATOR "TGZ")
140
141 include(ConfigureChecks.cmake)
142
143 #Big or little endian ?
144 include(TestBigEndian)
145 test_big_endian(WORDS_BIGENDIAN)
146
147 set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}")
148
149 #Platform specific
150 if(UNIX)
151   set(WS_VAR_IMPORT "extern")
152 endif()
153
154 if(APPLE)
155 #TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS
156   set(HAVE_OS_X_FRAMEWORKS 1)
157 endif()
158
159 if(WIN32)
160   add_definitions(-DHAVE_WIN32_LIBWIRESHARK_LIB -D_NEED_VAR_IMPORT_)
161   set(WS_VAR_IMPORT "__declspec(dllimport) extern")
162
163   # Disable deprecation
164   if(MSVC80 OR MSVC90)
165     add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
166   endif()
167 endif()
168
169
170 configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
171
172 link_directories(
173   wiretap
174   wsutil
175 )
176
177 ADD_CUSTOM_COMMAND(
178    OUTPUT ${CMAKE_BINARY_DIR}/svnversion.h
179    COMMAND ${PERL} ${CMAKE_SOURCE_DIR}/make-version.pl
180    ARGS
181    ${CMAKE_SOURCE_DIR}
182 )
183 SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/svnversion.h GENERATED)
184
185 if(UNIX)
186   set(PLATFORM_SRC
187     capture-pcap-util-unix.c
188   )
189 endif()
190
191 if(WIN32)
192   set(PLATFORM_SRC
193     capture-wpcap.c capture_wpcap_packet.c
194   )
195 endif()
196
197 if(BUILD_wireshark)
198 # todo
199 endif()
200
201 if(BUILD_tshark)
202 # todo
203 endif()
204
205 if(BUILD_rawshark)
206 # todo
207 endif()
208
209 if(BUILD_randpkt)
210 # todo
211 endif()
212
213 if(BUILD_dftest)
214 # todo
215 endif()
216
217 if(BUILD_text2pcap)
218   set(text2pcap_LIBS
219     wiretap
220     wsutil
221     ${GLIB2_LIBRARIES}
222   )
223   set(text2pcap_FILES
224     text2pcap.c
225   )
226   add_lex_files(text2pcap_FILES
227     text2pcap-scanner.l
228   )
229   add_executable(text2pcap ${text2pcap_FILES})
230   target_link_libraries(text2pcap ${text2pcap_LIBS})
231   install(TARGETS text2pcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
232 endif()
233
234 if(BUILD_mergecap)
235   set(mergecap_LIBS
236     wiretap
237     wsutil
238     ${GLIB2_LIBRARIES}
239   )
240   set(mergecap_FILES
241     mergecap.c
242     merge.c
243     svnversion.h
244   )
245   add_executable(mergecap ${mergecap_FILES})
246   target_link_libraries(mergecap ${mergecap_LIBS})
247   install(TARGETS mergecap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
248 endif()
249
250 if(BUILD_capinfos)
251   set(capinfos_LIBS
252     wiretap
253     wsutil
254     ${GLIB2_LIBRARIES}
255   )
256   set(capinfos_FILES
257     capinfos.c
258   )
259   add_executable(capinfos ${capinfos_FILES})
260   target_link_libraries(capinfos ${capinfos_LIBS})
261   install(TARGETS capinfos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
262 endif()
263
264 if(BUILD_editcap)
265   set(editcap_LIBS
266     wiretap
267     wsutil
268     ${GLIB2_LIBRARIES}
269   )
270   set(editcap_FILES
271     editcap.c
272     epan/crypt/crypt-md5.c
273     epan/nstime.c
274   )
275   add_executable(editcap ${editcap_FILES})
276   target_link_libraries(editcap ${editcap_LIBS})
277   install(TARGETS editcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
278 endif()
279
280 if(BUILD_dumpcap)
281   set(dumpcap_LIBS
282     wiretap
283     wsutil
284     ${GLIB2_LIBRARIES}
285     ${PCAP_LIBRARIES}
286   )
287   set(dumpcap_FILES
288         svnversion.h
289         capture_opts.c
290         capture-pcap-util.c
291         capture_stop_conditions.c
292         clopts_common.c
293         conditions.c
294         dumpcap.c
295         pcapio.c
296         ringbuffer.c
297         sync_pipe_write.c
298         tempfile.c
299         version_info.c
300         ${PLATFORM_SRC}
301   )
302   add_executable(dumpcap ${dumpcap_FILES})
303   target_link_libraries(dumpcap ${dumpcap_LIBS})
304   install(TARGETS dumpcap RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
305 endif()