3 # Wireshark - Network traffic analyzer
4 # By Gerald Combs <gerald@wireshark.org>
5 # Copyright 1998 Gerald Combs
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.
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.
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.
24 set(WSUTIL_COMMON_FILES
71 set(WSUTIL_FILES ${WSUTIL_COMMON_FILES})
73 list(APPEND WSUTIL_FILES
82 if(HAVE_OS_X_FRAMEWORKS)
83 list(APPEND WSUTIL_FILES cfutils.c)
87 # XXX - we're assuming MSVC doesn't require a flag to enable SSE 4.2
88 # support, and that, if the compiler supports a flag for SSE 4.2
89 # support, the intrinsics are supported iff we can include the
92 # We only check for the GCC-style -msse4.2 flag and the Sun C
95 if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
96 set(COMPILER_CAN_HANDLE_SSE4_2 TRUE)
99 message(STATUS "Checking for c-compiler flag: -msse4.2")
100 check_c_compiler_flag(-msse4.2 COMPILER_CAN_HANDLE_SSE4_2)
101 if(COMPILER_CAN_HANDLE_SSE4_2)
102 set(SSE4_2_FLAG "-msse4.2")
104 message(STATUS "Checking for c-compiler flag: -xarch=sse4_2")
105 check_c_compiler_flag(-xarch=sse4_2 COMPILER_CAN_HANDLE_SSE4_2)
106 if(COMPILER_CAN_HANDLE_SSE4_2)
107 set(SSE4_2_FLAG "-xarch=sse4_2")
111 if(COMPILER_CAN_HANDLE_SSE4_2)
113 # Make sure we have the necessary headers for the SSE4.2 intrinsics
114 # and that we can use them.
116 # First, check whether we have emmintrin.h and can use it
117 # *without* the SSE 4.2 flag.
119 check_include_file("emmintrin.h" EMMINTRIN_H_WORKS)
122 # OK, if that works, see whether we have nmmintrin.h and
123 # can use it *with* the SSE 4.2 flag.
125 if(EMMINTRIN_H_WORKS)
127 # Does this add the SSE4.2 flags to the beginning of
130 # Note that if there's a mix of "enable SSE 4.2" and
131 # "disable SSE 4.2" flags, this may not indicate that
132 # we can use the header. That's not a bug, that's a
133 # feature; the other flags may have been forced by
134 # the build process, e.g. in Gentoo Linux, and we want
135 # to check this with whatever flags will actually be
136 # used when building (see bug 10792).
138 cmake_push_check_state()
139 set(CMAKE_REQUIRED_FLAGS "${SSE4_2_FLAG}")
140 check_include_file("nmmintrin.h" HAVE_SSE4_2)
141 cmake_pop_check_state()
145 list(APPEND WSUTIL_FILES ws_mempbrk_sse42.c)
148 if(NOT HAVE_GETOPT_LONG)
149 list(APPEND WSUTIL_FILES getopt_long.c)
152 if(NOT HAVE_INET_ATON)
153 list(APPEND WSUTIL_FILES inet_aton.c)
156 if(NOT HAVE_POPCOUNT)
157 list(APPEND WSUTIL_FILES popcount.c)
160 if(NOT HAVE_STRPTIME)
161 list(APPEND WSUTIL_FILES strptime.c)
166 # We assume that APPLE means macOS so that we have the macOS
169 FIND_LIBRARY (APPLE_CORE_FOUNDATION_LIBRARY CoreFoundation)
174 ${APPLE_CORE_FOUNDATION_LIBRARY}
175 ${GMODULE2_LIBRARIES}
179 ${WIN_WSOCK32_LIBRARY}
182 set(wsutil_LIBS ${wsutil_LIBS} "iphlpapi.lib" "ws2_32.lib")
189 set_source_files_properties(
192 COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
195 # TODO with CMake 2.8.12, we could use COMPILE_OPTIONS and just append
196 # instead of this COMPILE_FLAGS duplication...
197 set_source_files_properties(
200 COMPILE_FLAGS "${WERROR_COMMON_FLAGS} ${SSE4_2_FLAG}"
204 add_library(wsutil ${LINK_MODE_LIB}
206 ${CMAKE_BINARY_DIR}/image/libwsutil.rc
209 set(FULL_SO_VERSION "0.0.0")
211 set_target_properties(wsutil PROPERTIES
213 COMPILE_DEFINITIONS "WS_BUILD_DLL"
214 COMPILE_OPTIONS "${WS_WARNINGS_C_FLAGS}"
215 LINK_FLAGS "${WS_LINK_FLAGS}"
216 VERSION ${FULL_SO_VERSION} SOVERSION 0
219 if(ENABLE_APPLICATION_BUNDLE)
220 set_target_properties(wsutil PROPERTIES
221 LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Frameworks
227 add_custom_command(OUTPUT libwsutil.abi.tar.gz
228 COMMAND ${CMAKE_COMMAND} -E remove_directory ${ABICHECK_TMPDIR}
229 COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}
230 COMMAND ${ABI_COPY_COMMAND} ../config.h ${ABICHECK_TMPDIR}/ ${ABI_COPY_FLAGS}
231 COMMAND ${ABI_COPY_COMMAND} ${ABICHECK_HEADERS} ${ABICHECK_TMPDIR}/ ${ABI_COPY_FLAGS}
232 COMMAND ${ABICHECK_COMMAND}
233 COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps/libwsutil/libwsutil_* ${CMAKE_CURRENT_BINARY_DIR}/libwsutil.abi.tar.gz
234 COMMAND rm -rf ${ABICHECK_TMPDIR} ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps
235 DEPENDS ${HEADERS} wsutil)
237 target_link_libraries(wsutil ${wsutil_LIBS})
239 if(NOT ${ENABLE_STATIC})
240 install(TARGETS wsutil
241 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
242 RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
243 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
247 # Export build-time datadir (note: the macro "DATAFILE_DIR" is defined in
248 # config.h and points to the install-time data directory, hence the different
250 set_property(SOURCE filesystem.c APPEND PROPERTY
251 COMPILE_DEFINITIONS BUILD_TIME_DATAFILE_DIR="${DATAFILE_DIR}"
260 ${WSUTIL_COMMON_FILES}
263 set_source_files_properties(jsmn.c PROPERTIES COMPILE_DEFINITIONS "JSMN_STRICT")
266 # Editor modelines - http://www.wireshark.org/tools/modelines.html
271 # indent-tabs-mode: t
274 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
275 # :indentSize=8:tabSize=8:noTabs=false: