1# Copyright 2020 The SwiftShader Authors. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15set(LLVM_SUBZERO_SRC_FILES
16    "build/Android/include/llvm/Config/abi-breaking.h"
17    "build/Android/include/llvm/Config/config.h"
18    "build/Android/include/llvm/Config/llvm-config.h"
19    "build/Android/include/llvm/Support/DataTypes.h"
20    "build/Fuchsia/include/llvm/Config/abi-breaking.h"
21    "build/Fuchsia/include/llvm/Config/config.h"
22    "build/Fuchsia/include/llvm/Config/llvm-config.h"
23    "build/Fuchsia/include/llvm/Support/DataTypes.h"
24    "build/Linux/include/llvm/Config/abi-breaking.h"
25    "build/Linux/include/llvm/Config/config.h"
26    "build/Linux/include/llvm/Config/llvm-config.h"
27    "build/Linux/include/llvm/Support/DataTypes.h"
28    "build/MacOS/include/llvm/Config/abi-breaking.h"
29    "build/MacOS/include/llvm/Config/config.h"
30    "build/MacOS/include/llvm/Config/llvm-config.h"
31    "build/MacOS/include/llvm/Support/DataTypes.h"
32    "build/Windows/include/llvm/Config/abi-breaking.h"
33    "build/Windows/include/llvm/Config/config.h"
34    "build/Windows/include/llvm/Config/llvm-config.h"
35    "build/Windows/include/llvm/Support/DataTypes.h"
36    "include/llvm-c/ErrorHandling.h"
37    "include/llvm-c/Support.h"
38    "include/llvm-c/Types.h"
39    "include/llvm/ADT/APFloat.h"
40    "include/llvm/ADT/APInt.h"
41    "include/llvm/ADT/ArrayRef.h"
42    "include/llvm/ADT/BitVector.h"
43    "include/llvm/ADT/DenseMap.h"
44    "include/llvm/ADT/DenseMapInfo.h"
45    "include/llvm/ADT/edit_distance.h"
46    "include/llvm/ADT/EpochTracker.h"
47    "include/llvm/ADT/FoldingSet.h"
48    "include/llvm/ADT/Hashing.h"
49    "include/llvm/ADT/ilist_base.h"
50    "include/llvm/ADT/ilist_iterator.h"
51    "include/llvm/ADT/ilist_node_base.h"
52    "include/llvm/ADT/ilist_node_options.h"
53    "include/llvm/ADT/ilist_node.h"
54    "include/llvm/ADT/ilist.h"
55    "include/llvm/ADT/IntrusiveRefCntPtr.h"
56    "include/llvm/ADT/iterator_range.h"
57    "include/llvm/ADT/iterator.h"
58    "include/llvm/ADT/None.h"
59    "include/llvm/ADT/Optional.h"
60    "include/llvm/ADT/PointerIntPair.h"
61    "include/llvm/ADT/PointerUnion.h"
62    "include/llvm/ADT/simple_ilist.h"
63    "include/llvm/ADT/SmallPtrSet.h"
64    "include/llvm/ADT/SmallSet.h"
65    "include/llvm/ADT/SmallString.h"
66    "include/llvm/ADT/SmallVector.h"
67    "include/llvm/ADT/Statistic.h"
68    "include/llvm/ADT/STLExtras.h"
69    "include/llvm/ADT/StringExtras.h"
70    "include/llvm/ADT/StringMap.h"
71    "include/llvm/ADT/StringRef.h"
72    "include/llvm/ADT/StringSwitch.h"
73    "include/llvm/ADT/Twine.h"
74    "include/llvm/Demangle/Demangle.h"
75    "include/llvm/IR/Argument.h"
76    "include/llvm/IR/Attributes.h"
77    "include/llvm/IR/BasicBlock.h"
78    "include/llvm/IR/CallingConv.h"
79    "include/llvm/IR/Constant.h"
80    "include/llvm/IR/DebugLoc.h"
81    "include/llvm/IR/DerivedTypes.h"
82    "include/llvm/IR/Function.h"
83    "include/llvm/IR/GlobalObject.h"
84    "include/llvm/IR/GlobalValue.h"
85    "include/llvm/IR/Instruction.h"
86    "include/llvm/IR/Intrinsics.h"
87    "include/llvm/IR/LLVMContext.h"
88    "include/llvm/IR/Metadata.h"
89    "include/llvm/IR/OperandTraits.h"
90    "include/llvm/IR/SymbolTableListTraits.h"
91    "include/llvm/IR/TrackingMDRef.h"
92    "include/llvm/IR/Type.h"
93    "include/llvm/IR/Use.h"
94    "include/llvm/IR/User.h"
95    "include/llvm/IR/Value.h"
96    "include/llvm/IRReader/IRReader.h"
97    "include/llvm/Support/AlignOf.h"
98    "include/llvm/Support/Allocator.h"
99    "include/llvm/Support/ARMBuildAttributes.h"
100    "include/llvm/Support/Atomic.h"
101    "include/llvm/Support/Casting.h"
102    "include/llvm/Support/CBindingWrapping.h"
103    "include/llvm/Support/Chrono.h"
104    "include/llvm/Support/circular_raw_ostream.h"
105    "include/llvm/Support/COFF.h"
106    "include/llvm/Support/CommandLine.h"
107    "include/llvm/Support/Compiler.h"
108    "include/llvm/Support/ConvertUTF.h"
109    "include/llvm/Support/DataStream.h"
110    "include/llvm/Support/Debug.h"
111    "include/llvm/Support/ELF.h"
112    "include/llvm/Support/Endian.h"
113    "include/llvm/Support/Errc.h"
114    "include/llvm/Support/Errno.h"
115    "include/llvm/Support/Error.h"
116    "include/llvm/Support/ErrorHandling.h"
117    "include/llvm/Support/ErrorOr.h"
118    "include/llvm/Support/FileSystem.h"
119    "include/llvm/Support/FileUtilities.h"
120    "include/llvm/Support/Format.h"
121    "include/llvm/Support/FormatCommon.h"
122    "include/llvm/Support/FormatProviders.h"
123    "include/llvm/Support/FormatVariadic.h"
124    "include/llvm/Support/FormatVariadicDetails.h"
125    "include/llvm/Support/MachO.h"
126    "include/llvm/Support/ManagedStatic.h"
127    "include/llvm/Support/MathExtras.h"
128    "include/llvm/Support/MD5.h"
129    "include/llvm/Support/Memory.h"
130    "include/llvm/Support/MemoryBuffer.h"
131    "include/llvm/Support/MemoryObject.h"
132    "include/llvm/Support/Mutex.h"
133    "include/llvm/Support/MutexGuard.h"
134    "include/llvm/Support/NativeFormatting.h"
135    "include/llvm/Support/Options.h"
136    "include/llvm/Support/Path.h"
137    "include/llvm/Support/PointerLikeTypeTraits.h"
138    "include/llvm/Support/Process.h"
139    "include/llvm/Support/Program.h"
140    "include/llvm/Support/raw_os_ostream.h"
141    "include/llvm/Support/raw_ostream.h"
142    "include/llvm/Support/Regex.h"
143    "include/llvm/Support/Signals.h"
144    "include/llvm/Support/SMLoc.h"
145    "include/llvm/Support/SourceMgr.h"
146    "include/llvm/Support/StreamingMemoryObject.h"
147    "include/llvm/Support/StringSaver.h"
148    "include/llvm/Support/SwapByteOrder.h"
149    "include/llvm/Support/thread.h"
150    "include/llvm/Support/Threading.h"
151    "include/llvm/Support/Timer.h"
152    "include/llvm/Support/TimeValue.h"
153    "include/llvm/Support/type_traits.h"
154    "include/llvm/Support/UniqueLock.h"
155    "include/llvm/Support/Valgrind.h"
156    "include/llvm/Support/WindowsError.h"
157    "include/llvm/Support/YAMLParser.h"
158    "include/llvm/Support/YAMLTraits.h"
159    "lib/Demangle/ItaniumDemangle.cpp"
160    "lib/Support/APInt.cpp"
161    "lib/Support/Atomic.cpp"
162    "lib/Support/circular_raw_ostream.cpp"
163    "lib/Support/CommandLine.cpp"
164    "lib/Support/ConvertUTF.cpp"
165    "lib/Support/ConvertUTFWrapper.cpp"
166    "lib/Support/Debug.cpp"
167    "lib/Support/Errno.cpp"
168    "lib/Support/ErrorHandling.cpp"
169    "lib/Support/FoldingSet.cpp"
170    "lib/Support/Hashing.cpp"
171    "lib/Support/ManagedStatic.cpp"
172    "lib/Support/MemoryBuffer.cpp"
173    "lib/Support/Mutex.cpp"
174    "lib/Support/NativeFormatting.cpp"
175    "lib/Support/Path.cpp"
176    "lib/Support/Process.cpp"
177    "lib/Support/Program.cpp"
178    "lib/Support/raw_os_ostream.cpp"
179    "lib/Support/raw_ostream.cpp"
180    "lib/Support/regcclass.h"
181    "lib/Support/regcname.h"
182    "lib/Support/regcomp.c"
183    "lib/Support/regerror.c"
184    "lib/Support/regex_impl.h"
185    "lib/Support/Regex.cpp"
186    "lib/Support/regex2.h"
187    "lib/Support/regexec.c"
188    "lib/Support/regfree.c"
189    "lib/Support/regstrlcpy.c"
190    "lib/Support/regutils.h"
191    "lib/Support/Signals.cpp"
192    "lib/Support/SmallPtrSet.cpp"
193    "lib/Support/SmallVector.cpp"
194    "lib/Support/StringExtras.cpp"
195    "lib/Support/StringMap.cpp"
196    "lib/Support/StringRef.cpp"
197    "lib/Support/StringSaver.cpp"
198    "lib/Support/Threading.cpp"
199    "lib/Support/Timer.cpp"
200    "lib/Support/Twine.cpp"
201    "lib/Support/Unix/Unix.h"
202    "lib/Support/Windows/WindowsSupport.h"
203)
204
205
206if(WIN32)
207    set(LLVM_SUBZERO_PLATFORM_INCLUDE_DIR "build/Windows/include")
208elseif(LINUX)
209    set(LLVM_SUBZERO_PLATFORM_INCLUDE_DIR "build/Linux/include")
210elseif(APPLE)
211    set(LLVM_SUBZERO_PLATFORM_INCLUDE_DIR "build/MacOS/include")
212endif()
213
214if(WIN32)
215    list(APPEND LLVM_SUBZERO_COMPILE_OPTIONS
216        "/wd4141"  # 'inline': used more than once
217        "/wd4146" # unary minus operator applied to unsigned type, result still unsigned
218        "/wd4244"  # '=': conversion from '__int64' to 'llvm_regoff_t', possible loss of data
219        "/wd4267"  # '=': conversion from 'size_t' to 'sopno', possible loss of data
220        "/wd4291"  # 'void *operator new(size_t,const `anonymous-namespace'::NamedBufferAlloc &)': no matching operator delete found; memory will not be freed if initialization throws an exception
221        "/wd4334" # ''operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
222        "/wd4996" # The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: new_name.
223    )
224endif()
225
226add_library(llvm-subzero STATIC EXCLUDE_FROM_ALL
227  ${LLVM_SUBZERO_SRC_FILES}
228)
229
230set_target_properties(llvm-subzero PROPERTIES
231    POSITION_INDEPENDENT_CODE 1
232)
233
234target_include_directories(llvm-subzero
235    PUBLIC
236        "include"
237        ${LLVM_SUBZERO_PLATFORM_INCLUDE_DIR}
238)
239
240target_compile_options(llvm-subzero
241    PUBLIC
242        ${LLVM_SUBZERO_COMPILE_OPTIONS}
243)
244