File: CheckCompilerArch.cmake

package info (click to toggle)
capstats 0.31-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 488 kB
  • sloc: cpp: 498; sh: 165; makefile: 38
file content (47 lines) | stat: -rw-r--r-- 1,165 bytes parent folder | download | duplicates (8)
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
# 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}")