Fossil SCM

fossil-scm / compat / zlib / contrib / crc32vx / CMakeLists.txt
Blame History Raw 68 lines
1
# check if we compile for IBM s390x
2
#
3
CHECK_C_SOURCE_COMPILES("
4
#ifndef __s390x__
5
#error
6
#endif
7
int main() {return 0;}
8
" HAS_S390X_SUPPORT)
9
10
#
11
# Check for IBM S390X - VX extensions
12
#
13
if(ZLIB_WITH_CRC32VX AND HAS_S390X_SUPPORT)
14
# preset the compiler specific flags
15
if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
16
set(VGFMAFLAG "-fzvector")
17
else()
18
set(VGFMAFLAG "-mzarch")
19
endif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
20
21
set(S390X_VX_TEST
22
"#ifndef __s390x__ \n\
23
#error \n\
24
#endif \n\
25
#include <vecintrin.h> \n\
26
int main(void) { \
27
unsigned long long a __attribute__((vector_size(16))) = { 0 }; \
28
unsigned long long b __attribute__((vector_size(16))) = { 0 }; \
29
unsigned char c __attribute__((vector_size(16))) = { 0 }; \
30
c = vec_gfmsum_accum_128(a, b, c); \
31
return c[0]; \
32
}")
33
34
# cflags already contains a valid march
35
set(CMAKE_REQUIRED_FLAGS "${VGFMAFLAG}")
36
check_c_source_compiles("${S390X_VX_TEST}" HAS_S390X_VX_SUPPORT)
37
unset(CMAKE_REQUIRED_FLAGS)
38
39
# or set march for our compile units
40
if(NOT HAS_S390X_VX_SUPPORT)
41
set(CMAKE_REQUIRED_FLAGS "${VGFMAFLAG} -march=z13")
42
check_c_source_compiles("${S390X_VX_TEST}" HAS_Z13_S390X_VX_SUPPORT)
43
unset(CMAKE_REQUIRED_FLAGS )
44
list(APPEND VGFMAFLAG "-march=z13")
45
endif(NOT HAS_S390X_VX_SUPPORT)
46
47
# prepare compiling for s390x
48
if(HAS_S390X_VX_SUPPORT OR HAS_Z13_S390X_VX_SUPPORT)
49
if(ZLIB_BUILD_SHARED)
50
target_sources(zlib
51
PRIVATE
52
crc32_vx.c
53
crc32_vx_hooks.h)
54
target_compile_definitions(zlib PUBLIC -DHAVE_S390X_VX=1)
55
endif(ZLIB_BUILD_SHARED)
56
if(ZLIB_BUILD_STATIC)
57
target_sources(zlibstatic
58
PRIVATE
59
crc32_vx.c
60
crc32_vx_hooks.h)
61
target_compile_definitions(zlibstatic PUBLIC -DHAVE_S390X_VX=1)
62
endif(ZLIB_BUILD_STATIC)
63
set_source_files_properties(
64
crc32_vx.c
65
PROPERTIES COMPILE_OPTIONS "${VGFMAFLAG}")
66
endif(HAS_S390X_VX_SUPPORT OR HAS_Z13_S390X_VX_SUPPORT)
67
endif(ZLIB_WITH_CRC32VX AND HAS_S390X_SUPPORT)
68

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button