forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
229 lines (197 loc) · 6.71 KB
/
CMakeLists.txt
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# -*- mode: cmake -*-
################################################################################
# WARNING: This file is automatically generated from templates and should not
# be directly modified. Instead, make changes to
# scripts/generate_harness/CMakeLists.txt_template and run
# scripts/generate_harness/generate_harness.py to regenerate this file.
################################################################################
cmake_minimum_required(VERSION 2.8.12)
# Add path for custom CMake modules.
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
include(AddSwiftBenchmarkSuite)
set(SWIFT_BENCH_MODULES
single-source/unit-tests/ObjectiveCBridging
single-source/unit-tests/ObjectiveCBridgingStubs
single-source/unit-tests/ObjectiveCNoBridgingStubs
single-source/unit-tests/StackPromo
single-source/Ackermann
single-source/AngryPhonebook
single-source/Array2D
single-source/ArrayAppend
single-source/ArrayInClass
single-source/ArrayLiteral
single-source/ArrayOfGenericPOD
single-source/ArrayOfGenericRef
single-source/ArrayOfPOD
single-source/ArrayOfRef
single-source/ArraySubscript
single-source/BitCount
single-source/ByteSwap
single-source/Calculator
single-source/CaptureProp
single-source/Chars
single-source/ClassArrayGetter
single-source/DeadArray
single-source/DictionaryBridge
single-source/DictionaryLiteral
single-source/DictionaryRemove
single-source/DictionarySwap
single-source/DictTest
single-source/DictTest2
single-source/DictTest3
single-source/ErrorHandling
single-source/Fibonacci
single-source/GlobalClass
single-source/Hanoi
single-source/Hash
single-source/Histogram
single-source/Integrate
single-source/Join
single-source/LinkedList
single-source/MapReduce
single-source/Memset
single-source/MonteCarloE
single-source/MonteCarloPi
single-source/NopDeinit
single-source/NSDictionaryCastToSwift
single-source/NSError
single-source/NSStringConversion
single-source/ObjectAllocation
single-source/OpenClose
single-source/Phonebook
single-source/PolymorphicCalls
single-source/PopFront
single-source/PopFrontGeneric
single-source/Prims
single-source/ProtocolDispatch
single-source/ProtocolDispatch2
single-source/RangeAssignment
single-source/RC4
single-source/RecursiveOwnedParameter
single-source/RGBHistogram
single-source/SetTests
single-source/SevenBoom
single-source/Sim2DArray
single-source/SortLettersInPlace
single-source/SortStrings
single-source/StaticArray
single-source/StrComplexWalk
single-source/StringBuilder
single-source/StringInterpolation
single-source/StringTests
single-source/StringWalk
single-source/StrToInt
single-source/SuperChars
single-source/TwoSum
single-source/TypeFlood
single-source/UTF8Decode
single-source/Walsh
single-source/XorLoop
)
set(SWIFT_MULTISOURCE_BENCHES
)
set(BENCH_DRIVER_LIBRARY_MODULES
utils/DriverUtils
utils/TestsUtils
)
set(BENCH_DRIVER_LIBRARY_FLAGS)
if (SWIFT_RUNTIME_ENABLE_LEAK_CHECKER)
set(BENCH_DRIVER_LIBRARY_FLAGS -DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER)
endif()
set(BENCH_LIBRARY_MODULES
)
add_definitions(-DSWIFT_EXEC -DSWIFT_LIBRARY_PATH -DONLY_PLATFORMS
-DSWIFT_OPTIMIZATION_LEVELS -DSWIFT_BENCHMARK_EMIT_SIB)
if(NOT ONLY_PLATFORMS)
set(ONLY_PLATFORMS "macosx" "iphoneos" "appletvos" "watchos")
endif()
if(NOT SWIFT_EXEC)
runcmd(COMMAND "xcrun" "-f" "swiftc"
VARIABLE SWIFT_EXEC
ERROR "Unable to find Swift driver")
endif()
if(NOT SWIFT_LIBRARY_PATH)
get_filename_component(tmp_dir "${SWIFT_EXEC}" DIRECTORY)
get_filename_component(tmp_dir "${tmp_dir}" DIRECTORY)
set(SWIFT_LIBRARY_PATH "${tmp_dir}/lib/swift")
endif()
runcmd(COMMAND "xcrun" "-toolchain" "${SWIFT_DARWIN_XCRUN_TOOLCHAIN}" "-f" "clang"
VARIABLE CLANG_EXEC
ERROR "Unable to find Clang driver")
# You have to delete CMakeCache.txt in the swift build to force a
# reconfiguration.
set(SWIFT_EXTRA_BENCH_CONFIGS CACHE STRING
"A semicolon separated list of benchmark configurations. \
Available configurations: <Optlevel>_SINGLEFILE, <Optlevel>_MULTITHREADED")
# Syntax for an optset: <optimization-level>_<configuration>
# where "_<configuration>" is optional.
if(NOT SWIFT_OPTIMIZATION_LEVELS)
set(SWIFT_OPTIMIZATION_LEVELS "Onone" "O" "Ounchecked"
${SWIFT_EXTRA_BENCH_CONFIGS})
endif()
# Options for the default (= empty) configuration
set(BENCHOPTS "-whole-module-optimization")
# Options for other configurations
set(BENCHOPTS_MULTITHREADED
"-whole-module-optimization" "-num-threads" "4")
set(BENCHOPTS_SINGLEFILE "")
set(macosx_arch "x86_64")
set(iphoneos_arch "arm64" "armv7")
set(appletvos_arch "arm64")
set(watchos_arch "armv7k")
set(macosx_ver "10.9")
set(iphoneos_ver "8.0")
set(appletvos_ver "9.1")
set(watchos_ver "2.0")
set(macosx_triple_platform "macosx")
set(iphoneos_triple_platform "ios")
set(appletvos_triple_platform "tvos")
set(watchos_triple_platform "watchos")
set(sdks)
set(platforms)
foreach(platform ${ONLY_PLATFORMS})
execute_process(
COMMAND "xcrun" "--sdk" "${platform}" "--show-sdk-path"
OUTPUT_VARIABLE ${platform}_sdk
RESULT_VARIABLE result
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if("${result}" MATCHES "0")
list(APPEND sdks "${${platform}_sdk}")
list(APPEND platforms ${platform})
endif()
endforeach()
message("--")
message("-- Swift Benchmark Suite:")
message("-- SWIFT_EXEC = ${SWIFT_EXEC}")
message("-- SWIFT_LIBRARY_PATH = ${SWIFT_LIBRARY_PATH}")
message("-- CLANG_EXEC = ${CLANG_EXEC}")
message("-- SWIFT_OPTIMIZATION_LEVELS = ${SWIFT_OPTIMIZATION_LEVELS}")
message("-- ONLY_PLATFORMS = ${ONLY_PLATFORMS}")
message("-- found platforms: ${platforms}")
message("-- found sdks:")
foreach(sdk ${sdks})
message("-- ${sdk}")
endforeach()
set(executable_targets)
if(SWIFT_SDKS)
set(IS_SWIFT_BUILD true)
endif()
set(srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
if(IS_SWIFT_BUILD)
get_filename_component(swift-bin-dir "${SWIFT_EXEC}" DIRECTORY)
else()
set(swift-bin-dir "${CMAKE_BINARY_DIR}/bin")
endif()
set(benchmark-bin-dir "${CMAKE_CURRENT_BINARY_DIR}/bin")
set(benchmark-lib-dir "${CMAKE_CURRENT_BINARY_DIR}/lib")
set(benchmark-lib-swift-dir "${CMAKE_CURRENT_BINARY_DIR}/lib/swift")
file(MAKE_DIRECTORY "${swift-bin-dir}")
file(MAKE_DIRECTORY "${benchmark-bin-dir}")
file(MAKE_DIRECTORY "${benchmark-lib-dir}")
file(MAKE_DIRECTORY "${benchmark-lib-swift-dir}")
# Compile the perf test suite for each platform
foreach(platform ${platforms})
swift_benchmark_compile(PLATFORM ${platform})
endforeach()
add_subdirectory(scripts)