cmake: make all assembly options depend on SDL_ASSEMBLY and architecture

main
Anonymous Maarten 2022-11-25 01:27:44 +01:00 committed by Anonymous Maarten
parent d0e14008b5
commit d1f423d9db
1 changed files with 40 additions and 31 deletions

View File

@ -135,8 +135,11 @@ set(SDL_GENERATED_HEADERS)
#message(STATUS "${LT_VERSION} :: ${LT_AGE} :: ${LT_REVISION} :: ${LT_CURRENT} :: ${LT_RELEASE}")
# General settings & flags
set(LIBRARY_OUTPUT_DIRECTORY "build")
check_cpu_architecture(x86 SDL_CPU_X86)
check_cpu_architecture(x64 SDL_CPU_X64)
check_cpu_architecture(arm32 SDL_CPU_ARM32)
check_cpu_architecture(arm64 SDL_CPU_ARM64)
# Check for 64 or 32 bit
set(SIZEOF_VOIDP ${CMAKE_SIZEOF_VOID_P})
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
@ -284,11 +287,6 @@ if(USE_GCC OR USE_CLANG)
endif()
# Default option knobs
if(APPLE OR ARCH_64 OR MSVC_CLANG)
if(NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES "arm")
set(OPT_DEF_SSEMATH ON)
endif()
endif()
if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS)
set(OPT_DEF_LIBC ON)
endif()
@ -376,7 +374,6 @@ endif()
# All these ENABLED_BY_DEFAULT vars will default to ON if not specified, so
# you only need to have a platform override them if they are disabling.
set(OPT_DEF_ASM TRUE)
if(EMSCRIPTEN)
# Set up default values for the currently supported set of subsystems:
# Emscripten/Javascript does not have assembly support, a dynamic library
@ -440,18 +437,19 @@ set_option(SDL3_DISABLE_UNINSTALL "Disable uninstallation of SDL3" OFF)
option_string(SDL_ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
#set_option(SDL_DEPENDENCY_TRACKING "Use gcc -MMD -MT dependency tracking" ON)
set_option(SDL_ASSEMBLY "Enable assembly routines" ${OPT_DEF_ASM})
dep_option(SDL_SSEMATH "Allow GCC to use SSE floating point math" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_SSE "Use SSE assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_SSE2 "Use SSE2 assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_SSE3 "Use SSE3 assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_MMX "Use MMX assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_3DNOW "Use 3Dnow! MMX assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
dep_option(SDL_ALTIVEC "Use Altivec assembly routines" ON "SDL_ASSEMBLY" OFF)
dep_option(SDL_ARMSIMD "Use SIMD assembly blitters on ARM" OFF "SDL_ASSEMBLY;SDL_CPU_ARM32" OFF)
dep_option(SDL_ARMNEON "Use NEON assembly blitters on ARM" OFF "SDL_ASSEMBLY;SDL_CPU_ARM32" OFF)
set_option(SDL_LIBC "Use the system C library" ${OPT_DEF_LIBC})
set_option(SDL_GCC_ATOMICS "Use gcc builtin atomics" ${OPT_DEF_GCC_ATOMICS})
set_option(SDL_ASSEMBLY "Enable assembly routines" ${OPT_DEF_ASM})
set_option(SDL_SSEMATH "Allow GCC to use SSE floating point math" ${OPT_DEF_SSEMATH})
set_option(SDL_MMX "Use MMX assembly routines" ${OPT_DEF_ASM})
set_option(SDL_3DNOW "Use 3Dnow! MMX assembly routines" ${OPT_DEF_ASM})
set_option(SDL_SSE "Use SSE assembly routines" ${OPT_DEF_ASM})
set_option(SDL_SSE2 "Use SSE2 assembly routines" ${OPT_DEF_SSEMATH})
set_option(SDL_SSE3 "Use SSE3 assembly routines" ${OPT_DEF_SSEMATH})
set_option(SDL_ALTIVEC "Use Altivec assembly routines" ${OPT_DEF_ASM})
set_option(SDL_ARMSIMD "use SIMD assembly blitters on ARM" OFF)
set_option(SDL_ARMNEON "use NEON assembly blitters on ARM" OFF)
dep_option(SDL_DBUS "Enable D-Bus support" ON ${UNIX_SYS} OFF)
set_option(SDL_DISKAUDIO "Support the disk writer audio driver" ON)
set_option(SDL_DUMMYAUDIO "Support the dummy audio driver" ON)
@ -834,8 +832,9 @@ if(SDL_ASSEMBLY)
#ifndef __SSE2__
#error Assembler CPP flag not enabled
#endif
int main(int argc, char **argv) { return 0; }" HAVE_SSE2)
if(HAVE_SSE2)
int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_SSE2)
if(CPU_SUPPORTS_SSE2)
set(HAVE_SSE2 TRUE)
list(APPEND EXTRA_CFLAGS "-msse2")
endif()
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
@ -857,8 +856,9 @@ if(SDL_ASSEMBLY)
#ifndef __SSE3__
#error Assembler CPP flag not enabled
#endif
int main(int argc, char **argv) { return 0; }" HAVE_SSE3)
if(HAVE_SSE3)
int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_SSE3)
if(CPU_SUPPORTS_SSE3)
set(HAVE_SSE3 TRUE)
list(APPEND EXTRA_CFLAGS "-msse3")
endif()
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
@ -891,9 +891,9 @@ if(SDL_ASSEMBLY)
vector unsigned int vzero() {
return vec_splat_u32(0);
}
int main(int argc, char **argv) { return 0; }" HAVE_ALTIVEC)
int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_ALTIVEC)
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
if(HAVE_ALTIVEC OR HAVE_ALTIVEC_H_HDR)
if(CPU_SUPPORTS_ALTIVEC OR HAVE_ALTIVEC_H_HDR)
set(HAVE_ALTIVEC TRUE) # if only HAVE_ALTIVEC_H_HDR is set
list(APPEND EXTRA_CFLAGS "-maltivec")
set(SDL_ALTIVEC_BLITTERS 1)
@ -961,12 +961,22 @@ if(SDL_ASSEMBLY)
# TODO: SDL_cpuinfo.h needs to support the user's configuration wish
# for MSVC - right now it is always activated
if(NOT ARCH_64)
set(HAVE_MMX TRUE)
set(HAVE_3DNOW TRUE)
if(SDL_MMX)
set(HAVE_MMX TRUE)
endif()
if(SDL_3DNOW)
set(HAVE_3DNOW TRUE)
endif()
endif()
if(SDL_SSE)
set(HAVE_SSE TRUE)
endif()
if(SDL_SSE2)
set(HAVE_SSE2 TRUE)
endif()
if(SDL_SSE3)
set(HAVE_SSE3 TRUE)
endif()
set(HAVE_SSE TRUE)
set(HAVE_SSE2 TRUE)
set(HAVE_SSE3 TRUE)
check_include_file("immintrin.h" HAVE_IMMINTRIN_H)
endif()
endif()
@ -3204,8 +3214,7 @@ if(SDL_SHARED)
add_library(SDL3::SDL3 ALIAS SDL3)
set_target_properties(SDL3 PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
if(NOT SDL_LIBC)
check_cpu_architecture(x86 HAS_X86)
if(HAS_X86)
if(SDL_CPU_X86)
# FIXME: should be added for all architectures (missing symbols for ARM)
target_link_libraries(SDL3 PRIVATE "-nodefaultlib:MSVCRT")
endif()