shithub: opus

Download patch

ref: d4b8707b1460c90682ee91f1283d361b90feddd2
parent: 8ad827c3ff99f08b4087cf47637c722020d3c958
author: Zeno Endemann <[email protected]>
date: Wed Jul 15 17:45:42 EDT 2020

CMake: Make _FORTIFY_SOURCE optional

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -109,6 +109,12 @@
                        OFF)
 add_feature_info(OPUS_STACK_PROTECTOR OPUS_STACK_PROTECTOR ${OPUS_STACK_PROTECTOR_HELP_STR})
 
+if(NOT MSVC AND NOT MINGW)
+    set(OPUS_FORTIFY_SOURCE_HELP_STR "add protection against buffer overflows.")
+    option(OPUS_FORTIFY_SOURCE ${OPUS_FORTIFY_SOURCE_HELP_STR} ON)
+    add_feature_info(OPUS_FORTIFY_SOURCE OPUS_FORTIFY_SOURCE ${OPUS_FORTIFY_SOURCE_HELP_STR})
+endif()
+
 if(OPUS_CPU_X86 OR OPUS_CPU_X64)
   set(OPUS_X86_MAY_HAVE_SSE_HELP_STR "does runtime check for SSE1 support.")
   cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE
@@ -241,7 +247,7 @@
 target_link_libraries(opus PRIVATE ${OPUS_REQUIRED_LIBRARIES})
 target_compile_definitions(opus PRIVATE OPUS_BUILD ENABLE_HARDENING)
 
-if(NOT MSVC)
+if(OPUS_FORTIFY_SOURCE)
   target_compile_definitions(opus PRIVATE _FORTIFY_SOURCE=2)
 endif()