summaryrefslogtreecommitdiff
path: root/src/contrib/SDL-2.30.2/cmake/CheckCPUArchitecture.cmake
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2024-05-04 16:51:29 -0700
committer3gg <3gg@shellblade.net>2024-05-04 16:51:29 -0700
commit8222bfe56d4dabe8d92fc4b25ea1b0163b16f3e1 (patch)
tree763389e42276035ac134d94eb1dc32293b88d807 /src/contrib/SDL-2.30.2/cmake/CheckCPUArchitecture.cmake
Initial commit.
Diffstat (limited to 'src/contrib/SDL-2.30.2/cmake/CheckCPUArchitecture.cmake')
-rw-r--r--src/contrib/SDL-2.30.2/cmake/CheckCPUArchitecture.cmake42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/contrib/SDL-2.30.2/cmake/CheckCPUArchitecture.cmake b/src/contrib/SDL-2.30.2/cmake/CheckCPUArchitecture.cmake
new file mode 100644
index 0000000..7e3e459
--- /dev/null
+++ b/src/contrib/SDL-2.30.2/cmake/CheckCPUArchitecture.cmake
@@ -0,0 +1,42 @@
1include(CheckCSourceCompiles)
2include(CMakePushCheckState)
3
4function(_internal_check_cpu_architecture macro_check NAME VARIABLE)
5 cmake_push_check_state(RESET)
6 string(TOUPPER "${NAME}" UPPER_NAME)
7 set(CACHE_VARIABLE "CHECK_CPU_ARCHITECTURE_${UPPER_NAME}")
8 set(test_src "
9int main(int argc, char *argv[]) {
10#if ${macro_check}
11 return 0;
12#else
13 choke
14#endif
15}
16")
17 check_c_source_compiles("${test_src}" "${CACHE_VARIABLE}")
18 cmake_pop_check_state()
19 if(${CACHE_VARIABLE})
20 set(${VARIABLE} "TRUE" PARENT_SCOPE)
21 else()
22 set(${VARIABLE} "FALSE" PARENT_SCOPE)
23 endif()
24endfunction()
25
26function(check_cpu_architecture ARCH VARIABLE)
27 if(ARCH STREQUAL "x86")
28 _internal_check_cpu_architecture("defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) ||defined( __i386) || defined(_M_IX86)" x86 ${VARIABLE})
29 elseif(ARCH STREQUAL "x64")
30 _internal_check_cpu_architecture("defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)" x64 ${VARIABLE})
31 elseif(ARCH STREQUAL "arm32")
32 _internal_check_cpu_architecture("defined(__arm__) || defined(_M_ARM)" arm32 ${VARIABLE})
33 elseif(ARCH STREQUAL "arm64")
34 _internal_check_cpu_architecture("defined(__aarch64__) || defined(_M_ARM64)" arm64 ${VARIABLE})
35 elseif(ARCH STREQUAL "loongarch64")
36 _internal_check_cpu_architecture("defined(__loongarch64)" loongarch64 ${VARIABLE})
37 else()
38 message(WARNING "Unknown CPU architectures (${ARCH}).")
39 set(${VARIABLE} FALSE)
40 endif()
41 set("${VARIABLE}" "${${VARIABLE}}" PARENT_SCOPE)
42endfunction()