Skip to content

Commit

Permalink
CheckSupportSSE2: Fix sse flags unexpected propagation (#1721)
Browse files Browse the repository at this point in the history
Set function will affects all variables in current directory. If sse
flags are added in CheckSupportSSE2.cmake, they will remain in
Findminizip-ng.cmake which will cause liblzma cannot be detected. This
patch keep CMAKE_REQUIRED_FLAGS being changed only in current file
scope. This patch has been tested on riscv64.

Signed-off-by: Letu Ren <fantasquex@gmail.com>

Signed-off-by: Letu Ren <fantasquex@gmail.com>
Co-authored-by: Doug Walker <doug.walker@autodesk.com>
  • Loading branch information
FantasqueX and doug-walker committed Dec 3, 2022
1 parent d5cedbf commit b6e40f4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions share/cmake/utils/CheckSupportSSE2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

include(CheckCXXSourceCompiles)

set(_cmake_required_flags_old "${CMAKE_REQUIRED_FLAGS}")

if(NOT CMAKE_SIZE_OF_VOID_P EQUAL 8)
# As CheckCXXCompilerFlag implicitly uses CMAKE_CXX_FLAGS some custom flags could trigger
# unrelated warnings causing a detection failure. So, the code disables all warnings to focus
Expand All @@ -27,4 +29,7 @@ check_cxx_source_compiles ("
}"
HAVE_SSE2)

set(CMAKE_REQUIRED_FLAGS "${_cmake_required_flags_old}")
unset(_cmake_required_flags_old)

mark_as_advanced(HAVE_SSE2)

0 comments on commit b6e40f4

Please sign in to comment.