From 5bb2691b91c7458b971863ade27444b70e8a5745 Mon Sep 17 00:00:00 2001 From: Colton Pawielski Date: Sat, 4 Mar 2023 16:13:44 -0600 Subject: [PATCH] Change CMakeLists.txt to add -mfsrra and -mfsca only if supported by compiler GCC4.7 does not support these flags and cause a failure to build --- CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d54ba2..a9d9982 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,16 @@ if(NOT PLATFORM_DREAMCAST) set(FIND_LIBRARY_USE_LIB32_PATHS true) set(FIND_LIBRARY_USE_LIB64_PATHS false) else() - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -mfsrra -ffp-contract=fast -mfsca -ffast-math") + include(CheckCCompilerFlag) + check_c_compiler_flag("-mfsrra" COMPILER_HAS_FSRRA) + check_c_compiler_flag("-mfsca" COMPILER_HAS_FSCA) + if(COMPILER_HAS_FSRRA) + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -mfsrra") + endif() + if(COMPILER_HAS_FSCA) + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -mfsca") + endif() + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffp-contract=fast -ffast-math") endif() set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -fexpensive-optimizations")