From 1e24fcd9a48d70a6e4389125713c6e52a34086a4 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 29 Aug 2024 09:25:00 +0200 Subject: [PATCH] [cmake,android] check compiler flags Check -mfloat-abi=softfp supported before use. This workaround is for older NDK versions that do not properly set this in the toolchain file. Newer NDK versions changed compiler no longer supporting that flag. --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f60c67f5c..9f0743e53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -422,8 +422,13 @@ if(ANDROID) endif() if(ANDROID_ABI STREQUAL arm64-v8a) - # https://github.com/android/ndk/issues/910 - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=softfp") + include (CheckCCompilerFlag) + check_c_compiler_flag("-mfloat-abi=softfp" ABI_SOFTFP_SUPPORTED) + + if (ABI_SOFTFP_SUPPORTED) + # https://github.com/android/ndk/issues/910 + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=softfp") + endif() endif() if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")