3 # Wireshark - Network traffic analyzer
4 # By Gerald Combs <gerald@wireshark.org>
5 # Copyright 1998 Gerald Combs
7 # SPDX-License-Identifier: GPL-2.0-or-later
12 add_definitions(-DPLUGIN_DIR=\"${CMAKE_INSTALL_PREFIX}/${PLUGIN_INSTALL_LIBDIR}\")
13 add_definitions(-DEXTCAP_DIR=\"${CMAKE_INSTALL_PREFIX}/${EXTCAP_INSTALL_LIBDIR}\")
14 add_definitions(-DDATA_DIR=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}\")
16 set(WSUTIL_PUBLIC_HEADERS
76 set(WSUTIL_COMMON_FILES
124 list(APPEND WSUTIL_COMMON_FILES
129 set(WSUTIL_FILES ${WSUTIL_COMMON_FILES})
131 list(APPEND WSUTIL_FILES
138 if(HAVE_MACOS_FRAMEWORKS)
139 list(APPEND WSUTIL_FILES cfutils.c)
143 # XXX - we're assuming MSVC doesn't require a flag to enable SSE 4.2
144 # support, and that, if the compiler supports a flag for SSE 4.2
145 # support, the intrinsics are supported iff we can include the
146 # <nmmintrin.h> flag.
148 # We only check for the GCC-style -msse4.2 flag and the Sun C
149 # -xarch=sse4_2 flag.
151 if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
152 set(COMPILER_CAN_HANDLE_SSE4_2 TRUE)
155 message(STATUS "Checking for c-compiler flag: -msse4.2")
156 check_c_compiler_flag(-msse4.2 COMPILER_CAN_HANDLE_SSE4_2)
157 if(COMPILER_CAN_HANDLE_SSE4_2)
158 set(SSE4_2_FLAG "-msse4.2")
160 message(STATUS "Checking for c-compiler flag: -xarch=sse4_2")
161 check_c_compiler_flag(-xarch=sse4_2 COMPILER_CAN_HANDLE_SSE4_2)
162 if(COMPILER_CAN_HANDLE_SSE4_2)
163 set(SSE4_2_FLAG "-xarch=sse4_2")
167 if(COMPILER_CAN_HANDLE_SSE4_2)
169 # Make sure we have the necessary headers for the SSE4.2 intrinsics
170 # and that we can use them.
172 # First, check whether we have emmintrin.h and can use it
173 # *without* the SSE 4.2 flag.
175 check_include_file("emmintrin.h" EMMINTRIN_H_WORKS)
178 # OK, if that works, see whether we have nmmintrin.h and
179 # can use it *with* the SSE 4.2 flag.
181 if(EMMINTRIN_H_WORKS)
183 # Does this add the SSE4.2 flags to the beginning of
186 # Note that if there's a mix of "enable SSE 4.2" and
187 # "disable SSE 4.2" flags, this may not indicate that
188 # we can use the header. That's not a bug, that's a
189 # feature; the other flags may have been forced by
190 # the build process, e.g. in Gentoo Linux, and we want
191 # to check this with whatever flags will actually be
192 # used when building (see bug 10792).
194 cmake_push_check_state()
195 set(CMAKE_REQUIRED_FLAGS "${SSE4_2_FLAG}")
196 check_include_file("nmmintrin.h" HAVE_SSE4_2)
197 cmake_pop_check_state()
201 list(APPEND WSUTIL_FILES ws_mempbrk_sse42.c)
204 if(NOT HAVE_GETOPT_LONG)
205 list(APPEND WSUTIL_FILES getopt_long.c)
208 if(NOT HAVE_STRPTIME)
209 list(APPEND WSUTIL_FILES strptime.c)
214 # We assume that APPLE means macOS so that we have the macOS
217 FIND_LIBRARY (APPLE_CORE_FOUNDATION_LIBRARY CoreFoundation)
220 set_source_files_properties(
223 COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
226 # TODO with CMake 2.8.12, we could use COMPILE_OPTIONS and just append
227 # instead of this COMPILE_FLAGS duplication...
228 set_source_files_properties(
231 COMPILE_FLAGS "${WERROR_COMMON_FLAGS} ${SSE4_2_FLAG}"
237 ${CMAKE_BINARY_DIR}/image/libwsutil.rc
240 set_target_properties(wsutil PROPERTIES
242 COMPILE_DEFINITIONS "WS_BUILD_DLL"
243 LINK_FLAGS "${WS_LINK_FLAGS}"
244 VERSION "0.0.0" SOVERSION 0
250 add_custom_command(OUTPUT libwsutil.abi.tar.gz
251 COMMAND ${CMAKE_COMMAND} -E remove_directory ${ABICHECK_TMPDIR}
252 COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}
253 COMMAND ${ABI_COPY_COMMAND} ../config.h ${ABICHECK_TMPDIR}/ ${ABI_COPY_FLAGS}
254 COMMAND ${ABI_COPY_COMMAND} ${ABICHECK_HEADERS} ${ABICHECK_TMPDIR}/ ${ABI_COPY_FLAGS}
255 COMMAND ${ABICHECK_COMMAND}
256 COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps/libwsutil/libwsutil_* ${CMAKE_CURRENT_BINARY_DIR}/libwsutil.abi.tar.gz
257 COMMAND rm -rf ${ABICHECK_TMPDIR} ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps
258 DEPENDS ${HEADERS} wsutil)
260 target_link_libraries(wsutil
263 ${APPLE_CORE_FOUNDATION_LIBRARY}
264 ${GMODULE2_LIBRARIES}
268 ${WIN_WSOCK32_LIBRARY}
273 target_link_libraries(wsutil PRIVATE "iphlpapi.lib" "ws2_32.lib")
276 target_include_directories(wsutil SYSTEM
279 ${GCRYPT_INCLUDE_DIRS}
280 ${GNUTLS_INCLUDE_DIRS}
283 install(TARGETS wsutil
284 EXPORT WiresharkTargets
285 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
286 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
287 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
290 install(FILES ${WSUTIL_PUBLIC_HEADERS}
291 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${CPACK_PACKAGE_NAME}/wsutil"
298 --group termoutput:2 --summary-group termoutput --build
300 ${WSUTIL_COMMON_FILES}
303 set_source_files_properties(jsmn.c PROPERTIES COMPILE_DEFINITIONS "JSMN_STRICT")
306 # Editor modelines - http://www.wireshark.org/tools/modelines.html
311 # indent-tabs-mode: t
314 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
315 # :indentSize=8:tabSize=8:noTabs=false: