@@ -50,6 +50,43 @@ function(add_sourcekit_symbol_exports target_name export_file)
50
50
endif ()
51
51
endfunction ()
52
52
53
+ # Add default compiler and linker flags to 'target'.
54
+ #
55
+ # FIXME: this is a HACK. All SourceKit CMake code using this function
56
+ # should be rewritten to use 'add_swift_library'.
57
+ function (add_sourcekit_default_compiler_flags target )
58
+ set (sdk "${SWIFT_HOST_VARIANT_SDK} " )
59
+ set (arch "${SWIFT_HOST_VARIANT_ARCH} " )
60
+ set (c_compile_flags)
61
+ set (link_flags )
62
+
63
+ # Add variant-specific flags.
64
+ set (build_type "${CMAKE_BUILD_TYPE} " )
65
+ set (enable_assertions "${LLVM_ENABLE_ASSERTIONS} " )
66
+ _add_variant_c_compile_flags(
67
+ "${sdk} "
68
+ "${arch} "
69
+ "${build_type} "
70
+ "${enable_assertions} "
71
+ c_compile_flags)
72
+ _add_variant_link_flags(
73
+ "${sdk} "
74
+ "${arch} "
75
+ "${build_type} "
76
+ "${enable_assertions} "
77
+ link_flags )
78
+
79
+ # Convert variables to space-separated strings.
80
+ _list_escape_for_shell("${c_compile_flags} " c_compile_flags)
81
+ _list_escape_for_shell("${link_flags} " link_flags )
82
+
83
+ # Set compilation and link flags.
84
+ set_property (TARGET "${target} " APPEND_STRING PROPERTY
85
+ COMPILE_FLAGS " ${c_compile_flags} " )
86
+ set_property (TARGET "${target} " APPEND_STRING PROPERTY
87
+ LINK_FLAGS " ${link_flags} " )
88
+ endfunction ()
89
+
53
90
# Add a new SourceKit library.
54
91
#
55
92
# Usage:
@@ -152,6 +189,7 @@ macro(add_sourcekit_library name)
152
189
ARCHIVE DESTINATION "lib${LLVM_LIBDIR_SUFFIX} "
153
190
RUNTIME DESTINATION "bin" )
154
191
set_target_properties (${name} PROPERTIES FOLDER "SourceKit libraries" )
192
+ add_sourcekit_default_compiler_flags("${name} " )
155
193
endmacro ()
156
194
157
195
# Add a new SourceKit executable.
@@ -198,6 +236,7 @@ macro(add_sourcekit_executable name)
198
236
LINK_FLAGS "-Wl,-exported_symbol,_main" )
199
237
endif ()
200
238
endif ()
239
+ add_sourcekit_default_compiler_flags("${name} " )
201
240
endmacro ()
202
241
203
242
# Add a new SourceKit framework.
@@ -313,6 +352,7 @@ macro(add_sourcekit_framework name)
313
352
COMMAND ${CMAKE_COMMAND} -E copy "${hdr} " "${framework_location} /Headers/${hdrname} " )
314
353
endforeach ()
315
354
endif ()
355
+ add_sourcekit_default_compiler_flags("${name} " )
316
356
endmacro (add_sourcekit_framework)
317
357
318
358
# Add a new SourceKit XPC service to a framework.
@@ -384,6 +424,7 @@ macro(add_sourcekit_xpc_service name framework_target)
384
424
LINK_FLAGS "-Wl,-exported_symbol,_main" )
385
425
endif ()
386
426
endif ()
427
+ add_sourcekit_default_compiler_flags("${name} " )
387
428
endmacro ()
388
429
389
430
if ("${CMAKE_SYSTEM_NAME} " STREQUAL "Darwin" )
0 commit comments