aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil/CMakeLists.txt
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-01-20 19:17:36 -0800
committerGuy Harris <guy@alum.mit.edu>2015-01-21 03:18:06 +0000
commit8a0bd92722356c8e23c34104d82ba872ad5c5ac5 (patch)
tree3a9b5403faeb46f9c95d6c85bf73c9cc4d52c9df /wsutil/CMakeLists.txt
parent8051657ccbd33bd73471068cb72431bda5bc5db3 (diff)
Check whether we can use nmmintrin.h.
If we think the compiler supports SSE 4.2, check whether we can use nmmintrin.h if we tell the compiler to compile with SSE 4.2 support; if not, disable SSE 4.2 support. This matches what we do in autotools. Change-Id: I474d53d2fe7e2628faca7309efd7155b63bd7eab Reviewed-on: https://code.wireshark.org/review/6702 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wsutil/CMakeLists.txt')
-rw-r--r--wsutil/CMakeLists.txt55
1 files changed, 33 insertions, 22 deletions
diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt
index 4d97665614..99e46a0a75 100644
--- a/wsutil/CMakeLists.txt
+++ b/wsutil/CMakeLists.txt
@@ -88,9 +88,32 @@ set(WSUTIL_FILES
#
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(HAVE_SSE4_2 TRUE)
+ set(SSE4_2_FLAG "")
else()
message(STATUS "Checking for c-compiler flag: -msse4.2")
check_c_compiler_flag(-msse4.2 HAVE_SSE4_2)
+ set(SSE4_2_FLAG "-msse4.2")
+endif()
+if(HAVE_SSE4_2)
+ #
+ # Make sure we have the necessary header for the SSE4.2 intrinsics
+ # and that we can use it.
+ #
+
+ #
+ # Does this add the SSE4.2 flags to the beginning of CFLAGS?
+ #
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_FLAGS "${SSE4_2_FLAG}")
+ check_include_file("nmmintrin.h" CAN_USE_SSE4_2)
+ cmake_pop_check_state()
+ if(NOT CAN_USE_SSE4_2)
+ #
+ # OK, it's not working for some reason, perhaps because
+ # ${SSE4_2_FLAG} above didn't enable SSE 4.2 support.
+ #
+ set(HAVE_SSE4_2 FALSE)
+ endif()
endif()
if(HAVE_SSE4_2)
set(WSUTIL_FILES ${WSUTIL_FILES} ws_mempbrk_sse42.c)
@@ -143,28 +166,16 @@ if (WERROR)
)
endif()
if (HAVE_SSE4_2)
- #
- # XXX - we're assuming MSVC supports the SSE 4.2 intrinsics and
- # that other C compilers support them iff they support the
- # -msse4.2 flag.
- #
- # Perhaps we should check whether we can compile something
- # that uses them, instead, and do something else to figure
- # out what compiler flag, if any, we need to pass to the
- # compiler to compile code that uses them.
- #
- if(NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
- get_source_file_property(
- WS_MEMPBRK_SSE42_COMPILE_FLAGS
- ws_mempbrk_sse42.c
- COMPILE_FLAGS
- )
- set_source_files_properties(
- ws_mempbrk_sse42.c
- PROPERTIES
- COMPILE_FLAGS "${WS_MEMPBRK_SSE42_COMPILE_FLAGS} -msse4.2"
- )
- endif()
+ get_source_file_property(
+ WS_MEMPBRK_SSE42_COMPILE_FLAGS
+ ws_mempbrk_sse42.c
+ COMPILE_FLAGS
+ )
+ set_source_files_properties(
+ ws_mempbrk_sse42.c
+ PROPERTIES
+ COMPILE_FLAGS "${WS_MEMPBRK_SSE42_COMPILE_FLAGS} ${SSE4_2_FLAG}"
+ )
endif()
add_library(wsutil ${LINK_MODE_LIB}