Skip to content

Commit efee787

Browse files
authored
Merge pull request #660 from wlemkows/add-compiler-flags
Add strongly recommended security compiler flags
2 parents 566169d + 64a847b commit efee787

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,11 @@ if(NOT MSVC)
5757
add_compile_options(-fPIC -Wall -Wpedantic
5858
$<$<CXX_COMPILER_ID:GNU>:-fdiagnostics-color=always>
5959
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-fcolor-diagnostics>)
60+
if (CMAKE_BUILD_TYPE STREQUAL "Release")
61+
add_compile_options(-D_FORTIFY_SOURCE=2)
62+
endif()
6063
if(UR_DEVELOPER_MODE)
61-
add_compile_options(-Werror -fno-omit-frame-pointer)
64+
add_compile_options(-Werror -fno-omit-frame-pointer -fstack-protector-strong)
6265
endif()
6366
# Determine if libstdc++ is being used.
6467
check_cxx_source_compiles("
@@ -81,7 +84,7 @@ elseif(MSVC)
8184
add_compile_options(/MP /W3 /MD$<$<CONFIG:Debug>:d>)
8285

8386
if(UR_DEVELOPER_MODE)
84-
add_compile_options(/WX)
87+
add_compile_options(/WX /GS)
8588
endif()
8689
endif()
8790

0 commit comments

Comments
 (0)