CMakeLists: option to disable -fstack-protector

This flag is not supported by all GCC + libc combination, for example it is not suported with GCC and uClibc.
This commit is contained in:
Gleb Mazovetskiy
2021-10-15 18:22:32 +01:00
parent 20e20be0f3
commit 601ba45318

View File

@@ -380,10 +380,15 @@ if(BUILD_WIN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc -DNOMINMAX")
else()
option(STACK_PROTECTOR "Compile with -fstack-protector" ON)
if(STACK_PROTECTOR)
set(STACK_PROTECTOR_FLAGS -fstack-protector)
endif()
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} \
${ZT_FLAGS} \
-fstack-protector")
${STACK_PROTECTOR_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG
"${CMAKE_C_FLAGS_DEBUG} \
@@ -393,7 +398,7 @@ else()
set(CMAKE_C_FLAGS_RELEASE
"${CMAKE_C_FLAGS_RELEASE} \
${RELEASE_OPTIMIZATION} \
-fstack-protector")
${STACK_PROTECTOR_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
${ZT_FLAGS} -Wall -Wextra -std=c++11")