Changeset View
Changeset View
Standalone View
Standalone View
src/CMakeLists.txt
Show First 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | |||||
endif() | endif() | ||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||||
if(ENABLE_HARDENING) | if(ENABLE_HARDENING) | ||||
# Enable stack protection | # Enable stack protection | ||||
add_cxx_compiler_flags(-fstack-protector-all -Wstack-protector) | add_cxx_compiler_flags(-fstack-protector-all -Wstack-protector) | ||||
# Enable some buffer overflow checking | # Enable some buffer overflow checking, except in -O0 builds which | ||||
add_compiler_flags(-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2) | # do not support them | ||||
add_compiler_flags(-U_FORTIFY_SOURCE) | |||||
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-D_FORTIFY_SOURCE=2>) | |||||
# Enable ASLR (these flags are primarily targeting MinGw) | # Enable ASLR (these flags are primarily targeting MinGw) | ||||
add_linker_flags(-Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va) | add_linker_flags(-Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va) | ||||
# Make the relocated sections read-only | # Make the relocated sections read-only | ||||
add_linker_flags(-Wl,-z,relro -Wl,-z,now) | add_linker_flags(-Wl,-z,relro -Wl,-z,now) | ||||
# CMake provides the POSITION_INDEPENDENT_CODE property to set PIC/PIE. | # CMake provides the POSITION_INDEPENDENT_CODE property to set PIC/PIE. | ||||
▲ Show 20 Lines • Show All 520 Lines • Show Last 20 Lines |