Skip to content

Commit 988f722

Browse files
olszomalmtrojnar
authored andcommitted
Simplify ASLR/PIE flags check for macOS
1 parent c23f92c commit 988f722

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

cmake/SetCompilerFlags.cmake

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,11 @@ function(add_compile_flags target)
9696
message(WARNING "No stack protection supported")
9797
endif(HAVE_STACK_PROTECTOR)
9898
endif(HAVE_STACK_PROTECTOR_ALL)
99-
# Support address space layout randomization (ASLR)
100-
if(NOT (MINGW OR CYGWIN OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang"
101-
OR ((CMAKE_SYSTEM_NAME MATCHES Darwin) AND (CMAKE_C_COMPILER_ID MATCHES Clang))))
99+
# Support address space layout randomization (ASLR) / PIE
100+
if(UNIX AND NOT APPLE)
102101
target_compile_options(${target} PRIVATE -fPIE)
103-
target_link_options(${target} PRIVATE -fPIE -pie)
104-
target_link_options(${target} PRIVATE -Wl,-z,relro)
105-
target_link_options(${target} PRIVATE -Wl,-z,now)
106-
target_link_options(${target} PRIVATE -Wl,-z,noexecstack)
107-
endif(NOT (MINGW OR CYGWIN OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang"
108-
OR ((CMAKE_SYSTEM_NAME MATCHES Darwin) AND (CMAKE_C_COMPILER_ID MATCHES Clang))))
102+
target_link_options(${target} PRIVATE -fPIE -pie -Wl,-z,relro,-z,now,-z,noexecstack)
103+
endif(UNIX AND NOT APPLE)
109104
target_link_options(${target} PRIVATE -fstack-check)
110105
add_compile_flag_to_targets(${target})
111106
endif(MSVC)

0 commit comments

Comments
 (0)