dumpcap: Include CPU info as hardware description in SHB
[metze/wireshark/wip.git] / wsutil / CMakeLists.txt
1 # CMakeLists.txt
2 #
3 # Wireshark - Network traffic analyzer
4 # By Gerald Combs <gerald@wireshark.org>
5 # Copyright 1998 Gerald Combs
6 #
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21
22 include(UseABICheck)
23
24 set(WSUTIL_COMMON_FILES
25         adler32.c
26         aes.c
27         airpdcap_wep.c
28         base64.c
29         bitswap.c
30         buffer.c
31         clopts_common.c
32         cmdarg_err.c
33         copyright_info.c
34         crash_info.c
35         crc10.c
36         crc16.c
37         crc16-plain.c
38         crc32.c
39         crc6.c
40         crc7.c
41         crc8.c
42         crc11.c
43         des.c
44         eax.c
45         filesystem.c
46         frequency-utils.c
47         g711.c
48         inet_addr.c
49         interface.c
50         jsmn.c
51         md4.c
52         md5.c
53         mpeg-audio.c
54         nstime.c
55         cpu_info.c
56         os_version_info.c
57         plugins.c
58         privileges.c
59         sha1.c
60         sha2.c
61         sober128.c
62         strnatcmp.c
63         str_util.c
64         strtoi.c
65         rc4.c
66         report_err.c
67         tempfile.c
68         time_util.c
69         type_util.c
70         unicode-utils.c
71         ws_mempbrk.c
72 )
73
74 set(WSUTIL_FILES ${WSUTIL_COMMON_FILES})
75 if(WIN32)
76         list(APPEND WSUTIL_FILES
77                 file_util.c
78                 inet_ntop.c
79                 inet_pton.c
80                 win32-utils.c
81         )
82 ENDIF(WIN32)
83
84
85 if(HAVE_OS_X_FRAMEWORKS)
86         list(APPEND WSUTIL_FILES cfutils.c)
87 endif()
88
89 #
90 # XXX - we're assuming MSVC doesn't require a flag to enable SSE 4.2
91 # support, and that, if the compiler supports a flag for SSE 4.2
92 # support, the intrinsics are supported iff we can include the
93 # <nmmintrin.h> flag.
94 #
95 # We only check for the GCC-style -msse4.2 flag and the Sun C
96 # -xarch=sse4_2 flag.
97 #
98 if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
99         set(COMPILER_CAN_HANDLE_SSE4_2 TRUE)
100         set(SSE4_2_FLAG "")
101 else()
102         message(STATUS "Checking for c-compiler flag: -msse4.2")
103         check_c_compiler_flag(-msse4.2 COMPILER_CAN_HANDLE_SSE4_2)
104         if(COMPILER_CAN_HANDLE_SSE4_2)
105                 set(SSE4_2_FLAG "-msse4.2")
106         else()
107                 message(STATUS "Checking for c-compiler flag: -xarch=sse4_2")
108                 check_c_compiler_flag(-xarch=sse4_2 COMPILER_CAN_HANDLE_SSE4_2)
109                 if(COMPILER_CAN_HANDLE_SSE4_2)
110                         set(SSE4_2_FLAG "-xarch=sse4_2")
111                 endif()
112         endif()
113 endif()
114 if(COMPILER_CAN_HANDLE_SSE4_2)
115         #
116         # Make sure we have the necessary headers for the SSE4.2 intrinsics
117         # and that we can use them.
118         #
119         # First, check whether we have emmintrin.h and can use it
120         # *without* the SSE 4.2 flag.
121         #
122         check_include_file("emmintrin.h" EMMINTRIN_H_WORKS)
123
124         #
125         # OK, if that works, see whether we have nmmintrin.h and
126         # can use it *with* the SSE 4.2 flag.
127         #
128         if(EMMINTRIN_H_WORKS)
129                 #
130                 # Does this add the SSE4.2 flags to the beginning of
131                 # CFLAGS?
132                 #
133                 # Note that if there's a mix of "enable SSE 4.2" and
134                 # "disable SSE 4.2" flags, this may not indicate that
135                 # we can use the header.  That's not a bug, that's a
136                 # feature; the other flags may have been forced by
137                 # the build process, e.g. in Gentoo Linux, and we want
138                 # to check this with whatever flags will actually be
139                 # used when building (see bug 10792).
140                 #
141                 cmake_push_check_state()
142                 set(CMAKE_REQUIRED_FLAGS "${SSE4_2_FLAG}")
143                 check_include_file("nmmintrin.h" HAVE_SSE4_2)
144                 cmake_pop_check_state()
145         endif()
146 endif()
147 if(HAVE_SSE4_2)
148         list(APPEND WSUTIL_FILES ws_mempbrk_sse42.c)
149 endif()
150
151 if(NOT HAVE_GETOPT_LONG)
152         list(APPEND WSUTIL_FILES getopt_long.c)
153 endif()
154
155 if(NOT HAVE_INET_ATON)
156         list(APPEND WSUTIL_FILES inet_aton.c)
157 endif()
158
159 if(NOT HAVE_POPCOUNT)
160         list(APPEND WSUTIL_FILES popcount.c)
161 endif()
162
163 if(NOT HAVE_STRPTIME)
164         list(APPEND WSUTIL_FILES strptime.c)
165 endif()
166
167 if(APPLE)
168         #
169         # We assume that APPLE means OS X so that we have the OS X
170         # frameworks.
171         #
172         FIND_LIBRARY (APPLE_CORE_FOUNDATION_LIBRARY CoreFoundation)
173 endif()
174
175 set(wsutil_LIBS
176         ${CMAKE_DL_LIBS}
177         ${APPLE_CORE_FOUNDATION_LIBRARY}
178         ${GMODULE2_LIBRARIES}
179         ${GLIB2_LIBRARIES}
180         ${GCRYPT_LIBRARIES}
181         ${ZLIB_LIBRARIES}
182         ${WIN_WSOCK32_LIBRARY}
183 )
184 IF(WIN32)
185         set(wsutil_LIBS ${wsutil_LIBS} "iphlpapi.lib" "ws2_32.lib")
186 ENDIF(WIN32)
187
188 set(CLEAN_FILES
189         ${WSUTIL_FILES}
190 )
191
192 if (WERROR_COMMON_FLAGS)
193         set_source_files_properties(
194                 ${CLEAN_FILES}
195                 PROPERTIES
196                 COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
197         )
198 else()
199         #
200         # Set the property to an empty string, so that if we try
201         # to get it below, it succeeds.
202         #
203         set_source_files_properties(
204                 ${CLEAN_FILES}
205                 PROPERTIES
206                 COMPILE_FLAGS ""
207         )
208 endif()
209 if (HAVE_SSE4_2)
210         get_source_file_property(
211                 WS_MEMPBRK_SSE42_COMPILE_FLAGS
212                 ws_mempbrk_sse42.c
213                 COMPILE_FLAGS
214         )
215         set_source_files_properties(
216                 ws_mempbrk_sse42.c
217                 PROPERTIES
218                 COMPILE_FLAGS "${WS_MEMPBRK_SSE42_COMPILE_FLAGS} ${SSE4_2_FLAG}"
219         )
220 endif()
221
222 add_library(wsutil ${LINK_MODE_LIB}
223         ${WSUTIL_FILES}
224         ${CMAKE_BINARY_DIR}/image/libwsutil.rc
225 )
226
227 set(FULL_SO_VERSION "0.0.0")
228
229 set_target_properties(wsutil PROPERTIES
230         PREFIX "lib"
231         COMPILE_DEFINITIONS "WS_BUILD_DLL"
232         COMPILE_OPTIONS "${WS_WARNINGS_C_FLAGS}"
233         LINK_FLAGS "${WS_LINK_FLAGS}"
234         VERSION ${FULL_SO_VERSION} SOVERSION 0
235         FOLDER "DLLs")
236
237 if(ENABLE_APPLICATION_BUNDLE)
238         set_target_properties(wsutil PROPERTIES
239                 LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Frameworks
240         )
241 endif()
242
243 ABICHECK(libwsutil)
244
245 add_custom_command(OUTPUT libwsutil.abi.tar.gz
246         COMMAND ${CMAKE_COMMAND} -E remove_directory ${ABICHECK_TMPDIR}
247         COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}
248         COMMAND ${ABI_COPY_COMMAND} ../config.h ${ABICHECK_TMPDIR}/ ${ABI_COPY_FLAGS}
249         COMMAND ${ABI_COPY_COMMAND} ${ABICHECK_HEADERS} ${ABICHECK_TMPDIR}/ ${ABI_COPY_FLAGS}
250         COMMAND ${ABICHECK_COMMAND}
251         COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps/libwsutil/libwsutil_* ${CMAKE_CURRENT_BINARY_DIR}/libwsutil.abi.tar.gz
252         COMMAND rm -rf ${ABICHECK_TMPDIR} ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps
253         DEPENDS ${HEADERS} wsutil)
254
255 target_link_libraries(wsutil ${wsutil_LIBS})
256
257 if(NOT ${ENABLE_STATIC})
258         install(TARGETS wsutil
259                 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
260                 RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
261                 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
262         )
263 endif()
264
265 add_definitions( -DTOP_SRCDIR=\"${CMAKE_SOURCE_DIR}\" )
266
267 CHECKAPI(
268         NAME
269           wsutil
270         SWITCHES
271           -g termoutput -build
272         SOURCES
273           ${WSUTIL_COMMON_FILES}
274 )
275
276 #
277 # Editor modelines  -  http://www.wireshark.org/tools/modelines.html
278 #
279 # Local variables:
280 # c-basic-offset: 8
281 # tab-width: 8
282 # indent-tabs-mode: t
283 # End:
284 #
285 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
286 # :indentSize=8:tabSize=8:noTabs=false:
287 #