File tree Expand file tree Collapse file tree 4 files changed +43
-22
lines changed Expand file tree Collapse file tree 4 files changed +43
-22
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,32 @@ dispatch_common_warnings()
3333option (ENABLE_DISPATCH_INIT_CONSTRUCTOR "enable libdispatch_init as a constructor" ON )
3434set (USE_LIBDISPATCH_INIT_CONSTRUCTOR ${ENABLE_DISPATCH_INIT_CONSTRUCTOR} )
3535
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 ()
3762
3863option (BUILD_SHARED_LIBS "build shared libraries" ON )
3964
Original file line number Diff line number Diff line change @@ -14,11 +14,12 @@ install(FILES
1414 source .h
1515 time.h
1616 DESTINATION
17- ${CMAKE_INSTALL_FULL_INCLUDEDIR} /dispatch/ )
17+ ${CMAKE_INSTALL_FULL_INCLUDEDIR} /dispatch)
1818if (ENABLE_SWIFT)
19+ get_filename_component (MODULE_MAP module.modulemap REALPATH)
1920 install (FILES
20- module.modulemap
21+ ${MODULE_MAP}
2122 DESTINATION
22- ${CMAKE_INSTALL_FULL_INCLUEDIR } /dispatch/ )
23+ ${CMAKE_INSTALL_FULL_INCLUDEDIR } /dispatch)
2324endif ()
2425
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ if(HAVE_OBJC)
6969 data.m
7070 object.m)
7171endif ()
72- if (CMAKE_SWIFT_COMPILER )
72+ if (ENABLE_SWIFT )
7373 set (swift_optimization_flags)
7474 if (CMAKE_BUILD_TYPE MATCHES Release)
7575 set (swift_optimization_flags -O)
@@ -203,4 +203,11 @@ install(TARGETS
203203 dispatch
204204 DESTINATION
205205 "${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 ()
206213
Original file line number Diff line number Diff line change 22execute_process (COMMAND "${CMAKE_COMMAND} " -E create_symlink "${CMAKE_SOURCE_DIR} /private" "${CMAKE_CURRENT_BINARY_DIR} /dispatch" )
33execute_process (COMMAND "${CMAKE_COMMAND} " -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR} /leaks-wrapper.sh" "${CMAKE_CURRENT_BINARY_DIR} /leaks-wrapper" )
44
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-
185add_library (bsdtests
196 STATIC
207 bsdtests.c
@@ -74,10 +61,11 @@ function(add_unit_test name)
7461 ${CMAKE_CURRENT_BINARY_DIR}
7562 ${CMAKE_CURRENT_SOURCE_DIR}
7663 ${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)
8169 endif ()
8270 if (WITH_BLOCKS_RUNTIME)
8371 target_include_directories (${name}
You can’t perform that action at this time.
0 commit comments