File tree 4 files changed +43
-22
lines changed
4 files changed +43
-22
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,32 @@ dispatch_common_warnings()
33
33
option (ENABLE_DISPATCH_INIT_CONSTRUCTOR "enable libdispatch_init as a constructor" ON )
34
34
set (USE_LIBDISPATCH_INIT_CONSTRUCTOR ${ENABLE_DISPATCH_INIT_CONSTRUCTOR} )
35
35
36
- # TODO(compnerd) swift options
36
+ option (ENABLE_SWIFT "enable libdispatch swift overlay" OFF )
37
+ if (ENABLE_SWIFT)
38
+ if (NOT CMAKE_SWIFT_COMPILER)
39
+ message (FATAL_ERROR "CMAKE_SWIFT_COMPILER must be defined to enable swift" )
40
+ endif ()
41
+
42
+ get_filename_component (SWIFT_TOOLCHAIN ${CMAKE_SWIFT_COMPILER} DIRECTORY )
43
+ get_filename_component (SWIFT_TOOLCHAIN ${SWIFT_TOOLCHAIN} DIRECTORY )
44
+
45
+ string (TOLOWER ${CMAKE_SYSTEM_NAME} SWIFT_OS)
46
+ set (SWIFT_RUNTIME_LIBDIR ${SWIFT_TOOLCHAIN} /lib/swift/${SWIFT_OS} /${CMAKE_SYSTEM_PROCESSOR} )
47
+
48
+ add_library (swiftCore
49
+ SHARED IMPORTED GLOBAL )
50
+ set_target_properties (swiftCore
51
+ PROPERTIES
52
+ IMPORTED_LOCATION
53
+ ${SWIFT_RUNTIME_LIBDIR} /${CMAKE_SHARED_LIBRARY_PREFIX} swiftCore${CMAKE_SHARED_LIBRARY_SUFFIX} )
54
+
55
+ add_library (swiftSwiftOnoneSupport
56
+ SHARED IMPORTED GLOBAL )
57
+ set_target_properties (swiftSwiftOnoneSupport
58
+ PROPERTIES
59
+ IMPORTED_LOCATION
60
+ ${SWIFT_RUNTIME_LIBDIR} /${CMAKE_SHARED_LIBRARY_PREFIX} swiftSwiftOnoneSupport${CMAKE_SHARED_LIBRARY_SUFFIX} )
61
+ endif ()
37
62
38
63
option (BUILD_SHARED_LIBS "build shared libraries" ON )
39
64
Original file line number Diff line number Diff line change @@ -14,11 +14,12 @@ install(FILES
14
14
source .h
15
15
time.h
16
16
DESTINATION
17
- ${CMAKE_INSTALL_FULL_INCLUDEDIR} /dispatch/ )
17
+ ${CMAKE_INSTALL_FULL_INCLUDEDIR} /dispatch)
18
18
if (ENABLE_SWIFT)
19
+ get_filename_component (MODULE_MAP module.modulemap REALPATH)
19
20
install (FILES
20
- module.modulemap
21
+ ${MODULE_MAP}
21
22
DESTINATION
22
- ${CMAKE_INSTALL_FULL_INCLUEDIR } /dispatch/ )
23
+ ${CMAKE_INSTALL_FULL_INCLUDEDIR } /dispatch)
23
24
endif ()
24
25
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ if(HAVE_OBJC)
69
69
data.m
70
70
object.m)
71
71
endif ()
72
- if (CMAKE_SWIFT_COMPILER )
72
+ if (ENABLE_SWIFT )
73
73
set (swift_optimization_flags)
74
74
if (CMAKE_BUILD_TYPE MATCHES Release)
75
75
set (swift_optimization_flags -O)
@@ -203,4 +203,11 @@ install(TARGETS
203
203
dispatch
204
204
DESTINATION
205
205
"${CMAKE_INSTALL_FULL_LIBDIR} " )
206
+ if (ENABLE_SWIFT)
207
+ install (FILES
208
+ ${CMAKE_CURRENT_BINARY_DIR} /swift/Dispatch.swiftmodule
209
+ ${CMAKE_CURRENT_BINARY_DIR} /swift/Dispatch.swiftdoc
210
+ DESTINATION
211
+ "${CMAKE_INSTALL_FULL_LIBDIR} /swift/${SWIFT_OS} /${CMAKE_SYSTEM_PROCESSOR} " )
212
+ endif ()
206
213
Original file line number Diff line number Diff line change 2
2
execute_process (COMMAND "${CMAKE_COMMAND} " -E create_symlink "${CMAKE_SOURCE_DIR} /private" "${CMAKE_CURRENT_BINARY_DIR} /dispatch" )
3
3
execute_process (COMMAND "${CMAKE_COMMAND} " -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR} /leaks-wrapper.sh" "${CMAKE_CURRENT_BINARY_DIR} /leaks-wrapper" )
4
4
5
- # TODO(compnerd) hoist this out of the test directory
6
- if (SWIFT_RUNTIME_LIBDIR)
7
- add_library (swiftCore SHARED IMPORTED )
8
- set_target_properties (swiftCore
9
- PROPERTIES
10
- IMPORTED_LOCATION ${SWIFT_RUNTIME_LIBDIR} /${CMAKE_SHARED_LIBRARY_PREFIX} swiftCore${CMAKE_SHARED_LIBRARY_SUFFIX} )
11
-
12
- add_library (swiftSwiftOnoneSupport SHARED IMPORTED )
13
- set_target_properties (swiftSwiftOnoneSupport
14
- PROPERTIES
15
- IMPORTED_LOCATION ${SWIFT_RUNTIME_LIBDIR} /${CMAKE_SHARED_LIBRARY_PREFIX} swiftSwiftOnoneSupport${CMAKE_SHARED_LIBRARY_SUFFIX} )
16
- endif ()
17
-
18
5
add_library (bsdtests
19
6
STATIC
20
7
bsdtests.c
@@ -74,10 +61,11 @@ function(add_unit_test name)
74
61
${CMAKE_CURRENT_BINARY_DIR}
75
62
${CMAKE_CURRENT_SOURCE_DIR}
76
63
${CMAKE_SOURCE_DIR} )
77
- if (CMAKE_SWIFT_COMPILER)
78
- # For testing in swift.org CI system; make deadlines lenient by default
79
- # to reduce probability of test failures due to machine load.
80
- target_compile_options (${name} PRIVATE -DLENIENT_DEADLINES=1)
64
+ if (ENABLE_SWIFT)
65
+ # For testing in swift.org CI system; make deadlines lenient by default
66
+ # to reduce probability of test failures due to machine load.
67
+ target_compile_options (${name} PRIVATE -DLENIENT_DEADLINES=1)
68
+ target_link_libraries (${name} PRIVATE swiftCore swiftSwiftOnoneSupport)
81
69
endif ()
82
70
if (WITH_BLOCKS_RUNTIME)
83
71
target_include_directories (${name}
You can’t perform that action at this time.
0 commit comments