-
Notifications
You must be signed in to change notification settings - Fork 253
/
Copy pathcmake_core.cmake
158 lines (134 loc) · 4.85 KB
/
cmake_core.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# SPDX-License-Identifier: Apache-2.0
# ----------------------------------------------------------------------------
# Copyright 2020-2024 Arm Limited
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy
# of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
set(ASTCENC_TEST test-unit-${ASTCENC_ISA_SIMD})
add_executable(${ASTCENC_TEST})
# Enable LTO under the conditions where the codec library will use LTO.
# The library link will fail if the settings don't match
if(${ASTCENC_CLI})
set_property(TARGET ${ASTCENC_TEST}
PROPERTY
INTERPROCEDURAL_OPTIMIZATION_RELEASE True)
endif()
target_sources(${ASTCENC_TEST}
PRIVATE
test_simd.cpp
test_softfloat.cpp
test_decode.cpp
../astcenc_mathlib_softfloat.cpp)
target_include_directories(${ASTCENC_TEST}
PRIVATE
${gtest_SOURCE_DIR}/include)
target_link_libraries(${ASTCENC_TEST}
PRIVATE
astcenc-${ASTCENC_ISA_SIMD}-static)
target_compile_options(${ASTCENC_TEST}
PRIVATE
# Use pthreads on Linux/macOS
$<$<PLATFORM_ID:Linux,Darwin>:-pthread>
# MSVC compiler defines
$<$<CXX_COMPILER_ID:MSVC>:/EHsc>
# G++ and Clang++ compiler defines
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wextra>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wpedantic>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Werror>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wshadow>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-c++98-compat-pedantic>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-c++98-c++11-compat-pedantic>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-float-equal>
# Ignore things that the googletest build triggers
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-unknown-warning-option>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-double-promotion>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-undef>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-reserved-identifier>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wno-global-constructors>)
# Set up configuration for SIMD ISA builds
if(${ASTCENC_ISA_SIMD} MATCHES "none")
target_compile_definitions(${ASTCENC_TEST}
PRIVATE
ASTCENC_NEON=0
ASTCENC_SVE=0
ASTCENC_SSE=0
ASTCENC_AVX=0
ASTCENC_POPCNT=0
ASTCENC_F16C=0)
elseif(${ASTCENC_ISA_SIMD} MATCHES "neon")
target_compile_definitions(${ASTCENC_TEST}
PRIVATE
ASTCENC_NEON=1
ASTCENC_SVE=0
ASTCENC_SSE=0
ASTCENC_AVX=0
ASTCENC_POPCNT=0
ASTCENC_F16C=0)
elseif(${ASTCENC_ISA_SIMD} MATCHES "sve_256")
target_compile_definitions(${ASTCENC_TEST}
PRIVATE
ASTCENC_NEON=1
ASTCENC_SVE=8
ASTCENC_SSE=0
ASTCENC_AVX=0
ASTCENC_POPCNT=0
ASTCENC_F16C=0)
# Enable SVE
target_compile_options(${ASTCENC_TEST}
PRIVATE
-march=armv8-a+sve -msve-vector-bits=256)
elseif(${ASTCENC_ISA_SIMD} MATCHES "sse2")
target_compile_definitions(${ASTCENC_TEST}
PRIVATE
ASTCENC_NEON=0
ASTCENC_SVE=0
ASTCENC_SSE=20
ASTCENC_AVX=0
ASTCENC_POPCNT=0
ASTCENC_F16C=0)
target_compile_options(${ASTCENC_TEST}
PRIVATE
$<$<CXX_COMPILER_ID:${GNU_LIKE}>:-msse2>)
elseif(${ASTCENC_ISA_SIMD} MATCHES "sse4.1")
target_compile_definitions(${ASTCENC_TEST}
PRIVATE
ASTCENC_NEON=0
ASTCENC_SVE=0
ASTCENC_SSE=41
ASTCENC_AVX=0
ASTCENC_POPCNT=1
ASTCENC_F16C=0)
target_compile_options(${ASTCENC_TEST}
PRIVATE
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-msse4.1 -mpopcnt>)
elseif(${ASTCENC_ISA_SIMD} MATCHES "avx2")
target_compile_definitions(${ASTCENC_TEST}
PRIVATE
ASTCENC_NEON=0
ASTCENC_SVE=0
ASTCENC_SSE=41
ASTCENC_AVX=2
ASTCENC_POPCNT=1
ASTCENC_F16C=1)
target_compile_options(${ASTCENC_TEST}
PRIVATE
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-mavx2 -mpopcnt -mf16c>
$<$<CXX_COMPILER_ID:MSVC>:/arch:AVX2>)
endif()
target_link_libraries(${ASTCENC_TEST}
PRIVATE
gtest_main)
add_test(NAME ${ASTCENC_TEST}
COMMAND ${ASTCENC_TEST})
install(TARGETS ${ASTCENC_TEST})