Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit ab9afce

Browse files
committed
Link against libicucore on OSX
OSX ships with a copy of ICU (their globalization APIs are built on top of it). Since we only use stable c based APIs, we can link against it using the methods described in using a System ICU in the ICU User's Guide (basically we disable function renaming, don't use C++ and only use stable APIs). The ICU headers are not part of the SDK, so we continue to need ICU installed via Homebrew as a build time dependency. Fixes dotnet/corefx#3849
1 parent 21567a7 commit ab9afce

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

src/corefx/System.Globalization.Native/CMakeLists.txt

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,25 @@ add_definitions(-DBIT64=1)
99
set(ICU_HOMEBREW_LIB_PATH "/usr/local/opt/icu4c/lib")
1010
set(ICU_HOMEBREW_INC_PATH "/usr/local/opt/icu4c/include")
1111

12-
find_library(ICUUC NAMES icuuc PATHS ${ICU_HOMEBREW_LIB_PATH})
13-
if(ICUUC STREQUAL ICUUC-NOTFOUND)
14-
message(FATAL_ERROR "Cannot find libicuuc, try installing libicu-dev (or the appropriate package for your platform)")
15-
return()
16-
endif()
17-
18-
find_library(ICUI18N NAMES icui18n PATHS ${ICU_HOMEBREW_LIB_PATH})
19-
if(ICUI18N STREQUAL ICUI18N-NOTFOUND)
20-
message(FATAL_ERROR "Cannot find libicui18n, try installing libicu-dev (or the appropriate package for your platform)")
21-
return()
12+
if(NOT CLR_CMAKE_PLATFORM_DARWIN)
13+
find_library(ICUUC NAMES icuuc PATHS ${ICU_HOMEBREW_LIB_PATH})
14+
if(ICUUC STREQUAL ICUUC-NOTFOUND)
15+
message(FATAL_ERROR "Cannot find libicuuc, try installing libicu-dev (or the appropriate package for your platform)")
16+
return()
17+
endif()
18+
19+
find_library(ICUI18N NAMES icui18n PATHS ${ICU_HOMEBREW_LIB_PATH})
20+
if(ICUI18N STREQUAL ICUI18N-NOTFOUND)
21+
message(FATAL_ERROR "Cannot find libicui18n, try installing libicu-dev (or the appropriate package for your platform)")
22+
return()
23+
endif()
24+
25+
else()
26+
find_library(ICUCORE NAMES icucore)
27+
if(ICUI18N STREQUAL ICUCORE-NOTFOUND)
28+
message(FATAL_ERROR "Cannot find libicucore, skipping build for System.Globalization.Native. .NET globalization is not expected to function.")
29+
return()
30+
endif()
2231
endif()
2332

2433
find_path(UTYPES_H "unicode/utypes.h" PATHS ${ICU_HOMEBREW_INC_PATH})
@@ -61,9 +70,17 @@ add_library(System.Globalization.Native
6170
# Disable the "lib" prefix.
6271
set_target_properties(System.Globalization.Native PROPERTIES PREFIX "")
6372

64-
target_link_libraries(System.Globalization.Native
65-
${ICUUC}
66-
${ICUI18N}
67-
)
73+
if(NOT CLR_CMAKE_PLATFORM_DARWIN)
74+
target_link_libraries(System.Globalization.Native
75+
${ICUUC}
76+
${ICUI18N}
77+
)
78+
else()
79+
target_link_libraries(System.Globalization.Native
80+
${ICUCORE}
81+
)
82+
83+
add_definitions(-DU_DISABLE_RENAMING=1)
84+
endif()
6885

6986
install (TARGETS System.Globalization.Native DESTINATION .)

0 commit comments

Comments
 (0)