-
Notifications
You must be signed in to change notification settings - Fork 116
/
CMakeLists.txt
188 lines (168 loc) · 5.69 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
# Clear the LD_LIBRARY_PATH if GNUstep set it so that we don't accidentally use
# the installed version
set(INCREMENTAL " ")
if (MSVC)
set(CMAKE_EXE_LINKER_FLAGS "/DEBUG /INCREMENTAL:NO ${CMAKE_EXE_LINKER_FLAGS}")
set(INCREMENTAL "/INCREMENTAL:NO")
endif ()
# List of single-file tests.
set(TESTS
alias.m
alignTest.m
AllocatePair.m
AssociatedObject.m
AssociatedObject2.m
BlockImpTest.m
BlockTest_arc.m
ConstantString.m
Category.m
ExceptionTest.m
FastARC.m
FastARCPool.m
FastRefCount.m
Forward.m
ManyManySelectors.m
NestedExceptions.m
PropertyAttributeTest.m
ProtocolExtendedProperties.m
PropertyIntrospectionTest.m
ProtocolCreation.m
ResurrectInDealloc_arc.m
RuntimeTest.m
SuperMethodMissing.m
WeakBlock_arc.m
WeakRefLoad.m
WeakReferences_arc.m
WeakImportClass.m
ivar_arc.m
ivar_atomic.m
IVarOverlap.m
IVarSuperclassOverlap.m
objc_msgSend.m
msgInterpose.m
NilException.m
MethodArguments.m
zeroSizedIVar.m
exchange.m
hash_table_delete.c
hash_test.c
setSuperclass.m
UnexpectedException.m
)
set(ENABLE_ALL_OBJC_ARC_TESTS On)
if (WIN32)
# On Windows these tests work only with more recent versions of Clang
set(ENABLE_ALL_OBJC_ARC_TESTS Off)
if (CMAKE_C_COMPILER_ID STREQUAL Clang)
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0.0)
set(ENABLE_ALL_OBJC_ARC_TESTS On)
endif()
endif()
if (CMAKE_SYSTEM_PROCESSOR STREQUAL ARM64)
list(APPEND TESTS
objc_msgSend_WoA64.mm
)
endif()
else ()
# Don't run the tests that are specific to Itanium-style exceptions on
# Windows.
list(APPEND TESTS
BoxedForeignException.m
ForeignException.m
)
endif ()
if (ENABLE_ALL_OBJC_ARC_TESTS)
list(APPEND TESTS
ARCTest_arc.m
PropertyIntrospectionTest2_arc.m
)
endif()
# List of single-file tests that won't work with the legacy ABI and so
# shouldn't be run in legacy mode.
set(NEW_TESTS
category_properties.m
DirectMethods.m
FastPathAlloc.m
)
remove_definitions(-D__OBJC_RUNTIME_INTERNAL__=1)
add_library(test_runtime_legacy OBJECT Test.m)
set_target_properties(test_runtime_legacy PROPERTIES
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}"
COMPILE_FLAGS "-Xclang -fblocks -fobjc-runtime=gnustep-1.7"
LINKER_LANGUAGE C
)
add_library(test_runtime OBJECT Test.m)
set_target_properties(test_runtime PROPERTIES
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}"
COMPILE_FLAGS "-Xclang -fblocks -fobjc-runtime=gnustep-2.0"
LINKER_LANGUAGE C
)
# Function for adding a test. This takes the name of the test and the list of
# source files as arguments.
function(addtest_flags TEST_NAME FLAGS TEST_SOURCE)
if (${TEST_NAME} MATCHES ".*_arc")
# Only compile the main file with ARC
set_source_files_properties(${TEST_SOURCE}
COMPILE_FLAGS "-Xclang -fobjc-arc")
endif()
add_executable(${TEST_NAME} ${TEST_SOURCE})
add_test(${TEST_NAME} ${TEST_NAME})
set(ARC "")
set_target_properties(${TEST_NAME} PROPERTIES
INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}"
COMPILE_FLAGS "-Xclang -fblocks -Xclang -fobjc-exceptions ${FLAGS}"
LINK_FLAGS ${INCREMENTAL}
LINKER_LANGUAGE C
)
set_property(TEST ${TEST_NAME} PROPERTY SKIP_RETURN_CODE 77)
set_property(TEST ${TEST_NAME} PROPERTY
ENVIRONMENT "LD_LIBRARY_PATH=" "LLVM_PROFILE_FILE=${TEST_NAME}.profraw"
)
if(WIN32)
set_property(TEST ${TEST_NAME} PROPERTY ENVIRONMENT_MODIFICATION "PATH=path_list_append:${CMAKE_BINARY_DIR}")
endif()
target_link_libraries(${TEST_NAME} objc)
endfunction(addtest_flags)
function(addtest_variants TEST TEST_SOURCE LEGACY)
addtest_flags(${TEST} "-O0 -fobjc-runtime=gnustep-2.2 -UNDEBUG -DGS_RUNTIME_V2" "${TEST_SOURCE}")
target_sources(${TEST} PRIVATE $<TARGET_OBJECTS:test_runtime>)
addtest_flags("${TEST}_optimised" "-O3 -fobjc-runtime=gnustep-2.2 -UNDEBUG -DGS_RUNTIME_V2" "${TEST_SOURCE}")
target_sources("${TEST}_optimised" PRIVATE $<TARGET_OBJECTS:test_runtime>)
# -fobjc-arc is not supported on platforms using the legacy runtime
if (${LEGACY} AND ${OLDABI_COMPAT} AND NOT ${TEST} MATCHES ".*_arc")
addtest_flags("${TEST}_legacy" "-O0 -fobjc-runtime=gnustep-1.7 -UNDEBUG" "${TEST_SOURCE}")
target_sources("${TEST}_legacy" PRIVATE $<TARGET_OBJECTS:test_runtime_legacy>)
addtest_flags("${TEST}_legacy_optimised" "-O3 -fobjc-runtime=gnustep-1.7 -UNDEBUG" "${TEST_SOURCE}")
target_sources("${TEST}_legacy_optimised" PRIVATE $<TARGET_OBJECTS:test_runtime_legacy>)
endif()
endfunction(addtest_variants)
foreach(TEST_SOURCE ${TESTS})
get_filename_component(TEST ${TEST_SOURCE} NAME_WE)
addtest_variants(${TEST} ${TEST_SOURCE} true)
endforeach()
foreach(TEST_SOURCE ${NEW_TESTS})
get_filename_component(TEST ${TEST_SOURCE} NAME_WE)
addtest_variants(${TEST} ${TEST_SOURCE} false)
endforeach()
# Tests that are more than a single file.
addtest_variants("CXXExceptions" "CXXException.m;CXXException.cc" true)
addtest_variants("ForwardDeclareProtocolAccess" "ForwardDeclareProtocolAccess.m;ForwardDeclareProtocol.m" true)
if (ENABLE_OBJCXX)
addtest_variants(ObjCXXEHInterop "ObjCXXEHInterop.mm;ObjCXXEHInterop.m" true)
addtest_variants(ObjCXXEHInteropTwice "ObjCXXEHInteropTwice.mm" true)
if (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0.0)
addtest_variants(ObjCXXEHInterop_arc "ObjCXXEHInterop_arc.mm;ObjCXXEHInterop_arc.m" true)
endif()
else()
addtest_variants(ObjCXXEHInterop_arc "ObjCXXEHInterop_arc.mm;ObjCXXEHInterop_arc.m" true)
endif()
endif()
# Some tests use enough memory that they fail on CI intermittently if they
# happen to run in parallel with each other.
set_tests_properties(ManyManySelectors PROPERTIES PROCESSORS 3)
set_tests_properties(ManyManySelectors_optimised PROPERTIES PROCESSORS 3)
if (${LEGACY})
set_tests_properties(ManyManySelectors_legacy PROPERTIES PROCESSORS 3)
set_tests_properties(ManyManySelectors_legacy_optimised PROPERTIES PROCESSORS 3)
endif ()