Port CMake changes from dhewm3 (up to "Fix runtime assert on PPC OS X")

- (Hopefully) better workaround for miscompiled cross products, #147
  (-ffp-contract=off)
- GCC/Clang: Remove -fno-unsafe-math-optimizations
  (redundant as long as -ffast-math isn't used)
- Fix runtime assert on PPC OS X
  (-mone-byte-bool)
This commit is contained in:
Daniel Gibson 2022-05-17 01:09:30 +02:00
parent bc10904bff
commit ec18111bbc

View file

@ -138,14 +138,17 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS_DEBUG "-g -D_DEBUG -O0") set(CMAKE_C_FLAGS_DEBUG "-g -D_DEBUG -O0")
set(CMAKE_C_FLAGS_DEBUGALL "-g -ggdb -D_DEBUG") set(CMAKE_C_FLAGS_DEBUGALL "-g -ggdb -D_DEBUG")
set(CMAKE_C_FLAGS_PROFILE "-g -ggdb -D_DEBUG -O1 -fno-omit-frame-pointer") set(CMAKE_C_FLAGS_PROFILE "-g -ggdb -D_DEBUG -O1 -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS_RELEASE "-O2 -fno-unsafe-math-optimizations -fno-math-errno -fno-trapping-math -fomit-frame-pointer") set(CMAKE_C_FLAGS_RELEASE "-O2 -fno-math-errno -fno-trapping-math -fomit-frame-pointer")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -ggdb -fno-unsafe-math-optimizations -fno-math-errno -fno-trapping-math -fno-omit-frame-pointer") set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -ggdb -fno-math-errno -fno-trapping-math -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -fno-unsafe-math-optimizations -fno-math-errno -fno-trapping-math -fomit-frame-pointer") set(CMAKE_C_FLAGS_MINSIZEREL "-Os -fno-math-errno -fno-trapping-math -fomit-frame-pointer")
set(CMAKE_CXX_FLAGS_DEBUGALL ${CMAKE_C_FLAGS_DEBUGALL}) set(CMAKE_CXX_FLAGS_DEBUGALL ${CMAKE_C_FLAGS_DEBUGALL})
set(CMAKE_CXX_FLAGS_PROFILE ${CMAKE_C_FLAGS_PROFILE}) set(CMAKE_CXX_FLAGS_PROFILE ${CMAKE_C_FLAGS_PROFILE})
add_compile_options(-fno-strict-aliasing) add_compile_options(-fno-strict-aliasing)
# dear idiot compilers, don't fuck up math code with useless FMA "optimizations"
# (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100839)
add_compile_options(-ffp-contract=off)
if(NOT AROS) if(NOT AROS)
CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" cxx_has_fvisibility) CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" cxx_has_fvisibility)
@ -198,8 +201,8 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
elseif(cpu STREQUAL "ppc") elseif(cpu STREQUAL "ppc")
CHECK_CXX_COMPILER_FLAG("-arch ppc" cxx_has_arch_ppc) CHECK_CXX_COMPILER_FLAG("-arch ppc" cxx_has_arch_ppc)
if(cxx_has_arch_ppc) if(cxx_has_arch_ppc)
add_compile_options(-arch ppc) add_compile_options(-arch ppc -mone-byte-bool)
set(ldflags "${ldflags} -arch ppc") set(ldflags "${ldflags} -arch ppc -mone-byte-bool")
endif() endif()
add_compile_options(-mmacosx-version-min=10.4) add_compile_options(-mmacosx-version-min=10.4)