diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-01-20 18:44:17 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-01-21 02:45:35 +0000 |
commit | bf239535b9c054d7d8d919558ff352c8ce648842 (patch) | |
tree | 2ef12823067d1bbf411396d0dcc056e4f94c9183 /wsutil/CMakeLists.txt | |
parent | f2151025401d345a9ce1c2ee0860dc69d1c6d9c0 (diff) |
Only turn -msse4.2 on for ws_mempbrk_sse42.c, and don't always build it.
Move all the SSE 4.2 stuff to wsutil/CMakeLists.txt.
Don't put ws_mempbrk_sse42.c in WSUTIL_FILES by default; add it if we
think the compiler supports compiling for SSE 4.2.
Add -msse4.2 to its COMPILE_FLAGS, but don't add it to any other
compiler flags - we don't want to build anything else with -msse4.2 by
default, as the only code that uses SSE 4.2 instructions but *only* does
so if the processor supports it is our mempbrk implementation. (And
*add* it, don't *replace* the existing flags with -msse4.2; that way,
-Werror is left in there as well.)
Change-Id: I979b37a37e4b88b3af11e2275e89441118c8ce0a
Reviewed-on: https://code.wireshark.org/review/6698
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wsutil/CMakeLists.txt')
-rw-r--r-- | wsutil/CMakeLists.txt | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt index ec2896da5b..4d97665614 100644 --- a/wsutil/CMakeLists.txt +++ b/wsutil/CMakeLists.txt @@ -72,11 +72,26 @@ set(WSUTIL_FILES u3.c unicode-utils.c ws_mempbrk.c - ws_mempbrk_sse42.c ws_version_info.c ${WSUTIL_PLATFORM_FILES} ) +# +# 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(CMAKE_C_COMPILER_ID MATCHES "MSVC") + set(HAVE_SSE4_2 TRUE) +else() + message(STATUS "Checking for c-compiler flag: -msse4.2") + check_c_compiler_flag(-msse4.2 HAVE_SSE4_2) +endif() if(HAVE_SSE4_2) set(WSUTIL_FILES ${WSUTIL_FILES} ws_mempbrk_sse42.c) endif() @@ -139,10 +154,15 @@ if (HAVE_SSE4_2) # 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( - ${WSUTIL_SSE42_FILES} + ws_mempbrk_sse42.c PROPERTIES - COMPILE_FLAGS -msse4.2 + COMPILE_FLAGS "${WS_MEMPBRK_SSE42_COMPILE_FLAGS} -msse4.2" ) endif() endif() |