@@ -160,6 +160,30 @@ set_target_properties(Foundation PROPERTIES
160
160
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR} /swift
161
161
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR} /swift)
162
162
163
+ if (NOT BUILD_SHARED_LIBS )
164
+ # ICU_I18N_LIBRARY is set by find_package(ICU) in the top level CMakeLists.txt
165
+ # It's an absolute path to the found library file
166
+ get_target_property (icui18n_path ICU::i18n IMPORTED_LOCATION )
167
+ get_filename_component (icu_i18n_basename "${icui18n_path} " NAME_WE )
168
+ get_filename_component (icu_i18n_dir "${icui18n_path} " DIRECTORY )
169
+ string (REPLACE "lib" "" icu_i18n_basename "${icu_i18n_basename} " )
170
+
171
+ target_compile_options (Foundation
172
+ PRIVATE
173
+ "SHELL:-Xfrontend -public-autolink-library -Xfrontend ${icu_i18n_basename}
174
+ -Xfrontend -public-autolink-library -Xfrontend BlocksRuntime" )
175
+ # ICU libraries are linked by absolute library path in this project,
176
+ # but -public-autolink-library forces to resolve library path by
177
+ # library search path given by -L, so add a directory of icui18n
178
+ # in the search path
179
+ target_link_directories (Foundation PUBLIC "${icu_i18n_dir} " )
180
+
181
+ # Merge private dependencies into single static objects archive
182
+ set_property (TARGET Foundation PROPERTY STATIC_LIBRARY_OPTIONS
183
+ $<TARGET_OBJECTS:CoreFoundation>
184
+ $<TARGET_OBJECTS:uuid>)
185
+ endif ()
186
+
163
187
if (CMAKE_SYSTEM_NAME STREQUAL Windows)
164
188
# NOTE: workaround for CMake which doesn't link in OBJECT libraries properly
165
189
add_dependencies (Foundation CoreFoundationResources)
0 commit comments