Skip to content

Commit

Permalink
add fPIC only if CMAKE_POSITION_INDEPENDENT_CODE is ON
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkingsugar committed Nov 18, 2023
1 parent f71c92a commit 2e92358
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmake/compilers/Clang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ if (CMAKE_SYSTEM_PROCESSOR MATCHES "(AMD64|amd64|i.86|x86)")
endif()

# Clang flags to prevent compiler from optimizing out security checks
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -Wformat -Wformat-security -Werror=format-security -fPIC $<$<NOT:$<BOOL:${EMSCRIPTEN}>>:-fstack-protector-strong>)
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -Wformat -Wformat-security -Werror=format-security $<$<NOT:$<BOOL:${EMSCRIPTEN}>>:-fstack-protector-strong>)

if(CMAKE_POSITION_INDEPENDENT_CODE)
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -fPIC)
endif()

# -z switch is not supported on MacOS
if (NOT APPLE)
Expand Down

0 comments on commit 2e92358

Please sign in to comment.