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
74 set(WSUTIL_FILES ${WSUTIL_COMMON_FILES})
76 list(APPEND WSUTIL_FILES
85 if(HAVE_OS_X_FRAMEWORKS)
86 list(APPEND WSUTIL_FILES cfutils.c)
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
95 # We only check for the GCC-style -msse4.2 flag and the Sun C
98 if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
99 set(COMPILER_CAN_HANDLE_SSE4_2 TRUE)
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")
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")
114 if(COMPILER_CAN_HANDLE_SSE4_2)
116 # Make sure we have the necessary headers for the SSE4.2 intrinsics
117 # and that we can use them.
119 # First, check whether we have emmintrin.h and can use it
120 # *without* the SSE 4.2 flag.
122 check_include_file("emmintrin.h" EMMINTRIN_H_WORKS)
125 # OK, if that works, see whether we have nmmintrin.h and
126 # can use it *with* the SSE 4.2 flag.
128 if(EMMINTRIN_H_WORKS)
130 # Does this add the SSE4.2 flags to the beginning of
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).
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()
148 list(APPEND WSUTIL_FILES ws_mempbrk_sse42.c)
151 if(NOT HAVE_GETOPT_LONG)
152 list(APPEND WSUTIL_FILES getopt_long.c)
155 if(NOT HAVE_INET_ATON)
156 list(APPEND WSUTIL_FILES inet_aton.c)
159 if(NOT HAVE_POPCOUNT)
160 list(APPEND WSUTIL_FILES popcount.c)
163 if(NOT HAVE_STRPTIME)
164 list(APPEND WSUTIL_FILES strptime.c)
169 # We assume that APPLE means OS X so that we have the OS X
172 FIND_LIBRARY (APPLE_CORE_FOUNDATION_LIBRARY CoreFoundation)
177 ${APPLE_CORE_FOUNDATION_LIBRARY}
178 ${GMODULE2_LIBRARIES}
182 ${WIN_WSOCK32_LIBRARY}
185 set(wsutil_LIBS ${wsutil_LIBS} "iphlpapi.lib" "ws2_32.lib")
192 if (WERROR_COMMON_FLAGS)
193 set_source_files_properties(
196 COMPILE_FLAGS ${WERROR_COMMON_FLAGS}
200 # Set the property to an empty string, so that if we try
201 # to get it below, it succeeds.
203 set_source_files_properties(
210 get_source_file_property(
211 WS_MEMPBRK_SSE42_COMPILE_FLAGS
215 set_source_files_properties(
218 COMPILE_FLAGS "${WS_MEMPBRK_SSE42_COMPILE_FLAGS} ${SSE4_2_FLAG}"
222 add_library(wsutil ${LINK_MODE_LIB}
224 ${CMAKE_BINARY_DIR}/image/libwsutil.rc
227 set(FULL_SO_VERSION "0.0.0")
229 set_target_properties(wsutil PROPERTIES
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
237 if(ENABLE_APPLICATION_BUNDLE)
238 set_target_properties(wsutil PROPERTIES
239 LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Frameworks
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)
255 target_link_libraries(wsutil ${wsutil_LIBS})
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}
265 add_definitions( -DTOP_SRCDIR=\"${CMAKE_SOURCE_DIR}\" )
273 ${WSUTIL_COMMON_FILES}
277 # Editor modelines - http://www.wireshark.org/tools/modelines.html
282 # indent-tabs-mode: t
285 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
286 # :indentSize=8:tabSize=8:noTabs=false: