Skip to content

Commit

Permalink
Build: Fix float test errors with Xcode 14.2/Arm
Browse files Browse the repository at this point in the history
Unlike other versions of Clang 14.0.0, AppleClang 14.0.0 in Xcode 14.2
retains the old -ffp-contract=off default.  Apple didn't adopt
-ffp-contract=on as the default until Xcode 14.3 (AppleClang 14.0.3.)
This has been confirmed in the Xcode 14.3 release notes.
  • Loading branch information
dcommander committed Dec 12, 2024
1 parent 1c864a9 commit b4ca1ba
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -935,8 +935,14 @@ if(CPU_TYPE STREQUAL "x86_64" OR CPU_TYPE STREQUAL "i386")
endif()
elseif(CPU_TYPE STREQUAL "powerpc" OR CPU_TYPE STREQUAL "arm64")
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(CMAKE_C_COMPILER_VERSION VERSION_EQUAL 14.0.0 OR
CMAKE_C_COMPILER_VERSION VERSION_GREATER 14.0.0)
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang")
# Xcode 14.3 and later
set(MIN_FP_CONTRACT_VERSION 14.0.1)
else()
set(MIN_FP_CONTRACT_VERSION 14.0.0)
endif()
if(CMAKE_C_COMPILER_VERSION VERSION_EQUAL ${MIN_FP_CONTRACT_VERSION} OR
CMAKE_C_COMPILER_VERSION VERSION_GREATER ${MIN_FP_CONTRACT_VERSION})
set(DEFAULT_FLOATTEST8 fp-contract)
else()
set(DEFAULT_FLOATTEST8 no-fp-contract)
Expand Down Expand Up @@ -977,8 +983,14 @@ if(CPU_TYPE STREQUAL "x86_64")
set(DEFAULT_FLOATTEST12 no-fp-contract)
elseif(CPU_TYPE STREQUAL "powerpc" OR CPU_TYPE STREQUAL "arm64")
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(CMAKE_C_COMPILER_VERSION VERSION_EQUAL 14.0.0 OR
CMAKE_C_COMPILER_VERSION VERSION_GREATER 14.0.0)
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang")
# Xcode 14.3 and later
set(MIN_FP_CONTRACT_VERSION 14.0.1)
else()
set(MIN_FP_CONTRACT_VERSION 14.0.0)
endif()
if(CMAKE_C_COMPILER_VERSION VERSION_EQUAL ${MIN_FP_CONTRACT_VERSION} OR
CMAKE_C_COMPILER_VERSION VERSION_GREATER ${MIN_FP_CONTRACT_VERSION})
set(DEFAULT_FLOATTEST12 fp-contract)
else()
set(DEFAULT_FLOATTEST12 no-fp-contract)
Expand Down

0 comments on commit b4ca1ba

Please sign in to comment.