Skip to content

Commit f1a5aa7

Browse files
Determine actual icui18n library name based on CMake package system
This patch allows the "swift" suffixed ICU library files
1 parent dd02e66 commit f1a5aa7

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ if(HAS_LIBDISPATCH_API)
4747
find_package(dispatch CONFIG REQUIRED)
4848
endif()
4949

50+
find_package(ICU COMPONENTS uc i18n REQUIRED)
51+
5052
include(SwiftSupport)
5153
include(GNUInstallDirs)
5254
include(XCTest)

CoreFoundation/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
3232
else()
3333
find_package(CURL REQUIRED)
3434
endif()
35-
find_package(ICU COMPONENTS uc i18n REQUIRED)
3635
endif()
3736

3837
include(GNUInstallDirs)

Sources/Foundation/CMakeLists.txt

+13-1
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,22 @@ set_target_properties(Foundation PROPERTIES
161161
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/swift)
162162

163163
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+
164171
target_compile_options(Foundation
165172
PRIVATE
166-
"SHELL:-Xfrontend -public-autolink-library -Xfrontend icui18n
173+
"SHELL:-Xfrontend -public-autolink-library -Xfrontend ${icu_i18n_basename}
167174
-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}")
168180

169181
# Merge private dependencies into single static objects archive
170182
set_property(TARGET Foundation PROPERTY STATIC_LIBRARY_OPTIONS

0 commit comments

Comments
 (0)