Skip to content

Commit 8ff60d1

Browse files
refactor NEO_DISABLE_MITIGATIONS option
Related-To: NEO-7227 Signed-off-by: Artur Harasimiuk <[email protected]>
1 parent 5986a71 commit 8ff60d1

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

CMakeLists.txt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -617,18 +617,18 @@ if(MSVC)
617617
endif()
618618

619619
# spectre mitigation
620-
if(MSVC)
621-
check_cxx_compiler_flag(/Qspectre COMPILER_SUPPORTS_QSPECTRE)
622-
check_cxx_compiler_flag(/d2guardspecload COMPILER_SUPPORTS_D2GUARDSPECLOAD)
623-
if(COMPILER_SUPPORTS_QSPECTRE)
624-
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qspectre")
625-
elseif(COMPILER_SUPPORTS_D2GUARDSPECLOAD)
626-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /d2guardspecload")
620+
if(NOT NEO_DISABLE_MITIGATIONS)
621+
if(MSVC)
622+
check_cxx_compiler_flag(/Qspectre COMPILER_SUPPORTS_QSPECTRE)
623+
check_cxx_compiler_flag(/d2guardspecload COMPILER_SUPPORTS_D2GUARDSPECLOAD)
624+
if(COMPILER_SUPPORTS_QSPECTRE)
625+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qspectre")
626+
elseif(COMPILER_SUPPORTS_D2GUARDSPECLOAD)
627+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /d2guardspecload")
628+
else()
629+
message(WARNING "Spectre mitigation is not supported by the compiler")
630+
endif()
627631
else()
628-
message(WARNING "Spectre mitigation is not supported by the compiler")
629-
endif()
630-
else()
631-
if(NOT NEO_DISABLE_MITIGATIONS)
632632
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
633633
check_cxx_compiler_flag(-mretpoline COMPILER_SUPPORTS_RETPOLINE)
634634
if(COMPILER_SUPPORTS_RETPOLINE)
@@ -656,9 +656,12 @@ else()
656656
message(WARNING "Spectre mitigation -mindirect-branch-register flag is not supported by the compiler")
657657
endif()
658658
endif()
659-
else()
660-
message(WARNING "Spectre mitigation DISABLED")
661659
endif()
660+
else()
661+
message(WARNING "Spectre mitigation DISABLED")
662+
endif()
663+
664+
if(NOT MSVC)
662665
check_cxx_compiler_flag(-msse4.2 COMPILER_SUPPORTS_SSE42)
663666
check_cxx_compiler_flag(-mavx2 COMPILER_SUPPORTS_AVX2)
664667
check_cxx_compiler_flag(-march=armv8-a+simd COMPILER_SUPPORTS_NEON)

0 commit comments

Comments
 (0)