]> git.saurik.com Git - apple/libdispatch.git/blob - src/CMakeLists.txt
libdispatch-913.1.6.tar.gz
[apple/libdispatch.git] / src / CMakeLists.txt
1
2 include(SwiftSupport)
3 include(DTrace)
4
5 add_library(dispatch
6 allocator.c
7 apply.c
8 benchmark.c
9 data.c
10 init.c
11 introspection.c
12 io.c
13 mach.c
14 object.c
15 once.c
16 queue.c
17 semaphore.c
18 source.c
19 time.c
20 transform.c
21 voucher.c
22 protocol.defs
23 provider.d
24 allocator_internal.h
25 data_internal.h
26 inline_internal.h
27 internal.h
28 introspection_internal.h
29 io_internal.h
30 mach_internal.h
31 object_internal.h
32 queue_internal.h
33 semaphore_internal.h
34 shims.h
35 source_internal.h
36 trace.h
37 voucher_internal.h
38 event/event.c
39 event/event_config.h
40 event/event_epoll.c
41 event/event_internal.h
42 event/event_kevent.c
43 firehose/firehose_internal.h
44 shims/android_stubs.h
45 shims/atomic.h
46 shims/atomic_sfb.h
47 shims/getprogname.h
48 shims/hw_config.h
49 shims/linux_stubs.c
50 shims/linux_stubs.h
51 shims/lock.c
52 shims/lock.h
53 shims/perfmon.h
54 shims/time.h
55 shims/tsd.h
56 shims/yield.h)
57 if(DISPATCH_USE_INTERNAL_WORKQUEUE)
58 target_sources(dispatch
59 PRIVATE
60 event/workqueue.c
61 event/workqueue_internal.h)
62 endif()
63 target_sources(dispatch
64 PRIVATE
65 block.cpp)
66 if(HAVE_OBJC)
67 target_sources(dispatch
68 PRIVATE
69 data.m
70 object.m)
71 endif()
72 if(CMAKE_SWIFT_COMPILER)
73 set(swift_optimization_flags)
74 if(CMAKE_BUILD_TYPE MATCHES Release)
75 set(swift_optimization_flags -O)
76 endif()
77 add_swift_library(swiftDispatch
78 MODULE_NAME
79 Dispatch
80 MODULE_LINK_NAME
81 dispatch
82 MODULE_PATH
83 ${CMAKE_CURRENT_BINARY_DIR}/swift/Dispatch.swiftmodule
84 OUTPUT
85 ${CMAKE_CURRENT_BINARY_DIR}/swiftDispatch.o
86 SOURCES
87 swift/Block.swift
88 swift/Data.swift
89 swift/Dispatch.swift
90 swift/IO.swift
91 swift/Private.swift
92 swift/Queue.swift
93 swift/Source.swift
94 swift/Time.swift
95 swift/Wrapper.swift
96 CFLAGS
97 -fblocks
98 -fmodule-map-file=${CMAKE_SOURCE_DIR}/dispatch/module.modulemap
99 SWIFT_FLAGS
100 -I ${CMAKE_SOURCE_DIR}
101 ${swift_optimization_flags})
102 target_sources(dispatch
103 PRIVATE
104 swift/DispatchStubs.cc
105 ${CMAKE_CURRENT_BINARY_DIR}/swiftDispatch.o)
106 endif()
107 if(dtrace_EXECUTABLE)
108 dtrace_usdt_probe(${CMAKE_CURRENT_SOURCE_DIR}/provider.d
109 OUTPUT_SOURCES
110 dispatch_dtrace_provider_headers)
111 target_sources(dispatch
112 PRIVATE
113 ${dispatch_dtrace_provider_headers})
114 endif()
115 target_include_directories(dispatch
116 PRIVATE
117 ${CMAKE_BINARY_DIR}
118 ${CMAKE_SOURCE_DIR}
119 ${CMAKE_CURRENT_SOURCE_DIR}
120 ${CMAKE_CURRENT_BINARY_DIR}
121 ${CMAKE_SOURCE_DIR}/private)
122 if(WITH_BLOCKS_RUNTIME)
123 target_include_directories(dispatch
124 SYSTEM BEFORE PRIVATE
125 "${WITH_BLOCKS_RUNTIME}")
126 endif()
127 if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
128 target_compile_options(dispatch PRIVATE /EHsc-)
129 else()
130 target_compile_options(dispatch PRIVATE -fno-exceptions)
131 endif()
132 if(DISPATCH_ENABLE_ASSERTS)
133 target_compile_definitions(dispatch
134 PRIVATE
135 -DDISPATCH_DEBUG=1)
136 endif()
137 if(CMAKE_SYSTEM_NAME STREQUAL Windows)
138 target_compile_definitions(dispatch
139 PRIVATE
140 -D_CRT_SECURE_NO_WARNINGS)
141 endif()
142 if(BSD_OVERLAY_FOUND)
143 target_compile_options(dispatch
144 PRIVATE
145 ${BSD_OVERLAY_CFLAGS})
146 endif()
147 if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
148 target_compile_options(dispatch
149 PRIVATE
150 /W3)
151 else()
152 target_compile_options(dispatch
153 PRIVATE
154 -Wall)
155 endif()
156 # FIXME(compnerd) add check for -fblocks?
157 if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
158 target_compile_options(dispatch
159 PRIVATE
160 -Xclang -fblocks)
161 else()
162 # FIXME(compnerd) add check for -momit-leaf-frame-pointer?
163 target_compile_options(dispatch
164 PRIVATE
165 -fblocks
166 -momit-leaf-frame-pointer)
167 endif()
168 if(BSD_OVERLAY_FOUND)
169 target_link_libraries(dispatch PRIVATE ${BSD_OVERLAY_LDFLAGS})
170 endif()
171 target_link_libraries(dispatch PRIVATE Threads::Threads)
172 if(WITH_BLOCKS_RUNTIME)
173 target_link_libraries(dispatch PRIVATE BlocksRuntime)
174 endif()
175 if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
176 set_property(TARGET dispatch
177 APPEND_STRING
178 PROPERTY LINK_FLAGS
179 "-Xlinker -compatibility_version -Xlinker 1"
180 "-Xlinker -current_version -Xlinker ${VERSION}"
181 "-Xlinker -dead_strip"
182 "-Xlinker -alias_list -Xlinker ${CMAKE_SOURCE_DIR}/xcodeconfig/libdispatch.aliases")
183 endif()
184 if(USE_GOLD_LINKER)
185 set_property(TARGET dispatch
186 APPEND_STRING
187 PROPERTY LINK_FLAGS
188 -fuse-ld=gold)
189 endif()
190
191 # Temporary staging; the various swift projects that depend on libdispatch
192 # all expect libdispatch.so to be in src/.libs/libdispatch.so
193 # So for now, make a copy so we don't have to do a coordinated commit across
194 # all the swift projects to change this assumption.
195 add_custom_command(TARGET dispatch POST_BUILD
196 COMMAND cmake -E make_directory .libs
197 COMMAND cmake -E copy $<TARGET_FILE:dispatch> .libs
198 COMMENT "Copying libdispatch to .libs")
199
200 install(TARGETS
201 dispatch
202 DESTINATION
203 "${CMAKE_INSTALL_FULL_LIBDIR}")
204