cmake: use 'TargetConditionals.h' on Apple for SIMD tests

(cherry picked from commit e15e2808f2)
This commit is contained in:
Anonymous Maarten
2025-04-03 21:32:16 +02:00
committed by Ozkan Sezer
parent 3b4a198655
commit e8cc359b5e
2 changed files with 90 additions and 29 deletions

View File

@@ -160,3 +160,65 @@ function(SDL_AddCommonCompilerFlags TARGET)
endif()
endif()
endfunction()
function(check_x86_source_compiles BODY VAR)
if(ARGN)
message(FATAL_ERROR "Unknown arguments: ${ARGN}")
endif()
if(APPLE AND DEFINED CMAKE_OSX_ARCHITECTURES)
set(test_conditional 1)
else()
set(test_conditional 0)
endif()
check_c_source_compiles("
#if ${test_conditional}
# include \"TargetConditionals.h\"
# if TARGET_CPU_X86 || TARGET_CPU_X86_64
# define test_enabled 1
# else
# define test_enabled 0
# endif
#else
# define test_enabled 1
#endif
#if test_enabled
${BODY}
#else
int main(int argc, char *argv[]) {
(void)argc;
(void)argv;
return 0;
}
#endif" ${VAR})
endfunction()
function(check_arm_source_compiles BODY VAR)
if(ARGN)
message(FATAL_ERROR "Unknown arguments: ${ARGN}")
endif()
if(APPLE AND DEFINED CMAKE_OSX_ARCHITECTURES)
set(test_conditional 1)
else()
set(test_conditional 0)
endif()
check_c_source_compiles("
#if ${test_conditional}
# include \"TargetConditionals.h\"
# if TARGET_CPU_ARM || TARGET_CPU_ARM64
# define test_enabled 1
# else
# define test_enabled 0
# endif
#else
# define test_enabled 1
#endif
#if test_enabled
${BODY}
#else
int main(int argc, char *argv[]) {
(void)argc;
(void)argv;
return 0;
}
#endif" ${VAR})
endfunction()