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

Commit e93beb1

Browse files
committed
Merge pull request #1851 from ellismg/icu-remove-c-plus-plus
Remove OSX Homebrew ICU dependency
2 parents f7ea566 + 392f5f4 commit e93beb1

File tree

8 files changed

+716
-503
lines changed

8 files changed

+716
-503
lines changed

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

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,49 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
66
add_definitions(-DPIC=1)
77
add_definitions(-DBIT64=1)
88

9-
set(ICU_HOMEBREW_LIB_PATH "/usr/local/opt/icu4c/lib")
109
set(ICU_HOMEBREW_INC_PATH "/usr/local/opt/icu4c/include")
1110

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()
22-
endif()
23-
2411
find_path(UTYPES_H "unicode/utypes.h" PATHS ${ICU_HOMEBREW_INC_PATH})
2512
if(UTYPES_H STREQUAL UTYPES_H-NOTFOUND)
2613
message(FATAL_ERROR "Cannont find utypes.h, try installing libicu-dev (or the appropriate package for your platform)")
2714
return()
2815
endif()
2916

30-
set(CMAKE_REQUIRED_INCLUDES ${ICU_HOMEBREW_INC_PATH})
31-
CHECK_CXX_SOURCE_COMPILES("
32-
#include <unicode/dtfmtsym.h>
33-
int main() { DateFormatSymbols::DtWidthType e = DateFormatSymbols::DtWidthType::SHORT; }
34-
" HAVE_DTWIDTHTYPE_SHORT)
17+
if(NOT CLR_CMAKE_PLATFORM_DARWIN)
18+
find_library(ICUUC icuuc)
19+
if(ICUUC STREQUAL ICUUC-NOTFOUND)
20+
message(FATAL_ERROR "Cannot find libicuuc, try installing libicu-dev (or the appropriate package for your platform)")
21+
return()
22+
endif()
23+
24+
find_library(ICUI18N icui18n)
25+
if(ICUI18N STREQUAL ICUI18N-NOTFOUND)
26+
message(FATAL_ERROR "Cannot find libicui18n, try installing libicu-dev (or the appropriate package for your platform)")
27+
return()
28+
endif()
29+
30+
set(CMAKE_REQUIRED_INCLUDES ${ICU_HOMEBREW_INC_PATH})
31+
CHECK_CXX_SOURCE_COMPILES("
32+
#include <unicode/udat.h>
33+
int main() { UDateFormatSymbolType e = UDAT_STANDALONE_SHORTER_WEEKDAYS; }
34+
" HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS)
3535

36-
if(HAVE_DTWIDTHTYPE_SHORT)
37-
add_definitions(-DHAVE_DTWIDTHTYPE_SHORT=1)
38-
endif(HAVE_DTWIDTHTYPE_SHORT)
36+
if(HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS)
37+
add_definitions(-DHAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS=1)
38+
endif(HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS)
39+
40+
else()
41+
42+
find_library(ICUCORE icucore)
43+
if(ICUI18N STREQUAL ICUCORE-NOTFOUND)
44+
message(FATAL_ERROR "Cannot find libicucore, skipping build for System.Globalization.Native. .NET globalization is not expected to function.")
45+
return()
46+
endif()
47+
48+
# libicucore supports UDAT_STANDALONE_SHORTER_WEEKDAYS
49+
add_definitions(-DHAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS=1)
50+
51+
endif()
3952

4053
add_compile_options(-fPIC)
4154

@@ -61,9 +74,17 @@ add_library(System.Globalization.Native
6174
# Disable the "lib" prefix.
6275
set_target_properties(System.Globalization.Native PROPERTIES PREFIX "")
6376

64-
target_link_libraries(System.Globalization.Native
65-
${ICUUC}
66-
${ICUI18N}
67-
)
77+
if(NOT CLR_CMAKE_PLATFORM_DARWIN)
78+
target_link_libraries(System.Globalization.Native
79+
${ICUUC}
80+
${ICUI18N}
81+
)
82+
else()
83+
target_link_libraries(System.Globalization.Native
84+
${ICUCORE}
85+
)
86+
87+
add_definitions(-DU_DISABLE_RENAMING=1)
88+
endif()
6889

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

0 commit comments

Comments
 (0)