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