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
77 set(WSUTIL_FILES ${WSUTIL_COMMON_FILES})
79 list(APPEND WSUTIL_FILES
88 if(HAVE_OS_X_FRAMEWORKS)
89 list(APPEND WSUTIL_FILES cfutils.c)
93 # XXX - we're assuming MSVC doesn't require a flag to enable SSE 4.2
94 # support, and that, if the compiler supports a flag for SSE 4.2
95 # support, the intrinsics are supported iff we can include the
98 # We only check for the GCC-style -msse4.2 flag and the Sun C
101 if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
102 set(COMPILER_CAN_HANDLE_SSE4_2 TRUE)
105 message(STATUS "Checking for c-compiler flag: -msse4.2")
106 check_c_compiler_flag(-msse4.2 COMPILER_CAN_HANDLE_SSE4_2)
107 if(COMPILER_CAN_HANDLE_SSE4_2)
108 set(SSE4_2_FLAG "-msse4.2")
110 message(STATUS "Checking for c-compiler flag: -xarch=sse4_2")
111 check_c_compiler_flag(-xarch=sse4_2 COMPILER_CAN_HANDLE_SSE4_2)
112 if(COMPILER_CAN_HANDLE_SSE4_2)
113 set(SSE4_2_FLAG "-xarch=sse4_2")
117 if(COMPILER_CAN_HANDLE_SSE4_2)
119 # Make sure we have the necessary headers for the SSE4.2 intrinsics
120 # and that we can use them.
122 # First, check whether we have emmintrin.h and can use it
123 # *without* the SSE 4.2 flag.
125 check_include_file("emmintrin.h" EMMINTRIN_H_WORKS)
128 # OK, if that works, see whether we have nmmintrin.h and
129 # can use it *with* the SSE 4.2 flag.
131 if(EMMINTRIN_H_WORKS)
133 # Does this add the SSE4.2 flags to the beginning of
136 # Note that if there's a mix of "enable SSE 4.2" and
137 # "disable SSE 4.2" flags, this may not indicate that
138 # we can use the header. That's not a bug, that's a
139 # feature; the other flags may have been forced by
140 # the build process, e.g. in Gentoo Linux, and we want
141 # to check this with whatever flags will actually be
142 # used when building (see bug 10792).
144 cmake_push_check_state()
145 set(CMAKE_REQUIRED_FLAGS "${SSE4_2_FLAG}")
146 check_include_file("nmmintrin.h" HAVE_SSE4_2)
147 cmake_pop_check_state()
151 list(APPEND WSUTIL_FILES ws_mempbrk_sse42.c)
154 if(NOT HAVE_GETOPT_LONG)
155 list(APPEND WSUTIL_FILES getopt_long.c)
158 if(NOT HAVE_INET_ATON)
159 list(APPEND WSUTIL_FILES inet_aton.c)
162 if(NOT HAVE_POPCOUNT)
163 list(APPEND WSUTIL_FILES popcount.c)
166 if(NOT HAVE_STRPTIME)
167 list(APPEND WSUTIL_FILES strptime.c)
172 # We assume that APPLE means OS X so that we have the OS X
175 FIND_LIBRARY (APPLE_CORE_FOUNDATION_LIBRARY CoreFoundation)
180 ${APPLE_CORE_FOUNDATION_LIBRARY}
181 ${GMODULE2_LIBRARIES}
185 ${WIN_WSOCK32_LIBRARY}
188 set(wsutil_LIBS ${wsutil_LIBS} "iphlpapi.lib" "ws2_32.lib")
195 set_source_files_properties(
198 COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
201 # TODO with CMake 2.8.12, we could use COMPILE_OPTIONS and just append
202 # instead of this COMPILE_FLAGS duplication...
203 set_source_files_properties(
206 COMPILE_FLAGS "${WERROR_COMMON_FLAGS} ${SSE4_2_FLAG}"
210 add_library(wsutil ${LINK_MODE_LIB}
212 ${CMAKE_BINARY_DIR}/image/libwsutil.rc
215 set(FULL_SO_VERSION "0.0.0")
217 set_target_properties(wsutil PROPERTIES
219 COMPILE_DEFINITIONS "WS_BUILD_DLL"
220 COMPILE_OPTIONS "${WS_WARNINGS_C_FLAGS}"
221 LINK_FLAGS "${WS_LINK_FLAGS}"
222 VERSION ${FULL_SO_VERSION} SOVERSION 0
225 if(ENABLE_APPLICATION_BUNDLE)
226 set_target_properties(wsutil PROPERTIES
227 LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Frameworks
233 add_custom_command(OUTPUT libwsutil.abi.tar.gz
234 COMMAND ${CMAKE_COMMAND} -E remove_directory ${ABICHECK_TMPDIR}
235 COMMAND ${CMAKE_COMMAND} -E make_directory ${ABICHECK_TMPDIR}
236 COMMAND ${ABI_COPY_COMMAND} ../config.h ${ABICHECK_TMPDIR}/ ${ABI_COPY_FLAGS}
237 COMMAND ${ABI_COPY_COMMAND} ${ABICHECK_HEADERS} ${ABICHECK_TMPDIR}/ ${ABI_COPY_FLAGS}
238 COMMAND ${ABICHECK_COMMAND}
239 COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps/libwsutil/libwsutil_* ${CMAKE_CURRENT_BINARY_DIR}/libwsutil.abi.tar.gz
240 COMMAND rm -rf ${ABICHECK_TMPDIR} ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps
241 DEPENDS ${HEADERS} wsutil)
243 target_link_libraries(wsutil ${wsutil_LIBS})
245 if(NOT ${ENABLE_STATIC})
246 install(TARGETS wsutil
247 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
248 RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
249 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
253 # Export build-time datadir (note: the macro "DATAFILE_DIR" is defined in
254 # config.h and points to the install-time data directory, hence the different
256 set_property(SOURCE filesystem.c APPEND PROPERTY
257 COMPILE_DEFINITIONS BUILD_TIME_DATAFILE_DIR="${DATAFILE_DIR}"
266 ${WSUTIL_COMMON_FILES}
269 set_source_files_properties(jsmn.c PROPERTIES COMPILE_DEFINITIONS "JSMN_STRICT")
272 # Editor modelines - http://www.wireshark.org/tools/modelines.html
277 # indent-tabs-mode: t
280 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
281 # :indentSize=8:tabSize=8:noTabs=false: