diff --git a/CMakeLists.txt b/CMakeLists.txt index 252a2fd..cd65155 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,9 +206,18 @@ endif() if(NOT CMAKE_CROSSCOMPILING) find_program(HARDENING_CHECK hardening-check) if(HARDENING_CHECK) - add_test(NAME hardening_check - COMMAND ${HARDENING_CHECK} $ - --nofortify --nostackprotector) + # Control flow integrity (CET) is x86-only and branch protection (PAC/BTI) + # is arm64-only, so ignore whichever doesn't apply. + if(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR + STREQUAL arm64) + set(hardening_check_arch_flags --nocfprotection) + else() + set(hardening_check_arch_flags --nobranchprotection) + endif() + add_test( + NAME hardening_check + COMMAND ${HARDENING_CHECK} $ --nofortify + --nostackprotector ${hardening_check_arch_flags}) endif() endif()