shithub: opus

Download patch

ref: 4fc7d874969da418d81b6e0d44b41759c19836aa
parent: 66422d0bac8652ee8d2a2477077e735ca54cfa68
author: Marcus Asteborg <maastebo@microsoft.com>
date: Tue Apr 7 09:56:04 EDT 2020

cmake - Fix OPUS_STACK_PROTECTOR option

Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,12 +52,19 @@
 endif()
 
 if(OPUS_STACK_PROTECTOR)
-  if(NOT MSVC) # GC on by default on MSVC
-    check_and_set_flag(STACK_PROTECTION_STRONG -fstack-protector-strong)
+  if(MSVC) # GC on by default on MSVC
+    check_and_set_flag(STACK_PROTECTOR /GS)
+  else()
+    check_and_set_flag(STACK_PROTECTOR -fstack-protector-strong)
   endif()
 else()
   if(MSVC)
-    check_and_set_flag(BUFFER_SECURITY_CHECK /GS-)
+    check_and_set_flag(STACK_PROTECTOR_DISABLED /GS-)
+    if (STACK_PROTECTOR_DISABLED_SUPPORTED)
+      set(STACK_PROTECTOR_SUPPORTED OFF)
+    endif()
+  else()
+    set(STACK_PROTECTOR_SUPPORTED OFF)
   endif()
 endif()
 
@@ -132,7 +139,7 @@
                        "required to set up package version")
 
 add_feature_info(OPUS_BUILD_SHARED_LIBRARY OPUS_BUILD_SHARED_LIBRARY "Build shared library")
-add_feature_info(OPUS_STACK_PROTECTOR OPUS_STACK_PROTECTOR "Use stack protection")
+add_feature_info(OPUS_STACK_PROTECTOR STACK_PROTECTOR_SUPPORTED "Use stack protection")
 add_feature_info(OPUS_USE_ALLOCA OPUS_USE_ALLOCA
                  "Use alloca for stack arrays (on non-C99 compilers)")
 add_feature_info(OPUS_CUSTOM_MODES OPUS_CUSTOM_MODES