-
Notifications
You must be signed in to change notification settings - Fork 60
/
CheckCompilerArch.cmake
55 lines (51 loc) · 1.19 KB
/
CheckCompilerArch.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Findm the name of the architecture that we compile to. Currently
# this is used for highwayhash - but may be generally useful.
include(CheckCSourceCompiles)
check_c_source_compiles(
"
#if defined(__x86_64__) || defined(_M_X64)
int main() { return 0; }
#else
#error wrongarch
#endif
"
test_arch_x64)
check_c_source_compiles(
"
#if defined(__aarch64__) || defined(__arm64__)
int main() { return 0; }
#else
#error wrongarch
#endif
"
test_arch_aarch64)
check_c_source_compiles(
"
#if defined(__arm__) || defined(__ARM_NEON__) || defined(__ARM_NEON)
int main() { return 0; }
#else
#error wrongarch
#endif
"
test_arch_arm)
check_c_source_compiles(
"
#if defined(__powerpc64__) || defined(_M_PPC)
int main() { return 0; }
#else
#error wrongarch
#endif
"
test_arch_power)
if (test_arch_x64)
set(COMPILER_ARCHITECTURE "x86_64")
elseif (test_arch_aarch64)
set(COMPILER_ARCHITECTURE "aarch64")
elseif (test_arch_arm)
set(COMPILER_ARCHITECTURE "arm")
elseif (test_arch_power)
set(COMPILER_ARCHITECTURE "power")
else ()
set(COMPILER_ARCHITECTURE "portable")
endif ()
message(STATUS "Determined target architecture (for hashing): ${COMPILER_ARCHITECTURE}")