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
72 set(WSUTIL_FILES ${WSUTIL_COMMON_FILES})
74 list(APPEND WSUTIL_FILES
83 if(HAVE_OS_X_FRAMEWORKS)
84 list(APPEND WSUTIL_FILES cfutils.c)
88 # XXX - we're assuming MSVC doesn't require a flag to enable SSE 4.2
89 # support, and that, if the compiler supports a flag for SSE 4.2
90 # support, the intrinsics are supported iff we can include the
93 # We only check for the GCC-style -msse4.2 flag and the Sun C
96 if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
97 set(COMPILER_CAN_HANDLE_SSE4_2 TRUE)
100 message(STATUS "Checking for c-compiler flag: -msse4.2")
101 check_c_compiler_flag(-msse4.2 COMPILER_CAN_HANDLE_SSE4_2)
102 if(COMPILER_CAN_HANDLE_SSE4_2)
103 set(SSE4_2_FLAG "-msse4.2")
105 message(STATUS "Checking for c-compiler flag: -xarch=sse4_2")
106 check_c_compiler_flag(-xarch=sse4_2 COMPILER_CAN_HANDLE_SSE4_2)
107 if(COMPILER_CAN_HANDLE_SSE4_2)
108 set(SSE4_2_FLAG "-xarch=sse4_2")
112 if(COMPILER_CAN_HANDLE_SSE4_2)
114 # Make sure we have the necessary headers for the SSE4.2 intrinsics
115 # and that we can use them.
117 # First, check whether we have emmintrin.h and can use it
118 # *without* the SSE 4.2 flag.
120 check_include_file("emmintrin.h" EMMINTRIN_H_WORKS)
123 # OK, if that works, see whether we have nmmintrin.h and
124 # can use it *with* the SSE 4.2 flag.
126 if(EMMINTRIN_H_WORKS)
128 # Does this add the SSE4.2 flags to the beginning of
131 # Note that if there's a mix of "enable SSE 4.2" and
132 # "disable SSE 4.2" flags, this may not indicate that
133 # we can use the header. That's not a bug, that's a
134 # feature; the other flags may have been forced by
135 # the build process, e.g. in Gentoo Linux, and we want
136 # to check this with whatever flags will actually be
137 # used when building (see bug 10792).
139 cmake_push_check_state()
140 set(CMAKE_REQUIRED_FLAGS "${SSE4_2_FLAG}")
141 check_include_file("nmmintrin.h" HAVE_SSE4_2)
142 cmake_pop_check_state()
146 list(APPEND WSUTIL_FILES ws_mempbrk_sse42.c)
149 if(NOT HAVE_GETOPT_LONG)
150 list(APPEND WSUTIL_FILES getopt_long.c)
153 if(NOT HAVE_INET_ATON)
154 list(APPEND WSUTIL_FILES inet_aton.c)
157 if(NOT HAVE_POPCOUNT)
158 list(APPEND WSUTIL_FILES popcount.c)
161 if(NOT HAVE_STRPTIME)
162 list(APPEND WSUTIL_FILES strptime.c)
167 # We assume that APPLE means macOS so that we have the macOS
170 FIND_LIBRARY (APPLE_CORE_FOUNDATION_LIBRARY CoreFoundation)
175 ${APPLE_CORE_FOUNDATION_LIBRARY}
176 ${GMODULE2_LIBRARIES}
180 ${WIN_WSOCK32_LIBRARY}
184 set(wsutil_LIBS ${wsutil_LIBS} "iphlpapi.lib" "ws2_32.lib")
191 set_source_files_properties(
194 COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
197 # TODO with CMake 2.8.12, we could use COMPILE_OPTIONS and just append
198 # instead of this COMPILE_FLAGS duplication...
199 set_source_files_properties(
202 COMPILE_FLAGS "${WERROR_COMMON_FLAGS} ${SSE4_2_FLAG}"
206 add_library(wsutil ${LINK_MODE_LIB}
208 ${CMAKE_BINARY_DIR}/image/libwsutil.rc
211 set(FULL_SO_VERSION "0.0.0")
213 set_target_properties(wsutil PROPERTIES
215 COMPILE_DEFINITIONS "WS_BUILD_DLL"
216 COMPILE_OPTIONS "${WS_WARNINGS_C_FLAGS}"
217 LINK_FLAGS "${WS_LINK_FLAGS}"
218 VERSION ${FULL_SO_VERSION} SOVERSION 0
221 if(ENABLE_APPLICATION_BUNDLE)
222 set_target_properties(wsutil PROPERTIES
223 LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Frameworks
229 add_custom_command(OUTPUT libwsutil.abi.tar.gz
230 COMMAND ${CMAKE_COMMAND} -E remove_directory ${ABICHECK_TMPDIR}
231 COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}
232 COMMAND ${ABI_COPY_COMMAND} ../config.h ${ABICHECK_TMPDIR}/ ${ABI_COPY_FLAGS}
233 COMMAND ${ABI_COPY_COMMAND} ${ABICHECK_HEADERS} ${ABICHECK_TMPDIR}/ ${ABI_COPY_FLAGS}
234 COMMAND ${ABICHECK_COMMAND}
235 COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps/libwsutil/libwsutil_* ${CMAKE_CURRENT_BINARY_DIR}/libwsutil.abi.tar.gz
236 COMMAND rm -rf ${ABICHECK_TMPDIR} ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps
237 DEPENDS ${HEADERS} wsutil)
239 target_link_libraries(wsutil ${wsutil_LIBS})
241 if(NOT ${ENABLE_STATIC})
242 install(TARGETS wsutil
243 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
244 RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
245 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
249 # Export build-time datadir (note: the macro "DATAFILE_DIR" is defined in
250 # config.h and points to the install-time data directory, hence the different
252 set_property(SOURCE filesystem.c APPEND PROPERTY
253 COMPILE_DEFINITIONS BUILD_TIME_DATAFILE_DIR="${DATAFILE_DIR}"
262 ${WSUTIL_COMMON_FILES}
265 set_source_files_properties(jsmn.c PROPERTIES COMPILE_DEFINITIONS "JSMN_STRICT")
268 # Editor modelines - http://www.wireshark.org/tools/modelines.html
273 # indent-tabs-mode: t
276 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
277 # :indentSize=8:tabSize=8:noTabs=false: