diff --git a/llvm/cmake/modules/AddSecurityFlags.cmake b/llvm/cmake/modules/AddSecurityFlags.cmake index ca8c03a3dbf94..5edbf4ee47e6e 100644 --- a/llvm/cmake/modules/AddSecurityFlags.cmake +++ b/llvm/cmake/modules/AddSecurityFlags.cmake @@ -133,7 +133,10 @@ macro(append_common_extra_security_flags) # Position Independent Execution # We rely on CMake to set the right -fPIE flags for us, but it must be # explicitly requested - if (NOT CMAKE_POSITION_INDEPENDENT_CODE) + if (CMAKE_POSITION_INDEPENDENT_CODE) + include(CheckPIESupported) + check_pie_supported() + else() message(FATAL_ERROR "To enable all necessary security flags, CMAKE_POSITION_INDEPENDENT_CODE must be set to ON") endif()